Skip to content

Commit

Permalink
[Renaming] Handle crash on assign on for loop on RenameFunctionRector (
Browse files Browse the repository at this point in the history
…#6730)

* [Renaming] Handle crash on for loop on RenameFunctionRector

* Fix

* [ci-review] Rector Rectify

---------

Co-authored-by: GitHub Action <[email protected]>
  • Loading branch information
samsonasik and actions-user authored Feb 11, 2025
1 parent 36f2d21 commit 8efb34e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Rector\Tests\Renaming\Rector\FuncCall\RenameFunctionRector\Fixture;

class InFor {
function process($file) {
for ($i=0;$n=sizeof($files),$i<$n;$i++) {
$products_image_name = $files[$i]['text'];
}
}
}

?>
-----
<?php

namespace Rector\Tests\Renaming\Rector\FuncCall\RenameFunctionRector\Fixture;

class InFor {
function process($file) {
for ($i=0;$n=count($files),$i<$n;$i++) {
$products_image_name = $files[$i]['text'];
}
}
}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
'view' => 'Laravel\Templating\render',
'sprintf' => 'Safe\sprintf',
'abc2' => 'abc',
'sizeof' => 'count',
]);
};
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,10 @@ public function processNodes(
if ($expr instanceof BinaryOp) {
$this->processBinaryOp($expr, $mutatingScope);
}

if ($expr instanceof Assign) {
$this->processAssign($expr, $mutatingScope);
}
}

return;
Expand Down

0 comments on commit 8efb34e

Please sign in to comment.