Category
language · php-src-strict
Problem
Closure::fromCallable([E::A, 'm']) must treat the first element as an object (the enum case instance) and create an object-method callable.
Today it resolves the enum case name as a class-string and fails with Class 'A' not found.
php-src reference
Zend/zend_closures.c — Closure::fromCallable
Zend/zend_API.c / Zend/zend_execute_API.c — callable resolution for [object, "method"]
Zend/zend_enum.c — enum case objects
Repro
<?php
enum E {
case A;
public function m(): void { echo "ok\n"; }
}
$c = Closure::fromCallable([E::A, 'm']);
$c();
Commands
# Zend
php repro.php
# This compiler
php bin/vm.php repro.php
Expected (Zend)
Prints:
Actual (VM today)
Fatal LogicException: Closure::fromCallable(): Class 'A' not found.
Scope (this repo)
- Callable normalization / resolution for array-callables where element 0 is an enum case object
- Ensure no enum-case-to-string coercion occurs on
[object, method] paths
Done when
- Repro prints
ok under php bin/vm.php
- Additional guard:
[E::class, 'm'] still resolves as class-method callable, while [E::A, 'm'] is object-method
- Add compliance coverage:
test/compliance/cases/language/closure_from_callable_enum_case_object_method.phpt
Category
language· php-src-strictProblem
Closure::fromCallable([E::A, 'm'])must treat the first element as an object (the enum case instance) and create an object-method callable.Today it resolves the enum case name as a class-string and fails with
Class 'A' not found.php-src reference
Zend/zend_closures.c—Closure::fromCallableZend/zend_API.c/Zend/zend_execute_API.c— callable resolution for[object, "method"]Zend/zend_enum.c— enum case objectsRepro
Commands
Expected (Zend)
Prints:
Actual (VM today)
Fatal
LogicException: Closure::fromCallable(): Class 'A' not found.Scope (this repo)
[object, method]pathsDone when
okunderphp bin/vm.php[E::class, 'm']still resolves as class-method callable, while[E::A, 'm']is object-methodtest/compliance/cases/language/closure_from_callable_enum_case_object_method.phpt