- Corrected a bug where the 'or' variable was not reset properly on a iterations of for/foreach.
This commit is contained in:
1 parent
8df38b568c
commit
30af321215
2 files changed
+9
-15
No files matched your search
@@ -4,13 +4,10 @@ namespace Picea\ControlStructure;
|
||||
|
||||
class ForeachToken implements ControlStructure {
|
||||
|
||||
public array $token = [ "foreach", "endforeach", "continue" ];
|
||||
public array $token = [ "foreach", "endforeach" ];
|
||||
|
||||
public function parse(/*\Picae\Compiler\Context*/ &$context, ?string $arguments, string $token) {
|
||||
switch($token) {
|
||||
case "continue":
|
||||
return "<?php continue; ?>";
|
||||
|
||||
case "foreach":
|
||||
$name = "$".uniqid("foreach_");
|
||||
|
||||
@@ -30,14 +27,16 @@ class ForeachToken implements ControlStructure {
|
||||
'token' => 'endforeach',
|
||||
];
|
||||
|
||||
return "<?php foreach ($arguments): $name = ( $name ?? 0 ) + 1; ?>";
|
||||
return "<?php foreach ($arguments): $name = ( $name ?? 0 ) + 1; ; ?>";
|
||||
|
||||
case "endforeach":
|
||||
if ( end($context->iterationStack)['or'] === false ) {
|
||||
$last = end($context->iterationStack);
|
||||
|
||||
if ( $last['or'] === false ) {
|
||||
$output = "<?php endforeach; ?>";
|
||||
}
|
||||
else {
|
||||
$output = "<?php endif; ?>";
|
||||
$output = "<?php endif; unset({$last['uid']}) ?>";
|
||||
}
|
||||
|
||||
array_pop($context->iterationStack);
|
||||
|
||||
Reference in new issue
Block a user