mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 01:57:13 +00:00
README: improve install and examples
This commit is contained in:
committed by
Jaap van Otterdijk
parent
8959be6da0
commit
03b7048a61
@@ -10,16 +10,12 @@ 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
|
With this component, a library can provide support for annotations via DocBlocks
|
||||||
or otherwise retrieve information that is embedded in a DocBlock.
|
or otherwise retrieve information that is embedded in a DocBlock.
|
||||||
|
|
||||||
> **Note**: *this is a core component of phpDocumentor and is constantly being
|
|
||||||
> optimized for performance.*
|
|
||||||
|
|
||||||
Installation
|
Installation
|
||||||
------------
|
------------
|
||||||
|
|
||||||
You can install the component in the following ways:
|
```bash
|
||||||
|
composer require phpdocumentor/reflection-docblock
|
||||||
* Use the official Github repository (https://github.com/phpDocumentor/ReflectionDocBlock)
|
```
|
||||||
* Via Composer (http://packagist.org/packages/phpdocumentor/reflection-docblock)
|
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
-----
|
-----
|
||||||
@@ -52,18 +48,20 @@ $docblock = $factory->create($docComment);
|
|||||||
```
|
```
|
||||||
|
|
||||||
The `create` method will yield an object of type `\phpDocumentor\Reflection\DocBlock`
|
The `create` method will yield an object of type `\phpDocumentor\Reflection\DocBlock`
|
||||||
whose methods can be queried as shown in the following example.
|
whose methods can be queried:
|
||||||
|
|
||||||
```php
|
```php
|
||||||
// Should contain the summary for this DocBlock
|
// Contains the summary for this DocBlock
|
||||||
$summary = $docblock->getSummary();
|
$summary = $docblock->getSummary();
|
||||||
|
|
||||||
// Contains an object of type \phpDocumentor\Reflection\DocBlock\Description;
|
// Contains \phpDocumentor\Reflection\DocBlock\Description object
|
||||||
// you can either cast it to string or use the render method to get a string
|
|
||||||
// representation of the Description.
|
|
||||||
$description = $docblock->getDescription();
|
$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`
|
> For more examples it would be best to review the scripts in the [`/examples` folder](/examples).
|
||||||
> folder.
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user