Special Types

PHP defines some special types.

  • mixed : any type

  • void : no returned value

  • callable : may be used as a callback

  • iterable : may be used with foreach(), including array

  • never : never returns

  • object : object of any class

  • parent : any of the parent class of the current class, excluding it

  • self : the current class

  • static : the current called class

Other special types are the scalar types.

<?php
function foo(iterable $i) : never {
    foreach ($i as $j) {
        echo $j;
    }

    die();
}

?>

Documentation

Related : Type System

Added in PHP 7.0