Menu

← Back to staticMethod.*

Error Identifier: staticMethod.callToAbstract

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

interface Processor
{
	public static function process(): void;
}

function doFoo(): void
{
	Processor::process();
}

Why is it reported? #

An abstract static method is being called directly on an interface or abstract class. Abstract methods have no implementation, so calling them will result in a fatal error at runtime. Static calls to abstract methods cannot be dispatched to a concrete implementation because there is no instance to determine which class should handle the call.

This commonly happens when calling a static method on an interface type rather than on a concrete class that implements it.

How to fix it #

Call the method on a concrete class that implements the interface:

+class MyProcessor implements Processor
+{
+	public static function process(): void
+	{
+		// implementation
+	}
+}
+
 function doFoo(): void
 {
-	Processor::process();
+	MyProcessor::process();
 }

Or pass a concrete instance and call the method on it:

-function doFoo(): void
+function doFoo(Processor $processor): void
 {
-	Processor::process();
+	$processor::process();
 }

How to ignore this error #

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

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

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.