Repository navigation
Stdlib: coerce str_replace/str_ireplace array subject values (#27165) - #28951
Merged
PurHur merged 1 commit intoAug 8, 2026
Merged
Conversation
Match php-src php_str_replace_array convert_to_string per element instead of LogicException / skipping non-strings on the JIT hashtable walk (sibling #27164). Co-authored-by: Cursor <cursoragent@cursor.com>
This was referenced Aug 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
LogicExceptionrequiring string-only array$subjectvalues forstr_replace/str_ireplace.convert_to_stringsemantics (Variable::toString) like php-srcphp_str_replace_arrayand sibling Stdlib: preg_grep/preg_filter/preg_replace non-string array values throw LogicException — Zend coerces (ext/pcre/php_pcre.c) #27164 (preg_*).JitStrReplaceArrayusesstrvalper packed slot instead of skipping non-strings.Closes #27165
php-src reference
ext/standard/string.c—php_str_replace_array/php_str_replace_commonTest plan
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php test/repro/issue_27165_str_replace_array_value_coerce.php && php bin/vm.php test/repro/issue_27165_str_replace_array_value_coerce.php && php bin/jit.php test/repro/issue_27165_str_replace_array_value_coerce.php'['X2','X3']then['X','12','X']viavar_export.test/repro-maintainer/str_replace_array_subject.phpVM+JIT).vendor/bin/phpunit test/unit/StrReplaceRuntimeShrinkTest.php— OK (3 tests)..phptguards added (str_replace_array_value_coerce{,_jit}.phpt).VMTestdiscovery currently aborts on an unrelatedEXTENSIONSphpt section mid-provider (pre-existing); AOT thin standalone aborts onvar_export(array)(Regression: AOT BackedEnum::tryFrom segfaults after build — VM/JIT match Zend (re-#24208, Zend/zend_enum.c) #26855) — issue done-when is VM+JIT.Made with Cursor