Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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;
    }

?>

Documentation

See Also