NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Multilevel code completion.
Veteran

Joined: 30 Nov 2006
Posts: 186
Reply with quote
If I have a class

Class A
{

function setQuery()
{}

function returnClass()
{
return new A();
}

}

And a class that extends from Class B

Class B extends A
{
}

Then create an instance of Class B

$b = new b();

Then it is possible to do code completion for the first level.

$b->setQuery() That works

But if I call returnClass that returns an instance of another class (in this example it is just an instance of class A) then it should be possible to write a statement like :

$b->getClass()->setQuery()

Because getClass() returns an instance of class A and that holds a function setQuery()

But that is not possible. There is only support for first level code completion, and no second level.

If I write $b->getClass()-> and press CTRL SPACE I get an error message telling me that it does know my type but are unable to do code completion.

This is possible in IDE's like visual studio etc. I could really use something like this.



$b->setQuery
View user's profileFind all posts by hgrSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8351
Reply with quote
You're not right. Nested calls are perfectly well supported by PhpED.
If returning class is not recognized, you may specify it using TYPE HINTS, see it explained on FAQ forum.

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

Joined: 30 Nov 2006
Posts: 186
Reply with quote
Well that is just great.

I will have to find out about the TYPE HINT then.
View user's profileFind all posts by hgrSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8351
Reply with quote
With your example you're calling $b->getClass() which is not defined, neither in class A nor in class B.
In this case Code Completion says:
"Code Completion is not available due to the following error(s):"
"Failed to find "B::getClass()" method"

Hope it's clear.

If you try returnClass() instead of getClass(), you'd get code completion like shown below:


Please note, that such calls are supported for PHP5 only. In php4 they give syntax error (php does not support such syntax, PhpED has nothing to do with this).

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
Multilevel code completion.
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