website/errors/staticMethod.callToAbstract.md
<?php declare(strict_types = 1);
interface Processor
{
public static function process(): void;
}
function doFoo(): void
{
Processor::process();
}
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.
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();
}