Skip to content

Stdlib: RecursiveRegexIterator — regex-filtered Iterator missing (ext/spl/spl_iterators.c) #6693

Description

@PurHur

Category

stdlib

Problem

RecursiveRegexIterator wraps an Iterator and yields only elements matching a PCRE pattern (used with RecursiveIteratorIterator for directory trees, config scanners, etc.). Not registered in this compiler (class_exists false).

Distinct from #6639 (preg JIT lowering) and #6593 (base SPL iterators). Needs VM class + accept() regex match using existing VmPreg / host PCRE.

php-src reference

Repro

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php -r "echo class_exists(\"RecursiveRegexIterator\")?\"yes\":\"no\", PHP_EOL;"
php -r "echo class_exists(\"RecursiveRegexIterator\")?\"yes\":\"no\", PHP_EOL;"
'
<?php
$it = new ArrayIterator(['a1', 'b2', 'a3']);
$rx = new RecursiveRegexIterator($it, '/^a/', RecursiveRegexIterator::MATCH);
foreach ($rx as $v) { echo $v, "\n"; } // Zend: a1, a3
Runtime class exists output
Zend yes a1/a3 lines
VM no

Scope (this repo)

Area Files
Class ext/spl/RecursiveRegexIterator.php + constants (MATCH, GET_MATCH, …)
Register ext/spl/Module.php, ext/spl/BuiltinClasses.php
VM Extend filter-iterator base; delegate regex to preg_match parity layer
Tests test/compliance/cases/stdlib/recursive_regex_iterator.phpt

Done when

  • Class registered; repro foreach matches Zend.
  • Invalid pattern → Error/ValueError per php-src mode flags.
  • Enum case pattern operand → TypeError (php-src-strict), not silent backing coercion.

Related

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