-
-
Notifications
You must be signed in to change notification settings - Fork 20
lint: best-practices/no-boolean-literal-comparison shouldn't always be thrown for === false
#129
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
Comments
I'm also confused by this rule. I have several reports. I'm wondering if the rule was supposed to check for literal boolean strings (eg. [$isValid, $message] = match (true) {
is_string($result) => [false, $result],
$result === false => [false, 'Value did not pass validation.'],
default => [true, ''],
};
if ($result === false) {
return [];
}
|
This rule is meant to force you to write |
@azjezz Maybe we can change it to be opt-in? I would basically disable it in every project if the behaviour can't change |
I agree that this should be better opt-in given its current behavior |
the rule is now disabled by default. |
🐞 Describe the Bug
Some php functions returns a union type like
json_encode
that has return typestring|false
, so it's should be valid behaviour comparing it to false with the strict equal.Of course many other functions have this behaviour this is just an example.
🔄 Steps to Reproduce
mago lint test.php
⚙️ Configuration (mago.toml)
none
📜 Command Output
📂 PHP Code Sample (If Applicable)
🖥️ Operating System
Linux
📦 How did you install Mago?
Homebrew (brew install mago)
📝 Additional Context
No response
The text was updated successfully, but these errors were encountered: