phpstorm 不提示 $this->response->array () 中的 array () 方法

写到后面, $this->response->item(***)->setStatusCode(***) 中的 item() 和 setStatusCode() 都有提示,
刚想要回来提问 $this->response->array() 没有提示, 就看到第三个问题 $this->response()$this->response 的区别, 实际上是一个东西, 翻了下源码, 果真是一样的
顺带找了下 __call ,果然有结果

    public function __call($method, $parameters)
    {
        if (method_exists($this->response(), $method) || $method == 'array') {
            return call_user_func_array([$this->response(), $method], $parameters);
        }

        throw new ErrorException('Undefined method '.get_class($this).'::'.$method);
    }

意为调用 $this->response() 类( Factory类)的 $method (也就是 array() 方法), 并将 $parameters 作为参数
也就是 Factory 类的 array() 方法, 没想到 在 Factory 类中, array() 方法也是通过 __call() 魔术方法调用的...

另: call_user_func_array() 方法: 调用回调函数,并把一个数组参数作为回调函数的参数
如果调用的方法是一个类方法, 那么用 数组将 类名和方法名 组合起来 [$this->response(), $method] 表示回调方法

《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!