[ticket/15214] Replace arrow functions with anonymous functions

Arrow functions aren't added until PHP 7.4, so we can't use them yet.
Anonymous functions have been added since PHP 5.3

PHPBB3-15214
This commit is contained in:
toxyy 2023-12-03 17:44:38 -05:00
parent c7d16febef
commit 8d6d016a5a

View file

@ -65,15 +65,18 @@ class event extends \Twig\Node\Node
// templates on page load rather than at compile. This is
// slower, but makes developing extensions easier (no need to
// purge the cache when a new event template file is added)
$compiler_calls[] = fn() => $compiler
$compiler_calls[] = function() use($compiler, $ext_namespace, $location) {
$compiler
->write("if (\$this->env->getLoader()->exists('@{$ext_namespace}/{$location}.html')) {\n")
->indent()
;
};
}
if ($this->environment->isDebug() || $this->environment->getLoader()->exists('@' . $ext_namespace . '/' . $location . '.html'))
{
$compiler_calls[] = fn() => $compiler
$compiler_calls[] = function() use($compiler, $ext_namespace, $location) {
$compiler
->write("\$previous_look_up_order = \$this->env->getNamespaceLookUpOrder();\n")
// We set the namespace lookup order to be this extension first, then the main path
@ -81,14 +84,17 @@ class event extends \Twig\Node\Node
->write("\$this->env->loadTemplate('@{$ext_namespace}/{$location}.html')->display(\$context);\n")
->write("\$this->env->setNamespaceLookUpOrder(\$previous_look_up_order);\n")
;
};
}
if ($this->environment->isDebug())
{
$compiler_calls[] = fn() => $compiler
$compiler_calls[] = function() use($compiler) {
$compiler
->outdent()
->write("}\n\n")
;
};
}
if (!empty($compiler_calls))