You are here

protected function Twig_TokenParser_For::checkLoopUsageCondition in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/twig/twig/lib/Twig/TokenParser/For.php \Twig_TokenParser_For::checkLoopUsageCondition()
1 call to Twig_TokenParser_For::checkLoopUsageCondition()
Twig_TokenParser_For::parse in vendor/twig/twig/lib/Twig/TokenParser/For.php
Parses a token and returns a node.

File

vendor/twig/twig/lib/Twig/TokenParser/For.php, line 79

Class

Twig_TokenParser_For
Loops over each item of a sequence.

Code

protected function checkLoopUsageCondition(Twig_TokenStream $stream, Twig_NodeInterface $node) {
  if ($node instanceof Twig_Node_Expression_GetAttr && $node
    ->getNode('node') instanceof Twig_Node_Expression_Name && 'loop' == $node
    ->getNode('node')
    ->getAttribute('name')) {
    throw new Twig_Error_Syntax('The "loop" variable cannot be used in a looping condition.', $node
      ->getLine(), $stream
      ->getFilename());
  }
  foreach ($node as $n) {
    if (!$n) {
      continue;
    }
    $this
      ->checkLoopUsageCondition($stream, $n);
  }
}