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 trumpet(Elephpant $trunk) : void {}
class Herd {
private Elephpant $tusk;
}
?>
See Also
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
- Autocompletion
- Question Mark ?
- resource
- Types Erasure
- Type Inference
- Alias Types
- Array, []
- Type Coercion
- Composite Type
- Parameter
- Return
- Type Checking
- Void