mirror of
https://github.com/slawkens/myaac.git
synced 2025-10-14 17:54:55 +02:00
Update Twig to v2.15.4
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
|
||||
namespace Twig;
|
||||
|
||||
use Twig\Node\Expression\FunctionExpression;
|
||||
use Twig\Node\Node;
|
||||
|
||||
/**
|
||||
@@ -19,16 +20,29 @@ use Twig\Node\Node;
|
||||
* @final
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @see https://twig.symfony.com/doc/templates.html#functions
|
||||
*/
|
||||
class TwigFunction
|
||||
{
|
||||
protected $name;
|
||||
protected $callable;
|
||||
protected $options;
|
||||
protected $arguments = [];
|
||||
private $name;
|
||||
private $callable;
|
||||
private $options;
|
||||
private $arguments = [];
|
||||
|
||||
public function __construct($name, $callable, array $options = [])
|
||||
/**
|
||||
* Creates a template function.
|
||||
*
|
||||
* @param string $name Name of this function
|
||||
* @param callable|null $callable A callable implementing the function. If null, you need to overwrite the "node_class" option to customize compilation.
|
||||
* @param array $options Options array
|
||||
*/
|
||||
public function __construct(string $name, $callable = null, array $options = [])
|
||||
{
|
||||
if (__CLASS__ !== static::class) {
|
||||
@trigger_error('Overriding '.__CLASS__.' is deprecated since Twig 2.4.0 and the class will be final in 3.0.', \E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
$this->name = $name;
|
||||
$this->callable = $callable;
|
||||
$this->options = array_merge([
|
||||
@@ -37,7 +51,7 @@ class TwigFunction
|
||||
'is_variadic' => false,
|
||||
'is_safe' => null,
|
||||
'is_safe_callback' => null,
|
||||
'node_class' => '\Twig\Node\Expression\FunctionExpression',
|
||||
'node_class' => FunctionExpression::class,
|
||||
'deprecated' => false,
|
||||
'alternative' => null,
|
||||
], $options);
|
||||
@@ -48,6 +62,11 @@ class TwigFunction
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the callable to execute for this function.
|
||||
*
|
||||
* @return callable|null
|
||||
*/
|
||||
public function getCallable()
|
||||
{
|
||||
return $this->callable;
|
||||
@@ -85,7 +104,7 @@ class TwigFunction
|
||||
}
|
||||
|
||||
if (null !== $this->options['is_safe_callback']) {
|
||||
return \call_user_func($this->options['is_safe_callback'], $functionArgs);
|
||||
return $this->options['is_safe_callback']($functionArgs);
|
||||
}
|
||||
|
||||
return [];
|
||||
@@ -112,7 +131,10 @@ class TwigFunction
|
||||
}
|
||||
}
|
||||
|
||||
class_alias('Twig\TwigFunction', 'Twig_SimpleFunction');
|
||||
// For Twig 1.x compatibility
|
||||
class_alias('Twig\TwigFunction', 'Twig_SimpleFunction', false);
|
||||
|
||||
class_alias('Twig\TwigFunction', 'Twig_Function');
|
||||
|
||||
// Ensure that the aliased name is loaded to keep BC for classes implementing the typehint with the old aliased name.
|
||||
class_exists('Twig\Node\Node');
|
||||
|
Reference in New Issue
Block a user