PHP 8 · Types and functions
Declare properties in the constructor
Define and assign properties from constructor parameters.
class User
{
public function __construct(
public readonly string $name,
public readonly string $email,
) {}
}