At the time of this writing there is no support for multiple explicit types. You have to rely on documentation and PHP's dynamic type system.
However, I do have a mostly incomplete proposal for union types. It is targeting 7.NEXT (at the time of this writing this is 7.1) or 8 (whichever comes first).
Here is a simple example of something that I think would be very valuable: array | Traversable
:
function map(callable $fn, array|Traversable $input) {
foreach ($input as $key => $value) {
yield $key => $fn($value);
}
}
Unfortunately the RFC did not pass; however for the specific type array|Traversable
there is now an iterable
type which is exactly that.