class DocCommentParser (View source)

A little parser which creates tag objects from doc comments

Properties

protected string $description

The description as found in the doc comment

protected array $tags

An array of tag names and their values (multiple values are possible)

Methods

void
parseDocComment(string $docComment)

Parses the given doc comment and saves the result (description and tags) in the parser's object. They can be retrieved by the getTags() getTagValues() and getDescription() methods.

array
getTagsValues()

Returns the tags which have been previously parsed

array
getTagValues(string $tagName)

Returns the values of the specified tag. The doc comment must be parsed with parseDocComment() before tags are available.

bool
isTaggedWith(string $tagName)

Checks if a tag with the given name exists

string
getDescription()

Returns the description which has been previously parsed

void
parseTag(string $line)

Parses a line of a doc comment for a tag and its value.

Details

void parseDocComment(string $docComment)

Parses the given doc comment and saves the result (description and tags) in the parser's object. They can be retrieved by the getTags() getTagValues() and getDescription() methods.

Parameters

string $docComment

A doc comment as returned by the reflection getDocComment() method

Return Value

void

array getTagsValues()

Returns the tags which have been previously parsed

Return Value

array

Array of tag names and their (multiple) values

array getTagValues(string $tagName)

Returns the values of the specified tag. The doc comment must be parsed with parseDocComment() before tags are available.

Parameters

string $tagName

The tag name to retrieve the values for

Return Value

array

The tag's values

Exceptions

Exception

bool isTaggedWith(string $tagName)

Checks if a tag with the given name exists

Parameters

string $tagName

The tag name to check for

Return Value

bool

true the tag exists, otherwise false

string getDescription()

Returns the description which has been previously parsed

Return Value

string

The description which has been parsed

protected void parseTag(string $line)

Parses a line of a doc comment for a tag and its value.

The result is stored in the internal tags array.

Parameters

string $line

A line of a doc comment which starts with an @-sign

Return Value

void