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

Add AmbiguousReturnCheck #24

Merged
merged 2 commits into from
Jan 1, 2018
Merged

Add AmbiguousReturnCheck #24

merged 2 commits into from
Jan 1, 2018

Conversation

wata727
Copy link
Owner

@wata727 wata727 commented Dec 31, 2017

For example, strpos returns false when a second argument string is not included in a first argument.

<?php

strpos("abc", "d"); # => false

However, this function may return falsy value. The example is as follows:

<?php

strpos("abc", "a"); # => 0

In other words, unless you use the identical operator, you may get unintended results.

<?php

if (strpos("abc", "a") == false) {
    echo "not found.";
}

This tool gives hints to the above code.

@wata727 wata727 force-pushed the ambiguous_comparison branch 4 times, most recently from fbdb32b to f3c50a6 Compare January 1, 2018 10:55
@wata727 wata727 force-pushed the ambiguous_comparison branch from f3c50a6 to 8eee6eb Compare January 1, 2018 11:54
@wata727 wata727 changed the title Add AmbiguousFalsyValue Add AmbiguousReturnCheck Jan 1, 2018
@wata727 wata727 merged commit 16e627c into master Jan 1, 2018
@wata727 wata727 deleted the ambiguous_comparison branch January 1, 2018 14:24
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.

1 participant