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

Pseudo-type

A pseudo-type is a keyword and a type that describes an input or output, but is not an actual type.

For example, iterable represents both array and Traversable objects, yet a variable cannot be both, not be instantiated as such.

Union type, DNF or intersectional types are not pseudo-types, as they are made of multiple keywords.

There are several pseudo-type: mixed, callable, object, iterable.

<?php

function trumpet(iterable $trunk) { }

trumpet([]); // OK
trumpet(new ArrayIterator([1])); // OK
trumpet(1); // KO

?>

Documentation

See Also