Fix PHPStan @return unused type return.type on RectorInterface #7406
Merged
samsonasik merged 5 commits intomainfrom Oct 3, 2025
Merged
Fix PHPStan @return unused type return.type on RectorInterface #7406samsonasik merged 5 commits intomainfrom
samsonasik merged 5 commits intomainfrom
Conversation
Member
Author
|
All checks have passed 🎉 @TomasVotruba I am merging it ;) |
calebdw
reviewed
Oct 3, 2025
TomasVotruba
reviewed
Oct 3, 2025
Comment on lines
+23
to
33
| * @return Node|Node[]|null|int | ||
| * | ||
| * For int return, choose: | ||
| * | ||
| * ✔️ To decorate current node and its children to not be traversed on current rule, return one of: | ||
| * - NodeVisitor::DONT_TRAVERSE_CHILDREN | ||
| * - NodeVisitor::DONT_TRAVERSE_CURRENT_AND_CHILDREN | ||
| * | ||
| * ✔️ To remove node of Node\Stmt or Node\Param, return: | ||
| * - NodeVisitor::REMOVE_NODE | ||
| */ |
Member
There was a problem hiding this comment.
I prefer to keep original list, as now any int value can be returned by PHPStan, which is not true.
Could you revert this one?
Member
Author
There was a problem hiding this comment.
Ok, the rule classes itself then need update to add @return for specific constant then, eg:
/**
* @param StmtsAwareInterface $node
+ * @return null|Node|NodeVisitor::DONT_TRAVERSE_CHILDREN
*/
public function refactor(Node $node): null|Node|intI will revert this and update rule classes
Member
Author
There was a problem hiding this comment.
I created PR to use NodeVisitor::* on RectorInterface::refactor(), then update its rules @return to use its constant at PR:
Contributor
|
This pull request has been automatically locked because it has been closed for 150 days. Please open a new PR if you want to continue the work. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
On latest PHPStan
2.1.30, usingInterface::*seems mark as all must be returned, but not support partial of it, so useintover it.Added comment note for how return
intworks.