[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); // trueThe type in the docblock says only |
GrahamCampbell
left a comment
There was a problem hiding this comment.
👎 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