/**
  * Tests the ctor and the {@link \PDepend\Source\AST\ASTClass::getName()}.
  *
  * @return void
  */
 public function testCreateNewClassInstance()
 {
     $class = new ASTClass(__CLASS__);
     $this->assertEquals(__CLASS__, $class->getName());
 }
 /**
  * Visits a class node.
  *
  * @param \PDepend\Source\AST\ASTClass $class
  * @return void
  */
 public function visitClass(ASTClass $class)
 {
     if (!$class->isUserDefined()) {
         return;
     }
     $doc = $this->packages->ownerDocument;
     $classXml = $doc->createElement('Class');
     $classXml->setAttribute('sourceFile', (string) $class->getCompilationUnit());
     $classXml->appendChild($doc->createTextNode($class->getName()));
     if ($class->isAbstract()) {
         $this->abstractClasses->appendChild($classXml);
     } else {
         $this->concreteClasses->appendChild($classXml);
     }
 }
예제 #3
0
    /**
     * Generates the XML for a class or trait node.
     *
     * @param \PDepend\Source\AST\ASTClass $type
     * @param string $typeIdentifier
     * @return void
     */
    private function generateTypeXml(ASTClass $type, $typeIdentifier)
    {
        if (!$type->isUserDefined()) {
            return;
        }

        $xml = end($this->xmlStack);
        $doc = $xml->ownerDocument;

        $typeXml = $doc->createElement($typeIdentifier);
        $typeXml->setAttribute('name', $type->getName());

        $this->writeNodeMetrics($typeXml, $type);
        $this->writeFileReference($typeXml, $type->getCompilationUnit());

        $xml->appendChild($typeXml);

        array_push($this->xmlStack, $typeXml);

        foreach ($type->getMethods() as $method) {
            $method->accept($this);
        }
        foreach ($type->getProperties() as $property) {
            $property->accept($this);
        }

        array_pop($this->xmlStack);
    }
 /**
  * Visits a class node.
  *
  * @param \PDepend\Source\AST\ASTClass $class
  * @return void
  */
 public function visitClass(ASTClass $class)
 {
     $this->visits[] = $class->getName();
     parent::visitClass($class);
 }
 /**
  * Visits a class node.
  *
  * @param \PDepend\Source\AST\ASTClass $class
  * @return void
  */
 public function visitClass(ASTClass $class)
 {
     if (!$class->isUserDefined()) {
         return;
     }
     $xml = end($this->xmlStack);
     $doc = $xml->ownerDocument;
     $classXml = $doc->createElement('class');
     $classXml->setAttribute('name', $class->getName());
     $this->writeNodeMetrics($classXml, $class);
     $this->writeFileReference($classXml, $class->getCompilationUnit());
     $xml->appendChild($classXml);
     array_push($this->xmlStack, $classXml);
     foreach ($class->getMethods() as $method) {
         $method->accept($this);
     }
     foreach ($class->getProperties() as $property) {
         $property->accept($this);
     }
     array_pop($this->xmlStack);
 }