v1/vendor/phpowermove/docblock
Gdilove 927f32325b 初始化 2023-11-13 20:36:13 +08:00
..
.github/workflows 初始化 2023-11-13 20:36:13 +08:00
.settings 初始化 2023-11-13 20:36:13 +08:00
src 初始化 2023-11-13 20:36:13 +08:00
tests 初始化 2023-11-13 20:36:13 +08:00
.gitignore 初始化 2023-11-13 20:36:13 +08:00
.php-cs-fixer.php 初始化 2023-11-13 20:36:13 +08:00
.project 初始化 2023-11-13 20:36:13 +08:00
LICENSE 初始化 2023-11-13 20:36:13 +08:00
README.md 初始化 2023-11-13 20:36:13 +08:00
composer.json 初始化 2023-11-13 20:36:13 +08:00
phpunit.xml.dist 初始化 2023-11-13 20:36:13 +08:00
psalm.xml 初始化 2023-11-13 20:36:13 +08:00
sami.php 初始化 2023-11-13 20:36:13 +08:00

README.md

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.

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:

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'));

2. Manipulate tags

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');

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