Menu

← Back to property.*

Error Identifier: property.override

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

class Foo
{
	public int $foo;
}

class Bar extends Foo
{
	#[\Override]
	public int $foo;

	#[\Override]
	public int $bar;
}

Why is it reported? #

The #[\Override] attribute on a property declares that the property is intended to override a property from a parent class. If the parent class does not have a property with the same name, the attribute is incorrect. This prevents situations where a parent property is renamed or removed but the child class still claims to override it.

In the example above, Bar::$foo correctly overrides Foo::$foo, but Bar::$bar has the #[\Override] attribute even though Foo does not have a $bar property, which is an error.

This feature requires PHP 8.5 or later for the #[\Override] attribute on properties.

How to fix it #

If the property is not meant to override a parent property, remove the #[\Override] attribute:

 <?php declare(strict_types = 1);
 
 class Bar extends Foo
 {
 	#[\Override]
 	public int $foo;

-	#[\Override]
 	public int $bar;
 }

If the property should override a parent property, verify the parent class actually declares a property with the same name, or fix the property name to match:

 <?php declare(strict_types = 1);
 
 class Bar extends Foo
 {
 	#[\Override]
 	public int $foo;

 	#[\Override]
-	public int $bar;
+	public int $baz; // if Foo has $baz
 }

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.