Type System

Type declarations can be added to function arguments, return values, and, as of PHP 7.4.0, class properties. They ensure that the value is of the specified type at call time, otherwise a TypeError is thrown.

<?php

function foo(A $a) : void {}

class x {
    private A $p;
}

?>

Documentation

See also https://backendtea.com/post/explore-your-types/, https://seld.be/notes/narrowing-types-for-static-analysis/

Related : Disjunctive Normal Form (DNF), False, Mixed, Never Type, Nullable, Object, Properties, Return Type, strict_types, True, Property Type Declaration, Typed Property, Intersection Type, Object Type, Scalar Types, Special Types, Union Type, Variables, Autowiring, Propagation, Pseudo-type, Type Coverage, Dependent Type, Gradual Type Checking, Relative Types, Standalone Types

Added in PHP 7.0