Skip to content

Repository files navigation

Docblock

LicenseLatest Stable VersionTotal DownloadsTestsCoverage reportScrutinizer Code QualityCode Coverage

PHP Docblock parser and generator. An API to read and write Docblocks.

WARNING: starting from version 4.0 the library has moved to phpowermove organization and the namespace is phpowermove\docblock.

Installation

Install via Composer:

composer require phpowermove/docblock

Usage

1. Generate a Docblock instance

a) Simple:

usephpowermove\docblock\Docblock;
$docblock = newDocblock();

b) Create from string:

usephpowermove\docblock\Docblock;
$docblock = newDocblock('/** * Short Description. * * Long Description. * * @author gossi */');

c) Create from reflection:

usephpowermove\docblock\Docblock;
$docblock = newDocblock(new \ReflectionClass('MyClass'));

2. Manipulate tags

Get the tags:

$tags = $docblock->getTags();

Get tags by name:

$tags = $docblock->getTags('author');

Append a tag:

usephpowermove\docblock\tags\AuthorTag;
$author = newAuthorTag();
$author->setName('gossi');
$docblock->appendTag($author);

or with fluent API:

usephpowermove\docblock\tags\AuthorTag;
$docblock->appendTag(AuthorTag::create()
->setName('gossi')
);

Check tag existence:

$docblock->hasTag('author');

3. Get back the string

Call toString():

$docblock->toString();

or if you are in a write-context, the magical __toString() will take care of it:

echo$docblock;

Documentation Api

See https://phpowermove.github.io/docblock

Contributing

Feel free to fork and submit a pull request (don't forget the tests) and I am happy to merge.

References

Changelog

Refer to Releases

About

PHP DocBlock parser and generator. An API to read and write DocBlocks.

Topics

Resources

Stars

25 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages