picea/src/ControlStructure/EndforToken.php

21 lines
475 B
PHP

<?php
namespace Picea\ControlStructure;
class EndforToken implements ControlStructure {
public string $token = "endfor";
public function parse(/*\Picae\Compiler\Context*/ &$context, ?string $arguments) {
if ( end($context->iterationStack)['or'] === false ) {
$output = "<?php endfor; ?>";
}
else {
$output = "<?php endif; ?>";
}
array_pop($context->iterationStack);
return $output;
}
}