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.

CloneableFinalInstantiable
ImplementsphpDocumentor\Reflection\DocBlock\TagFactory
Constants
public phpDocumentor\Reflection\DocBlock\StandardTagFactory::REGEX_TAGNAME = '[\w\-\_\\:]+'
 

PCRE regular expression matching a tag name.

Methods
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(string $name, $value) : void
 
    public addService(object $service, ?string $alias = NULL) : void
    public create(string $tagLine, ?phpDocumentor\Reflection\Types\Context $context = NULL) : phpDocumentor\Reflection\DocBlock\Tag
    public registerTagHandler(string $tagName, string $handler) : void
    Properties
    private $annotationMappings
     
    • var class-string<\Tag>[] An array with a anotation s a key, and an FQCN to a class that handles it as an array value.
    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 class-string<\Tag>[] 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.
    Methods
    private createTag(string $body, string $name, phpDocumentor\Reflection\Types\Context $context) : phpDocumentor\Reflection\DocBlock\Tag
     

    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.

    private extractTagParts(string $tagLine) : array
     

    Extracts all components for a tag.

    • return string[]
    private fetchParametersForHandlerFactoryMethod(string $handlerClassName) : array
     

    Retrieves a series of ReflectionParameter objects for the static 'create' method of the given
    tag handler class name.

    • return ReflectionParameter[]
    private findHandlerClassName(string $tagName, phpDocumentor\Reflection\Types\Context $context) : string
     

    Determines the Fully Qualified Class Name of the Factory or Tag (containing a Factory Method create).

    • return class-string<\Tag>
    private getArgumentsForParametersFromWiring(array $parameters, array $locator) : array
     

    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, string $tagName, string $tagBody) : array
     

    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(string $tagContent) : bool
     

    Returns whether the given tag belongs to an annotation.

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