I\'m trying to use PHP reflection to dynamically load the class files of models automatically based upon the type of parameter that is in the controller method. Here\'s an e
I supposed this is what you are looking for:
class MyClass {
function __construct(AnotherClass $requiredParameter, YetAnotherClass $optionalParameter = null) {
}
}
$reflector = new ReflectionClass("MyClass");
foreach ($reflector->getConstructor()->getParameters() as $param) {
// param name
$param->name;
// param type hint (or null, if not specified).
$param->getClass()->name;
// finds out if the param is required or optional
$param->isOptional();
}