ReflectionDocBlock

  • 所有者: phpDocumentor/ReflectionDocBlock
  • 平台:
  • 许可证: MIT License
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

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 = <<<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.

主要指标

概览
名称与所有者phpDocumentor/ReflectionDocBlock
主编程语言PHP
编程语言PHP (语言数: 2)
平台
许可证MIT License
所有者活动
创建于2012-04-06 17:17:37
推送于2025-04-21 07:16:29
最后一次提交
发布数65
最新版本名称5.6.2 (发布于 )
第一版名称1.0.0-beta1 (发布于 )
用户参与
星数9.4k
关注者数18
派生数126
提交数778
已启用问题?
问题数107
打开的问题数9
拉请求数210
打开的拉请求数1
关闭的拉请求数90
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?