Code quality improvements powered by PHPStan#6019
Merged
swissspidy merged 22 commits intomainfrom Nov 26, 2024
Merged
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
mrsdizzie
reviewed
Nov 26, 2024
| * Composite commands can only be known by one name. | ||
| * | ||
| * @return false | ||
| * @return string|false |
Member
There was a problem hiding this comment.
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
Member
Author
There was a problem hiding this comment.
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.
mrsdizzie
approved these changes
Nov 26, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.