Menu

← Back to booleanOr.*

Error Identifier: booleanOr.alwaysFalse

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 (is_string($i) || is_array($i)) {
        // ...
    }
}

Why is it reported? #

The result of the || (boolean or) expression is always false. Both the left and right sides of the expression evaluate to false for every possible value, which means the condition can never be satisfied and the code inside the if block is dead code. This typically happens when the types involved make one or both sides of the expression impossible to be truthy.

How to fix it #

Fix the condition to match the intended logic:

 <?php declare(strict_types = 1);
 
-function doFoo(int $i): void
+function doFoo(int|string|array $i): void
 {
     if (is_string($i) || is_array($i)) {
         // ...
     }
 }

Or remove the always-false condition entirely:

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

How to ignore this error #

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

// @phpstan-ignore booleanOr.alwaysFalse
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.alwaysFalse

Rules that report this error #

  • PHPStan\Rules\Comparison\BooleanOrConstantConditionRule [1]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.