Skip to content

Stdlib: SPL iterator wrappers — FilterIterator, LimitIterator, AppendIterator, … (ext/spl parity) #4546

Closed

Description

@PurHur

Category

stdlib | runtime

Problem

Zend ships a family of SPL iterator wrapper classes used throughout frameworks and the standard library:

  • FilterIterator / RecursiveFilterIterator
  • LimitIterator
  • AppendIterator
  • InfiniteIterator
  • NoRewindIterator
  • ParentIterator
  • MultipleIterator
  • GlobIterator
  • CachingIterator

This compiler has partial SPL coverage (SplFileObject, RecursiveIteratorIterator, ArrayIterator, … per #3330) but none of the wrapper classes above are registered. User code calling new FilterIterator(...) fails with unknown class.

php-src reference

Repro (failure today)

<?php
declare(strict_types=1);
$it = new ArrayIterator([1, 2, 3, 4, 5]);
$limited = new LimitIterator($it, 1, 2);
foreach ($limited as $v) {
    echo $v, "\n";
}
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php repro.php
php bin/vm.php repro.php'
Runtime Output
Zend PHP 8.x 2 then 3 (two lines)
This compiler fatal: class LimitIterator not found

Scope (this repo)

Piece Path / notes
Builtin classes new handlers under lib/VM/Builtin/ or ext/spl/
Iterator protocol reuse lib/VM.php foreach / VmIteratorWalk.php
v1 surface LimitIterator, FilterIterator, AppendIterator, NoRewindIterator, InfiniteIterator
v2 follow-ups MultipleIterator, GlobIterator, CachingIterator, recursive variants
Tests test/compliance/cases/stdlib/spl_limit_iterator.phpt, spl_filter_iterator.phpt
JIT/AOT VM-only v1 acceptable; document in capability matrix

Implement real Iterator protocol delegation — no permanent internal_* shims.

Done when

  • Repro LimitIterator foreach output matches Zend on VM
  • FilterIterator with user accept() method filters elements like Zend
  • AppendIterator chains two iterators in order
  • ./script/ci-fast.sh --filter 'LimitIterator|FilterIterator|AppendIterator' green
  • Rows added via script/capability-matrix.php

Related

Activity

  1. added
    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 2, 2026
  2. PurHur commented on Jul 15, 2026

    @PurHur
    OwnerAuthor

    Verified green on master (2026-07-15): FilterIterator, LimitIterator, AppendIterator, InfiniteIterator, ParentIterator, MultipleIterator, CachingIterator, GlobIterator, NoRewindIterator all class_exists true. Closing meta wrappers issue — use child tickets for remaining method-level gaps.

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 machineimplementation-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