Chris@0
|
1 The ReflectionDocBlock Component [](https://travis-ci.org/phpDocumentor/ReflectionDocBlock)
|
Chris@0
|
2 ================================
|
Chris@0
|
3
|
Chris@0
|
4 Introduction
|
Chris@0
|
5 ------------
|
Chris@0
|
6
|
Chris@0
|
7 The ReflectionDocBlock component of phpDocumentor provides a DocBlock parser
|
Chris@0
|
8 that is 100% compatible with the [PHPDoc standard](http://phpdoc.org/docs/latest).
|
Chris@0
|
9
|
Chris@0
|
10 With this component, a library can provide support for annotations via DocBlocks
|
Chris@0
|
11 or otherwise retrieve information that is embedded in a DocBlock.
|
Chris@0
|
12
|
Chris@0
|
13 > **Note**: *this is a core component of phpDocumentor and is constantly being
|
Chris@0
|
14 > optimized for performance.*
|
Chris@0
|
15
|
Chris@0
|
16 Installation
|
Chris@0
|
17 ------------
|
Chris@0
|
18
|
Chris@0
|
19 You can install the component in the following ways:
|
Chris@0
|
20
|
Chris@0
|
21 * Use the official Github repository (https://github.com/phpDocumentor/ReflectionDocBlock)
|
Chris@0
|
22 * Via Composer (http://packagist.org/packages/phpdocumentor/reflection-docblock)
|
Chris@0
|
23
|
Chris@0
|
24 Usage
|
Chris@0
|
25 -----
|
Chris@0
|
26
|
Chris@0
|
27 The ReflectionDocBlock component is designed to work in an identical fashion to
|
Chris@0
|
28 PHP's own Reflection extension (http://php.net/manual/en/book.reflection.php).
|
Chris@0
|
29
|
Chris@0
|
30 Parsing can be initiated by instantiating the
|
Chris@0
|
31 `\phpDocumentor\Reflection\DocBlock()` class and passing it a string containing
|
Chris@0
|
32 a DocBlock (including asterisks) or by passing an object supporting the
|
Chris@0
|
33 `getDocComment()` method.
|
Chris@0
|
34
|
Chris@0
|
35 > *Examples of objects having the `getDocComment()` method are the
|
Chris@0
|
36 > `ReflectionClass` and the `ReflectionMethod` classes of the PHP
|
Chris@0
|
37 > Reflection extension*
|
Chris@0
|
38
|
Chris@0
|
39 Example:
|
Chris@0
|
40
|
Chris@0
|
41 $class = new ReflectionClass('MyClass');
|
Chris@0
|
42 $phpdoc = new \phpDocumentor\Reflection\DocBlock($class);
|
Chris@0
|
43
|
Chris@0
|
44 or
|
Chris@0
|
45
|
Chris@0
|
46 $docblock = <<<DOCBLOCK
|
Chris@0
|
47 /**
|
Chris@0
|
48 * This is a short description.
|
Chris@0
|
49 *
|
Chris@0
|
50 * This is a *long* description.
|
Chris@0
|
51 *
|
Chris@0
|
52 * @return void
|
Chris@0
|
53 */
|
Chris@0
|
54 DOCBLOCK;
|
Chris@0
|
55
|
Chris@0
|
56 $phpdoc = new \phpDocumentor\Reflection\DocBlock($docblock);
|
Chris@0
|
57
|