Skip to content

Stdlib: coerce str_replace/str_ireplace array subject values (#27165) - #28951

Merged
PurHur merged 1 commit into
masterfrom
agent/advanced-stdlib-27165-str-replace-array-coerce
Aug 8, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/advanced-stdlib-27165-str-replace-array-coerce

Conversation

@PurHur

@PurHur PurHur commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #27165

php-src reference

  • ext/standard/string.c — php_str_replace_array / php_str_replace_common

Test plan

  • Issue repro Zend / VM / JIT identical:
    ./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'
    Output (all three): ['X2','X3'] then ['X','12','X'] via var_export.
  • Existing string-only array subject still OK (test/repro-maintainer/str_replace_array_subject.php VM+JIT).
  • vendor/bin/phpunit test/unit/StrReplaceRuntimeShrinkTest.php — OK (3 tests).
  • Compliance .phpt guards added (str_replace_array_value_coerce{,_jit}.phpt).
  • Not covered: full VMTest discovery currently aborts on an unrelated EXTENSIONS phpt section mid-provider (pre-existing); AOT thin standalone aborts on var_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

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stdlib: str_replace/str_ireplace non-string array subject throws LogicException — Zend coerces (ext/standard/string.c)

1 participant