composer package updates
[openemr.git] / vendor / twig / twig / lib / Twig / Function.php
blob9dc16e90820c1a2fa3a31c383bc94c693f9e5a7e
1 <?php
3 /*
4 * This file is part of Twig.
6 * (c) Fabien Potencier
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 @trigger_error('The Twig_Function class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFunction instead.', E_USER_DEPRECATED);
14 /**
15 * Represents a template function.
17 * Use Twig_SimpleFunction instead.
19 * @author Fabien Potencier <fabien@symfony.com>
21 * @deprecated since 1.12 (to be removed in 2.0)
23 abstract class Twig_Function implements Twig_FunctionInterface, Twig_FunctionCallableInterface
25 protected $options;
26 protected $arguments = array();
28 public function __construct(array $options = array())
30 $this->options = array_merge(array(
31 'needs_environment' => false,
32 'needs_context' => false,
33 'callable' => null,
34 ), $options);
37 public function setArguments($arguments)
39 $this->arguments = $arguments;
42 public function getArguments()
44 return $this->arguments;
47 public function needsEnvironment()
49 return $this->options['needs_environment'];
52 public function needsContext()
54 return $this->options['needs_context'];
57 public function getSafe(Twig_Node $functionArgs)
59 if (isset($this->options['is_safe'])) {
60 return $this->options['is_safe'];
63 if (isset($this->options['is_safe_callback'])) {
64 return call_user_func($this->options['is_safe_callback'], $functionArgs);
67 return array();
70 public function getCallable()
72 return $this->options['callable'];