大佬教程收集整理的这篇文章主要介绍了php – 使用singleton检索对象而不是new运算符时netbeans自动完成?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
$instance = new Singleton(); $instance-> // shows test() method
但是当我使用单例来检索对象时,它无法自动完成检索对象中的成员.
public function test() { echo "Hello"; } public static function geTinstance() { if ( ! is_object(self::$_instancE)) { self::$_instance = new self(); self::$_instance->initialize(); } return self::$_instance; }
所以我使用:
$instance = Singleton::geTinstance(); $instance-> // no autocompletion!
有没有人有同样的问题?
我该如何解决这个问题?
谢谢!
/* @var $instance Singleton */ $instance = Singleton::geTinstance();
你会得到自动完成:
http://extern.pascal-martin.fr/so/question-2796730-netbeans.png
(最近每晚建立的netbeans测试)
另一种解决方案是在geTinstance()方法的声明中添加一个docblock,以指示它返回Singleton类的实例:
/** * @return Singleton */ public static function geTinstance() { }
http://extern.pascal-martin.fr/so/question-2796730-netbeans-2.png
以上是大佬教程为你收集整理的php – 使用singleton检索对象而不是new运算符时netbeans自动完成?全部内容,希望文章能够帮你解决php – 使用singleton检索对象而不是new运算符时netbeans自动完成?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。