NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
[resolved] Intellisense


Joined: 18 May 2007
Posts: 11
Reply with quote
I have created a template engine similar to the Zend Framework MVC (mostly the views), where I have a class similar to:
Code:

class foo
{
   private $bar;
   ...
     some __set(), etc
   ...
   function getView($file)
   {
     include($file); 
   }
}


Now, when we include the file in the getView function, it will have the same variable scope of the class for variables, so inside of $file we can access the variables from the class, ie: $this->bar. But inside of $file, the intellisense doesn't pickup $this->bar, like it would if we referenced it inside that class declaration file.

Now, I understand PHPEd probably won't, on its own, understand that $file will be part of class foo, but is there a way for me to instruct it so I can get the intellisense on those class vars?

Thanks!
View user's profileFind all posts by hergy80Send private message
Site Admin

Joined: 13 Jul 2003
Posts: 8202
Reply with quote
Quote:
so inside of $file we can access the variables from the class

You can't access properties of the class this way.

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


Joined: 18 May 2007
Posts: 11
Reply with quote
Sure you can. When you include a file, you get the scope of the parent (except for functions, they become global).

So inside $file, you can reach the class var $bar by using $this->bar.

Code:

When a file is included, the code it contains inherits the variable scope of the line on which the include occurs. Any variables available at that line in the calling file will be available within the called file, from that point forward. However, all functions and classes defined in the included file have the global scope.

http://us3.php.net/manual/en/function.include.php


If you need, I can privately send you my class (sorry I cannot post it). It works fine, just my intellisense isn't there, which is a bummer..
View user's profileFind all posts by hergy80Send private message
Site Admin

Joined: 13 Jul 2003
Posts: 8202
Reply with quote
heh Smile

try the following in the included file:

Code:
<?php
    /** @var foo */
    $this->



it will cause intellisense to treat $this as an instance of foo class.

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


Joined: 18 May 2007
Posts: 11
Reply with quote
Ahh man.. you rock!! I hated having to open a file to see a var's properties Smile

Thanks!
View user's profileFind all posts by hergy80Send private message
[resolved] Intellisense
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