How can I pass an array as constructor parameters in class instantiation?
abstract class Person {
protected function __construct(){
}
public static final function __callStatic($name, $arguments){
return new $name($arguments);
}
}
class Mike extends Person {
protected function __construct($age, $hobby){
echo get_called_class().' is '.$age.' years old and likes '.$hobby;
}
}
// =============================================
Person::Mike(15, 'golf');
This should output
Mike is 15 years old and likes golf
But I get second parameter missing in Mike's constructor, because both parameters from __callStatic are sent as array into $age. My question is how can I send them as parameters instead of array?