Menu

← Back to property.*

Error Identifier: property.promotedNotSupported

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 User
{
	public function __construct(
		public string $name,
		public string $email,
	) {
	}
}

Why is it reported? #

The code uses constructor property promotion, which is only available in PHP 8.0 and later. The configured phpVersion is set to a version earlier than PHP 8.0, so this syntax is not supported.

How to fix it #

If upgrading to PHP 8.0+ is not possible, declare properties explicitly and assign them in the constructor body:

 class User
 {
+	public string $name;
+	public string $email;
+
 	public function __construct(
-		public string $name,
-		public string $email,
+		string $name,
+		string $email,
 	) {
+		$this->name = $name;
+		$this->email = $email;
 	}
 }

Alternatively, update the phpVersion in the PHPStan configuration to match the actual PHP version in use.

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

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.