本文整理汇总了PHP中phpDocumentor\Reflection\DocBlock::getContext方法的典型用法代码示例。如果您正苦于以下问题:PHP DocBlock::getContext方法的具体用法?PHP DocBlock::getContext怎么用?PHP DocBlock::getContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phpDocumentor\Reflection\DocBlock
的用法示例。
在下文中一共展示了DocBlock::getContext方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testConstruct
/**
* @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());
}
示例2: createInstance
/**
* Factory method responsible for instantiating the correct sub type.
*
* @param string $tag_line The text for this tag, including description.
* @param DocBlock $docblock The DocBlock which this tag belongs to.
* @param Location $location Location of the tag.
*
* @throws \InvalidArgumentException if an invalid tag line was presented.
*
* @return static A new tag object.
*/
public static final function createInstance($tag_line, DocBlock $docblock = null, Location $location = null)
{
$matches = self::extractTagParts($tag_line);
$handler = __CLASS__;
if (isset(self::$tagHandlerMappings[$matches[1]])) {
$handler = self::$tagHandlerMappings[$matches[1]];
} elseif (isset($docblock)) {
$tagName = (string) new Type\Collection(array($matches[1]), $docblock->getContext());
if (isset(self::$tagHandlerMappings[$tagName])) {
$handler = self::$tagHandlerMappings[$tagName];
}
}
return new $handler($matches[1], isset($matches[2]) ? $matches[2] : '', $docblock, $location);
}
示例3: createInstance
/**
* Factory method responsible for instantiating the correct sub type.
*
* @param string $tag_line The text for this tag, including description.
* @param DocBlock $docblock The DocBlock which this tag belongs to.
* @param Location $location Location of the tag.
*
* @throws \InvalidArgumentException if an invalid tag line was presented.
*
* @return static A new tag object.
*/
public static final function createInstance($tag_line, DocBlock $docblock = null, Location $location = null)
{
if (!preg_match('/^@([\\w\\-\\_\\\\]+)(?:\\s*([^\\s].*)|$)?/us', $tag_line, $matches)) {
throw new \InvalidArgumentException('Invalid tag_line detected: ' . $tag_line);
}
$handler = __CLASS__;
if (isset(self::$tagHandlerMappings[$matches[1]])) {
$handler = self::$tagHandlerMappings[$matches[1]];
} elseif (isset($docblock)) {
$tagName = (string) new Type\Collection(array($matches[1]), $docblock->getContext());
if (isset(self::$tagHandlerMappings[$tagName])) {
$handler = self::$tagHandlerMappings[$tagName];
}
}
return new $handler($matches[1], isset($matches[2]) ? $matches[2] : '', $docblock, $location);
}
示例4: testDocBlockKnowsInWhichNamespaceItIsAndWhichAliasesThereAre
/**
* @covers ::__construct
* @covers ::getContext
*
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\Types\Context
*/
public function testDocBlockKnowsInWhichNamespaceItIsAndWhichAliasesThereAre()
{
$context = new Context('');
$fixture = new DocBlock('', null, [], $context);
$this->assertSame($context, $fixture->getContext());
}