I have a basic singleton class, similar to the one shown in the PHP documentation:
// Based on Example from
// us2.php.net/manual/en/language.oop5.patterns.php#language.oop5.patterns.singleton
class Example {
private static $instance;
private function __construct()
{
echo 'I am constructed';
}
public static function singleton()
{
if (!isset(self::$instance)) {
$c = __CLASS__;
self::$instance = new $c;
}
return self::$instance;
}
public function myMethod() {
return 'This is my method';
}
}
The code I write to get an instance of this class is:
$myExample = Example::singleton();
Using PDT, if I try to use its word completion to find the method myMethod in this instance, it fails. That is, if I type the following in the editor:
And immediately after the "->", I press the key combination for word completion (ctrl-space on my computer), Eclipse tells me "No Default Proposals".
How can I make word completion work? Do I need to configure Eclipse differently? Do I need to write my singleton a different way?
[Updated on: Wed, 11 May 2011 14:17] by Moderator