-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
Description
您的功能请求与问题相关吗?
当前 invoke 函数调用类时无法使用 IDE 提示
描述您想要的解决方案
invoke 函数通过 template 泛型返回对应的类型
/**
* 调用反射实例化对象或者执行方法 支持依赖注入
* @template T
* @param class-string<T>|callable $call 类名或者callable
* @param array $args 参数
* @return T
*/
function invoke($call, array $args = [])
{
if (is_callable($call)) {
return Container::getInstance()->invoke($call, $args);
}
return Container::getInstance()->invokeClass($call, $args);
}
invoke(Foo::class)->bar();
描述您考虑过的替代方案
-
在 common.php 覆盖 invoke 函数,但 vscode DEVSENSE.phptools-vscode 插件无法识别。
-
重新写一个其他名称相同功能的函数。
其它信息