Menu

Error Identifier: property.notWritable

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

interface HasValue
{
	public int $value { get; set; }
}

class Foo implements HasValue
{
	public int $value {
		get => 42;
	}
}

Why is it reported? #

A child class overrides a writable property from a parent class or interface but makes it non-writable. In the example above, the interface HasValue declares $value as both readable and writable, but Foo only defines a get hook. Since the get hook does not reference the backing store, the property becomes virtual and has no set capability. This violates the writability contract established by the interface.

This rule applies to PHP 8.4+ property hooks.

How to fix it #

Ensure the overriding property also supports writes:

 class Foo implements HasValue
 {
 	public int $value {
 		get => 42;
+		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]
Theme
A
© 2026 PHPStan s.r.o.