PHP-Дайджест № 140 (17 – 30 сентября 2018)

0870f16a9c6f4066aca9c6230cfdda33.jpg
class Example {
    // All types with the exception of "void" and "callable" are supported
    public int $scalarType;
    protected Type $type;
    private ?Type $nullableType;
 
    // Types are also legal on static properties
    public static iterable $staticProp;
 
    // Types can also be used with the "var" notation
    var bool $flag;
 
    // Typed properties may have default values (more below)
    public string $str = "foo";
    public ?string $nullableStr = null;
 
    // The type applies to all properties in one declaration
    public float $x, $y;
    // equivalent to:
    public float $x;
    public float $y;
}

© Habrahabr.ru