[type-declaration-docblocks] Add AddReturnDocblockForCommonObjectDenominatorRector#7249
Merged
TomasVotruba merged 3 commits intomainfrom Sep 12, 2025
Merged
Conversation
366dafd to
4b949f8
Compare
d37b773 to
f5fdb86
Compare
f5fdb86 to
dbdf9de
Compare
samsonasik
reviewed
Sep 12, 2025
| return null; | ||
| } | ||
|
|
||
| return $returnsScoped[0]; |
Member
There was a problem hiding this comment.
this needs count() for only returns 1 return:
Suggested change
| return $returnsScoped[0]; | |
| return count($returnsScoped) === 1 ? $returnsScoped[0] : null; |
multiple returns should be skipped on this case for this rule purpose.
Member
There was a problem hiding this comment.
TomasVotruba
commented
Sep 12, 2025
| $returnsScoped = $this->betterNodeFinder->findReturnsScoped($functionLike); | ||
| if (! $this->returnAnalyzer->hasOnlyReturnWithExpr($functionLike, $returnsScoped)) { | ||
| return null; | ||
| } |
Member
Author
There was a problem hiding this comment.
@samsonasik I think this method already covers it.
Member
There was a problem hiding this comment.
no, $returnsScoped can be many returns, see PR:
Member
There was a problem hiding this comment.
hasOnlyReturnWithExpr is verify that All returns has Expr.
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.
This rule adds @return array based on shared interface/object in an array of objects 👍
final class ReturnOfObjects { + /** + * @return ExtensionInterface[] + */ public function getExtensions(): array { return [ new FirstExtension(), new SecondExtension() ]; } }