1 | <?php |
||
8 | use Twig\Node\Node as Twig_Node; |
||
9 | use Twig\Token as Twig_Token; |
||
10 | use Twig\TokenParser\AbstractTokenParser as Twig_TokenParser; |
||
11 | use Twig\Error\SyntaxError as Twig_Error_Syntax; |
||
12 | use Twig\Node\Expression\AbstractExpression as Twig_Node_Expression; |
||
13 | use Twig\Node\Expression\ArrayExpression as Twig_Node_Expression_Array; |
||
14 | |||
15 | /** |
||
16 | * Class BaseTokenParser. |
||
17 | */ |
||
18 | abstract class BaseTokenParser extends Twig_TokenParser |
||
19 | { |
||
20 | /** |
||
21 | * @var int |
||
22 | */ |
||
23 | const PARAMETER_TYPE_ARRAY = 0; |
||
24 | |||
25 | /** |
||
26 | * @var int |
||
27 | */ |
||
28 | const PARAMETER_TYPE_VALUE = 1; |
||
29 | |||
30 | /** |
||
31 | * @var array |
||
32 | */ |
||
33 | private $attributes; |
||
34 | |||
35 | /** |
||
36 | * BaseTokenParser constructor. |
||
37 | * |
||
38 | * @param array $attributes optional attributes for the corresponding node |
||
39 | */ |
||
40 | public function __construct(array $attributes = []) |
||
44 | |||
45 | /** |
||
46 | * @param Twig_Token $token |
||
47 | * |
||
48 | * @return array |
||
49 | */ |
||
50 | public function configureParameters(Twig_Token $token): array |
||
54 | |||
55 | /** |
||
56 | * @return array |
||
57 | */ |
||
58 | public function getAttributes(): array |
||
62 | |||
63 | /** |
||
64 | * Create a concrete node. |
||
65 | * |
||
66 | * @param array $nodes |
||
67 | * @param int $lineNo |
||
68 | * |
||
69 | * @return Twig_Node |
||
70 | */ |
||
71 | abstract public function createNode(array $nodes = [], int $lineNo = 0): Twig_Node; |
||
72 | |||
73 | /** |
||
74 | * @return bool |
||
75 | */ |
||
76 | public function hasBody(): bool |
||
80 | |||
81 | /** |
||
82 | * {@inheritdoc} |
||
83 | * |
||
84 | * @throws Exception |
||
85 | * @throws InvalidArgumentException |
||
86 | */ |
||
87 | public function parse(Twig_Token $token) |
||
99 | |||
100 | /** |
||
101 | * @param array $parameterConfiguration |
||
102 | * |
||
103 | * @throws Exception |
||
104 | * @throws InvalidArgumentException |
||
105 | * @throws Twig_Error_Syntax |
||
106 | * |
||
107 | * @return Twig_Node_Expression[] |
||
108 | */ |
||
109 | private function parseParameters(array $parameterConfiguration = []): array |
||
159 | |||
160 | /** |
||
161 | * @return Twig_Node |
||
162 | * @throws Twig_Error_Syntax |
||
172 |