Menu

← Back to property.*

Error Identifier: property.finalInInterface

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

Why is it reported? #

The property in an interface is declared as final. Interfaces define a contract that implementing classes must follow, and all interface properties are inherently abstract. Marking an interface property as final contradicts its purpose – interface members are meant to be implemented, not finalized.

This is a PHP language-level restriction enforced since PHP 8.4 property hooks.

How to fix it #

Remove the final keyword from the interface property:

 interface HasName
 {
-	final public string $name { get; }
+	public string $name { get; }
 }

If the property should not be overridden by subclasses of the implementing class, apply final in the implementing class instead:

<?php declare(strict_types = 1);

interface HasName
{
	public string $name { get; }
}

class User implements HasName
{
	final public string $name {
		get {
			return 'John';
		}
	}
}

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\PropertiesInInterfaceRule [1]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.