Tim Bezhashvyly recently wrote an article in which he explains an interesting approach to make sure all items in array are of a certain type. It leverages variadic functions which were introduced in PHP 5.6

Consider this piece of code (borrowed from Tim's post):

function foo (Product ...$products )
{
/* ... */
}

In PHP 7 you can even using the scalar types, such as string and int, to make sure all elements are of that type.

Read Tim's full article here: https://thephp.cc/news/2016/02/typed-arrays-in-php