Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » PHP Development Tools (PDT) » PDT word completion fails with PHP singleton(PDT word completion fails to find methods of a PHP singleton instance.)
icon5.gif  PDT word completion fails with PHP singleton [message #669834] Wed, 11 May 2011 18:09 Go to next message
Lance E Sloan is currently offline Lance E SloanFriend
Messages: 7
Registered: July 2009
Junior Member
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:
$myExample->

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 18:17]

Report message to a moderator

Re: PDT word completion fails with PHP singleton [message #670306 is a reply to message #669834] Fri, 13 May 2011 13:22 Go to previous message
Lance E Sloan is currently offline Lance E SloanFriend
Messages: 7
Registered: July 2009
Junior Member
I received an answer to this problem by posting to stackoverflow.com. See:

stackoverflow.com/questions/5982323/eclipse-pdt-word-complet ion-fails-for-php-singleton-instances#

stackoverflow.com appears to be a more active and knowledgeable forum for Eclipse discussions than the Eclipse forum is. (And it doesn't have the limitation of posting five messages before I can use actual links in my messages.)
Previous Topic:[Solved] Spell checking isn't working
Next Topic:Saving .sql always opens Save As
Goto Forum:
  


Current Time: Thu Mar 28 08:18:10 GMT 2024

Powered by FUDForum. Page generated in 0.03357 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top