Skip to content

Regression: array_walk() inline new object subject — LogicException vs Zend notice+ok (ext/standard/array.c) #17504

Description

@PurHur

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

  • Inline new ArrayObject(...) (and other traversable objects) walk without fatal; Zend-parity notice preserved
  • Compliance .phpt guard under test/compliance/cases/array/
  • VM/JIT/AOT agree when JIT lowers array_walk closures
  • php-src-strict; no php-compiler-strict shortcut

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:compilerCompiler / CFG / JITarea:vmVirtual machinebugSomething isn't workingimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions