Menu

← Back to property.*

Error Identifier: property.notReadable

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

class Child extends Base
{
	public string $name { // ERROR: Property Child::$name overriding readable property Base::$name also has to be readable.
		set => $value;
	}
}

Why is it reported? #

When a child class overrides a property from a parent class or interface, it must preserve the readability contract. If the parent property is readable (has a get hook or is a regular property), the overriding property must also be readable. Removing readability from an overriding property would break the Liskov Substitution Principle – code that expects to read the property based on the parent type would fail.

This rule applies to PHP 8.4+ property hooks.

How to fix it #

Add a get hook to the overriding property so it remains readable:

 <?php declare(strict_types = 1);
 
 abstract class Base
 {
 	abstract public string $name { get; set; }
 }

 class Child extends Base
 {
 	public string $name {
+		get => $this->name;
 		set => $value;
 	}
 }

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

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.