Category
language · stdlib · php-src-strict
Problem
Enum case instance method first-class callables (E::Case->method(...)) compile and invoke correctly, but is_callable() returns false while Zend returns true. This breaks guards that gate invocation on is_callable() before calling.
Related compile work: #9398 (FCC parse). This issue is the runtime is_callable() probe once FCC exists.
php-src reference
Repro
<?php
enum E: int {
case A = 1;
public function m(): string { return 'ok'; }
}
var_export(is_callable([E::A, 'm']));
echo "\n";
var_export(is_callable(E::A->m(...)));
echo "\n";
$c = E::A->m(...);
var_export($c());
echo "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php test/repro/enum_case_fcc_is_callable.php; php bin/vm.php test/repro/enum_case_fcc_is_callable.php'
| Probe |
Zend PHP 8.2+ |
VM today |
is_callable([E::A, 'm']) |
true |
true |
is_callable(E::A->m(...)) |
true |
false |
(E::A->m(...))() |
'ok' |
'ok' |
Scope (PHP-in-PHP)
| Layer |
Path |
| VM |
ext/standard/is_callable.php / callable classification helpers |
| Shared |
Treat bound enum-case FCC like other Closure/FirstClassCallable objects |
| Tests |
test/compliance/cases/language/enum_case_fcc_is_callable.phpt |
Done when (php-src-strict)
Related
Category
language·stdlib· php-src-strictProblem
Enum case instance method first-class callables (
E::Case->method(...)) compile and invoke correctly, butis_callable()returnsfalsewhile Zend returnstrue. This breaks guards that gate invocation onis_callable()before calling.Related compile work: #9398 (FCC parse). This issue is the runtime
is_callable()probe once FCC exists.php-src reference
Zend/zend_callable.c—zend_is_callable_at_frame, first-class callable / enum case method handlingZend/zend_enum.c— enum case method bindingRepro
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php test/repro/enum_case_fcc_is_callable.php; php bin/vm.php test/repro/enum_case_fcc_is_callable.php'is_callable([E::A, 'm'])truetrueis_callable(E::A->m(...))truefalse(E::A->m(...))()'ok''ok'Scope (PHP-in-PHP)
ext/standard/is_callable.php/ callable classification helpersClosure/FirstClassCallableobjectstest/compliance/cases/language/enum_case_fcc_is_callable.phptDone when (php-src-strict)
is_callable(E::A->m(...))istrueon VM(E::A->m(...))()still returns'ok'Related