Skip to content
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

[5.2] Update Str::plural() to use intval() #14502

Merged
merged 2 commits into from
Jul 28, 2016
Merged

[5.2] Update Str::plural() to use intval() #14502

merged 2 commits into from
Jul 28, 2016

Conversation

SaeedPrez
Copy link
Contributor

A lot of the time when you use str_plural() you get the $count value from a form request which returns the number as a string and therefore this won't work as expected. This small change should make sure the $count is in integer format.

Many thanks to @barryvdh for suggesting to do this change deeper in the code.

A lot of the time when you use str_plural() you get the $count value from a form request which returns the number as a string and therefore this plural won't work as expected. This small change should make sure the $count is in integer format.

Thanks to @barryvdh for suggesting to do this change deeper in the code.
@GrahamCampbell GrahamCampbell changed the title Update Str::plural() to use intval() [5.2] Update Str::plural() to use intval() Jul 27, 2016
@GrahamCampbell
Copy link
Member

Thank you, but could you please update this to use the (int) casting rather than calling the intval function.

Using `(int) $count` instead of `intval($count)` as requested.
@SaeedPrez
Copy link
Contributor Author

@GrahamCampbell Thank you for your suggestion, I have made the requested changes.

@taylorotwell taylorotwell merged commit 51fcca4 into laravel:5.2 Jul 28, 2016
@SaeedPrez SaeedPrez deleted the patch-2 branch July 28, 2016 13:32
@antonkomarev
Copy link
Contributor

@GrahamCampbell Could you please explain why (int) casting preferable over intval function?

@SaeedPrez
Copy link
Contributor Author

@a-komarev from what I understood, if you're using a base of 10, it's a lot faster and therefore preferred. intval() gives you more options though.

tillkruss pushed a commit to tillkruss/framework that referenced this pull request Aug 30, 2016
* Update Str::plural() to use intval()

A lot of the time when you use str_plural() you get the $count value from a form request which returns the number as a string and therefore this plural won't work as expected. This small change should make sure the $count is in integer format.

Thanks to @barryvdh for suggesting to do this change deeper in the code.

* Changed to type casting

Using `(int) $count` instead of `intval($count)` as requested.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants