You are here

protected function Twig_TokenParser_For::checkLoopUsageCondition in Translation template extractor 6.3

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

File

vendor/Twig/TokenParser/For.php, line 86

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);
  }
}