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

Fix #157 Insight #161

Closed
wants to merge 1 commit into from
Closed

Fix #157 Insight #161

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented May 18, 2015

This will fix #157.

is_string(false) = bool(false)
is_string(true) = bool(false)
is_string(NULL) = bool(false)
is_string('abc') = bool(true)
is_string('23') = bool(true)
is_string(23) = bool(false)
is_string('23.5') = bool(true)
is_string(23.5) = bool(false)
is_string('') = bool(true)
is_string(' ') = bool(true)
is_string('0') = bool(true)
is_string(0) = bool(false)

@@ -36,7 +36,7 @@ class FilterLocaleSwitchEvent extends Event
*/
public function __construct(Request $request, $locale)
{
if (!is_string($locale) || null == $locale || '' == $locale) {
if (!is_string($locale)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this is incorrect. you need to keep the check for empty string, as that would be is_string but still not ok.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it important that empty strings are not allowed?
But ok, let's add || !empty($locale).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because something is really wrong when the locale is an empty string. i would do '' === $locale - empty checks other things we don't care as null is not is_string.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok 👍

This pull request was closed.
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.

[Insight] Boolean should be compared strictly - in Event/FilterLocaleSwitchEvent.php, line 39
1 participant