2019-12-13 16:01:35 +01:00
2019-12-13 15:31:58 +01:00
2017-11-30 10:27:01 +01:00
2019-12-27 21:02:14 +01:00
2017-05-29 14:23:54 +02:00
2018-01-29 14:03:51 -06:00
2018-01-11 07:18:31 -06:00
2019-09-26 21:09:37 +02:00
2014-12-19 23:13:47 +01:00
2019-12-13 15:31:58 +01:00
2019-12-20 14:36:14 +01:00
2019-09-20 10:54:12 +02:00
2018-01-09 12:25:08 -06:00
2019-12-10 23:46:06 +01:00
2019-12-10 23:46:06 +01:00
2019-09-26 21:19:59 +02:00

License: MIT Travis Status Appveyor Status Coveralls Coverage Scrutinizer Code Coverage Scrutinizer Code Quality Stable Version Unstable Version

ReflectionDocBlock

Introduction

The ReflectionDocBlock component of phpDocumentor provides a DocBlock parser that is 100% compatible with the PHPDoc standard.

With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.

Installation

composer require phpdocumentor/reflection-docblock

Usage

In order to parse the DocBlock one needs a DocBlockFactory that can be instantiated using its createInstance factory method like this:

$factory  = \phpDocumentor\Reflection\DocBlockFactory::createInstance();

Then we can use the create method of the factory to interpret the DocBlock. Please note that it is also possible to provide a class that has the getDocComment() method, such as an object of type ReflectionClass, the create method will read that if it exists.

$docComment = <<<DOCCOMMENT
/**
 * This is an example of a summary.
 *
 * This is a Description. A Summary and Description are separated by either
 * two subsequent newlines (thus a whiteline in between as can be seen in this
 * example), or when the Summary ends with a dot (`.`) and some form of
 * whitespace.
 */
DOCCOMMENT;

$docblock = $factory->create($docComment);

The create method will yield an object of type \phpDocumentor\Reflection\DocBlock whose methods can be queried:

// Contains the summary for this DocBlock
$summary = $docblock->getSummary();

// Contains \phpDocumentor\Reflection\DocBlock\Description object
$description = $docblock->getDescription();

// You can either cast it to string
$description = (string) $docblock->getDescription();

// Or use the render method to get a string representation of the Description.
$description = $docblock->getDescription()->render();

For more examples it would be best to review the scripts in the /examples folder.

S
Description
No description provided
Readme MIT
1.7 MiB
Languages
PHP 100%