netbeans autocompletion when using singleton to retrieve object instead of new operator?
Posted
by fayer
on Stack Overflow
See other posts from Stack Overflow
or by fayer
Published on 2010-05-09T05:35:00Z
Indexed on
2010/05/09
5:38 UTC
Read the original article
Hit count: 230
when i use the 'new' operator to instantiate a class, netbeans has no problem to autocomplete the members of the object.
$instance = new Singleton();
$instance-> // shows test() method
but when i use a singleton to retrieve an object it cannot autocomplete the members in the object retrieved.
the getInstance code looks like this:
public function test() {
echo "hello";
}
public static function getInstance() {
if ( ! is_object(self::$_instance)) {
self::$_instance = new self();
self::$_instance->initialize();
}
return self::$_instance;
}
so i use:
$instance = Singleton::getInstance();
$instance-> // no autocompletion!
does anyone have the same problem?
how do i work around it?
thanks!
© Stack Overflow or respective owner