Skip to content

Regression: LimitIterator::__construct(null offset/limit) TypeError — Zend E_DEPRECATED + OutOfBoundsException (ext/spl/spl_iterators.c) #31621

Description

@PurHur

Category

Regression: · php-src-strict · LimitIterator soft-null ctor args

Problem

new LimitIterator(new ArrayIterator([1,2,3]), null, null) on Zend emits E_DEPRECATED for parameters #2/$offset and #3/$limit, coerces to 0, then throws OutOfBoundsException: Cannot seek to 0 which is behind offset 0 plus count 0 (limit 0). VM hard-rejects with TypeError: LimitIterator::__construct(): Argument #2 ($offset) must be of type int, null given — no soft-null path.

Not covered by #31513 (null inner iterator message citation).

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

Repro Zend 8.2+ VM (2026-08-16)
new LimitIterator(new ArrayIterator([1,2,3]), null, null) E_DEPRECATED×2 then OutOfBoundsException (limit 0) TypeError on $offset

php-src reference

PHP implementation target

  • ext/spl/LimitIteratorBuiltin.php (or shared SPL ctor coerce) — soft-null deprecate + coerce to int like Zend; then existing limit-0 seek behavior; no new runtime/*.c

Repro

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

Done when

  • null $offset/$limit emit Zend E_DEPRECATED (not TypeError) under non-strict
  • Coerced limit 0 still throws Zend OutOfBoundsException text
  • strict_types=1 TypeError preserved
  • 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