class Tag implements Reflector

Class Tag - Parses a tag definition for a DocBlock.

Constants

REGEX_TAGNAME

PCRE regular expression matching a tag name.

Properties

protected string $tag
protected string|null $content
protected string $description
protected array|null $parsedDescription
protected Location $location
protected DocBlock $docblock

Methods

static Tag
createInstance(string $tagLine, DocBlock $docblock = null, Location $location = null)

Factory method responsible for instantiating the correct sub type.

static bool
registerTagHandler(string $tag, string|null $handler)

Registers a handler for tags.

__construct(string $name, string $content, DocBlock $docblock = null, Location $location = null)

Parses a tag and populates the member variables.

string
getTag()

No description

string
getName()

Gets the name of this tag.

Tag
setName(string $name)

Sets the name of this tag.

string
getContent()

Gets the content of this tag.

Tag
setContent(string $content)

Sets the content of this tag.

string
getDescription()

Gets the description component of this tag.

Tag
setDescription(string $description)

Sets the description component of this tag.

array
getParsedDescription()

Gets the parsed text of this description.

getDocBlock()

Gets the docblock this tag belongs to.

Tag
setDocBlock(DocBlock $docblock = null)

Sets the docblock this tag belongs to.

getLocation()

Gets the location of the tag.

Tag
setLocation(Location $location = null)

Sets the location of the tag.

static void
export()

Builds a string representation of this object.

string
__toString()

Returns the tag as a serialized string

Details

at line 103
final static Tag createInstance(string $tagLine, DocBlock $docblock = null, Location $location = null)

Factory method responsible for instantiating the correct sub type.

Parameters

string $tagLine The text for this tag, including description.
DocBlock $docblock The DocBlock which this tag belongs to.
Location $location Location of the tag.

Return Value

Tag A new tag object.

Exceptions

InvalidArgumentException if an invalid tag line was presented.

at line 146
final static bool registerTagHandler(string $tag, string|null $handler)

Registers a handler for tags.

Registers a handler for tags. The class specified is autoloaded if it's not available. It must inherit from this class.

Parameters

string $tag Name of tag to regiser a handler for. When registering a namespaced tag, the full name, along with a prefixing slash MUST be provided.
string|null $handler FQCN of handler. Specifing NULL removes the handler for the specified tag, if any.

Return Value

bool TRUE on success, FALSE on failure.

at line 174
__construct(string $name, string $content, DocBlock $docblock = null, Location $location = null)

Parses a tag and populates the member variables.

Parameters

string $name Name of the tag.
string $content The contents of the given tag.
DocBlock $docblock The DocBlock which this tag belongs to.
Location $location Location of the tag.

at line 186
string getTag()

Return Value

string

at line 196
string getName()

Gets the name of this tag.

Return Value

string The name of this tag.

at line 210
Tag setName(string $name)

Sets the name of this tag.

Parameters

string $name The new name of this tag.

Return Value

Tag

Exceptions

InvalidArgumentException When an invalid tag name is provided.

at line 227
string getContent()

Gets the content of this tag.

Return Value

string

at line 243
Tag setContent(string $content)

Sets the content of this tag.

Parameters

string $content The new content of this tag.

Return Value

Tag

at line 256
string getDescription()

Gets the description component of this tag.

Return Value

string

at line 268
Tag setDescription(string $description)

Sets the description component of this tag.

Parameters

string $description The new description component of this tag.

Return Value

Tag

at line 283
array getParsedDescription()

Gets the parsed text of this description.

Return Value

array An array of strings and tag objects, in the order they occur within the description.

at line 298
DocBlock getDocBlock()

Gets the docblock this tag belongs to.

Return Value

DocBlock The docblock this tag belongs to.

at line 310
Tag setDocBlock(DocBlock $docblock = null)

Sets the docblock this tag belongs to.

Parameters

DocBlock $docblock The new docblock this tag belongs to. Setting NULL removes any association.

Return Value

Tag

at line 322
Location getLocation()

Gets the location of the tag.

Return Value

Location The tag's location.

at line 334
Tag setLocation(Location $location = null)

Sets the location of the tag.

Parameters

Location $location The new location of the tag.

Return Value

Tag

at line 352
static void export()

Builds a string representation of this object.

Return Value

void

Exceptions

Exception

at line 362
string __toString()

Returns the tag as a serialized string

Return Value

string