Category
Regression · php-src-strict
Problem
array_walk() first parameter is by-ref in php-src. When callers pass a non-variable object expression such as new ArrayObject([1]), Zend emits the usual "Only variables should be passed by reference" notice and still walks the object. This compiler fatals with LogicException (misrouted ArrayMapCallbackPolicy rejection).
| Repro |
Zend 8.2+ |
VM (2026-07-09) |
array_walk(new ArrayObject([1]), $cb) |
notice + ok |
notice + LogicException |
$ao = new ArrayObject([1]); array_walk($ao, $cb) |
notice + ok |
notice + ok |
php-src reference
PHP implementation target
ext/standard/array_walk.php — materialize by-ref object temps (or copy-on-walk for non-ref expressions) before callback dispatch; do not reject valid closures on object subjects
ext/standard/VmArrayWalk.php — object/Traversable walk path for ArrayObject et al.
Repro
./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_array_walk_inline_new_object.php'
# Zend: ok (after notice) · VM: LogicException fatal
Done when
Category
Regression· php-src-strictProblem
array_walk()first parameter is by-ref in php-src. When callers pass a non-variable object expression such asnew ArrayObject([1]), Zend emits the usual "Only variables should be passed by reference" notice and still walks the object. This compiler fatals withLogicException(misroutedArrayMapCallbackPolicyrejection).array_walk(new ArrayObject([1]), $cb)okLogicException$ao = new ArrayObject([1]); array_walk($ao, $cb)okokphp-src reference
ext/standard/array.c—php_array_walk()/ZEND_SEND_PREFER_REFtemporary handlingPHP implementation target
ext/standard/array_walk.php— materialize by-ref object temps (or copy-on-walk for non-ref expressions) before callback dispatch; do not reject valid closures on object subjectsext/standard/VmArrayWalk.php— object/Traversable walk path forArrayObjectet al.Repro
Done when
new ArrayObject(...)(and other traversable objects) walk without fatal; Zend-parity notice preserved.phptguard undertest/compliance/cases/array/array_walkclosures