-
Notifications
You must be signed in to change notification settings - Fork 161
Fix: Str::lower() expects string, Stringable given #148
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
base: main
Are you sure you want to change the base?
Conversation
…this->string('email')->value(). Illuminate\Support\Stringable -> string
@@ -80,6 +80,6 @@ public function ensureIsNotRateLimited(): void | |||
*/ | |||
public function throttleKey(): string | |||
{ | |||
return Str::transliterate(Str::lower($this->string('email')).'|'.$this->ip()); | |||
return Str::transliterate(Str::lower($this->string('email')->value()).'|'.$this->ip()); |
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 can directly call $this->input('email')
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.
$this->input('email') returns a mixed type. To ensure string type we need to use $this->string('email')->value()
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.
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.
Oh I see, you're right. However, I am still convinced we should not create a Stringable object just to get the string value of the email. Maybe casting to string
is a better way. What do you think? Is phpstan still complaining?
(string)$this->input('email')
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.
Stringable under the hood does casting mixed type into string and to me |
I think a proper fix here would be to PR a change to the framework |
You’re partly correct: the returned |
This doesn’t only occur in Str methods but in any methods that work with the string type. Using |
At the start of every project, phpstan complains that $this->string('email') is not a string but a Illuminate\Support\Stringable.
This PR fixes that issue.