Menu

← Back to staticProperty.*

Error Identifier: staticProperty.notFound

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 static int $count = 0;
}

function doFoo(): void
{
	echo Foo::$name;
}

Why is it reported? #

The code accesses a static property that does not exist on the specified class. In PHP, accessing an undefined static property results in a fatal error at runtime. PHPStan reports this to catch the error before the code is executed.

How to fix it #

Fix the property name if it was a typo:

 <?php declare(strict_types = 1);
 
 function doFoo(): void
 {
-	echo Foo::$name;
+	echo Foo::$count;
 }

Or add the missing static property to the class:

 <?php declare(strict_types = 1);
 
 class Foo
 {
 	public static int $count = 0;
+
+	public static string $name = '';
 }

If the class uses __get via a magic property pattern, declare the property using a @property PHPDoc tag on the class:

 <?php declare(strict_types = 1);
 
+/**
+ * @property string $name
+ */
 class Foo
 {
 	public static int $count = 0;
 }

How to ignore this error #

You can use the identifier staticProperty.notFound to ignore this error using a comment:

// @phpstan-ignore staticProperty.notFound
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: staticProperty.notFound

Rules that report this error #

  • PHPStan\Rules\Properties\AccessStaticPropertiesInAssignRule [1]
  • PHPStan\Rules\Properties\AccessStaticPropertiesRule [1]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.