Menu

Error Identifier: isset.initializedProperty

← Back to isset.*

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
{
	private int $value;

	public function __construct(int $value)
	{
		$this->value = $value;
	}

	public function doFoo(): void
	{
		if (isset($this->value)) {
			echo $this->value;
		}
	}
}

Why is it reported? #

The isset() check is used on a property that has a native type and is known to be initialized. PHPStan determined that $this->value is always assigned in the constructor, so the property can never be in an uninitialized state at the point of the check. Since the type int is also not nullable, isset() always evaluates to true, making the check redundant.

How to fix it #

Remove the unnecessary isset() check:

 public function doFoo(): void
 {
-	if (isset($this->value)) {
-		echo $this->value;
-	}
+	echo $this->value;
 }

If the property might legitimately be uninitialized in some code paths, consider making it nullable:

-private int $value;
+private ?int $value = null;

How to ignore this error #

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

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

Rules that report this error #

  • PHPStan\Rules\Variables\EmptyRule [1]
  • PHPStan\Rules\Variables\IssetRule [1]
  • PHPStan\Rules\Variables\NullCoalesceRule [1]
Theme
A
© 2026 PHPStan s.r.o.