13. Miscellaneous Additions
Class Constructor Property Promotion
In previous versions of PHP, the declarations needed to define a simple
value object were tedious and repetitive.
class Pants {
public float $x;
public float $y;
public float $z;
public function __construct(
float $x = 0.0,
float $y = 0.0,
float $z = 0.0,
) {
$this->x = $x;
$this->y = $y;
$this->z = $z;
}
}
In this new feature, PHP offers a more
optimized method for achieving a new class.
class Pants {
public function __construct( ...