Category
stdlib / reflection (php-src-strict)
Problem
PHP 8.1+ reflection factories for closures/callables are missing:
ReflectionFunction::createFromCallable(callable $callback)
ReflectionMethod::createFromClosure(Closure $closure, ?string $scope = null, ?string $name = null)
Without these, introspection of first-class callables and Closure objects cannot match Zend tooling.
php-src reference
Repro
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php -r "var_dump(method_exists(\"ReflectionFunction\", \"createFromCallable\"));" # false
php bin/vm.php -r "var_dump(method_exists(\"ReflectionMethod\", \"createFromClosure\"));" # false
php bin/vm.php test/repro/maintainer_reflection_create_from_callable.php # Error: missing
php -r "\$fn = fn() => 42; echo ReflectionFunction::createFromCallable(\$fn)->invoke();" # Zend: 42
'
Scope (this repo)
| Path |
Work |
| Reflection builtin handlers |
Register both static factories |
lib/VM/ |
Map Closure/callable zvals to reflection objects |
| Tests |
compliance .phpt for closure + invokable object callbacks |
Implement in ext/ + lib/VM/ — reuse existing ReflectionFunction/ReflectionMethod classes.
Done when
Related
Category
stdlib/ reflection (php-src-strict)Problem
PHP 8.1+ reflection factories for closures/callables are missing:
ReflectionFunction::createFromCallable(callable $callback)ReflectionMethod::createFromClosure(Closure $closure, ?string $scope = null, ?string $name = null)Without these, introspection of first-class callables and
Closureobjects cannot match Zend tooling.php-src reference
ext/reflection/php_reflection.c—ReflectionFunction::createFromCallable,ReflectionMethod::createFromClosureRepro
Scope (this repo)
lib/VM/Closure/callable zvals to reflection objects.phptfor closure + invokable object callbacksImplement in
ext/+lib/VM/— reuse existingReflectionFunction/ReflectionMethodclasses.Done when
42ReflectionException/TypeErrorper ZendcreateFromClosurehonors optional$scope/$namefor bound closuresRelated