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

See also An Exhaustive Guide to Understanding and Using PHP Data Types.

Related : Type System, Type System, Mixed, Void, Callables, Iterable, Never Type, Object, parent, static, Self

Added in PHP 7.0