So my understanding is I can not type hint multiple objects that may be passed to a class. So i figured i could leverage the reflection api to figure this out. maybe its bad practice in general but it is what it is. anyway, here is basically my layout. Without using reflection class, are there any ways of type hinting multiple classes? is this a good way of handling this situation?
interface Power { }
class mPower implements Power { }
class cPower implements Power { }
class Model extends ApiModel {
function __construct(stdClass $powerObj) {
$po = new ReflectionClass($powerObj);
if ( in_array('Power', $po->getInterfaceNames())) {
// do something
}
}
}
function __construct(Power $powerObj)
– Orangepill