Menu

← Back to booleanOr.*

Error Identifier: booleanOr.rightAlwaysFalse

Every error reported by PHPStan has an error identifier. Here’s a list of all error identifiers. In PHPStan Pro you can see the error identifier next to each error and filter errors by their identifiers.

Code example #

<?php declare(strict_types = 1);

function doFoo(int $i): void
{
	if ($i > 0 || $i > 5) {
		// ...
	}
}

Why is it reported? #

The right side of the || operator always evaluates to false. After evaluating the left side, the type of the right-side expression is narrowed in a way that makes it always false. In the example above, if $i > 0 is false, then $i <= 0, which means $i > 5 is always false.

How to fix it #

Remove the redundant right-side condition or fix the logic:

 <?php declare(strict_types = 1);
 
 function doFoo(int $i): void
 {
-	if ($i > 0 || $i > 5) {
+	if ($i > 0) {
 		// ...
 	}
 }

How to ignore this error #

You can use the identifier booleanOr.rightAlwaysFalse to ignore this error using a comment:

// @phpstan-ignore booleanOr.rightAlwaysFalse
codeThatProducesTheError();

You can also use only the identifier key to ignore all errors of the same type in your configuration file in the ignoreErrors parameter:

parameters:
	ignoreErrors:
		-
			identifier: booleanOr.rightAlwaysFalse

Rules that report this error #

  • PHPStan\Rules\Comparison\BooleanOrConstantConditionRule [1]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.