GitHunt
SA

sanmai/callable-reflection

Get ReflectionFunctionAbstract for any PHP callable - closures, functions, methods, invokables, first-class callables; anything works!

CallableReflection

Get ReflectionFunctionAbstract for any callable.

Installation

composer require sanmai/callable-reflection

Usage

use CallableReflection\CallableReflection;

$reflection = new CallableReflection();
$params = $reflection->reflect($callable)->getNumberOfParameters();

Works with closures, functions, methods, invokable objects, and first-class callables.

If it doesn't work with your callable, file an issue.

How is this better than ReflectionFunction(Closure::fromCallable($callable))?

Crickets

Well... you can dependency inject it I guess?

I was experimenting with Claude Code, and I was interested in whether it could build something like this entirely from my request. I didn't think very hard whenever it made sense, and it went from a few-sentence request to... Done. It turns out it can.

Languages

PHP100.0%

Contributors

Latest Release

1.0July 26, 2025
Apache License 2.0
Created July 26, 2025
Updated November 19, 2025
sanmai/callable-reflection | GitHunt