The PHP7 iterable pseudo type will match both Traversable and array. Great for return type-hinting so that you do not have to expose your Domain to Infrastructure code, e.g. instead of a Repository returning a Cursor, it can return hint 'iterable':
<?php
UserRepository::findUsers(): iterable
?>
Link: http://php.net/manual/en/migration71.new-features.php#migration71.new-features.iterable-pseudo-type
Also, instead of:
<?php
if( !is_array( $items ) && !$items instanceof Traversable )
//Throw exception here
?>
You can now do with the is_iterable() method:
<?php
if ( !is_iterable( $items ))
//Throw exception here
?>
Link: http://php.net/manual/en/function.is-iterable.php