Menu

← Back to staticMethod.*

Error Identifier: staticMethod.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 function existingMethod(): void {}
}

function doFoo(): void
{
    Foo::nonExistentMethod();
}

Why is it reported? #

The code calls a static method that does not exist on the specified class. In PHP, calling a non-existent static method results in a fatal error at runtime unless the class defines the __callStatic magic method. PHPStan reports this to catch the error before the code is executed.

How to fix it #

Fix the method name if it was a typo:

 <?php declare(strict_types = 1);
 
 function doFoo(): void
 {
-    Foo::nonExistentMethod();
+    Foo::existingMethod();
 }

Or add the missing static method to the class:

 <?php declare(strict_types = 1);
 
 class Foo
 {
     public static function existingMethod(): void {}
+
+    public static function nonExistentMethod(): void
+    {
+        // ...
+    }
 }

If the class uses __callStatic to handle dynamic static method calls, PHPStan may need to be informed about the available methods via a @method PHPDoc tag on the class:

 <?php declare(strict_types = 1);
 
+/**
+ * @method static void nonExistentMethod()
+ */
 class Foo
 {
     public static function __callStatic(string $name, array $arguments): mixed
     {
         // ...
     }
 }

How to ignore this error #

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

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

Rules that report this error #

  • PHPStan\Rules\Methods\CallStaticMethodsRule [1]
  • PHPStan\Rules\Methods\StaticMethodCallableRule [1]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.