Menu

← Back to property.*

Error Identifier: property.nonHookedInInterface

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

Why is it reported? #

The interface declares a property without any hooks. Since PHP 8.4, interfaces can include properties, but only hooked properties (properties with get and/or set hooks). A plain property without hooks is not allowed in an interface because interfaces cannot dictate how the implementing class stores its data – they can only define the access contract.

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

How to fix it #

Add hooks to the property to define the access contract:

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

If only read access is needed:

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

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.