Menu

← Back to isset.*

Error Identifier: isset.property

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);

class Foo
{
	public int $bar = 0;
}

function doFoo(Foo $foo): void
{
	if (isset($foo->bar)) {
		// ...
	}
}

Why is it reported? #

The isset() check on a property is unnecessary because the property always exists and is never null. The property $bar is declared with type int and has a default value, so it is always initialized and can never be null. Using isset() on it will always return true.

How to fix it #

Remove the unnecessary isset() check:

 function doFoo(Foo $foo): void
 {
-	if (isset($foo->bar)) {
-		// ...
-	}
+	// ...
 }

If the property can legitimately be nullable, declare it as such:

 class Foo
 {
-	public int $bar = 0;
+	public ?int $bar = 0;
 }

How to ignore this error #

You can use the identifier isset.property to ignore this error using a comment:

// @phpstan-ignore isset.property
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: isset.property

Rules that report this error #

  • PHPStan\Rules\Variables\EmptyRule [1]
  • PHPStan\Rules\Variables\IssetRule [1]
  • PHPStan\Rules\Variables\NullCoalesceRule [1]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.