mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-22 10:43:35 +01:00
This commit is contained in:
parent
0e5386c5d8
commit
75714bb3d6
@ -138,6 +138,11 @@ CODE_SAMPLE
|
||||
return null;
|
||||
}
|
||||
|
||||
$init = $node->init;
|
||||
if (count($init) > 2) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$iteratedVariableSingle = $this->inflector->singularize($iteratedVariable);
|
||||
$foreach = $this->createForeach($node, $iteratedVariableSingle);
|
||||
|
||||
|
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\CodeQuality\Tests\Rector\For_\ForToForeachRector\Fixture;
|
||||
|
||||
class SkipComplexAssignmentInInit
|
||||
{
|
||||
public function run($tokens)
|
||||
{
|
||||
$o = new class {
|
||||
public function getResult()
|
||||
{
|
||||
return ['a'];
|
||||
}
|
||||
};
|
||||
|
||||
for ($i = 0, $query = $o->getResult(), $c = count($query); $i < $c; $i ++)
|
||||
{
|
||||
echo $query[$i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user