1.2.999. Promoted Properties¶
Promoted properties is a way to declare the properties within the constructor, and have them assigned to the constructing value at instantiation.
<?php
class CustomerDTO
{
public function __construct(
public string $name,
public string $email,
public DateTimeImmutable $birth_date,
) {}
}
?>
See also Constructor Promotion and PHP 8: Constructor property promotion.
1.2.999.1. Connex PHP features¶
1.2.999.1.1. Specs¶
Short name |
Classes/PromotedProperties |
Rulesets |
|
Exakat since |
2.3.1 |
PHP Version |
With PHP 8.0 and more recent |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
Very high |
Available in |