定制 coroq/callable-reflector 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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.

统计信息

  • 总下载量: 117
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-04-15