在一个遗留项目中,当我试图在phpstorm中找到一个方法的用法时,我很困惑,但没有成功。
/**
* @param SomeEntity[] $someEntity
*
* @return bool
*/
protected function warmupSomeEntity(array $brandUniverses)
{
// I want to find this method's usage
}
进一步调试后,我发现该方法是通过动态类方法调用以一种相当抽象的方式动态调用的:
/**
* @param string $warmer
* @param array $objects
*
* @throws RuntimeException
*/
public function warmupType($warmer, array $objects)
{
$method = "warmup$warmer";
if (method_exists($this, $
$this->{$method}($objects);
} else {
throw new RuntimeException("There is no warmer '$warmer'");
}
}
有没有phpdoc语法可以记录warmUpType
方法将调用warmupSomeEntity
或warmupSomeOtherEntity
,这样如果我想再次跳转到调用代码块,我就可以再次找到它的用法?
@uses关键字是我想要的:
显示一个元素文档的链接,并在另一个元素的文档中创建到此的反向链接
它得到了PhpStorm的支持,并且再次找到了调用者。
/**
* @param string $warmer
* @param array $objects
* @uses warmupSomeEntity
* @uses warmupSomeOtherEntity
* @throws RuntimeException
*/
public function warmupType($warmer, array $objects)
{
...
}