-
Notifications
You must be signed in to change notification settings - Fork 998
Code quality improvements powered by PHPStan #6019
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
Conversation
At this point the foreach can be replaced with a simple implode too
The variable is immediately overwritten further down
The array returned by `error_get_last` always has this key
The `WP_CLI::error` call above always terminates execution
`$explanation` is never empty at this point
The variable is always set
This method never returns false
The `RequestsLibrary::get_class_name` method never throws
There is an early return above if `self::$logger` isn't set
@@ -277,7 +277,7 @@ private static function get_aliases( $subcommands ) { | |||
/** | |||
* Composite commands can only be known by one name. | |||
* | |||
* @return false | |||
* @return string|false |
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.
Hmm this seems confusing since all this method does is return false 🧐 I wonder is this tool getting confused and considering the subcommand version of this method which extends CompositeCommand?
wp-cli/php/WP_CLI/Dispatcher/Subcommand.php
Lines 76 to 85 in e214df2
/** | |
* If an alias is set, grant access to it. | |
* Aliases permit subcommands to be instantiated | |
* with a secondary identity. | |
* | |
* @return string | |
*/ | |
public function get_alias() { | |
return $this->alias; | |
} |
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.
Yep exactly. I wouldn't call it confused though, because it's definitely an incorrect documentation.
If the parent method returns only false, a child class returning a string is a type mismatch.
We can't use PHPStan out of the box right now because of the higher PHP version requirement (see wp-cli/wp-cli-tests#204), so I just ran it manually locally, level by level, fixing bugs along the way.
I went up to level ~5 here.