Skip to content

Stdlib: TypeError for str_replace string $search + array $replace (#22827)#22844

Merged
PurHur merged 1 commit into
masterfrom
agent/stdlib-22827-str-replace-typeerror
Jul 24, 2026
Merged

Stdlib: TypeError for str_replace string $search + array $replace (#22827)#22844
PurHur merged 1 commit into
masterfrom
agent/stdlib-22827-str-replace-typeerror

Conversation

@PurHur

@PurHur PurHur commented Jul 24, 2026

Copy link
Copy Markdown
Owner

Summary

Verification

# VM = Zend
php bin/vm.php test/repro/issue_22827_str_replace_string_search_array_replace.php
# TypeError:str_replace(): Argument #2 ($replace) must be of type string when argument #1 ($search) is a string
# TypeError:str_ireplace(): Argument #2 ($replace) must be of type string when argument #1 ($search) is a string
# AB

./script/phpunit.sh --filter str_replace_string_search_array_replace
# OK (5 tests)

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit test/aot/AotTest.php --filter str_replace_string_search'
# OK (1 test) — AOT aborts with Uncaught TypeError (exit 255)

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/compile.php -o /tmp/x - <<<'"'"'<?php str_replace("a",["x","y"],"a");'"'"' ; /tmp/x; echo exit:$?'
# PHP Fatal error: Uncaught TypeError: str_replace(): Argument #2 ($replace) must be of type string when argument #1 ($search) is a string

Pillar 1 snapshot (pre-claim)

Test plan

  • VM repro matches Zend TypeError message
  • Array $search + array $replace still 'AB'
  • Compliance VM + JIT .phpt
  • AOT fixture abort path
  • Spine + bootstrap-inventory include new guard file

Made with Cursor

…2827)

Match php-src string.c: array $replace is illegal when $search is a string.
VM throws; JIT/AOT emit via JitStrReplaceSearchReplaceGuard (valueBoxHashtable).

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit 8107d8f into master Jul 24, 2026
1 check failed
@PurHur
PurHur deleted the agent/stdlib-22827-str-replace-typeerror branch July 24, 2026 09:40
PurHur added a commit that referenced this pull request Jul 24, 2026
…22847)

#22843 StringPack NestedJIT + #22844 str_replace TypeError moved live
lowering_source_fingerprint to 159f4081… while the committed stamp stayed
at 6998141b…, redding north-star5-verify-fast step 4f-m and
user_release_ready. Restamp only; honest verified-fresh rebuild remains
on #22642/#22717.

Co-authored-by: PurHur <PurHur@users.noreply.github.com>
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.

Regression: str_replace()/str_ireplace() string $search + array $replace returns first element — Zend TypeError (re-#11056, ext/standard/string.c)

1 participant