Documentation

Description
in package

Object representing to description for a DocBlock.

A Description object can consist of plain text but can also include tags. A Description Formatter can then combine a body template with sprintf-style placeholders together with formatted tags in order to reconstitute a complete description text using the format that you would prefer.

Because parsing a Description text can be a verbose process this is handled by the DescriptionFactory. It is thus recommended to use that to create a Description object, like this:

$description = $descriptionFactory->create('This is a <a href="classes/phpDocumentor-Reflection-DocBlock-Description.html"><abbr title="\phpDocumentor\Reflection\DocBlock\Description">Description</abbr></a>', $context);

The description factory will interpret the given body and create a body template and list of tags from them, and pass that onto the constructor if this class.

The $context variable is a class of type Context and contains the namespace and the namespace aliases that apply to this DocBlock. These are used by the Factory to resolve and expand partial type names and FQSENs.

If you do not want to use the DescriptionFactory you can pass a body template and tag listing like this:

$description = new Description(
    'This is a %1$s',
    [ new See(new Fqsen('\phpDocumentor\Reflection\DocBlock\Description')) ]
);

It is generally recommended to use the Factory as that will also apply escaping rules, while the Description object is mainly responsible for rendering.

Tags
see
DescriptionFactory

to create a new Description.

see
Formatter

for the formatting of the body and tags.

Table of Contents

$bodyTemplate  : string
$tags  : array<string|int, mixed>
__construct()  : mixed
Initializes a Description with its body (template) and a listing of the tags used in the body template.
__toString()  : string
Returns a plain string representation of this description.
getBodyTemplate()  : string
Returns the body template.
getTags()  : array<string|int, Tag>
Returns the tags for this DocBlock.
render()  : string
Renders this description as a string where the provided formatter will format the tags in the expected string format.

Properties

Methods

__construct()

Initializes a Description with its body (template) and a listing of the tags used in the body template.

public __construct(string $bodyTemplate[, array<string|int, Tag$tags = [] ]) : mixed
Parameters
$bodyTemplate : string
$tags : array<string|int, Tag> = []
Return values
mixed

__toString()

Returns a plain string representation of this description.

public __toString() : string
Return values
string

getBodyTemplate()

Returns the body template.

public getBodyTemplate() : string
Return values
string

getTags()

Returns the tags for this DocBlock.

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

render()

Renders this description as a string where the provided formatter will format the tags in the expected string format.

public render([Formatter|null $formatter = null ]) : string
Parameters
$formatter : Formatter|null = null
Return values
string

Search results