Category
bug · php-src-strict · language · string offsets
Problem
Assigning an array to a string offset must emit E_WARNING: Array to string conversion before Only the first byte will be assigned to the string offset, then write the first byte of "Array" (A). The VM skips the Array-to-string warning and only emits the first-byte warning (result string still matches).
Distinct from #22895 (illegal dimension types → TypeError) and #22897 (assign-op on string offset).
Verified 2026-07-24 (Zend 8.2.32 vs php bin/vm.php, error_reporting(E_ALL)):
| Repro |
Zend 8.2 |
VM |
$s="ab"; $s[0]=[]; |
Warning: Array to string conversion and Warning: Only the first byte… → 'Ab' |
Only first-byte warning → 'Ab' |
php-src reference
PHP implementation target
lib/VM/ string-offset assign path — coerce array RHS via Zend-compatible cast (emit Array to string conversion) before first-byte assign
- JIT string-offset lowering must agree; no new
runtime/*.c
Repro
./script/docker-exec.sh -- bash -lc 'php -r '"'"'error_reporting(E_ALL); $s="ab"; $s[0]=[]; var_export($s); echo "\n";'"'"''
./script/docker-exec.sh -- bash -lc 'php bin/vm.php -r '"'"'error_reporting(E_ALL); $s="ab"; $s[0]=[]; var_export($s); echo "\n";'"'"''
Done when
Category
bug· php-src-strict · language · string offsetsProblem
Assigning an array to a string offset must emit
E_WARNING: Array to string conversionbeforeOnly the first byte will be assigned to the string offset, then write the first byte of"Array"(A). The VM skips the Array-to-string warning and only emits the first-byte warning (result string still matches).Distinct from #22895 (illegal dimension types → TypeError) and #22897 (assign-op on string offset).
Verified 2026-07-24 (Zend 8.2.32 vs
php bin/vm.php,error_reporting(E_ALL)):$s="ab"; $s[0]=[];'Ab''Ab'php-src reference
Zend/zend_execute.c— string offset assign /zend_assign_to_string_offsetZend/zend_operators.c— array to string conversionPHP implementation target
lib/VM/string-offset assign path — coerce array RHS via Zend-compatible cast (emit Array to string conversion) before first-byte assignruntime/*.cRepro
Done when
[](and other arrays) to a string offset emits Array to string conversion like Zend.phptguard; php-src-strict; no php-compiler-strict shortcut