Skip to content

Regression: ArrayObject::getIteratorClass() — var_export after setIteratorClass() returns __set_state (re-#10778, ext/spl/spl_array.c) #16794

Closed

Description

@PurHur

Category

stdlib · php-src-strict · compiler inline-call regression

Problem

#10778 was closed, but the compliance guard regressed: when setIteratorClass() is called as a void prelude immediately before var_export($ao->getIteratorClass(), true) in the same statement block, the compiler wires the wrong value into var_export and prints an ArrayObject::__set_state dump instead of the iterator class name string.

Repro Zend 8.2+ VM (2026-07-06)
var_export($ao->getIteratorClass(), true) after $ao->setIteratorClass('ArrayIterator') 'ArrayIterator' '\\ArrayObject::__set_state(array())'
Direct $ao->getIteratorClass() without preceding void call in expr 'ArrayIterator' 'ArrayIterator' (see arrayobject_iterator_class.phpt)

php-src reference

PHP implementation target

Repro

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php test/repro/maintainer_gap_arrayobject_getiterator_after_set.php'
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit test/compliance/VMTest.php --filter arrayobject_getiterator_after_set'

Done when

  • test/repro/maintainer_gap_arrayobject_getiterator_after_set.php prints 'ArrayIterator'
  • test/compliance/cases/stdlib/arrayobject_getiterator_after_set.phpt green in VMTest
  • test/unit/ArrayObjectGetIteratorAfterSetTest.php green if applicable
  • php-src-strict; no php-compiler-strict shortcut

Activity

  1. added
    bugSomething isn't working
    enhancementNew feature or request
    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 6, 2026
  2. PurHur commented on Jul 6, 2026

    @PurHur
    OwnerAuthor

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

  3. PurHur commented on Jul 6, 2026

    @PurHur
    OwnerAuthor

    Merged via #16803

    Root cause: resolveSiblingInlineCallArgProducerSlot mapped var_export arg #0 to the first FUNCCALL_EXEC_RETURN slot (the ArrayObject ctor) before compiling the hoisted getIteratorClass() MethodCall.

    Fix: compile hoisted MethodCall/StaticCall sibling producers and wire via operand slots; extend var_export arg-#0 matching for MethodCall producers.

    Verification (green):

    ./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php test/repro/maintainer_gap_arrayobject_getiterator_after_set.php'
    ./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit test/unit/ArrayObjectGetIteratorAfterSetTest.php'
    ./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit test/compliance/VMTest.php --filter arrayobject_getiterator_after_set'
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 workingenhancementNew feature or requestimplementation-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