-
-
Notifications
You must be signed in to change notification settings - Fork 374
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
[TypeDeclaration] Handle crash on concat param append returned used on Arg on StrictStringParamConcatRector #4774
Conversation
…ParamConcatRector
Fixed 🎉 /cc @smortexa |
...ector/ClassMethod/StrictStringParamConcatRector/Fixture/concat_param_append_returned.php.inc
Outdated
Show resolved
Hide resolved
function formatSizeUnits($bytes): string | ||
{ | ||
if ($bytes >= 1_073_741_824) { | ||
$bytes = number_format($bytes / 1_073_741_824, 1).' GB'; |
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.
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.
All checks have passed 🎉 @TomasVotruba I am merging it ;) |
@samsonasik Thanks. The issue is fixed. |
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) | ||
); | ||
} |
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.
@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:
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.
Variable Param reassign check probably better instead of Arg check, I will check tomorrow.
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.
Ref https://getrector.com/demo/36fc83c8-43ca-48a8-84cd-4500f534aa29
Fixes rectorphp/rector#8130