Just a curiosity, as I was working on a method that expects an instance of an object that implements two unrelated interfaces, I thought:
"wouldn't it be nice to be able to type hint multiple types"...
In PHP you can type hint:
public function foo(InterfaceA $param): bool {}
When dealing with a class that implements more than one interface I think it would be cool to be able to type hint for all possible types/interfaces/etc, something like:
public function foo(InterfaceA | InterfaceB | InterfaceC $param) : bool {}
or even:
public function foo(int | bool $param) : bool {}
or:
public function foo(array | \SplObjectStorage $param) : array {}
I'm sure there is a obvious reason this is not possible, but it's not clear to me and I would appreciate if someone who understands PHP's design better could explain why...? Thank you in advanced :)