-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[Console] Improve code coverage #19328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Console] Improve code coverage #19328
Conversation
689e2e4
to
b122d36
Compare
@@ -594,6 +594,8 @@ public function all($namespace = null) | |||
*/ | |||
public static function getAbbreviations($names) | |||
{ | |||
@trigger_error(sprintf('%s is deprecated as of 3.2 and will be removed in 4.0.', __METHOD__), E_USER_DEPRECATED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing deprecation in the phpdoc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the rationale for this deprecation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nicolas-grekas While looking for code not covered I noticed that this method wasn't used anywhere so I thought that it should be removed. What's your opinion ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@geoffrey-brier in any case, this has nothing to do in a PR adding more code coverage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say it's not related to this PR, and if this is the only reason, let's wait for a better reason before deprecating it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All right, I'm gonna remove it then :)
b122d36
to
366c69d
Compare
Test improvements should be done on the |
{ | ||
$application = new CustomDefaultCommandApplication(); | ||
|
||
$this->assertNull($application->add(new \DisabledCommand())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here $application is always new object so it will null and you assert it should be null. I think it is not helpful testcase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I remove the test then ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think change the logic of test case otherwise you can remove this test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here $application is always new object so it will null and you assert it should be null. I think it is not helpful testcase.
No the assert is on the return value of the call to add()
, which passes while it shouldn't.
The PHPDoc states it will always return the command:
https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Console/Application.php#L379
but it doesn't:
https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Console/Application.php#L388
I've opened a PR to correct it; #19389
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'll remove the test case then
This is wrong. Your PR is adding a deprecation (which looks wrong to me) |
@geoffrey-brier What's the status of your work here? |
366c69d
to
a9e4ff5
Compare
0f2b435
to
ebb2770
Compare
👍 |
public function formatMemoryProvider() | ||
{ | ||
return array( | ||
array(0, '0 B'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this kind of alignment allowed by the CS standards?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
array_element_white_space_after_comma [symfony]
In array declaration, there MUST be a whitespace after each comma.
(https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/1.11/README.rst)
so no rule about how much whitespace other than something ^_^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know there are many implicit rules that aren't yet declared @SpacePossum, that's why I'm asking. The reasons I have in mind are the very same that moved us to unalign =
and =>
in the past (#14438), given the code maintainability turns harder when any update to this "structures" is required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@phansys I formatted the array this way to be consistent with what's already in this file (take a look at the formatTimeProvider
function).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure @geoffrey-brier, thanks for pointing and putting the sight on this.
ebb2770
to
38d3b27
Compare
38d3b27
to
a4a3302
Compare
@@ -572,6 +572,8 @@ public function getSynopsis($short = false) | |||
* Add a command usage example. | |||
* | |||
* @param string $usage The usage, it'll be prefixed with the command name | |||
* | |||
* @return Command |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be @return self
(as in other places in the code base where fluent interface are in defined)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it could be even more strict and state @return $this
as not only a Command
class instance is returned but the instance itself is always returned (for ref. https://github.com/php-fig/fig-standards/blob/master/proposed/phpdoc.md#keyword point 13 vs. 15).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok for me
a4a3302
to
c17be71
Compare
Status: reviewed |
Reminder: for 2.7 |
@nicolas-grekas Should I close the PR, rebase it againt the 2.7 branch and reopen a new one ? |
@@ -572,6 +572,8 @@ public function getSynopsis($short = false) | |||
* Add a command usage example. | |||
* | |||
* @param string $usage The usage, it'll be prefixed with the command name | |||
* | |||
* @return $this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we are using @return self
everywhere else. Not sure which one is the right one, but I didn't find any occurrence of @return $this
in Symfony codebase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that is because of my suggestion I'm afraid
#19328 (comment)
sorry if misleading the pr!
This one is not mergeable as is. As it contains some small fixes, it should be split. If possible, I would prefer a PR on 2.7 first. |
@geoffrey-brier I'm closing this one as it cannot be merge as is. Feel free to reopen smaller and targeted PR. Thanks for your understanding. |
Hello,
I've added a few tests to improve the console component code coverage (around 3%).
What do you think ?