/**
  * testGetStartLineReturnsStartLineOfFirstToken
  *
  * @return void
  */
 public function testGetStartLineReturnsStartLineOfFirstToken()
 {
     $cache = $this->createCacheFixture();
     $cache->expects($this->once())->method('type')->will($this->returnValue($cache));
     $class = new ASTClass(__CLASS__);
     $class->setCache($cache)->setTokens(array(new Token(1, 'a', 23, 42, 0, 0), new Token(2, 'b', 17, 32, 0, 0)));
     $this->assertEquals(23, $class->getStartLine());
 }
Exemple #2
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', Utf8Util::ensureEncoding($type->getName()));
     $typeXml->setAttribute('start', Utf8Util::ensureEncoding($type->getStartLine()));
     $typeXml->setAttribute('end', Utf8Util::ensureEncoding($type->getEndLine()));
     $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);
 }