protected function checkNestedByReferenceForeach(Node\Stmt\Foreach_ $foreach)
{
if (!$foreach->byRef) {
return;
}
/** @var Node\Stmt\Foreach_ $ancestorForeach */
foreach ($this->getCurrentLoopStack() as $ancestorForeach) {
if ($ancestorForeach === $foreach) {
continue;
}
if ($ancestorForeach->byRef) {
$this->addContextMessage('Nested by-reference foreach loop, make sure there is no iteration over the same array', $foreach);
return;
}
}
}