Skip to content

Regression: AppendIterator/LimitIterator/CachingIterator null TypeError cites IteratorIterator — Zend method+Iterator (ext/spl/spl_iterators.c) #31513

Description

@PurHur

Category

Regression: · php-src-strict · SPL iterator null-inner TypeError message

Problem

Passing null where an Iterator is required throws on both engines, but VM attributes the TypeError to IteratorIterator::__construct with type Traversable. Zend cites the concrete method (AppendIterator::append, LimitIterator::__construct, CachingIterator::__construct) and type Iterator.

Same message-attribution class as open #31509 (SplObjectStorage::offsetSet citing attach).

Probed 2026-08-16 — host Zend PHP 8.2.32 vs php bin/vm.php.

Repro Zend 8.2+ VM (2026-08-16)
(new AppendIterator())->append(null) TypeError: AppendIterator::append(): Argument #1 ($iterator) must be of type Iterator, null given TypeError: IteratorIterator::__construct(): Argument #1 ($iterator) must be of type Traversable, null given
new LimitIterator(null) LimitIterator::__construct(): … Iterator, null given IteratorIterator::__construct(): … Traversable, null given
new CachingIterator(null) CachingIterator::__construct(): … Iterator, null given IteratorIterator::__construct(): … Traversable, null given

Also affects siblings that share the same parent check (NoRewindIterator, InfiniteIterator, MultipleIterator::attachIterator, RecursiveIteratorIterator) — fix the shared guard once.

php-src reference

PHP implementation target

  • ext/spl/ iterator builtins — type-check with Zend receiver method name + Iterator (not parent IteratorIterator / Traversable)
  • Prefer shared PHP guard used by Append/Limit/Caching/NoRewind/Infinite/Multiple/RII
  • No new runtime/*.c

Repro

./script/docker-exec.sh -- bash -lc 'php test/repro/maintainer_gap_spl_iterator_null_inner_message.php'
./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_spl_iterator_null_inner_message.php'

Done when

  • TypeError messages match Zend method + Iterator for Append/Limit/Caching (and listed siblings)
  • Targeted compliance/PHPUnit guard
  • php-src-strict; no php-compiler-strict shortcut

Activity

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