Skip to content

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

Closed

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

Activity

  1. added
    bugSomething isn't working
    phase-4:stdlibPhase 4 – stdlib for web apps
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jul 9, 2026
  2. PurHur commented on Jul 9, 2026

    @PurHur
    OwnerAuthor

    claim: cursor-agent-lane-c — starting this run

  3. PurHur commented on Jul 9, 2026

    @PurHur
    OwnerAuthor

    claim released: repro maintainer_gap_array_walk_inline_new_object.php matches Zend on master — both print ok after notice for closure callback. Stale regression report; pivoting to #10775.

  4. PurHur commented on Jul 9, 2026

    @PurHur
    OwnerAuthor

    claim released: repro green on master (VM+JIT) — array_walk(new ArrayObject([1]), $cb) emits notice + ok; moving to #16925.

  5. PurHur commented on Jul 10, 2026

    @PurHur
    OwnerAuthor

    claim: cursor-agent-lane-a — starting this run (lane A queue stale on master; compiler lowering per ladder step 3)

  6. PurHur commented on Jul 10, 2026

    @PurHur
    OwnerAuthor

    Merged via #17613.

    Fix: compileArrayWalkInlineNewClosureCallArgSends() wires hoisted inline New_ + Closure to array_walk() ARG_SEND slots (was sending New_ slot twice → LogicException).

    Verification:

    ./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
    php bin/vm.php test/repro/maintainer_gap_array_walk_inline_new_object.php
    vendor/bin/phpunit --filter array_walk_inline_new_object
    '
    # ok + OK (2 tests)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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