Lines Matching refs:node

70     protected function doEnterNode(Node $node, Environment $env)  argument
73 $this->enterOptimizeFor($node, $env);
78 if (!$node instanceof AbstractExpression) {
79 if ('Twig_Node' !== \get_class($node)) {
83 $node = $this->optimizeVariables($node, $env);
85 } elseif ($node instanceof BodyNode) {
90 return $node;
93 protected function doLeaveNode(Node $node, Environment $env) argument
95 $expression = $node instanceof AbstractExpression;
98 $this->leaveOptimizeFor($node, $env);
102 $node = $this->optimizeRawFilter($node, $env);
105 $node = $this->optimizePrintNode($node, $env);
108 if ($node instanceof BodyNode) {
111 …if (!$expression && 'Twig_Node' !== \get_class($node) && $prependedNodes = array_shift($this->prep…
114 $nodes[] = new SetTempNode($name, $node->getTemplateLine());
117 $nodes[] = $node;
118 $node = new Node($nodes);
123 return $node;
126 protected function optimizeVariables(\Twig_NodeInterface $node, Environment $env) argument
128 if ('Twig_Node_Expression_Name' === \get_class($node) && $node->isSimple()) {
129 $this->prependedNodes[0][] = $node->getAttribute('name');
131 return new TempNameExpression($node->getAttribute('name'), $node->getTemplateLine());
134 return $node;
146 protected function optimizePrintNode(\Twig_NodeInterface $node, Environment $env) argument
148 if (!$node instanceof PrintNode) {
149 return $node;
152 $exprNode = $node->getNode('expr');
162 return $node;
170 protected function optimizeRawFilter(\Twig_NodeInterface $node, Environment $env) argument
172 …if ($node instanceof FilterExpression && 'raw' == $node->getNode('filter')->getAttribute('value'))…
173 return $node->getNode('node');
176 return $node;
182 protected function enterOptimizeFor(\Twig_NodeInterface $node, Environment $env) argument
184 if ($node instanceof ForNode) {
186 $node->setAttribute('with_loop', false);
187 array_unshift($this->loops, $node);
188 … array_unshift($this->loopsTargets, $node->getNode('value_target')->getAttribute('name'));
189 array_unshift($this->loopsTargets, $node->getNode('key_target')->getAttribute('name'));
198 elseif ($node instanceof NameExpression && 'loop' === $node->getAttribute('name')) {
199 $node->setAttribute('always_defined', true);
204 …elseif ($node instanceof NameExpression && \in_array($node->getAttribute('name'), $this->loopsTarg…
205 $node->setAttribute('always_defined', true);
209 elseif ($node instanceof BlockReferenceNode || $node instanceof BlockReferenceExpression) {
214 elseif ($node instanceof IncludeNode && !$node->getAttribute('only')) {
219 elseif ($node instanceof FunctionExpression
220 && 'include' === $node->getAttribute('name')
221 && (!$node->getNode('arguments')->hasNode('with_context')
222 … || false !== $node->getNode('arguments')->getNode('with_context')->getAttribute('value')
229 elseif ($node instanceof GetAttrExpression
230 && (!$node->getNode('attribute') instanceof ConstantExpression
231 || 'parent' === $node->getNode('attribute')->getAttribute('value')
234 || ($node->getNode('node') instanceof NameExpression
235 && 'loop' === $node->getNode('node')->getAttribute('name')
246 protected function leaveOptimizeFor(\Twig_NodeInterface $node, Environment $env) argument
248 if ($node instanceof ForNode) {