Skip to content

Regression: DirectoryIterator/FilesystemIterator/RecursiveDirectoryIterator missing path RuntimeException — Zend UnexpectedValueException (ext/spl/spl_directory.c) #31506

Description

@PurHur

Category

Regression: · php-src-strict · SPL directory ctor open failure

Problem

When the directory path does not exist, Zend throws UnexpectedValueException with the concrete class name in the message. VM throws RuntimeException and always labels the message DirectoryIterator::__construct even for FilesystemIterator / RecursiveDirectoryIterator.

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

Repro Zend 8.2+ VM (2026-08-16)
new DirectoryIterator('/no/such') UnexpectedValueException: DirectoryIterator::__construct(...): Failed to open directory: ... RuntimeException: DirectoryIterator::__construct(...): ...
new FilesystemIterator('/no/such') UnexpectedValueException: FilesystemIterator::__construct(...): ... RuntimeException: DirectoryIterator::__construct(...): ...
new RecursiveDirectoryIterator('/no/such') UnexpectedValueException: RecursiveDirectoryIterator::__construct(...): ... RuntimeException: DirectoryIterator::__construct(...): ...

php-src reference

PHP implementation target

  • ext/spl/DirectoryIteratorBuiltin.php (DirectoryIteratorStorage::open) — throw UnexpectedValueException; use receiver class name in message
  • Call sites already share DirectoryIteratorStorage::open from Filesystem/Recursive ctors
  • No new runtime/*.c

Repro

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

Done when

  • All three ctors throw UnexpectedValueException with Zend-shaped class-qualified message
  • 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