Previously the code would generate an unset() for $loop each time a loop ended. This however means that $loop was not available after a nested loop, which is not how Blade works.
foreach ($items as $item) {
$loop = new Loop();
foreach ($item->names as $name) {
$loop = new Loop();
echo $name;
unset($loop); // <-- outloop nolonger has a context
}
echo $loop->odd ? 'odd-button.png' : 'even-button.png';
unset($loop);
}
PR:
foreach ($items as $item) {
$loop = new Loop();
foreach ($item->names as $name) {
echo $name;
}
echo $loop->odd ? 'odd-button.png' : 'even-button.png';
unset($loop);
}
Additionally I replaced the hack I did for creating the loop (using a comment) with the proper way of doing so now that I know how PhpParser works.
This indeed did solve the last of the errors I was getting for the two projects I work on for a living.
Previously the code would generate an
unset()
for$loop
each time a loop ended. This however means that $loop was not available after a nested loop, which is not how Blade works.PR:
Additionally I replaced the hack I did for creating the loop (using a comment) with the proper way of doing so now that I know how PhpParser works.
This indeed did solve the last of the errors I was getting for the two projects I work on for a living.