Skip to content

[12.x] fix invalid array doctypes for Str::replaceMatches in v12.47.0#58364

Merged
taylorotwell merged 2 commits into
laravel:12.xfrom
marcreichel:fix-str-invalid-replace-matches-doctypes
Jan 15, 2026
Merged

[12.x] fix invalid array doctypes for Str::replaceMatches in v12.47.0#58364
taylorotwell merged 2 commits into
laravel:12.xfrom
marcreichel:fix-str-invalid-replace-matches-doctypes

Conversation

@marcreichel

@marcreichel marcreichel commented Jan 13, 2026

Copy link
Copy Markdown
Contributor

With release 12.47.0 the Str::replaceMatches() method does not accept simple strings as the subject anymore (checked by PHPStan) and pretends to return a nullable array with a simple string subject whereas it should return a nullable string instead and only a nullable array if the subject is an array as well.

image

This PR fixes the doc types accordingly.

@marcreichel marcreichel changed the title fix invalid array doctypes for Str::replaceMatches in v12.47.0 [12.x] fix invalid array doctypes for Str::replaceMatches in v12.47.0 Jan 13, 2026
@shaedrich

Copy link
Copy Markdown
Contributor

Thanks for recognizing and fixing it this quick! 👍🏻

@taylorotwell taylorotwell merged commit 4c24ad3 into laravel:12.x Jan 15, 2026
69 of 70 checks passed
shaedrich added a commit to shaedrich/framework that referenced this pull request Jan 15, 2026
taylorotwell pushed a commit that referenced this pull request Jan 15, 2026
* Add type tests for `\Illuminate\Support\Str`

* Add missing parameter to startsWith

* Use short form of type

* Remove non-existing case

* Fix type

* Fix typo

* Narrow type

* Negate typesy

* Inverse expectation

* Use expected notation

* Same here

* Fix casing tests

* Fix `Str::position()` test case

* Fix remaining casing test cases

* Adjust `Str::replaceMatches()` to #58364

* Fix empty string type and narrow non-empty-string case-sensitive types

* Reorder types to assert
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.

3 participants