Category
Language: · php-src-strict · auto-array promotion on append
Problem
Appending with [] = to null correctly promotes to an array. Appending to false must do the same (legacy Zend auto-conversion). The VM throws Error: Cannot use a scalar value as an array instead.
true correctly fatals on both engines; only false (and historically null) promote.
| Repro |
Zend 8.2+ (2026-07-23) |
VM (2026-07-23) |
$f=false; $f[]=1; |
array(0=>1) type array |
fatal scalar-as-array |
$n=null; $n[]=1; |
array(0=>1) |
array(0=>1) ✅ |
$t=true; $t[]=1; |
fatal scalar-as-array |
fatal scalar-as-array ✅ |
php-src reference
PHP implementation target
lib/VM.php (and shared dim-write / append lowering) — treat false like null when the write is [] = append
- Mirror in
lib/JIT/ dim-write if AOT/JIT diverge
- Prefer PHP lowering; no new C runtime logic
Repro
./script/docker-exec.sh -- bash -lc 'php test/repro/maintainer_gap_false_append_promotes_array.php; php bin/vm.php test/repro/maintainer_gap_false_append_promotes_array.php'
# Zend: array ( 0 => 1, ) / array
# VM: Fatal Error Cannot use a scalar value as an array
Done when
Category
Language:· php-src-strict · auto-array promotion on appendProblem
Appending with
[] =tonullcorrectly promotes to an array. Appending tofalsemust do the same (legacy Zend auto-conversion). The VM throwsError: Cannot use a scalar value as an arrayinstead.truecorrectly fatals on both engines; onlyfalse(and historicallynull) promote.$f=false; $f[]=1;array(0=>1)typearray$n=null; $n[]=1;array(0=>1)array(0=>1)✅$t=true; $t[]=1;php-src reference
Zend/zend_execute.c—zend_assign_to_variable/ dim write; false/null → empty array before appendZend/zend_operators.c— scalar→array conversion rules for[]PHP implementation target
lib/VM.php(and shared dim-write / append lowering) — treatfalselikenullwhen the write is[] =appendlib/JIT/dim-write if AOT/JIT divergeRepro
Done when
$f=false; $f[]=1;yields[1]matching Zend on VM (and JIT/AOT when in scope)true/ int / float still Error.phptundertest/compliance/cases/language/