SourceTag
extends Tag
in package
Reflection class for a @source tag in a Docblock.
Tags
Table of Contents
- REGEX_TAGNAME = '[\w\-\_\\]+'
- PCRE regular expression matching a tag name.
- $content : string|null
- $description : string
- $docblock : DocBlock
- $lineCount : int|null
- $location : Location
- $parsedDescription : array<string|int, mixed>|null
- $startingLine : int
- $tag : string
- $tagHandlerMappings : array<string|int, mixed>
- __construct() : mixed
- Parses a tag and populates the member variables.
- __toString() : string
- Returns the tag as a serialized string
- createInstance() : static
- Factory method responsible for instantiating the correct sub type.
- export() : void
- Builds a string representation of this object.
- getContent() : string
- Gets the content of this tag.
- getDescription() : string
- Gets the description component of this tag.
- getDocBlock() : DocBlock
- Gets the docblock this tag belongs to.
- getLineCount() : int|null
- Returns the number of lines.
- getLocation() : Location
- Gets the location of the tag.
- getName() : string
- Gets the name of this tag.
- getParsedDescription() : array<string|int, mixed>
- Gets the parsed text of this description.
- getStartingLine() : int
- Gets the starting line.
- registerTagHandler() : bool
- Registers a handler for tags.
- setContent() : $this
- Sets the content of this tag.
- setDescription() : $this
- Sets the description component of this tag.
- setDocBlock() : $this
- Sets the docblock this tag belongs to.
- setLineCount() : $this
- Sets the number of lines.
- setLocation() : $this
- Sets the location of the tag.
- setName() : $this
- Sets the name of this tag.
- setStartingLine() : $this
- Sets the starting line.
Constants
REGEX_TAGNAME
PCRE regular expression matching a tag name.
public
mixed
REGEX_TAGNAME
= '[\w\-\_\\]+'
Properties
$content
protected
string|null
$content
= ''
Content of the tag. When set to NULL, it means it needs to be regenerated.
$description
protected
string
$description
= ''
Description of the content of this tag
$docblock
protected
DocBlock
$docblock
= null
The DocBlock which this tag belongs to.
$lineCount
protected
int|null
$lineCount
= null
The number of lines, relative to the starting line. NULL means "to the end".
$location
protected
Location
$location
= null
Location of the tag.
$parsedDescription
protected
array<string|int, mixed>|null
$parsedDescription
= null
The description, as an array of strings and Tag objects. When set to NULL, it means it needs to be regenerated.
$startingLine
protected
int
$startingLine
= 1
The starting line, relative to the structural element's location.
$tag
protected
string
$tag
= ''
Name of the tag
$tagHandlerMappings
private
static array<string|int, mixed>
$tagHandlerMappings
= array('author' => '\Barryvdh\Reflection\DocBlock\Tag\AuthorTag', 'covers' => '\Barryvdh\Reflection\DocBlock\Tag\CoversTag', 'deprecated' => '\Barryvdh\Reflection\DocBlock\Tag\DeprecatedTag', 'example' => '\Barryvdh\Reflection\DocBlock\Tag\ExampleTag', 'link' => '\Barryvdh\Reflection\DocBlock\Tag\LinkTag', 'method' => '\Barryvdh\Reflection\DocBlock\Tag\MethodTag', 'param' => '\Barryvdh\Reflection\DocBlock\Tag\ParamTag', 'property-read' => '\Barryvdh\Reflection\DocBlock\Tag\PropertyReadTag', 'property' => '\Barryvdh\Reflection\DocBlock\Tag\PropertyTag', 'property-write' => '\Barryvdh\Reflection\DocBlock\Tag\PropertyWriteTag', 'return' => '\Barryvdh\Reflection\DocBlock\Tag\ReturnTag', 'see' => '\Barryvdh\Reflection\DocBlock\Tag\SeeTag', 'since' => '\Barryvdh\Reflection\DocBlock\Tag\SinceTag', 'source' => '\Barryvdh\Reflection\DocBlock\Tag\SourceTag', 'throw' => '\Barryvdh\Reflection\DocBlock\Tag\ThrowsTag', 'throws' => '\Barryvdh\Reflection\DocBlock\Tag\ThrowsTag', 'uses' => '\Barryvdh\Reflection\DocBlock\Tag\UsesTag', 'var' => '\Barryvdh\Reflection\DocBlock\Tag\VarTag', 'version' => '\Barryvdh\Reflection\DocBlock\Tag\VersionTag')
An array with a tag as a key, and an FQCN to a class that handles it as an array value. The class is expected to inherit this class.
Methods
__construct()
Parses a tag and populates the member variables.
public
__construct(string $name, string $content[, DocBlock $docblock = null ][, Location $location = null ]) : mixed
Parameters
- $name : string
-
Name of the tag.
- $content : string
-
The contents of the given tag.
- $docblock : DocBlock = null
-
The DocBlock which this tag belongs to.
- $location : Location = null
-
Location of the tag.
Return values
mixed —__toString()
Returns the tag as a serialized string
public
__toString() : string
Return values
string —createInstance()
Factory method responsible for instantiating the correct sub type.
public
final static createInstance(string $tag_line[, DocBlock $docblock = null ][, Location $location = null ]) : static
Parameters
- $tag_line : string
-
The text for this tag, including description.
- $docblock : DocBlock = null
-
The DocBlock which this tag belongs to.
- $location : Location = null
-
Location of the tag.
Tags
Return values
static —A new tag object.
export()
Builds a string representation of this object.
public
static export() : void
Tags
Return values
void —getContent()
Gets the content of this tag.
public
getContent() : string
Return values
string —getDescription()
Gets the description component of this tag.
public
getDescription() : string
Return values
string —getDocBlock()
Gets the docblock this tag belongs to.
public
getDocBlock() : DocBlock
Return values
DocBlock —The docblock this tag belongs to.
getLineCount()
Returns the number of lines.
public
getLineCount() : int|null
Return values
int|null —The number of lines, relative to the starting line. NULL means "to the end".
getLocation()
Gets the location of the tag.
public
getLocation() : Location
Return values
Location —The tag's location.
getName()
Gets the name of this tag.
public
getName() : string
Return values
string —The name of this tag.
getParsedDescription()
Gets the parsed text of this description.
public
getParsedDescription() : array<string|int, mixed>
Return values
array<string|int, mixed> —An array of strings and tag objects, in the order they occur within the description.
getStartingLine()
Gets the starting line.
public
getStartingLine() : int
Return values
int —The starting line, relative to the structural element's location.
registerTagHandler()
Registers a handler for tags.
public
final static registerTagHandler(string $tag, string|null $handler) : bool
Registers a handler for tags. The class specified is autoloaded if it's not available. It must inherit from this class.
Parameters
- $tag : string
-
Name of tag to regiser a handler for. When registering a namespaced tag, the full name, along with a prefixing slash MUST be provided.
- $handler : string|null
-
FQCN of handler. Specifing NULL removes the handler for the specified tag, if any.
Return values
bool —TRUE on success, FALSE on failure.
setContent()
Sets the content of this tag.
public
setContent(mixed $content) : $this
Parameters
- $content : mixed
-
The new content of this tag.
Return values
$this —setDescription()
Sets the description component of this tag.
public
setDescription(string $description) : $this
Parameters
- $description : string
-
The new description component of this tag.
Return values
$this —setDocBlock()
Sets the docblock this tag belongs to.
public
setDocBlock([DocBlock $docblock = null ]) : $this
Parameters
- $docblock : DocBlock = null
-
The new docblock this tag belongs to. Setting NULL removes any association.
Return values
$this —setLineCount()
Sets the number of lines.
public
setLineCount(int|null $lineCount) : $this
Parameters
- $lineCount : int|null
-
The new number of lines, relative to the starting line. NULL means "to the end".
Return values
$this —setLocation()
Sets the location of the tag.
public
setLocation([Location $location = null ]) : $this
Parameters
- $location : Location = null
-
The new location of the tag.
Return values
$this —setName()
Sets the name of this tag.
public
setName(string $name) : $this
Parameters
- $name : string
-
The new name of this tag.
Tags
Return values
$this —setStartingLine()
Sets the starting line.
public
setStartingLine(int $startingLine) : $this
Parameters
- $startingLine : int
-
The new starting line, relative to the structural element's location.