Category
runtime — php-src-strict enum zval preservation in superglobals
Problem
Storing a backed enum case in $GLOBALS[...] (or assigning into the $GLOBALS array) materializes the backing scalar (int(1)) instead of keeping the enum case object. Zend preserves the enum zval.
Part of the enum-preservation cluster (#8746, #9342); distinct from compact() (#8686) and array helpers.
php-src reference
Repro
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php -r '"'"'enum E:int{case A=1;} $GLOBALS["e"]=E::A; var_dump($GLOBALS["e"]);'"'"''
Zend:
This compiler (bin/vm.php):
Scope (PHP-in-PHP)
lib/VM.php — $GLOBALS write path / superglobal table insert
lib/VM/Context.php — globals hashtable helpers
lib/VM/EnumCaseSupport.php — ensure enum zvals are not scalarized on hash insert
- JIT/AOT globals refresh if separate LLVM path exists
Done when (php-src-strict)
- Repro prints
enum(E::A) on VM (and JIT/AOT when globals touched in compiled code).
- Compliance guard
test/compliance/cases/runtime/globals_enum_case.phpt (add) matches Zend.
$_SERVER / other superglobals that accept enum values follow same preservation rule when in scope.
Related
#8746, #9342, #8686, closed #5547 enum preservation umbrella.
Category
runtime— php-src-strict enum zval preservation in superglobalsProblem
Storing a backed enum case in
$GLOBALS[...](or assigning into the$GLOBALSarray) materializes the backing scalar (int(1)) instead of keeping the enum case object. Zend preserves the enum zval.Part of the enum-preservation cluster (#8746, #9342); distinct from
compact()(#8686) and array helpers.php-src reference
Repro
Zend:
This compiler (
bin/vm.php):Scope (PHP-in-PHP)
lib/VM.php—$GLOBALSwrite path / superglobal table insertlib/VM/Context.php— globals hashtable helperslib/VM/EnumCaseSupport.php— ensure enum zvals are not scalarized on hash insertDone when (php-src-strict)
enum(E::A)on VM (and JIT/AOT when globals touched in compiled code).test/compliance/cases/runtime/globals_enum_case.phpt(add) matches Zend.$_SERVER/ other superglobals that accept enum values follow same preservation rule when in scope.Related
#8746, #9342, #8686, closed #5547 enum preservation umbrella.