Category
language · php-src-strict
Problem
First-class callable syntax on enum case instance methods (E::A->m(...)) is valid in Zend/php-src (PHP 8.1+). This compiler fails during compile/type reconstruction with Call to undefined method PHPTypes\Type::array() (vendor PHPTypes\TypeReconstructor) instead of lowering the callable.
Blocks enum APIs using ... for case methods and self-host when vendor/spine code uses the pattern.
php-src reference
Repro
<?php
enum E: string {
case A = 'a';
public function m(): string { return 'm'; }
}
$f = E::A->m(...);
echo $f(), "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro/maintainer_enum_case_first_class_callable.php # Zend: m
php bin/vm.php test/repro/maintainer_enum_case_first_class_callable.php'
# VM today: PHPTypes\TypeReconstructor fatal during parseAndCompile
Control (plain call — must work before/after):
<?php
enum E: string { case A = 'a'; public function m(): string { return 'm'; } }
echo E::A->m(), "\n";
Scope (this repo)
| Path |
Work |
lib/Compiler.php / AST lowering |
First-class callable on enum case receivers |
lib/Runtime.php / PHPTypes integration |
Fix type reconstructor for enum-case ... |
lib/VM.php |
Runtime callable binding for enum case methods |
| Tests |
test/compliance/cases/language/enum_case_first_class_callable.phpt |
Done when
Category
language· php-src-strictProblem
First-class callable syntax on enum case instance methods (
E::A->m(...)) is valid in Zend/php-src (PHP 8.1+). This compiler fails during compile/type reconstruction withCall to undefined method PHPTypes\Type::array()(vendorPHPTypes\TypeReconstructor) instead of lowering the callable.Blocks enum APIs using
...for case methods and self-host when vendor/spine code uses the pattern.php-src reference
Zend/zend_compile.c—ZEND_AST_CALLABLE_CONVERT/ first-class callable loweringZend/zend_enum.c— enum case as object receiverRepro
Control (plain call — must work before/after):
Scope (this repo)
lib/Compiler.php/ AST loweringlib/Runtime.php/PHPTypesintegration...lib/VM.phptest/compliance/cases/language/enum_case_first_class_callable.phptDone when
mon VME::A->m()control unchanged