Example #1
0
 function enterNode(\PhpParser\Node $node)
 {
     if ($node instanceof \PhpParser\Node\Stmt\Namespace_) {
         $this->addNamespace(array('namespace' => $node->name->toString(), 'line' => $node->getLine(), 'file' => $this->file));
     }
     if ($node instanceof \PhpParser\Node\Stmt\Use_) {
         foreach ($node->uses as $use) {
             $this->addUse(array('name' => $use->name, 'alias' => $use->alias));
         }
     }
     if ($node instanceof \PhpParser\Node\Stmt\Class_) {
         $this->addClass(array('name' => $node->name, 'extends' => $node->extends, 'implements' => $node->implements, 'abstract' => $node->isAbstract(), 'final' => $node->isFinal(), 'comment' => $node->getDocComment(), 'doc' => $this->doc_comment_parser->parse($node->getDocComment()), 'line' => $node->getLine(), 'file' => $this->file));
     }
     if ($node instanceof \PhpParser\Node\Stmt\Interface_) {
         $this->addInterface(array('name' => $node->name, 'extends' => $node->extends, 'comment' => $node->getDocComment(), 'doc' => $this->doc_comment_parser->parse($node->getDocComment()), 'line' => $node->getLine(), 'file' => $this->file));
     }
     if ($node instanceof \PhpParser\Node\Stmt\ClassMethod) {
         $this->addClassMethod(array('byRef' => $node->byRef, 'name' => $node->name, 'params' => $node->params, 'returnType' => $node->returnType, 'public' => $node->isPublic(), 'protected' => $node->isProtected(), 'private' => $node->isPrivate(), 'abstract' => $node->isAbstract(), 'final' => $node->isFinal(), 'static' => $node->isStatic(), 'comment' => $node->getDocComment(), 'doc' => $this->doc_comment_parser->parse($node->getDocComment()), 'line' => $node->getLine(), 'file' => $this->file));
     }
     if ($node instanceof \PhpParser\Node\Stmt\Property) {
         $this->last_property = $node;
     }
     if ($node instanceof \PhpParser\Node\Stmt\PropertyProperty) {
         $this->addClassProperty(array('name' => $node->name, 'default' => $node->default, 'public' => $this->last_property->isPublic(), 'protected' => $this->last_property->isProtected(), 'private' => $this->last_property->isPrivate(), 'static' => $this->last_property->isStatic(), 'comment' => $node->getDocComment(), 'doc' => $this->doc_comment_parser->parse($node->getDocComment()), 'line' => $node->getLine(), 'file' => $this->file));
     }
     // $this->logger->info(get_class($node));
 }
 public final function enter(Node $node)
 {
     if ($node->getType() == 'Stmt_ClassMethod' && $node->isPublic()) {
         $fqcn = $this->getCurrentFqcn();
         $this->enterPublicMethod($fqcn, $node);
     }
 }
Example #3
0
 protected function enter(Node $node)
 {
     if ($node instanceof Property) {
         if ($node->isPublic()) {
             foreach ($node->props as $property) {
                 $this->dispatch(new \Solidifier\Defects\PublicAttribute($this->currentObjectType, $property->name, $node));
             }
         }
     }
 }
Example #4
0
 public function enter(Node $node)
 {
     switch ($node->getType()) {
         case 'Stmt_ClassMethod':
             if ($node->isPublic()) {
                 $fqcn = $this->getCurrentFqcn();
                 $this->getReflectionContext()->addMethodToClass($fqcn, $node->name);
             }
             break;
     }
 }
Example #5
0
 public function enter(Node $node)
 {
     switch ($node->getType()) {
         case 'Stmt_ClassMethod':
             if ($node->isPublic()) {
                 $this->context->pushState('trait-method', $node);
                 $this->enterPublicMethod($node);
             }
             break;
         case 'Stmt_TraitUse':
             $fqcn = $this->getCurrentFqcn();
             $currentVertex = $this->findVertex('trait', $fqcn);
             $this->enterTraitUse($node, $currentVertex);
             break;
     }
 }
Example #6
0
 /**
  * Ищвлекает тело метода из текущего узла
  *
  * @param Node|ClassMethod $stmt    Узел
  * @param Method[]         $methods Список методов
  *
  * @return void
  */
 private function extractMethod($stmt, array &$methods)
 {
     if (!$stmt instanceof ClassMethod) {
         return;
     }
     $skip = $this->isPublicOnly && $stmt->isPublic() === false;
     if (!$skip) {
         $methods[] = new Method(new MethodContext($this->context->namespace, $this->context->class), $stmt->name, $this->printer->prettyPrint([$stmt]));
     }
 }
Example #7
0
 /**
  * @param \PhpParser\Node $node
  */
 private function detectNewMagicDefinitions(Node $node)
 {
     if ($node instanceof Node\Stmt\ClassMethod && $node->isPublic() || ($node instanceof Node\Expr\MethodCall || $node instanceof Node\Expr\StaticCall) && is_string($node->name)) {
         if (strcasecmp($node->name, '__callStatic') === 0) {
             $this->getResult()->addRequirement(Reason::CALLSTATIC_MAGIC_METHOD, $node->getLine());
         } elseif (strcasecmp($node->name, '__invoke') === 0) {
             $this->getResult()->addRequirement(Reason::INVOKE_MAGIC_METHOD, $node->getLine());
         }
     } elseif ($node instanceof Node\Scalar\MagicConst\Dir) {
         $this->getResult()->addRequirement(Reason::DIR_MAGIC_CONSTANT, $node->getLine());
     }
 }