Skip to content

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

License

Notifications You must be signed in to change notification settings

phpowermove/docblock

Repository files navigation

Docblock

License Latest Stable Version Total Downloads Tests Coverage report Scrutinizer Code Quality Code Coverage

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

Installation

Install via Composer:

composer require gossi/docblock

Usage

1. Generate a Docblock instance

a) Simple:

use gossi\docblock\Docblock;

$docblock = new Docblock();

b) Create from string:

use gossi\docblock\Docblock;

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

c) Create from reflection:

use gossi\docblock\Docblock;

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

2. Manipulate tags

Get the tags:

$tags = $docblock->getTags();

Get tags by name:

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

Append a tag:

use gossi\docblock\tags\AuthorTag;

$author = new AuthorTag();
$author->setName('gossi');
$docblock->appendTag($author);

or with fluent API:

use gossi\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://gossi.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

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages