Documentation

MethodTag extends ReturnTag
in package

Reflection class for a @method in a Docblock.

Tags
author

Mike van Riel mike.vanriel@naenius.com

license

http://www.opensource.org/licenses/mit-license.php MIT

link
http://phpdoc.org

Table of Contents

REGEX_TAGNAME  = '[\w\-\_\\]+'
PCRE regular expression matching a tag name.
$arguments  : string
$content  : string|null
$description  : string
$docblock  : DocBlock
$isStatic  : bool
$location  : Location
$method_name  : string
$parsedDescription  : array<string|int, mixed>|null
$tag  : string
$type  : string
$types  : Collection
$tagHandlerMappings  : array<string|int, mixed>
__construct()  : mixed
Parses a tag and populates the member variables.
__toString()  : string
Returns the tag as a serialized string
addType()  : $this
Add a type to the type section of the variable
createInstance()  : static
Factory method responsible for instantiating the correct sub type.
export()  : void
Builds a string representation of this object.
getArguments()  : array<string|int, string>
Returns an array containing each argument as array of type and name.
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.
getLocation()  : Location
Gets the location of the tag.
getMethodName()  : string
Retrieves the method name.
getName()  : string
Gets the name of this tag.
getParsedDescription()  : array<string|int, mixed>
Gets the parsed text of this description.
getType()  : string
Returns the type section of the variable.
getTypes()  : array<string|int, string>
Returns the unique types of the variable.
isStatic()  : bool
Checks whether the method tag describes a static method or not.
registerTagHandler()  : bool
Registers a handler for tags.
setArguments()  : void
Sets the arguments for this method.
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.
setIsStatic()  : $this
Sets a new value for whether the method is static or not.
setLocation()  : $this
Sets the location of the tag.
setMethodName()  : $this
Sets the name of this method.
setName()  : $this
Sets the name of this tag.
setType()  : $this
Set the type section of the variable
getTypesCollection()  : void
Returns the type collection.

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.

$location

protected Location $location = null

Location of the tag.

$method_name

protected string $method_name = ''

$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.

$tag

protected string $tag = ''

Name of the tag

$type

protected string $type = ''

The raw type component.

$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

addType()

Add a type to the type section of the variable

public addType(string $type) : $this
Parameters
$type : string
Return values
$this

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
throws
InvalidArgumentException

if an invalid tag line was presented.

Return values
static

A new tag object.

export()

Builds a string representation of this object.

public static export() : void
Tags
todo

determine the exact format as used by PHP Reflection and implement it.

codeCoverageIgnore

Not yet implemented

Return values
void

getArguments()

Returns an array containing each argument as array of type and name.

public getArguments() : array<string|int, string>

Please note that the argument sub-array may only contain 1 element if no type was specified.

Return values
array<string|int, string>

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.

getLocation()

Gets the location of the tag.

public getLocation() : Location
Return values
Location

The tag's location.

getMethodName()

Retrieves the method name.

public getMethodName() : string
Return values
string

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.

getType()

Returns the type section of the variable.

public getType() : string
Return values
string

getTypes()

Returns the unique types of the variable.

public getTypes() : array<string|int, string>
Return values
array<string|int, string>

isStatic()

Checks whether the method tag describes a static method or not.

public isStatic() : bool
Return values
bool

TRUE if the method declaration is for a static method, FALSE otherwise.

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.

setArguments()

Sets the arguments for this method.

public setArguments(string $arguments) : void
Parameters
$arguments : string

A comma-separated arguments line.

Return values
void

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

setIsStatic()

Sets a new value for whether the method is static or not.

public setIsStatic(bool $isStatic) : $this
Parameters
$isStatic : bool

The new value to set.

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

setMethodName()

Sets the name of this method.

public setMethodName(string $method_name) : $this
Parameters
$method_name : string

The name of the method.

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
throws
InvalidArgumentException

When an invalid tag name is provided.

Return values
$this

setType()

Set the type section of the variable

public setType(string $type) : $this
Parameters
$type : string
Return values
$this

getTypesCollection()

Returns the type collection.

protected getTypesCollection() : void
Return values
void

Search results