Blame view

vendor/phpdocumentor/reflection-docblock/README.md 2.32 KB
c4650843   Etienne Pallier   Ajout du dossier ...
1
2
3
4
5
6
7
8
9
10
11
12
The ReflectionDocBlock Component [![Build Status](https://secure.travis-ci.org/phpDocumentor/ReflectionDocBlock.png)](https://travis-ci.org/phpDocumentor/ReflectionDocBlock)
================================

Introduction
------------

The ReflectionDocBlock component of phpDocumentor provides a DocBlock parser
that is 100% compatible with the [PHPDoc standard](http://phpdoc.org/docs/latest).

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

d06254b2   Etienne Pallier   bugfix plugin mig...
13
14
15
> **Note**: *this is a core component of phpDocumentor and is constantly being
> optimized for performance.*

c4650843   Etienne Pallier   Ajout du dossier ...
16
17
18
Installation
------------

d06254b2   Etienne Pallier   bugfix plugin mig...
19
20
21
22
You can install the component in the following ways:

* Use the official Github repository (https://github.com/phpDocumentor/ReflectionDocBlock)
* Via Composer (http://packagist.org/packages/phpdocumentor/reflection-docblock)
c4650843   Etienne Pallier   Ajout du dossier ...
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54

Usage
-----

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

```php
$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.

```php
$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`
d06254b2   Etienne Pallier   bugfix plugin mig...
55
whose methods can be queried as shown in the following example.
c4650843   Etienne Pallier   Ajout du dossier ...
56
57

```php
d06254b2   Etienne Pallier   bugfix plugin mig...
58
// Should contain the summary for this DocBlock
c4650843   Etienne Pallier   Ajout du dossier ...
59
60
$summary = $docblock->getSummary();

d06254b2   Etienne Pallier   bugfix plugin mig...
61
62
63
// Contains an object of type \phpDocumentor\Reflection\DocBlock\Description; 
// you can either cast it to string or use the render method to get a string 
// representation of the Description.
c4650843   Etienne Pallier   Ajout du dossier ...
64
$description = $docblock->getDescription();
c4650843   Etienne Pallier   Ajout du dossier ...
65
66
```

d06254b2   Etienne Pallier   bugfix plugin mig...
67
68
> For more examples it would be best to review the scripts in the `/examples` 
> folder.