4,249
社区成员




public function dispatch(Route $route, $controller, $method)
{
$parameters = $this->resolveClassMethodDependencies(
$route->parametersWithoutNulls(), $controller, $method
);
if (method_exists($controller, 'callAction')) {
return $controller->callAction($method, $parameters);
}
return $controller->{$method}(...array_values($parameters));
}
class mm {
public $str = 1;
}
class nn {
}
function abc(mm $abc){ // 限制参数必须是mm类的对象
echo $abc->str;
}
$obj = new nn;
abc($obj);
Catchable fatal error: Argument 1 passed to abc() must be an instance of mm, instance of nn given, called
class mm{
public $str = 1;
}
function abc(mm $abc){ // 限制参数必须是mm类的对象
echo $abc->str;
}
$obj = new mm;
abc($obj);