Category
language · php-src-strict · regression (re-#9811, merged #9827)
Problem
E::Case::class must return the enum FQCN string on enum case operands. #9827 added tests and resolveClassPseudoConstFromOperand() for TYPE_ENUM_CASE, but direct TYPE_CLASS_CONST_FETCH on E::A::class still sees the class operand as a backing scalar int — resolveClassPseudoConstFromOperand() returns null and VM emits:
TypeError: Cannot use "::class" on value of type int
Root cause: enum case fetch at use-site materializes backing value before ::class pseudo-constant resolution (same enum-preservation cluster as #9727, #9712).
php-src reference
Repro (failure on master 2026-06-19)
<?php
enum E: int { case A = 1; case B = 2; }
echo E::A::class, "\n";
echo (E::B)::class, "\n";
$a = E::A;
echo $a::class, "\n";
enum U { case C; }
echo U::C::class, "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php test/repro/maintainer_enum_case_class_pseudo.php
'
| Engine |
Output |
| Zend PHP 8.3+ |
four lines: E, E, E, U |
| VM today |
Fatal TypeError on first E::A::class |
Existing guard file: test/repro/maintainer_enum_case_class_pseudo.php.
Scope (this repo)
| Layer |
Path |
| Compiler |
lib/Compiler.php — preserve enum case object (or dedicated opcode) through ::class fetch |
| VM |
lib/VM.php — TYPE_CLASS_CONST_FETCH + resolveClassPseudoConstFromOperand() |
| JIT |
lib/JIT.php — same identity rules when lowering fetch |
| Tests |
extend test/compliance/cases/language/enum_case_class_pseudo.phpt |
PHP-in-PHP only — no new C runtime branches.
Done when (php-src-strict)
Related
Category
language· php-src-strict · regression (re-#9811, merged #9827)Problem
E::Case::classmust return the enum FQCN string on enum case operands. #9827 added tests andresolveClassPseudoConstFromOperand()forTYPE_ENUM_CASE, but directTYPE_CLASS_CONST_FETCHonE::A::classstill sees the class operand as a backing scalar int —resolveClassPseudoConstFromOperand()returns null and VM emits:Root cause: enum case fetch at use-site materializes backing value before
::classpseudo-constant resolution (same enum-preservation cluster as #9727, #9712).php-src reference
Zend/zend_compile.c—ZEND_FETCH_CLASS_CONSTANT,::classon enum cases without scalarizingZend/zend_enum.c— enum case object identityRepro (failure on master 2026-06-19)
E,E,E,UE::A::classExisting guard file:
test/repro/maintainer_enum_case_class_pseudo.php.Scope (this repo)
lib/Compiler.php— preserve enum case object (or dedicated opcode) through::classfetchlib/VM.php—TYPE_CLASS_CONST_FETCH+resolveClassPseudoConstFromOperand()lib/JIT.php— same identity rules when lowering fetchtest/compliance/cases/language/enum_case_class_pseudo.phptPHP-in-PHP only — no new C runtime branches.
Done when (php-src-strict)
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter enum_case_class_pseudo'green./script/ci-fast.sh --filter enum_case_class_pseudogreenRelated