使PHP Storm意识到Singleton类 [英] Make PHP Storm Aware of Singleton Classes

查看:83
本文介绍了使PHP Storm意识到Singleton类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一段类似下面的代码,它工作得很好,但是PHP Storm没有显示代码完成,并且我无法按住CTRL键并单击以打开该方法.有没有一种方法可以使PHP迅速了解该方法的位置,以便更快地打开它?

I have a piece of code like below and it works perfectly fine but PHP Storm doesn't show code completion and I am unable to CTRL+click to open the method. Is there a way to make PHP storm aware of the method's location for quicker opening?

$data= MyCoolBusinessManager::Instance()->GetSomeData();

仅供参考,由于类遵循标准命名格式,因此我还使用了spl_autoload_register()函数,而不是使用所有位置.

Just an FYI, I am also making use of the spl_autoload_register() function instead of having includes all over the place since my classes follow a standard naming format.

推荐答案

您需要在单例中的Instance()函数上添加一个PHPDoc注释,即您的单例函数返回该类的类型:

You need to put a PHPDoc comment on the Instance() function in your singleton, that says your singleton function return a type of that class:

/**
* @return MyCoolBusinessManager
*/

这篇关于使PHP Storm意识到Singleton类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆