Skip to content

Stdlib: ArrayObject::getIteratorClass() undefined — must return iterator class name (ext/spl/spl_array.c) #10639

Description

@PurHur

Category

stdlib · php-src-strict · refs #1492

Problem

ArrayObject::getIteratorClass() must return the iterator class used by getIterator() (default 'ArrayIterator'). VM throws Call to undefined method.

Verified 2026-06-22:

$ao = new ArrayObject([1, 2, 3]);
var_export($ao->getIteratorClass());
// Zend: 'ArrayIterator'
// VM: Fatal Error — undefined method

php-src reference

Repro

test/repro/maintainer_gap_arrayobject_get_iterator_class.php

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro/maintainer_gap_arrayobject_get_iterator_class.php
php bin/vm.php test/repro/maintainer_gap_arrayobject_get_iterator_class.php'

Implementation hints (PHP-in-PHP)

  • SPL ArrayObject in ext/ — add getIteratorClass() / setIteratorClass() with default ArrayIterator
  • No new C runtime

Done when

  • Repro prints 'ArrayIterator' on VM; setIteratorClass() round-trip works

Related

Activity

  1. added
    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 Jun 22, 2026
  2. PurHur commented on Jun 23, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib — starting this run

  3. PurHur commented on Jun 23, 2026

    @PurHur
    OwnerAuthor

    Merged via #10762

    Verification

    • Zend + VM repro: test/repro/maintainer_gap_arrayobject_get_iterator_class.php — returns 'ArrayIterator', round-trip setIteratorClass('ArrayIterator'), TypeError for stdClass
    • Compliance: test/compliance/cases/stdlib/arrayobject_iterator_class.phpt — VM + JIT green
    • AOT lint: php bin/compile.php -l test/repro/maintainer_gap_arrayobject_get_iterator_class.php

    Implementation: ext/spl/SplArrayStorage.php + ext/spl/ArrayObjectBuiltin.php (php-src ext/spl/spl_array.c). No new C runtime.

  4. added 2 commits that reference this issue on Jun 23, 2026
  5. PurHur commented on Jul 12, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler Ext — I/O & Crypto — starting this run (arrayobject_get_iterator.phpt — var_export(isset) rewired to ARRAY_DIM_FETCH_WRITE lvalue slot)

  6. PurHur commented on Jul 12, 2026

    @PurHur
    OwnerAuthor

    Merged via #18271.

    Fix: lastPendingCallArgArrayDimFetchSlot() no longer treats TYPE_ARRAY_DIM_FETCH_WRITE (ArrayAccess write lvalues) as dim-fetch read producers for var_export() call-arg rewiring.

    Verification:

    PHP_COMPILER_SKIP_SELFHOST_PREFLIGHT=1 vendor/bin/phpunit --filter arrayobject_get_iterator

    OK (2 tests) — VM + JIT compliance for arrayobject_get_iterator.phpt.

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:vmVirtual machineenhancementNew 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