| 1 | <?php |
||
| 13 | class ExpressionLanguage extends \Symfony\Component\ExpressionLanguage\ExpressionLanguage { |
||
| 14 | 62 | public function __construct() { |
|
| 15 | 62 | parent::__construct(); |
|
| 16 | |||
| 17 | 62 | $this->registerNodeFunction(GetAttrNode::class, function (\Symfony\Component\ExpressionLanguage\Compiler $compiler, GetAttrNode $node) { |
|
| 18 | 8 | switch ($node->attributes['type']) { |
|
| 19 | 8 | 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 | 8 | case GetAttrNode::PROPERTY_CALL: |
|
| 31 | 8 | case GetAttrNode::ARRAY_CALL: |
|
| 32 | $compiler |
||
| 33 | 8 | ->compile($node->nodes['node']) |
|
| 34 | 8 | ->raw('[') |
|
| 35 | 8 | ->compile($node->nodes['attribute'])->raw(']') |
|
| 36 | ; |
||
| 37 | 8 | break; |
|
| 38 | 8 | } |
|
| 39 | 62 | }); |
|
| 40 | 62 | } |
|
| 41 | |||
| 42 | 21 | 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
@returnannotation as described here.