Category
Language · php-src-strict / ArrayAccess assign-op
Problem
$obj[$k] += n (and -=, *=) on a user ArrayAccess object whose offsetGet returns by reference must read the stored int and write the result back (Zend ZEND_ASSIGN_DIM_OP). The VM instead TypeErrors Unsupported operand types: mixed + int — the dim-fetch used for the assign-op is typed as the declared mixed return rather than the live integer. Postfix ++ on the same object already matches Zend.
Probed 2026-08-17 @ c202af3d73 — Zend 8.2.32 vs php bin/vm.php.
| Repro |
Zend 8.2.32 |
VM |
$a[0]++ with &offsetGet backing [0=>1] |
inc=2 |
inc=2 (parity OK) |
$a[0] += 2 |
plus=3 |
TypeError: Unsupported operand types: mixed + int |
$a[0] *= 3 |
mul=3 |
TypeError: Unsupported operand types: mixed * int |
Distinct from closed #3446 / #5460 (non-ref offsetGet nested write → notice / Error). This is the by-ref assign-op path that must succeed.
php-src reference
PHP implementation target
lib/VM/ArrayAccessDimension.php — read() for assign-op must yield the live value type, not the declared mixed
lib/VM.php — dim assign-op on ArrayAccess objects; reuse by-ref offsetGet then offsetSet
- JIT/AOT:
lib/VM/VmArrayAccess.php after VM green
- No new
runtime/*.c
Repro
./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_arrayaccess_assign_op.php'
./script/docker-exec.sh -- bash -lc 'php test/repro/maintainer_gap_arrayaccess_assign_op.php'
Done when
Category
Language· php-src-strict / ArrayAccess assign-opProblem
$obj[$k] += n(and-=,*=) on a userArrayAccessobject whoseoffsetGetreturns by reference must read the stored int and write the result back (ZendZEND_ASSIGN_DIM_OP). The VM instead TypeErrorsUnsupported operand types: mixed + int— the dim-fetch used for the assign-op is typed as the declaredmixedreturn rather than the live integer. Postfix++on the same object already matches Zend.Probed 2026-08-17 @
c202af3d73— Zend 8.2.32 vsphp bin/vm.php.$a[0]++with&offsetGetbacking[0=>1]inc=2inc=2(parity OK)$a[0] += 2plus=3TypeError: Unsupported operand types: mixed + int$a[0] *= 3mul=3TypeError: Unsupported operand types: mixed * intDistinct from closed #3446 / #5460 (non-ref
offsetGetnested write → notice / Error). This is the by-ref assign-op path that must succeed.php-src reference
Zend/zend_vm_def.h—ZEND_ASSIGN_DIM_OPZend/zend_interfaces.c—offsetGetby-ref /offsetSetZend/zend_object_handlers.c—zend_std_read_dimensionBP_VAR_RWPHP implementation target
lib/VM/ArrayAccessDimension.php—read()for assign-op must yield the live value type, not the declaredmixedlib/VM.php— dim assign-op on ArrayAccess objects; reuse by-refoffsetGetthenoffsetSetlib/VM/VmArrayAccess.phpafter VM greenruntime/*.cRepro
Done when
inc=2/plus=3/mul=3(matches Zend); nomixed + intTypeError.phptundertest/compliance/cases/language/