-
-
Notifications
You must be signed in to change notification settings - Fork 431
[type-declaration-docblocks] Add AddReturnDocblockForCommonObjectDenominatorRector #7249
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
366dafd to
4b949f8
Compare
d37b773 to
f5fdb86
Compare
f5fdb86 to
dbdf9de
Compare
| return null; | ||
| } | ||
|
|
||
| return $returnsScoped[0]; |
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.
this needs count() for only returns 1 return:
| return $returnsScoped[0]; | |
| return count($returnsScoped) === 1 ? $returnsScoped[0] : null; |
multiple returns should be skipped on this case for this rule purpose.
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.
| $returnsScoped = $this->betterNodeFinder->findReturnsScoped($functionLike); | ||
| if (! $this->returnAnalyzer->hasOnlyReturnWithExpr($functionLike, $returnsScoped)) { | ||
| return null; | ||
| } |
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.
@samsonasik I think this method already covers 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.
no, $returnsScoped can be many returns, see PR:
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.
hasOnlyReturnWithExpr is verify that All returns has Expr.
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 see.
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() ]; } }