Let's say I have a Product Class, How can I tell PHP that I want to accept only Array of Product?
In other words, Is there a way to do something like this method?:
private function method(Product[] $products)
{
// ...
}
I thought about doing something like this:
private function validate($products)
{
foreach ($products as $product)
if (!is_a($product, 'Product')
return false;
// ...
}
It could work, but I don't like this idea of adding a bunch of lines just to make sure it's a "Product[]".