Inheritance: extends AbstractVisitor
 /**
  * {@inheritdoc}
  */
 public function enterNode(Node $node)
 {
     parent::enterNode($node);
     if (($node instanceof Node\Stmt\Break_ || $node instanceof Node\Stmt\Continue_) && $this->getCurrentLoopStack()->isEmpty()) {
         $messageText = sprintf('%s not in the loop or switch context', $node instanceof Node\Stmt\Break_ ? 'break' : 'continue');
         $this->addContextMessage($messageText, $node);
     }
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function enterNode(Node $node)
 {
     parent::enterNode($node);
     if ($this->isTargetLoopNode($node)) {
         $this->checkNestedByReferenceForeach($node);
     } elseif (!$this->getCurrentLoopStack()->isEmpty()) {
         $this->checkInternalArrayPointerAccessInByValueForeach($node);
         $this->checkArrayModificationByFunctionInByReferenceForeach($node);
         $this->checkAddingToArrayInByReferenceForeach($node);
     }
 }