Summary
Zend supports preg_replace() with array $pattern and $replacement arguments (parallel pattern/replacement pairs). php-compiler VM rejects array $pattern with TypeError: Argument #1 ($pattern) must be of type string.
Distinct from #9363 (array subject replacement semantics).
php-src reference
ext/pcre/php_pcre.c — php_pcre_replace_impl() array-pattern branch
Repro
<?php
declare(strict_types=1);
echo preg_replace(['/a/'], ['A'], 'aba'); // Zend: AbA — VM: TypeError
Committed repro: test/repro/maintainer_gap_preg_replace_array_pattern.php
./script/docker-exec.sh -- php test/repro/maintainer_gap_preg_replace_array_pattern.php # PASS
./script/docker-exec.sh -- php bin/vm.php test/repro/maintainer_gap_preg_replace_array_pattern.php # TypeError
Expected (php-src-strict)
Implementation hints (PHP-in-PHP)
ext/standard / PCRE builtin in ext/ + VM lowering (lib/VM/Builtin/ or dedicated PCRE helper).
- Prefer PHP implementation shared by VM/JIT; shrink any C regex helpers rather than extending
runtime/.
Done when
- Repro green on VM.
- Targeted test; JIT/AOT if those paths expose
preg_replace.
Summary
Zend supports
preg_replace()with array$patternand$replacementarguments (parallel pattern/replacement pairs). php-compiler VM rejects array$patternwithTypeError: Argument #1 ($pattern) must be of type string.Distinct from #9363 (array subject replacement semantics).
php-src reference
ext/pcre/php_pcre.c—php_pcre_replace_impl()array-pattern branchRepro
Committed repro:
test/repro/maintainer_gap_preg_replace_array_pattern.phpExpected (php-src-strict)
preg_replace(['/a/'], ['A'], 'aba')→'AbA'ValueErrorlike ZendImplementation hints (PHP-in-PHP)
ext/standard/ PCRE builtin inext/+ VM lowering (lib/VM/Builtin/or dedicated PCRE helper).runtime/.Done when
preg_replace.