1.2.1227. Typed Property Usage¶
PHP properties may be typed. Since PHP 7.4, it is possible to type properties, just like arguments and return values.
<?php
class User {
public int $id;
public string $name;
public function __construct(int $id, string $name) {
$this->id = $id;
$this->name = $name;
}
}
?>
See also Typed Properties 2.0 and Typed Properties in PHP 7.4.
1.2.1227.1. Specs¶
Short name |
Php/TypedPropertyUsage |
Rulesets |
All, Appinfo, CE, CompatibilityPHP53, CompatibilityPHP54, CompatibilityPHP55, CompatibilityPHP56, CompatibilityPHP70, CompatibilityPHP71, CompatibilityPHP72, CompatibilityPHP73 |
Exakat since |
1.6.2 |
PHP Version |
With PHP 7.4 and more recent |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
Very high |
Features |
typehint, type-declaration-property |
Available in |