当前位置: 首页>>代码示例>>PHP>>正文


PHP DocBlock::getContext方法代码示例

本文整理汇总了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());
    }
开发者ID:ecmattos,项目名称:codemat,代码行数:28,代码来源:DocBlockTest.php

示例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);
 }
开发者ID:eristoddle,项目名称:zen-notebook,代码行数:25,代码来源:Tag.php

示例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);
 }
开发者ID:CobaltBlueDW,项目名称:oddsandends,代码行数:27,代码来源:Tag.php

示例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());
 }
开发者ID:jaapio,项目名称:ReflectionDocBlock,代码行数:13,代码来源:DocBlockTest.php


注:本文中的phpDocumentor\Reflection\DocBlock::getContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。