coroq/callable-reflector
最新稳定版本:v1.0.0
Composer 安装命令:
composer require coroq/callable-reflector
包简介
README 文档
README
Easily create reflections of callables in PHP.
Requirements
- PHP >= 7.2
Installation
composer require coroq/callable-reflector
Usage
use Coroq\CallableReflector\CallableReflector; $reflection = CallableReflector::createFromCallable($callable);
$callable can be a closure, a function, a static method, an instance method, or an invokable object.
The returned reflection object is an instance of ReflectionFunctionAbstract, which can be either ReflectionFunction or ReflectionMethod depending on the callable type.
Here's an example for each type of callable:
// Function $reflection = CallableReflector:createFromCallable('strlen'); // Closure $closure = function($x) { return $x * 2; }; $reflection = CallableReflector::createFromCallable($closure); // Static method $reflection = CallableReflector::createFromCallable('ExampleClass::staticMethod'); $reflection = CallableReflector::createFromCallable([ExampleClass::class, 'staticMethod']); // Instance method $object = new ExampleClass(); $reflection = CallableReflector::createFromCallable([$object, 'instanceMethod']); // Invokable object $object = new InvokableClass(); // InvokableClass has __invoke() $reflection = CallableReflector::createFromCallable($object);
License
This project is licensed under the MIT License.
统计信息
- 总下载量: 110
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-04-15