コード例 #1
0
 /**
  * Tests the parseSubElements method
  *
  * @covers phpDocumentor\Reflection\ClassReflector::isFinal
  *
  * @return void
  */
 public function testIsFinal()
 {
     $node = new NodeMock2();
     $class_reflector = new ClassReflector($node);
     $this->assertFalse($class_reflector->isFinal());
     $node->type = \PHPParser_Node_Stmt_Class::MODIFIER_FINAL;
     $this->assertTrue($class_reflector->isFinal());
 }
コード例 #2
0
 public function enterNode(\PHPParser_Node $node)
 {
     $prettyPrinter = new \PHPParser_PrettyPrinter_Zend();
     switch (get_class($node)) {
         case 'PHPParser_Node_Stmt_Use':
             /** @var \PHPParser_Node_Stmt_UseUse $use */
             foreach ($node->uses as $use) {
                 $this->namespace_aliases[$use->alias] = implode('\\', $use->name->parts);
             }
             break;
         case 'PHPParser_Node_Stmt_Namespace':
             $this->current_namespace = implode('\\', $node->name->parts);
             break;
         case 'PHPParser_Node_Stmt_Class':
             $class = new ClassReflector($node);
             $class->setNamespaceAliases($this->namespace_aliases);
             $class->parseSubElements();
             $this->classes[] = $class;
             break;
         case 'PHPParser_Node_Stmt_Trait':
             $trait = new TraitReflector($node);
             $trait->setNamespaceAliases($this->namespace_aliases);
             $this->traits[] = $trait;
             break;
         case 'PHPParser_Node_Stmt_Interface':
             $interface = new InterfaceReflector($node);
             $interface->setNamespaceAliases($this->namespace_aliases);
             $interface->parseSubElements();
             $this->interfaces[] = $interface;
             break;
         case 'PHPParser_Node_Stmt_Function':
             $function = new FunctionReflector($node);
             $function->setNamespaceAliases($this->namespace_aliases);
             $this->functions[] = $function;
             break;
         case 'PHPParser_Node_Stmt_Const':
             foreach ($node->consts as $constant) {
                 $reflector = new ConstantReflector($node, $constant);
                 $reflector->setNamespaceAliases($this->namespace_aliases);
                 $this->constants[$reflector->getName()] = $reflector;
             }
             break;
         case 'PHPParser_Node_Expr_FuncCall':
             if ($node->name instanceof \PHPParser_Node_Name && $node->name == 'define') {
                 $name = trim($prettyPrinter->prettyPrintExpr($node->args[0]->value), '\'');
                 $constant = new \PHPParser_Node_Const($name, $node->args[1]->value, $node->getAttributes());
                 $constant->namespacedName = new \PHPParser_Node_Name(($this->current_namespace ? $this->current_namespace . '\\' : '') . $name);
                 // we use $constant here both times since this is a
                 // FuncCall, which combines properties that are otherwise
                 // split over 2 objects
                 $reflector = new ConstantReflector($constant, $constant);
                 $reflector->setNamespaceAliases($this->namespace_aliases);
                 $this->constants[$reflector->getName()] = $reflector;
             }
             break;
         case 'PHPParser_Node_Expr_Include':
             $include = new IncludeReflector($node);
             $include->setNamespaceAliases($this->namespace_aliases);
             $this->includes[] = $include;
             break;
     }
 }