-
Notifications
You must be signed in to change notification settings - Fork 11.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[9.x] Stringable exactly not match with other Stringable variable #41846
Conversation
…n compare two string
Doesn't make a lot of sense to have a method called Might be a better idea to do this instead: if ($value instanceof Stringable) {
$value = $value->toString();
}
return $this->value === $value; |
if (is_object($value) && method_exists('__toString', $value)) {
$value = (string) $value;
} So that there is no loose comparison will happen. |
@imanghafoori1 I'm not sure every object that has a $model = new \App\Models\SomeModel;
str('[]')->exactly($model); // true The type in the docblock says only |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👎 You are incorrectly calling this function if you do not pass a string.
If you want this function to support stringable objects, then we would have to widen its param type. |
@GrahamCampbell that's what this PR tries to do 😅 I also misjudged this PR at first for wrong usage but I can see the use case here. |
The two itens has the exact values, so it should not return false. |
Description:
When need compare two Stringable variables with exactly method. Then false is returned
Steps To Reproduce:
Solution