sanmai / callable-reflection
ReflectionFunctionAbstract for any callable
Fund package maintenance!
sanmai
Requires
- php: ^8.2
Requires (Dev)
- ergebnis/composer-normalize: ^2.47
- friendsofphp/php-cs-fixer: ^3.84
- infection/infection: ^0.30.3
- phpunit/phpunit: ^11
- sanmai/phpstan-rules: ^0.3.10
This package is auto-updated.
Last update: 2025-07-27 05:06:51 UTC
README
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.