Skip to content
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

minor: ReturnAssignmentFixer - Support for anonymous classes, lambda and match #6391

Conversation

SpacePossum
Copy link
Contributor

No description provided.

@SpacePossum SpacePossum force-pushed the master_ReturnAssignmentFixer_support_more_cases branch 2 times, most recently from 9935c74 to 8bbfb97 Compare May 13, 2022 15:05
@coveralls
Copy link

coveralls commented May 13, 2022

Coverage Status

Coverage increased (+0.01%) to 92.926% when pulling 4aa3d86 on SpacePossum:master_ReturnAssignmentFixer_support_more_cases into 22804e8 on FriendsOfPHP:master.

@SpacePossum SpacePossum force-pushed the master_ReturnAssignmentFixer_support_more_cases branch from 8bbfb97 to 6218ed6 Compare May 13, 2022 16:27
@SpacePossum SpacePossum force-pushed the master_ReturnAssignmentFixer_support_more_cases branch from 6218ed6 to 08a7e83 Compare May 15, 2022 18:54
@GrahamCampbell
Copy link
Contributor

Note for other reviewers. Changes since the last version, in the force push:

image

With that in mind, are we missing a test case, here?

@SpacePossum
Copy link
Contributor Author

Thanks for providing the details about the change!

The first change is an internal PHPDoc change for the method, I noticed that I had copy-pasted the doc and as such decided to make it a bit more accurate.

The second change is adding !$tokens->isTokenKindsFound to the function.
The functions job is to figure out if we are detailing with an enum. The added check is a cheap negative test; it checks if when the PHP code was tokenized it did contain any enum. If it didn't we can skip all the detection logic for an enum as it will never be in the collection.
This, to me, seems a nice optimization, yet not required from a pure functional perspective which is why I didn't adjust a utest for it.

@GrahamCampbell
Copy link
Contributor

Ah, perfect. 👌

@SpacePossum SpacePossum changed the title ReturnAssignmentFixer - Support for anonymous classes, lambda and match feature: ReturnAssignmentFixer - Support for anonymous classes, lambda and match Jun 13, 2022
@SpacePossum SpacePossum changed the title feature: ReturnAssignmentFixer - Support for anonymous classes, lambda and match minor: ReturnAssignmentFixer - Support for anonymous classes, lambda and match Jun 13, 2022
@SpacePossum SpacePossum force-pushed the master_ReturnAssignmentFixer_support_more_cases branch from 08a7e83 to 34c51c5 Compare July 18, 2022 05:48
@SpacePossum
Copy link
Contributor Author

rebased, no other changes

@SpacePossum SpacePossum force-pushed the master_ReturnAssignmentFixer_support_more_cases branch from 34c51c5 to 8a77e10 Compare July 20, 2022 02:56
@SpacePossum
Copy link
Contributor Author

rebased without changes, than added a new commit

@SpacePossum
Copy link
Contributor Author

This PR is now a bug fix as well, as it fixes the previous fixed issue with references returned but this time for nested functions as well.

@SpacePossum SpacePossum force-pushed the master_ReturnAssignmentFixer_support_more_cases branch from 6758e0e to 4aa3d86 Compare July 25, 2022 04:51
@SpacePossum
Copy link
Contributor Author

rebased on latest without any other changes

@julienfalque julienfalque merged commit 255f39f into PHP-CS-Fixer:master Aug 1, 2022
@julienfalque
Copy link
Member

Thank you @SpacePossum.

@SpacePossum SpacePossum deleted the master_ReturnAssignmentFixer_support_more_cases branch August 1, 2022 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants