Menu

Error Identifier: property.abstractFinal

← Back to property.*

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 Foo
{
	abstract public string $name {
		final get;
	}
}

Why is it reported? #

A property (or its hook) cannot be both abstract and final. The abstract modifier requires subclasses to provide an implementation, while final prevents subclasses from overriding it. These two modifiers are mutually exclusive and combining them is a contradiction that PHP does not allow.

In the example above, the property is declared abstract and the get hook is declared final without a body. A final hook without a body is still abstract (it has no implementation), so this creates a conflict – the hook would need to be implemented by subclasses but the final modifier prevents that.

How to fix it #

Remove the final modifier from the abstract hook:

 abstract class Foo
 {
 	abstract public string $name {
-		final get;
+		get;
 	}
 }

Or provide an implementation and use final to prevent further overriding:

-abstract class Foo
+class Foo
 {
-	abstract public string $name {
-		final get;
+	public string $name {
+		final get => 'default';
 	}
 }

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\Properties\PropertyInClassRule [1] [2]
Theme
A
© 2026 PHPStan s.r.o.