Support question
I try to check if correct types where passed to the method, since there is no way to enforce it on language level, only specify via annotations.
Phpstan tells me its not necessary, since I have correct type in annotation.
class Test
{
/**
* @param iterable<SomeInterface> $items
*/
public function test(iterable $items): void
{
foreach ($items as $item) {
if (!$item instanceof SomeInterface) {
throw new \Exception('Unsupported');
}
}
}
}
https://phpstan.org/r/0fdb99ce-cd7e-49fe-8d59-5e57c526c9dc
What would be correct way to approach this?
if I loosen up annotations it might be misleading
if I don't check a type inside method it will fail in not a nice way.