1 | <?php |
||
13 | class ExpressionLanguage extends \Symfony\Component\ExpressionLanguage\ExpressionLanguage { |
||
14 | 46 | public function __construct() { |
|
15 | 46 | parent::__construct(); |
|
16 | |||
17 | 46 | $this->registerNodeFunction(GetAttrNode::class, function (\Symfony\Component\ExpressionLanguage\Compiler $compiler, GetAttrNode $node) { |
|
18 | 7 | switch ($node->attributes['type']) { |
|
19 | 7 | case GetAttrNode::METHOD_CALL: |
|
20 | $compiler |
||
21 | ->compile($node->nodes['node']) |
||
22 | ->raw('->') |
||
23 | ->raw($node->nodes['attribute']->attributes['value']) |
||
24 | ->raw('(') |
||
25 | ->compile($node->nodes['arguments']) |
||
26 | ->raw(')') |
||
27 | ; |
||
28 | break; |
||
29 | |||
30 | 7 | case GetAttrNode::PROPERTY_CALL: |
|
31 | 7 | case GetAttrNode::ARRAY_CALL: |
|
32 | $compiler |
||
33 | 7 | ->compile($node->nodes['node']) |
|
34 | 7 | ->raw('[') |
|
35 | 7 | ->compile($node->nodes['attribute'])->raw(']') |
|
36 | ; |
||
37 | 7 | break; |
|
38 | 7 | } |
|
39 | 46 | }); |
|
40 | 46 | } |
|
41 | |||
42 | 10 | public function getFunctionCompiler($name) { |
|
48 | } |
||
49 |
Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a
@return
annotation as described here.