enterNode() public method

public enterNode ( PhpParser\Node $node )
$node PhpParser\Node
Exemplo n.º 1
0
 public function enterNode(Node $node)
 {
     parent::enterNode($node);
     if ($node instanceof Class_) {
         $this->currentClass = (string) $node->namespacedName;
     }
     if ($node instanceof ClassMethod) {
         $methodName = $this->currentClass . ($node->isStatic() ? '::' : '->') . $node->name;
         $this->currentMethod[] = $methodName;
     }
     if ($node instanceof Function_) {
         $this->currentMethod[] = (string) $node->namespacedName;
     }
     if ($node instanceof FuncCall) {
         if ($this->isTombstoneFunction($node)) {
             $line = $node->getLine();
             $methodName = $this->getCurrentMethodName();
             $params = $this->extractParameters($node);
             $date = isset($params[0]) ? $params[0] : null;
             $author = isset($params[1]) ? $params[1] : null;
             $label = isset($params[2]) ? $params[2] : null;
             $tombstone = new Tombstone($date, $author, $label, $this->file, $line, $methodName);
             $this->tombstoneIndex->addTombstone($tombstone);
         }
     }
 }
Exemplo n.º 2
0
 public function enterNode(Node $node)
 {
     parent::enterNode($node);
     $comment = $node->getDocComment();
     if ($comment) {
         $regex = "(@(param|return|var|type)\\h+(\\S+))";
         $comment->setText(preg_replace_callback($regex, function ($match) {
             $type = $this->parseTypeDecl($match[2]);
             return "@{$match[1]} {$type}";
         }, $comment->getText()));
     }
 }
 function enterNode(\PhpParser\Node $node)
 {
     if ($this->useDocBlock) {
         if ($node instanceof Function_ || $node instanceof \PhpParser\Node\Stmt\ClassMethod) {
             $this->importReturnValue($node);
         }
         if ($node instanceof Property) {
             $this->importVarType($node);
         }
     }
     parent::enterNode($node);
 }
 /**
  * @param \PhpParser\Node $node
  */
 public function enterNode(Node $node)
 {
     parent::enterNode($node);
     if ($node instanceof UseUse) {
         $name = $node->name->toString();
         $this->addToRegistry($name);
     } elseif ($node instanceof Expr\StaticCall || $node instanceof Expr\StaticPropertyFetch || $node instanceof Expr\ClassConstFetch || $node instanceof Expr\New_ || $node instanceof Expr\Instanceof_) {
         if ($node->class instanceof Name) {
             $name = $node->class->toString();
             $this->addToRegistry($name);
         }
     }
 }
Exemplo n.º 5
0
 public function enterNode(Node $node)
 {
     parent::enterNode($node);
     try {
         if ($doc = $node->getDocComment()) {
             $docBlock = new DocBlock($doc->getText());
             if ($tagNames = $this->collectTagNamesBy($docBlock->getTags())) {
                 $node->setAttribute(self::TAG_NAMES_ATTRIBUTE, $tagNames);
             }
         }
     } catch (\Exception $e) {
         $parseError = new Error($e->getMessage(), $node->getLine());
         $this->logger->warning($parseError->getMessage(), array($this->file));
     }
 }
 /**
  * {@inheritDoc}
  */
 public function enterNode(Node $node)
 {
     parent::enterNode($node);
     if ($node instanceof Node\Stmt\Class_) {
         // Ticket #45 - This could potentially not be set for PHP 7 anonymous classes.
         if (isset($node->namespacedName)) {
             $this->currentStructuralElement = $node;
             $fqcn = $node->namespacedName->toString();
             $this->fqsenDependencyMap[$fqcn] = [];
             if ($node->extends) {
                 $this->fqsenDependencyMap[$fqcn][] = $node->extends->toString();
             }
             foreach ($node->implements as $implementedInterface) {
                 $this->fqsenDependencyMap[$fqcn][] = $implementedInterface->toString();
             }
         }
     } elseif ($node instanceof Node\Stmt\Interface_) {
         if (isset($node->namespacedName)) {
             $this->currentStructuralElement = $node;
             $fqcn = $node->namespacedName->toString();
             $this->fqsenDependencyMap[$fqcn] = [];
             if ($node->extends) {
                 $extends = $node->extends;
                 /** @var Node\Name $extends */
                 foreach ($node->extends as $extends) {
                     $this->fqsenDependencyMap[$fqcn][] = $extends->toString();
                 }
             }
         }
     } elseif ($node instanceof Node\Stmt\Trait_) {
         if (isset($node->namespacedName)) {
             $this->currentStructuralElement = $node;
             $fqcn = $node->namespacedName->toString();
             $this->fqsenDependencyMap[$fqcn] = [];
         }
     } elseif ($node instanceof Node\Stmt\TraitUse) {
         $fqcn = $this->currentStructuralElement->namespacedName->toString();
         foreach ($node->traits as $trait) {
             $this->fqsenDependencyMap[$fqcn][] = $trait->toString();
         }
     }
 }
 /**
  * {@inheritDoc}
  */
 public function enterNode(Node $node)
 {
     parent::enterNode($node);
     if ($node instanceof Node\Stmt\Class_) {
         $this->parseClassNode($node);
     } elseif ($node instanceof Node\Stmt\Interface_) {
         $this->parseInterfaceNode($node);
     } elseif ($node instanceof Node\Stmt\Trait_) {
         $this->parseTraitNode($node);
     } elseif ($node instanceof Node\Stmt\TraitUse) {
         $this->parseTraitUseNode($node);
     } elseif ($node instanceof Node\Stmt\Property) {
         $this->parseClassPropertyNode($node);
     } elseif ($node instanceof Node\Stmt\ClassMethod) {
         $this->parseClassMethodNode($node);
     } elseif ($node instanceof Node\Stmt\ClassConst) {
         $this->parseClassConstantNode($node);
     } elseif ($node instanceof Node\Stmt\Function_) {
         $this->parseFunctionNode($node);
     } elseif ($node instanceof Node\Stmt\Const_) {
         $this->parseConstantNode($node);
     }
 }
 public function enterNode(Node $node)
 {
     parent::enterNode($node);
     try {
         if ($doc = $node->getDocComment()) {
             $docBlock = $this->docBlockFactory->create(str_replace('[]', '', $doc->getText()), new Context((string) $this->namespace, (array) $this->namespaceAliases));
             if ($tagNames = $this->collectTagNamesBy($docBlock->getTags())) {
                 $node->setAttribute(self::TAG_NAMES_ATTRIBUTE, $tagNames);
             }
         }
     } catch (\Exception $e) {
         $parseError = new Error($e->getMessage(), $node->getLine());
         $this->logger->warning($parseError->getMessage(), array($this->file));
     }
 }