Menu

Error Identifier: method.abstractOverridingNonAbstract

← Back to method.*

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

abstract class ParentClass
{
	public function foo(): int
	{
		return 42;
	}
}

abstract class ChildClass extends ParentClass
{
	abstract public function foo(): int;
}

Why is it reported? #

PHP does not allow redeclaring a concrete (non-abstract) method as abstract in a child class. The parent class already provides an implementation of the method, and making it abstract in a subclass would remove that implementation, which is a fatal error at runtime.

This also applies to constructors, static methods, and methods inherited through multiple levels of inheritance.

How to fix it #

If the child class needs a different implementation, override the method with a concrete body instead of making it abstract:

 abstract class ChildClass extends ParentClass
 {
-	abstract public function foo(): int;
+	public function foo(): int
+	{
+		return 0;
+	}
 }

If the intent is to force subclasses to implement the method, consider using an interface instead:

 interface HasFoo
 {
 	public function foo(): int;
 }

-abstract class ChildClass extends ParentClass
+abstract class ChildClass extends ParentClass implements HasFoo
 {
-	abstract public function foo(): int;
 }

Non-ignorable error #

This error cannot be ignored using @phpstan-ignore or the ignoreErrors configuration. Non-ignorable errors indicate code that would cause a crash or a fatal error at runtime, or a fundamental problem in the analysed code that must be addressed.

Rules that report this error #

  • PHPStan\Rules\Methods\OverridingMethodRule [1] [2]
Theme
A
© 2026 PHPStan s.r.o.