DocBlock
DocBlock
The docblock parser class.
This class can be used to parse text comments in docblock format into an array of tags and their values.
Properties
vectors
Tags in the docblock that have a whitepace-delimited number of parameters
private array $vectors = array (
'param' =>
array (
'fields' =>
array (
0 => 'type',
1 => 'var',
2 => 'desc',
),
),
'return' =>
array (
0 => 'type',
1 => 'desc',
),
'var' =>
array (
'key' => 'var',
'fields' =>
array (
0 => 'type',
1 => 'var',
2 => 'desc',
),
),
'exception' =>
array (
0 => 'type',
1 => 'desc',
),
)(such as @param type var desc and @return type desc) and the names of those parameters.
brief
public string $briefdetail
public string $detailtags
The tags defined in the docblock.
private array $tagsThe array has keys which are the tag names (excluding the @) and values that are arrays, each of which is an entry for the tag.
In the case where the tag name is defined in {@see DocBlock
Methods
__construct
CONSTRUCTOR.
public __construct(NULL $comment): voidParameters
| Parameter | Type | Description |
|---|---|---|
$comment | NULL | The text of the docblock |
setComment
Set and parse the docblock comment.
public setComment(string $comment): voidParameters
| Parameter | Type | Description |
|---|---|---|
$comment | string | The docblock |
hasTag
Whether or not a docblock contains a given @tag.
public hasTag(string $tag): voidParameters
| Parameter | Type | Description |
|---|---|---|
$tag | string | The name of the @tag to check for |
tag
The value of a tag.
public tag(string $tag): voidParameters
| Parameter | Type | Description |
|---|---|---|
$tag | string |
tagImplode
The value of a tag (concatenated for multiple values).
public tagImplode(string $tag, string $sep = ' '): ?stringParameters
| Parameter | Type | Description |
|---|---|---|
$tag | string | |
$sep | string | The seperator for concatenating |
tagMerge
The value of a tag (merged recursively).
public tagMerge(string $tag): voidParameters
| Parameter | Type | Description |
|---|---|---|
$tag | string |
toArray
Return the parsed DocBlock as a nice friendly array.
public toArray(): voidbrief
Return the brief comment if set.
public brief(): ?stringdetail
Return the detailed comment if set.
public detail(): ?stringparseComment
Parse the comment into the component parts and set the state of the object.
protected parseComment(string $comment): voidParameters
| Parameter | Type | Description |
|---|---|---|
$comment | string | the docblock |
setDescription
Parse the description block.
protected setDescription(string $body): voidThis block can be either a single line, which will be used as the brief description. Anything after the first line is used as the detailed description.
Parameters
| Parameter | Type | Description |
|---|---|---|
$body | string | the description block |
trimTextBlock
private trimTextBlock(string $string): stringParameters
| Parameter | Type | Description |
|---|---|---|
$string | string |
isTagged
Whether or not a string begins with a @tag.
private isTagged(string $str): boolParameters
| Parameter | Type | Description |
|---|---|---|
$str | string |
strTag
The tag at the beginning of a string.
private strTag(string $str): ?stringParameters
| Parameter | Type | Description |
|---|---|---|
$str | string |
Generated by Hazaar API Doc Generator on Mon, 27 Oct 2025 13:01:29 +0000