Returns the current location.
public getLocation ( ) : phpDocumentor\Reflection\DocBlock\Location | ||
Résultat | phpDocumentor\Reflection\DocBlock\Location |
/** * Constructor * * @param string $name Name of the "entity" * @param DocBlock|null $docblock Docblock * @param BaseReflector|null $source Source Element. */ public function __construct($name, $docblock = null, $source = null) { $this->entityName = $name; $this->lineNumber = $docblock ? $docblock->getLocation()->getLineNumber() : $source->getLineNumber(); $this->docblock = $docblock; $this->source = $source; }
/** * Constructor * * @param \phpDocumentor\Plugin\Plugin $plugin Plugin to which this * validator belongs. * @param string $name Name of the "entity" * @param \phpDocumentor\Reflection\DocBlock|null $docblock Docblock * @param \phpDocumentor\Reflection\BaseReflector|null $source Source Element. */ public function __construct($plugin, $name, $docblock = null, $source = null) { $this->entityName = $name; $this->lineNumber = $docblock ? $docblock->getLocation()->getLineNumber() : $source->getLineNumber(); $this->docblock = $docblock; $this->source = $source; parent::__construct($plugin->getEventDispatcher(), $plugin->getConfiguration(), $plugin->getTranslator()); }
/** * @covers \phpDocumentor\Reflection\DocBlock * * @return void */ public function testConstruct() { $fixture = <<<DOCBLOCK /** * This is a short description * * This is a long description * * @see \\MyClass * @return void */ DOCBLOCK; $object = new DocBlock($fixture, new Context('\\MyNamespace', array('PHPDoc' => '\\phpDocumentor')), new Location(2)); $this->assertEquals('This is a short description', $object->getShortDescription()); $this->assertEquals('This is a long description', $object->getLongDescription()->getContents()); $this->assertCount(2, $object->getTags()); $this->assertTrue($object->hasTag('see')); $this->assertTrue($object->hasTag('return')); $this->assertFalse($object->hasTag('material_unit')); $this->assertSame('MyNamespace', $object->getContext()->getNamespace()); $this->assertSame(array('PHPDoc' => '\\phpDocumentor'), $object->getContext()->getNamespaceAliases()); $this->assertSame(2, $object->getLocation()->getLineNumber()); }
/** * @covers ::__construct * @covers ::getLocation * * @uses \phpDocumentor\Reflection\DocBlock\Description * @uses \phpDocumentor\Reflection\Location */ public function testDocBlockKnowsAtWhichLineItIs() { $location = new Location(10); $fixture = new DocBlock('', null, [], null, $location); $this->assertSame($location, $fixture->getLocation()); }