Sstalle\php7cc\NodeTraverser\Traverser::traverse PHP Метод

traverse() публичный Метод

public traverse ( array $nodes, Sstalle\php7cc\CompatibilityViolation\ContextInterface $context = null, array $tokens = [] )
$nodes array
$context Sstalle\php7cc\CompatibilityViolation\ContextInterface
$tokens array
    public function traverse(array $nodes, ContextInterface $context = null, array $tokens = array())
    {
        if ($context) {
            $tokenCollection = new TokenCollection($tokens);
            foreach ($this->visitors as $visitor) {
                if ($visitor instanceof VisitorInterface) {
                    $visitor->initializeContext($context);
                    $visitor->setTokenCollection($tokenCollection);
                }
            }
        }
        return parent::traverse($nodes);
    }

Usage Example

Пример #1
0
 /**
  * @param ContextInterface $context
  *
  * @return FileContext
  */
 public function checkContext(ContextInterface $context)
 {
     try {
         $parsedStatements = $this->parser->parse($context->getCheckedCode());
         $this->traverser->traverse($parsedStatements, $context, $this->lexer->getTokens());
     } catch (\Exception $e) {
         $context->addError(new CheckError($e->getMessage()));
     } catch (\ParseException $e) {
         $context->addError(new CheckError($e->getMessage(), $e->getLine()));
     }
 }
All Usage Examples Of Sstalle\php7cc\NodeTraverser\Traverser::traverse
Traverser