Category
language · php-src-strict
Problem
Zend rejects acquiring a reference to the superglobal $GLOBALS at compile time. This compiler accepts the assignment and runs the script.
| Snippet |
Zend 8.2+ |
VM (2026-07-03) |
$ref = &$GLOBALS; |
Fatal error: Cannot acquire reference to $GLOBALS (compile) |
prints fail: acquired GLOBALS reference, exit 0 |
php-src reference
PHP implementation target
lib/ compile path for assign_ref when RHS is $GLOBALS — emit Zend-equivalent compile-time fatal
- No new C runtime branches; guard in PHP lowering only
Repro
test/repro/maintainer_gap_globals_acquire_reference.php
./script/docker-exec.sh -- bash -lc 'php test/repro/maintainer_gap_globals_acquire_reference.php' # exit 255
./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_globals_acquire_reference.php' # exit 0 (wrong)
Done when
Category
language· php-src-strictProblem
Zend rejects acquiring a reference to the superglobal
$GLOBALSat compile time. This compiler accepts the assignment and runs the script.$ref = &$GLOBALS;Fatal error: Cannot acquire reference to $GLOBALS(compile)fail: acquired GLOBALS reference, exit 0php-src reference
Zend/zend_compile.c—zend_compile_assign_ref()/$GLOBALSreference guardZend/zend_variables.c— superglobal table semanticsPHP implementation target
lib/compile path forassign_refwhen RHS is$GLOBALS— emit Zend-equivalent compile-time fatalRepro
test/repro/maintainer_gap_globals_acquire_reference.phpDone when
.phptundertest/compliance/cases/language/