You are here

final public static function Tag::createInstance in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/phpdocumentor/reflection-docblock/src/phpDocumentor/Reflection/DocBlock/Tag.php \phpDocumentor\Reflection\DocBlock\Tag::createInstance()

Factory method responsible for instantiating the correct sub type.

Parameters

string $tag_line The text for this tag, including description.:

DocBlock $docblock The DocBlock which this tag belongs to.:

Location $location Location of the tag.:

Return value

static A new tag object.

Throws

\InvalidArgumentException if an invalid tag line was presented.

9 calls to Tag::createInstance()
Description::getParsedContents in vendor/phpdocumentor/reflection-docblock/src/phpDocumentor/Reflection/DocBlock/Description.php
Returns the parsed text of this description.
DocBlock::parseTags in vendor/phpdocumentor/reflection-docblock/src/phpDocumentor/Reflection/DocBlock.php
Creates the tag objects.
TagTest::testIncompatibleTagHandlerRegistration in vendor/phpdocumentor/reflection-docblock/tests/phpDocumentor/Reflection/DocBlock/TagTest.php
@covers \phpDocumentor\Reflection\DocBlock\Tag::registerTagHandler
TagTest::testInvalidTagLine in vendor/phpdocumentor/reflection-docblock/tests/phpDocumentor/Reflection/DocBlock/TagTest.php
@expectedException \InvalidArgumentException
TagTest::testNamespacedTagHandlerCorrectRegistration in vendor/phpdocumentor/reflection-docblock/tests/phpDocumentor/Reflection/DocBlock/TagTest.php
@depends testTagHandlerCorrectRegistration @covers \phpDocumentor\Reflection\DocBlock\Tag::registerTagHandler @covers \phpDocumentor\Reflection\DocBlock\Tag::createInstance

... See full list

File

vendor/phpdocumentor/reflection-docblock/src/phpDocumentor/Reflection/DocBlock/Tag.php, line 112

Class

Tag
Parses a tag definition for a DocBlock.

Namespace

phpDocumentor\Reflection\DocBlock

Code

public static final function createInstance($tag_line, DocBlock $docblock = null, Location $location = null) {
  if (!preg_match('/^@(' . self::REGEX_TAGNAME . ')(?:\\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);
}