Make PHP Storm Aware of Singleton Classes

删除回忆录丶 提交于 2020-01-04 09:35:29

问题


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();

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.


回答1:


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
*/


来源:https://stackoverflow.com/questions/26478638/make-php-storm-aware-of-singleton-classes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!