Security update to Drupal 8.4.6
[yaffs-website] / vendor / twig / twig / lib / Twig / Function.php
1 <?php
2
3 /*
4  * This file is part of Twig.
5  *
6  * (c) Fabien Potencier
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
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);
13
14 /**
15  * Represents a template function.
16  *
17  * Use Twig_SimpleFunction instead.
18  *
19  * @author Fabien Potencier <fabien@symfony.com>
20  *
21  * @deprecated since 1.12 (to be removed in 2.0)
22  */
23 abstract class Twig_Function implements Twig_FunctionInterface, Twig_FunctionCallableInterface
24 {
25     protected $options;
26     protected $arguments = array();
27
28     public function __construct(array $options = array())
29     {
30         $this->options = array_merge(array(
31             'needs_environment' => false,
32             'needs_context' => false,
33             'callable' => null,
34         ), $options);
35     }
36
37     public function setArguments($arguments)
38     {
39         $this->arguments = $arguments;
40     }
41
42     public function getArguments()
43     {
44         return $this->arguments;
45     }
46
47     public function needsEnvironment()
48     {
49         return $this->options['needs_environment'];
50     }
51
52     public function needsContext()
53     {
54         return $this->options['needs_context'];
55     }
56
57     public function getSafe(Twig_Node $functionArgs)
58     {
59         if (isset($this->options['is_safe'])) {
60             return $this->options['is_safe'];
61         }
62
63         if (isset($this->options['is_safe_callback'])) {
64             return call_user_func($this->options['is_safe_callback'], $functionArgs);
65         }
66
67         return array();
68     }
69
70     public function getCallable()
71     {
72         return $this->options['callable'];
73     }
74 }