NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Code completion request (objects in $GLOBALS)


Joined: 02 Apr 2007
Posts: 7
Location: San Francisco, CA
Reply with quote
Hey there!

This is a request for something I run across a lot... Code completion doesn't work for objects in $GLOBALS.

I often have a globally declared object with some methods. For example:
Code:

class SampleClass {
   public function something() {
      return true;
   }
}

$aninstance = new SampleClass();

function samplefunction() {
     $GLOBALS['aninstance']->something();   // <-- Code completion won't recognize $GLOBALS['instance'] as
                                            //       an instance of SampleClass and offer to complete
                                            //       something()
}


It would be awesome if PhpED could recognize object instances in arrays (or $GLOBALS at the very least) for code completion purposes.
View user's profileFind all posts by tabaccoSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
try this:
Code:
class SampleClass {
   public function something() {
      return true;
   }
}

$aninstance = new SampleClass();

function samplefunction() {
     global $aninstance;
     $aninstance->something();   // <-- Code completion will recognize $aninstance as
                                            //       an instance of SampleClass and offer to complete
                                            //       something()
}

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 02 Apr 2007
Posts: 7
Location: San Francisco, CA
Reply with quote
Oh I know that works, but I hate to add the extra global declarations in when I don't have to. It makes my function libraries a lot less readable.
View user's profileFind all posts by tabaccoSend private message
Code completion request (objects in $GLOBALS)
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic