class DocblockTag (View source)

Hold the tag definition for one tag in a DocBlock.

The tag can be sliced into the following forms:

  • "@tag content"
  • "@tag word description"
  • "@tag $variable description"
  • "@tag word $variable description"

Constants

TAG_REGEX

VARIABLE_REGEX

VARIABLE_OR_WORD_REGEX

TYPE_REGEX

WORD_REGEX

DESCRIPTION_REGEX

IS_TAG_REGEX

Properties

protected string $tag
protected string|null $content

Methods

static bool
isTag(string $subject)

Check if the provided string begins with a tag

static bool
splitTagAndContent(string $subject, string[] $matches)

Use a regular expression to separate the tag from the content.

__construct($tag, $content = null)

DockblockTag constructor

appendContent($line)

Add more content onto a tag during parsing.

string
getTag()

Return the tag - e.g. "@foo description" returns 'foo'

string
getContent()

Return the content portion of the tag - e.g. "@foo bar baz boz" returns "bar baz boz"

__toString()

Convert tag back into a string.

bool
hasVariable(string[] $matches)

Determine if tag is one of:

  • "@tag variable description"
  • "@tag $variable description"
  • "@tag type $variable description"

bool
hasVariableAndDescription(string[] $matches)

Determine if tag is "@tag $variable description"

bool
hasTypeVariableAndDescription(string[] $matches)

Determine if tag is "@tag type $variable description"

bool
hasWordAndDescription(string[] $matches)

Determine if tag is "@tag word description"

Details

static bool isTag(string $subject)

Check if the provided string begins with a tag

Parameters

string $subject

Return Value

bool

static bool splitTagAndContent(string $subject, string[] $matches)

Use a regular expression to separate the tag from the content.

Parameters

string $subject
string[] $matches

Sets $matches['tag'] and $matches['description']

Return Value

bool

__construct($tag, $content = null)

DockblockTag constructor

Parameters

$tag
$content

appendContent($line)

Add more content onto a tag during parsing.

Parameters

$line

string getTag()

Return the tag - e.g. "@foo description" returns 'foo'

Return Value

string

string getContent()

Return the content portion of the tag - e.g. "@foo bar baz boz" returns "bar baz boz"

Return Value

string

__toString()

Convert tag back into a string.

bool hasVariable(string[] $matches)

Determine if tag is one of:

  • "@tag variable description"
  • "@tag $variable description"
  • "@tag type $variable description"

Parameters

string[] $matches

Sets $matches['variable'] and $matches['description']; might set $matches['type'].

Return Value

bool

bool hasVariableAndDescription(string[] $matches)

Determine if tag is "@tag $variable description"

Parameters

string[] $matches

Sets $matches['variable'] and $matches['description']

Return Value

bool

bool hasTypeVariableAndDescription(string[] $matches)

Determine if tag is "@tag type $variable description"

Parameters

string[] $matches

Sets $matches['variable'], $matches['description'] and $matches['type'].

Return Value

bool

bool hasWordAndDescription(string[] $matches)

Determine if tag is "@tag word description"

Parameters

string[] $matches

Sets $matches['word'] and $matches['description']

Return Value

bool