[10.x] Deprecate Stringable test and whenTest methods #46345
Closed
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.
What does this PR propose
whenMatch
(orwhenIsMatch
, i don't know what is better 👀) method as alternative forwhenTest
Illuminate\Support\Stringable
test
andwhenTest
methods to deprecated statusWhy it do so
First reason
Recently
isMatch
method was added toIlluminate\Support\Str
andIlluminate\Support\Stringable
. It allows to check is string matching given pattern(s). There is alsotest
method inIlluminate\Support\Stringable
which do exactly the following:In prevoius PR, I explained why this is not fully correct way to check if string contains pattern.
Second reason
Illuminate\Support\Stringable
now has 2 methods for checking pattern matching which is ambigous in my opinion.Third reason
In my opinion
test
is not the best name for function that matches string against pattern.P.S.
I will glad to discuss this.