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.
Install via Composer:
composer require phpowermove/docblock
a) Simple:
use phpowermove\docblock\Docblock;
$docblock = new Docblock();b) Create from string:
use phpowermove\docblock\Docblock;
$docblock = new Docblock('/**
* Short Description.
*
* Long Description.
*
* @author gossi
*/');c) Create from reflection:
use phpowermove\docblock\Docblock;
$docblock = new Docblock(new \ReflectionClass('MyClass'));Get the tags:
$tags = $docblock->getTags();Get tags by name:
$tags = $docblock->getTags('author');Append a tag:
use phpowermove\docblock\tags\AuthorTag;
$author = new AuthorTag();
$author->setName('gossi');
$docblock->appendTag($author);or with fluent API:
use phpowermove\docblock\tags\AuthorTag;
$docblock->appendTag(AuthorTag::create()
->setName('gossi')
);Check tag existence:
$docblock->hasTag('author');Call toString():
$docblock->toString();or if you are in a write-context, the magical __toString() will take care of it:
echo $docblock;See https://phpowermove.github.io/docblock
Feel free to fork and submit a pull request (don't forget the tests) and I am happy to merge.
- This project uses the parsers from phpDocumentor/ReflectionDocBlock
Refer to Releases

