hahadu/reflector

v1.0.2 2022-01-14 04:28 UTC

This package is auto-updated.

Last update: 2024-09-14 09:58:06 UTC


README

简介

phpDocumentor 的 ReflectionDocBlock 组件提供了一个与 PHPDoc 标准完全兼容的 Reflection 解析器。

使用此组件,库可以通过 DocBlocks 提供对注释的支持,或者检索反射中嵌入的信息。

注意: 这是 phpDocumentor 的核心组件,正在不断优化以提升性能。

安装

您可以通过以下方式安装此组件

用法

ReflectionDocBlock 组件旨在以与 PHP 自身的 Reflection 扩展相同的方式工作 (https://php.ac.cn/manual/en/book.reflection.php).

可以通过实例化 \phpDocumentor\Reflection\Reflection() 类并传递包含反射(包括星号)的字符串,或者传递支持 getDocComment() 方法的对象来启动解析。

具有 getDocComment() 方法的对象示例包括 PHP Reflection 扩展的 ReflectionClass 和 ReflectionMethod 类

示例

$class = new ReflectionClass('MyClass');
$phpdoc = new \phpDocumentor\Reflection\Reflection($class);

$docblock = <<<DOCBLOCK
/**
 * This is a short description.
 *
 * This is a *long* description.
 *
 * @return void
 */
DOCBLOCK;

$phpdoc = new \phpDocumentor\Reflection\Reflection($docblock);