[12.x] Make Str::is()
match multiline strings
#51196
Merged
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.
Currently
Str::is()
almost always returns false for strings containing a newline, for example:This happens because the
*
wildcard gets changed to the regex pattern.*
, but the.
doesn't match newlines because thes
modifier isn't present.Str::is()
is used by the framework to match fake outputs for theProcess
facade. Currently you can't properly match a multiline command (as reported in #50158 and fixed with a hack in #50164). This PR fixes this problem properly. For example:After this PR the
*
pattern always matches everything, so I've added the$pattern === '*'
check because it is a minor speed boost.I've targeted 12.x because this PR is a breaking change. If you rely on
Str::is()
orstr()->is()
returning false on multiline strings then you'll have to update your code.