带有自定义 class 实例的 PhpStorm "Cannot find declaration to go"

PhpStorm "Cannot find declaration to go" with custom class instance

PhpStorm 是我的最爱 IDE,我每天都使用它。目前,我从事一个使用自定义 PHP 框架的 PHP 项目。这个项目和框架不遵循最佳 PHP 实践,也不专注于编写干净、可读的代码。

在源代码中,我们调用函数来获取 class 的新实例。例如:

cAlert()->addError('...')

函数 cAlert 在框架包含的 PHP 文件中声明:

function cAlert() {
    return c('Alert');
}

function c($className) {
    return ClassCall::getActive($className);
}

ClassCall 创建新实例或获取 class 的活动实例。最后使用警报 class:

class Alert {
    public function addError($error) {
        ...
    }
}

问题

在编辑源代码时,我想导航到方法所在的位置。这个 PhpStorm/IntelliJ 功能似乎并没有解释这个特定的架构。

PhpStorm 找不到要转到 class AlertaddError 方法的声明(但它当然可以找到 cAlert 方法)。

问题

我了解 PhpStorm 无法自动解析此方法声明。

是否可以配置 IDE 以便手动 link,在我的示例中,cAlert()Alert class?

cAlert() 函数上方添加一个 PHPDoc,声明返回哪个 class:

/**
 * @return My\Application\Class
 */
function cAlert() {
    return c('Alert');
}

然后 PHPStorm 知道要查找哪个 class。