Category
Language · php-src-strict · dim pre/post inc on undefined key
Problem
$a[0]++ when key 0 is undefined must emit Warning: Undefined array key 0, then treat the missing value as null and store 1. VM/JIT silently produce 1 with no Undefined array key Warning (final array matches).
Also visible after false→array auto-convert Deprecated: Zend still warns on the missing key; VM/JIT only show the Deprecated.
Probed 2026-08-11 — php:8.4-cli 8.4.24 vs PHP_COMPILER_PROFILE=8.4 @ a0e79a9651.
| Repro |
Zend 8.4.24 |
VM / JIT |
$x=[]; $x[0]++; |
Warning: Undefined array key 0 then done / [0=>1] |
no Warning; done / [0=>1] |
$x=false; $x[0]++; |
Deprecated: Automatic conversion of false to array… and Warning: Undefined array key 0 then [0=>1] |
Deprecated only; [0=>1] |
php-src reference
PHP implementation target
- Dim inc/dec fetch: emit Undefined array key Warning (E_WARNING) before coercing missing to null
lib/VM/ + JIT dim-inc/dec paths
- PHP-in-PHP; no new
runtime/*.c
Repro
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
export PHP_COMPILER_PROFILE=8.4
printf "%s\n" "<?php
\$x=[];
try { \$x[0]++; echo \"done\n\"; var_export(\$x); echo PHP_EOL; } catch (Throwable \$e) {
echo get_class(\$e), \": \", \$e->getMessage(), PHP_EOL;
}
" >/tmp/dim_inc_undef.php
php -d error_reporting=E_ALL -d display_errors=1 bin/vm.php /tmp/dim_inc_undef.php
php -d error_reporting=E_ALL -d display_errors=1 bin/jit.php /tmp/dim_inc_undef.php
'
Done when
Category
Language· php-src-strict · dim pre/post inc on undefined keyProblem
$a[0]++when key0is undefined must emitWarning: Undefined array key 0, then treat the missing value asnulland store1. VM/JIT silently produce1with no Undefined array key Warning (final array matches).Also visible after
false→arrayauto-convert Deprecated: Zend still warns on the missing key; VM/JIT only show the Deprecated.Probed 2026-08-11 —
php:8.4-cli8.4.24 vsPHP_COMPILER_PROFILE=8.4@a0e79a9651.$x=[]; $x[0]++;Warning: Undefined array key 0thendone/[0=>1]done/[0=>1]$x=false; $x[0]++;Deprecated: Automatic conversion of false to array…andWarning: Undefined array key 0then[0=>1][0=>1]php-src reference
Zend/zend_execute.c/ zend_vm_def.h —ZEND_PRE_INC/ZEND_POST_INCdim fetch undefined key WarningPHP implementation target
lib/VM/+ JIT dim-inc/dec pathsruntime/*.cRepro
Done when
Undefined array keyWarning for$a[missing]++/--(empty array case)1(php-src-strict).phptundertest/compliance/cases/