Need help with ReflectionDocBlock?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

phpDocumentor
8.6K Stars 83 Forks MIT License 571 Commits 20 Opened issues

Services available

!
?

Need anything else?

Contributors list

# 29,904
PHP
Shell
CSS
Unity
91 commits
# 54,178
PHP
CSS
dropbox
dropbox...
82 commits
# 101,975
PHP
Shell
routero...
nextjs
63 commits
# 68,169
PHP
jenkins...
Clojure
PHPUnit
57 commits
# 16,462
PHP
Nette
doctrin...
nette-f...
48 commits
# 56,194
PHP
phpstor...
php7
Compose...
21 commits
# 242,088
PHP
Shell
CSS
7 commits
# 2,431
PHP
CSS
Laravel
chatbot...
6 commits
# 10,377
Laravel
PHPUnit
curl
phpstan
5 commits
# 84,751
PHP
intelli...
phpstor...
php7
4 commits
# 95,741
yield
Compose...
Symfony
TeX
4 commits
# 2,291
PHP
Laravel
Compose...
framewo...
4 commits
# 7,325
PHP
Symfony
framewo...
httpcli...
3 commits
# 174,762
PHP
Shell
doctrin...
Symfony
2 commits
# 435,695
PHP
2 commits
# 437,633
PHP
2 commits
# 166,665
PHP
Symfony
symfony...
CSS
2 commits
# 20,583
Markdow...
phpstor...
captcha...
captcha...
2 commits
# 2,189
PHP
Yii Fra...
yii2
bootstr...
2 commits
# 453
PHP
Symfony
zend-fr...
Compose...
2 commits

License: MIT Qa workflow 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 = <<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.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.