Skip to content

Stdlib: MultipleIterator — parallel Traversable iteration (ext/spl/spl_iterators.c) #6792

Closed

Description

@PurHur

Category

stdlib

Problem

MultipleIterator (iterate several Traversable objects in lockstep) is missing. class_exists('MultipleIterator') is false on VM. SPL umbrella #4546 lists wrapper iterators broadly; this ticket scopes the multi-attach iterator used in zip-style foreach over parallel streams.

php-src reference

Repro (failure today)

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php -r "
var_dump(class_exists(\"MultipleIterator\"));
"'

Observed (2026-06-06): bool(false).

Minimal usage (Zend):

<?php
$m = new MultipleIterator(MultipleIterator::MIT_NEED_ALL);
$m->attachIterator(new ArrayIterator([1, 2]));
$m->attachIterator(new ArrayIterator(['a', 'b']));
foreach ($m as $row) { var_dump($row); }
// array(2) { [0]=> int(1) [1]=> string(1) "a" } …

Scope (this repo)

Area Path Notes
ext/spl MultipleIterator builtin class Register in ext/spl/Module.php + BuiltinClasses.php
lib/VM iterator protocol Reuse existing Iterator/IteratorAggregate dispatch
JIT/AOT optional follow-up VM parity sufficient

PHP-in-PHP first: implement attach/detach/valid/current/next in ext/spl/; no new C runtime.

Done when

  • class_exists('MultipleIterator') is true.
  • Constants MultipleIterator::MIT_NEED_ALL and MIT_NEED_ANY match Zend values.
  • Attach two ArrayIterators; foreach ($m as $row) yields parallel tuples matching php-src.
  • test/compliance/cases/stdlib/multiple_iterator.phpt passes on VM.

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
vendor/bin/phpunit test/compliance/VMTest.php --filter multiple_iterator
'

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 6, 2026
  2. PurHur commented on Jul 16, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib Advanced — batch (issues #6273, #6792, #3635, #4689) — verifying MultipleIterator; implementing RecursiveTreeIterator first (#6273).

  3. PurHur commented on Jul 16, 2026

    @PurHur
    OwnerAuthor

    claim released: MultipleIterator already green on master — class_exists true; test/repro/maintainer_gap_multipleiterator_attach.php → ok on VM. Recommend closing as done (superseded by earlier landings). Batch continued with #6273 merged via #19438.

  4. PurHur commented on Jul 16, 2026

    @PurHur
    OwnerAuthor

    Verified done on master: MultipleIterator registers; maintainer_gap_multipleiterator_attach.php → ok. Closing as superseded.

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 apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions