Category
language · runtime
Problem
PHP 8+ warns when using [/] offset access on scalars that are not arrays/strings/ArrayAccess (Trying to access array offset on value of type bool). This compiler reads $x = true[0]; silently (no warning, $x null) and prints done.
Same class of bug as missing unary-+ warnings (#4723 / #4820) — invalid container access should warn under E_ALL, not fail silently.
php-src reference
Repro
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro-maintainer/parity_array_offset_bool.php; echo zend:$?
php bin/vm.php test/repro-maintainer/parity_array_offset_bool.php; echo vm:$?
'
| Engine |
Output |
exit |
| Zend |
Warning: Trying to access array offset on value of type bool + done |
0 |
| VM |
done only |
0 |
Repro script: test/repro-maintainer/parity_array_offset_bool.php
Scope (this repo)
| Area |
Files |
| VM |
lib/VM.php — dim fetch on bool/int/float/null/resource |
| JIT/AOT |
mirror warning + null result after VM |
| Tests |
test/compliance/cases/language/array_offset_invalid_type.phpt (bool + int smoke) |
Done when
Links
Category
language·runtimeProblem
PHP 8+ warns when using
[/]offset access on scalars that are not arrays/strings/ArrayAccess (Trying to access array offset on value of type bool). This compiler reads$x = true[0];silently (no warning,$xnull) and printsdone.Same class of bug as missing unary-
+warnings (#4723 / #4820) — invalid container access should warn underE_ALL, not fail silently.php-src reference
Zend/zend_execute.c—ZEND_FETCH_DIM_R,zend_wrong_parameter_type_error/ warnings for invalid offsetsZend/zend_operators.cRepro
Warning: Trying to access array offset on value of type bool+donedoneonlyRepro script:
test/repro-maintainer/parity_array_offset_bool.phpScope (this repo)
lib/VM.php— dim fetch on bool/int/float/null/resourcetest/compliance/cases/language/array_offset_invalid_type.phpt(bool + int smoke)Done when
E_ALLnulllike Zend (no fatal)./script/ci-fast.sh --filter array_offset_invalidgreenLinks
+warnings), Language: unary + (+) on non-numeric strings — E_WARNING and int(0) like Zend (zend_operators.c) #4723