[TypeDeclaration] Handle crash on concat param append returned used on Arg on StrictStringParamConcatRector#4774
Merged
samsonasik merged 6 commits intomainfrom Aug 11, 2023
Merged
Conversation
…ParamConcatRector
Member
Author
|
Fixed 🎉 /cc @smortexa |
samsonasik
commented
Aug 11, 2023
samsonasik
commented
Aug 11, 2023
| function formatSizeUnits($bytes): string | ||
| { | ||
| if ($bytes >= 1_073_741_824) { | ||
| $bytes = number_format($bytes / 1_073_741_824, 1).' GB'; |
Member
Author
There was a problem hiding this comment.
here $bytes re-assign and used as Arg need to be float, that's why it need to be skipped as possible non string type.
Member
Author
|
All checks have passed 🎉 @TomasVotruba I am merging it ;) |
|
@samsonasik Thanks. The issue is fixed. |
samsonasik
commented
Aug 11, 2023
Comment on lines
+162
to
+168
| private function isVariableInArg(Arg $arg, string $paramName): bool | ||
| { | ||
| return (bool) $this->betterNodeFinder->findFirst( | ||
| $arg->value, | ||
| fn (Node $subNode): bool => $subNode instanceof Variable && $this->isName($subNode, $paramName) | ||
| ); | ||
| } |
Member
Author
There was a problem hiding this comment.
@TomasVotruba I think we can move this handling to a guard service to be reused when parameter used as Arg value in diferent rules, another rule that has same issue is:
Member
Author
There was a problem hiding this comment.
Variable Param reassign check probably better instead of Arg check, I will check tomorrow.
This was referenced Aug 11, 2023
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.
Ref https://getrector.com/demo/36fc83c8-43ca-48a8-84cd-4500f534aa29
Fixes rectorphp/rector#8130