Skip to content

[TypeDeclaration] Handle return from array_map() on ReturnTypeFromStrictTypedCallRector#3471

Merged
TomasVotruba merged 7 commits intomainfrom
handle-return-from-array-map
Mar 10, 2023
Merged

[TypeDeclaration] Handle return from array_map() on ReturnTypeFromStrictTypedCallRector#3471
TomasVotruba merged 7 commits intomainfrom
handle-return-from-array-map

Conversation

@samsonasik
Copy link
Copy Markdown
Member

@samsonasik
Copy link
Copy Markdown
Member Author

Fixed 🎉 /cc @staabm

@samsonasik samsonasik changed the title [TypeDeclration] Handle return from array_map() on ReturnTypeFromStrictTypedCallRector [TypeDeclaration] Handle return from array_map() on ReturnTypeFromStrictTypedCallRector Mar 10, 2023
@samsonasik
Copy link
Copy Markdown
Member Author

All checks have passed 🎉 @TomasVotruba I think it is ready.

Comment on lines -119 to -120
$currentFunctionLike = $this->betterNodeFinder->findParentType($currentReturn, FunctionLike::class);
if ($currentFunctionLike !== $node) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume the fix for the actual problem is in these lines here.. all other lines changed are only tests and var renames, right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, rectify commit are auto-committed due to change from contributors

@staabm
Copy link
Copy Markdown
Contributor

staabm commented Mar 10, 2023

thx for fixing it so fast.

does this also fix

if so, would be great to have the test-cases added here

@samsonasik
Copy link
Copy Markdown
Member Author

I added more fixture:

This rule is for strict typed call, so it will got the actual information from the function call definition.

@staabm
Copy link
Copy Markdown
Contributor

staabm commented Mar 10, 2023

This rule is for strict typed call, so it will got the actual information from the function call definition.

I guess it does currently not take phpstan return type extensions into account.. phpstan itself knows more precise types then the ones rector infers here.

but I think you are saying that it uses native-type knowledge and therefore it makes sense to me - since this means no return-type-extensions involved.

@TomasVotruba
Copy link
Copy Markdown
Member

Thank you 👍 Let's ship it

@TomasVotruba TomasVotruba merged commit dc52f2b into main Mar 10, 2023
@TomasVotruba TomasVotruba deleted the handle-return-from-array-map branch March 10, 2023 15:14
@staabm
Copy link
Copy Markdown
Contributor

staabm commented Mar 10, 2023

awesome, thanks to both of you.

samsonasik added a commit that referenced this pull request May 8, 2023
…ictTypedCallRector (#3471)

* [TypeDeclration] Handle return from array_map() on ReturnTypeFromStrictTypedCallRector

* Fixed 🎉

* [ci-review] Rector Rectify

* [ci-review] Rector Rectify

* add more test

* more fixture

* rename fixture

---------

Co-authored-by: GitHub Action <actions@github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ReturnTypeFromStrictTypedCallRector turns code into phpstan error

4 participants