Chris@0: The ReflectionDocBlock Component [![Build Status](https://secure.travis-ci.org/phpDocumentor/ReflectionDocBlock.png)](https://travis-ci.org/phpDocumentor/ReflectionDocBlock) Chris@0: ================================ Chris@0: Chris@0: Introduction Chris@0: ------------ Chris@0: Chris@0: The ReflectionDocBlock component of phpDocumentor provides a DocBlock parser Chris@0: that is 100% compatible with the [PHPDoc standard](http://phpdoc.org/docs/latest). Chris@0: Chris@0: With this component, a library can provide support for annotations via DocBlocks Chris@0: or otherwise retrieve information that is embedded in a DocBlock. Chris@0: Chris@0: Installation Chris@0: ------------ Chris@0: Chris@12: ```bash Chris@12: composer require phpdocumentor/reflection-docblock Chris@12: ``` Chris@0: Chris@0: Usage Chris@0: ----- Chris@0: Chris@12: In order to parse the DocBlock one needs a DocBlockFactory that can be Chris@12: instantiated using its `createInstance` factory method like this: Chris@0: Chris@12: ```php Chris@12: $factory = \phpDocumentor\Reflection\DocBlockFactory::createInstance(); Chris@12: ``` Chris@0: Chris@12: Then we can use the `create` method of the factory to interpret the DocBlock. Chris@12: Please note that it is also possible to provide a class that has the Chris@12: `getDocComment()` method, such as an object of type `ReflectionClass`, the Chris@12: create method will read that if it exists. Chris@0: Chris@12: ```php Chris@12: $docComment = <<create($docComment); Chris@12: ``` Chris@0: Chris@12: The `create` method will yield an object of type `\phpDocumentor\Reflection\DocBlock` Chris@12: whose methods can be queried: Chris@0: Chris@12: ```php Chris@12: // Contains the summary for this DocBlock Chris@12: $summary = $docblock->getSummary(); Chris@0: Chris@12: // Contains \phpDocumentor\Reflection\DocBlock\Description object Chris@12: $description = $docblock->getDescription(); Chris@0: Chris@12: // You can either cast it to string Chris@12: $description = (string) $docblock->getDescription(); Chris@12: Chris@12: // Or use the render method to get a string representation of the Description. Chris@12: $description = $docblock->getDescription()->render(); Chris@12: ``` Chris@12: Chris@12: > For more examples it would be best to review the scripts in the [`/examples` folder](/examples).