- Fixed a bug within FunctionToken control structure where multiple definition were runned if a view was loaded more than once

This commit is contained in:
Dave Mc Nicoll 2024-11-01 16:11:31 -04:00
parent fa815a506e
commit 3ffb69342b

@ -33,7 +33,9 @@ class FunctionToken implements ControlStructure {
protected function printFunction($context, ?string $arguments) : string
{
return "<?php function $arguments { ?>";
$name = trim(explode('(', $arguments, 2)[0]);
return "<?php if (! function_exists(__NAMESPACE__ . '\\$name')) { function $arguments { ?>";
}
protected function printReturn($context, ?string $arguments) : string
@ -43,6 +45,6 @@ class FunctionToken implements ControlStructure {
protected function printEndFunction($context) : string
{
return "<?php } ?>";
return "<?php } } ?>";
}
}