Skip to content

Language: E_WARNING for array offset on scalars (#4867) - #4884

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-4867-array-offset-scalar-warning
Jun 3, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-4867-array-offset-scalar-warning

Conversation

@PurHur

@PurHur PurHur commented Jun 3, 2026

Copy link
Copy Markdown
Owner

Summary

  • VM TYPE_ARRAY_DIM_FETCH read on null/bool/int/float: emit Zend-style E_WARNING (Trying to access array offset on value of type …) and yield null instead of TypeError (php-src Zend/zend_execute.c).
  • JIT read lowering uses ScalarDimFetchHelper with __compiler_trigger_error + null box.
  • Non-ArrayAccess object offset read raises catchable Error (Cannot use object of type … as array).
  • Compliance: array_offset_scalar_warning.phpt; dim_fetch_null_type_error.phpt narrowed to read-only cases (write parity tracked separately).

Closes #4867

Reference

php/php-src Zend/zend_execute.c (ZEND_FETCH_DIM_R on scalars)

Verification

./script/docker-exec.sh -- bash -lc 'vendor/bin/phpunit --filter "array_offset_scalar_warning|dim_fetch_null_type_error" test/compliance/'
PHPUnit 9.6.21 by Sebastian Bergmann and contributors.
...
OK (6 tests, 6 assertions)

Made with Cursor

Zend ZEND_FETCH_DIM_R on null/bool/int/float emits a warning and yields
null instead of TypeError. VM and JIT read paths match; object dim fetch
raises catchable Error with the php-src message.

Reference: php/php-src Zend/zend_execute.c
Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit e6a2cbe into master Jun 3, 2026
@PurHur
PurHur deleted the agent/issue-4867-array-offset-scalar-warning branch June 3, 2026 06:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Language: array offset on non-container types must emit E_WARNING (zend_execute.c)

1 participant