Creates a Tag object given the contents of a tag.

This Factory is capable of determining the appropriate class for a tag and instantiate it using its create
factory method. The create factory method of a Tag can have a variable number of arguments; this way you can
pass the dependencies that you need to construct a tag object.

Important: each parameter in addition to the body variable for the create method must default to null, otherwise
it violates the constraint with the interface; it is recommended to use the {@see \Assert::notNull()} method to
verify that a dependency is actually passed.

This Factory also features a Service Locator component that is used to pass the right dependencies to the
create method of a tag; each dependency should be registered as a service or as a parameter.

When you want to use a Tag of your own with custom handling you need to call the registerTagHandler method, pass
the name of the tag and a Fully Qualified Class Name pointing to a class that implements the Tag interface.

public phpDocumentor\Reflection\DocBlock\StandardTagFactory::REGEX_TAGNAME = '[\w\-\_\\]+'
PCRE regular expression matching a tag name.

public __construct(phpDocumentor\Reflection\FqsenResolver $fqsenResolver, ?array $tagHandlers = NULL)
Initialize this tag factory with the means to resolve an FQSEN and optionally a list of tag handlers.

If no tag handlers are provided than the default list in the {@see \self::$tagHandlerMappings} property
is used.

  • see \self::registerTagHandler()to add a new tag handler to the existing default list.
public addParameter( $name, $value)

public addService( $service, $alias = NULL)

public create( $tagLine, ?phpDocumentor\Reflection\Types\Context $context = NULL)

public registerTagHandler( $tagName, $handler)

private $fqsenResolver

  • var FqsenResolver
private $serviceLocator

  • var array an array representing a simple Service Locator where we can store parameters and services that can be inserted into the Factory Methods of Tag Handlers.
private $tagHandlerMappings

  • var string[] An array with a tag as a key, and an FQCN to a class that handles it as an array value.
private $tagHandlerParameterCache

  • var ReflectionParameter[][] a lazy-loading cache containing parameters for each tagHandler that has been used.
private createTag( $body, $name, phpDocumentor\Reflection\Types\Context $context)
Creates a new tag object with the given name and body or returns null if the tag name was recognized but the body was invalid.

  • return Tag|null
private extractTagParts( $tagLine)
Extracts all components for a tag.

  • return string[]
private fetchParametersForHandlerFactoryMethod( $handlerClassName)
Retrieves a series of ReflectionParameter objects for the static 'create' method of the given tag handler class name.

  • return ReflectionParameter[]
private findHandlerClassName( $tagName, phpDocumentor\Reflection\Types\Context $context)
Determines the Fully Qualified Class Name of the Factory or Tag (containing a Factory Method `create`).

  • return string
private getArgumentsForParametersFromWiring( $parameters, $locator)
Retrieves the arguments that need to be passed to the Factory Method with the given Parameters.

  • return array A series of values that can be passed to the Factory Method of the tag whose parameters is provided with this method.
private getServiceLocatorWithDynamicParameters(phpDocumentor\Reflection\Types\Context $context, $tagName, $tagBody)
Returns a copy of this class' Service Locator with added dynamic parameters, such as the tag's name, body and Context.

  • return array
private isAnnotation( $tagContent)
Returns whether the given tag belongs to an annotation.

  • todo this method should be populated once we implement Annotation notation support.
  • return bool
© 2020 Bruce Wells
Search Namespaces \ Classes
ConfigurationNumbers (0-9.) only