syberisle / filereflection
补充 PHP 反射 API 缺失的 ReflectionFile 类
1.3.0
2021-09-25 19:18 UTC
This package is auto-updated.
Last update: 2024-09-10 04:27:57 UTC
README
这个库通过补充缺失的 ReflectionFile 类来扩展 PHP 反射 API。
已经有一些其他库可以进行这个操作,但这个库实现了一个其他实现中缺失的重要功能:根据 命名空间解析规则解析本地类型名称。
安装
通过 Composer
$ composer require syberisle/filereflection
用法
接口非常简单
ReflectionFile {
public __construct( string $path )
public string getPath ( void )
public string getNamespaceName ( void )
public string resolveName ( string $name )
public ReflectionClass getClass ( string $name )
public ReflectionClass[] getClasses ( void )
}
用法也很直接
use SyberIsle\FileReflection\ReflectionFile;
$file = new ReflectionFile('/path/to/MyNamespace/MyClass.php');
var_dump($file->resolveName('MyOtherClass')); // => '\MyNamespace\MyOtherClass'
请注意,这个库目前不提供函数、常量等的反射/枚举。
贡献
请参阅CONTRIBUTING以获取详细信息。
鸣谢
许可协议
GPL 3.0+ 许可协议。请参阅 许可文件 以获取更多信息。