Menu

← Back to booleanNot.*

Error Identifier: booleanNot.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(): void
{
	$one = 1;
	if (!$one) {
		// never entered
	}
}

Why is it reported? #

The negated boolean expression (!$one) always evaluates to false because the operand is always truthy. In this example, the variable $one is always 1, which is truthy in PHP, so !$one is always false. This means the condition will never be entered, which usually indicates a logic error or dead code.

How to fix it #

Remove the unreachable condition:

 <?php declare(strict_types = 1);
 
 function doFoo(): void
 {
 	$one = 1;
-	if (!$one) {
-		// never entered
-	}
 }

Or fix the logic to check the correct variable or expression.

How to ignore this error #

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

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

Rules that report this error #

  • PHPStan\Rules\Comparison\BooleanNotConstantConditionRule [1]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.