Documentation

DocblockGenerator extends AbstractGenerator
in package

Abstract generator class

Tags
category

Pop

author

Nick Sagona, III nick@popphp.org

copyright

Copyright (c) 2009-2026 Nick Sagona, III

license

https://www.popphp.org/license New BSD License

version
6.0.0

Table of Contents

Properties

$desc  : string|null
Docblock description
$indent  : int
Code indent spaces
$output  : string|null
Output string
$tags  : array<string|int, mixed>
Docblock tags

Methods

__construct()  : mixed
Constructor
__toString()  : string
Print docblock
addParam()  : DocblockGenerator
Add a param tag
addParams()  : DocblockGenerator
Add a param tag
addTag()  : DocblockGenerator
Add a basic tag
addTags()  : DocblockGenerator
Add basic tags
findParam()  : array<string|int, mixed>|null
Find a param tag by its variable name (e.g. '$foo'), not by index -- returns the first match's full ['type' => ..., 'var' => ..., 'desc' => ...] array, or null if none matches.
getDesc()  : string|null
Get the docblock description
getIndent()  : int
Get the indent
getOutput()  : string|null
Get the output
getParam()  : array<string|int, mixed>|null
Get a param
getReturn()  : array<string|int, mixed>|null
Get the return
getTag()  : string|null
Get a tag
getThrows()  : array<string|int, mixed>|null
Get the throws
hasDesc()  : bool
Has a docblock description
hasIndent()  : bool
Has indent
hasOutput()  : bool
Has output
hasParam()  : bool
Has a param
hasReturn()  : bool
Has a return
hasTag()  : bool
Has a tag
hasTags()  : bool
Has tags
hasThrows()  : bool
Has a throws
isRendered()  : bool
Is rendered (alias to hasOutput())
printIndent()  : string
Print the indent
removeParam()  : DocblockGenerator
Remove a param tag by its variable name (e.g. '$foo'), not by index -- removes the first match, if any, and re-indexes the remaining params. A no-op if no param has that variable name. Used to replace a stale @param entry when a caller re-adds a parameter of the same name with a different type (params are otherwise append-only via addParam()/addParams()).
render()  : string
Render docblock
setDesc()  : DocblockGenerator
Set the docblock description
setIndent()  : AbstractGenerator
Set the indent
setReturn()  : DocblockGenerator
Add a return tag
setThrows()  : DocblockGenerator
Add a throws tag
formatTags()  : string
Format the docblock tags
getParamLength()  : int
Get the longest param type length
getTagLength()  : int
Get the longest tag length

Properties

$tags

Docblock tags

protected array<string|int, mixed> $tags = ['param' => []]

Methods

__construct()

Constructor

public __construct([string|null $desc = null ][, int $indent = 4 ]) : mixed

Instantiate the docblock generator object

Parameters
$desc : string|null = null
$indent : int = 4

__toString()

Print docblock

public __toString() : string
Return values
string

addParam()

Add a param tag

public addParam([string|null $type = null ][, string|null $var = null ][, string|null $desc = null ]) : DocblockGenerator
Parameters
$type : string|null = null
$var : string|null = null
$desc : string|null = null
Return values
DocblockGenerator

findParam()

Find a param tag by its variable name (e.g. '$foo'), not by index -- returns the first match's full ['type' => ..., 'var' => ..., 'desc' => ...] array, or null if none matches.

public findParam(string $var) : array<string|int, mixed>|null

Used to look up (and preserve) an existing param's description before removeParam() discards it, e.g. when re-syncing a param entry that already carries a hand-written description from a reflected docblock.

Parameters
$var : string
Return values
array<string|int, mixed>|null

getDesc()

Get the docblock description

public getDesc() : string|null
Return values
string|null

getOutput()

Get the output

public getOutput() : string|null
Return values
string|null

getParam()

Get a param

public getParam(int $index) : array<string|int, mixed>|null
Parameters
$index : int
Return values
array<string|int, mixed>|null

getReturn()

Get the return

public getReturn() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null

getTag()

Get a tag

public getTag(string $name) : string|null
Parameters
$name : string
Return values
string|null

getThrows()

Get the throws

public getThrows() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null

hasDesc()

Has a docblock description

public hasDesc() : bool
Return values
bool

hasParam()

Has a param

public hasParam(int $index) : bool
Parameters
$index : int
Return values
bool

hasTag()

Has a tag

public hasTag(string $name) : bool
Parameters
$name : string
Return values
bool

isRendered()

Is rendered (alias to hasOutput())

public isRendered() : bool
Return values
bool

printIndent()

Print the indent

public printIndent() : string
Return values
string

removeParam()

Remove a param tag by its variable name (e.g. '$foo'), not by index -- removes the first match, if any, and re-indexes the remaining params. A no-op if no param has that variable name. Used to replace a stale @param entry when a caller re-adds a parameter of the same name with a different type (params are otherwise append-only via addParam()/addParams()).

public removeParam(string $var) : DocblockGenerator
Parameters
$var : string
Return values
DocblockGenerator

formatTags()

Format the docblock tags

protected formatTags() : string
Return values
string

getParamLength()

Get the longest param type length

protected getParamLength() : int
Return values
int

getTagLength()

Get the longest tag length

protected getTagLength() : int
Return values
int

        
On this page

Search results