You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
auto-fix "Only booleans are allowed in an if condition" #316
when the native type of a property is known, we can auto-fix the "Only booleans are allowed in an if condition" phpstan-strict-error.
same is true for method-calls/function-calls etc. which have a native return-type.
I think this applies to any expression for which we know a non-union native type.
e.g.
class CoffeeBreak
{
privatearray$arr;
publicfunctiongetDuration(): int {
if ($this->arr) {
}
}
}
can get fixed to
class CoffeeBreak
{
privatearray$arr;
publicfunctiongetDuration(): int {
if (count($this->arr) !== 0) {
}
}
}
Activity
VincentLanglet commentedon May 8, 2026
I dunno if we should prefer
or a
!== []check.This could work for some union too. The one I saw a lot
staabm commentedon May 8, 2026
I don't care much about which expression we use (as projects will run code style fixing on it most of the time).
As soon as the expression is stricter we fix the phpstan error - thats most important
VincentLanglet commentedon May 8, 2026
Btw should be a feature request for the strict-rules repository no ?