Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
taylorotwell merged 2 commits into
laravel:5.2from
SaeedPrez:patch-2
Jul 28, 2016
Merged

[5.2] Update Str::plural() to use intval()#14502
taylorotwell merged 2 commits into
laravel:5.2from
SaeedPrez:patch-2

Conversation

@SaeedPrez
Copy link
Copy Markdown
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
Copy Markdown
Collaborator

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
Copy Markdown
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
Copy Markdown
Contributor

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

@SaeedPrez
Copy link
Copy Markdown
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.

4 participants