https://github.com/phpowermove/docblock
PHP DocBlock parser and generator. An API to read and write DocBlocks.
https://github.com/phpowermove/docblock
docblock
Last synced: 18 days ago
JSON representation
PHP DocBlock parser and generator. An API to read and write DocBlocks.
- Host: GitHub
- URL: https://github.com/phpowermove/docblock
- Owner: phpowermove
- License: mit
- Created: 2014-05-27T23:30:22.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2021-09-22T17:03:26.000Z (over 3 years ago)
- Last Synced: 2025-04-15T03:54:55.990Z (18 days ago)
- Topics: docblock
- Language: PHP
- Size: 282 KB
- Stars: 24
- Watchers: 2
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Docblock
[](https://packagist.org/packages/phpowermove/docblock)
[](https://packagist.org/packages/phpowermove/docblock)
[](https://packagist.org/packages/phpowermove/docblock)


[](https://scrutinizer-ci.com/g/phpowermove/docblock/?branch=master)
[](https://scrutinizer-ci.com/g/phpowermove/docblock/?branch=master)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](https://github.com/phpowermove) and the namespace is `phpowermove\docblock`.
## Installation
Install via Composer:
```
composer require phpowermove/docblock
```## Usage
### 1. Generate a Docblock instance
a) Simple:
```php
use phpowermove\docblock\Docblock;$docblock = new Docblock();
```b) Create from string:
```php
use phpowermove\docblock\Docblock;$docblock = new Docblock('/**
* Short Description.
*
* Long Description.
*
* @author gossi
*/');
```c) Create from reflection:
```php
use phpowermove\docblock\Docblock;$docblock = new Docblock(new \ReflectionClass('MyClass'));
```### 2. Manipulate tags
Get the tags:
```php
$tags = $docblock->getTags();
```Get tags by name:
```php
$tags = $docblock->getTags('author');
```Append a tag:
```php
use phpowermove\docblock\tags\AuthorTag;$author = new AuthorTag();
$author->setName('gossi');
$docblock->appendTag($author);
```or with fluent API:
```php
use phpowermove\docblock\tags\AuthorTag;$docblock->appendTag(AuthorTag::create()
->setName('gossi')
);
```Check tag existence:
```php
$docblock->hasTag('author');
```### 3. Get back the string
Call `toString()`:
```php
$docblock->toString();
```or if you are in a write-context, the magical `__toString()` will take care of it:
```php
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
- This project uses the parsers from [phpDocumentor/ReflectionDocBlock](https://github.com/phpDocumentor/ReflectionDocBlock)
## Changelog
Refer to [Releases](https://github.com/phpowermove/docblock/releases)