NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
objects inside functions not identified
Veteran

Joined: 30 Aug 2006
Posts: 116
Reply with quote
I'm wondering about some situations involving code completion and objects being passed to functions. Basically objects passed to functions are not recognized inside teh functions.

In the following code where a db object is instantiated outside of a function, and then passed to the function, code completion will NOT work within the function.

Code:
function test_object($db) {
   $db->readdb->
}

$db = new db();
echo test_object($db);



In the above example if you try to use code completion it says

"Code completion is not available due to the following error(s):
Failed to identify type of "$db" local variable"

However, if you globalize $db inside the test_object function, then code completion works perfectly.
View user's profileFind all posts by rudderSend private message
Veteran

Joined: 24 Jan 2006
Posts: 311
Reply with quote
I beleive your question might be answered in this FAQ:
http://forum.nusphere.com/tip-type-hints-t1563.html
Please take a look and see if it is what you are asking about. Thanks!
View user's profileFind all posts by yfaktorSend private message
Veteran

Joined: 30 Aug 2006
Posts: 116
Reply with quote
Thank you yfaktor.

The FAQ helps alot and solved my initial question. But I wonder about something else.

It seems to me like objects instantiated as stdClass() do not work with Code Insight at all.

eg:

Code:


$obj = new stdClass();
$obj->staff = 'test';


$obj->


Even if we use the tips provided in the FAQ and declare the class as stdClass
View user's profileFind all posts by rudderSend private message
Veteran

Joined: 24 Jan 2006
Posts: 311
Reply with quote
The reason that code completion
doesn't work for stdClassclass that stdClass is built-in PHP class and not
available/declared anywhere. As you may have guessed code completion works
by parsing the PHP files specified in the include path of your Project
(includes tab in Project properties).
We also support PHP built in functions of course for completion, there is a
tab called functions, which is based on the latest PHP.
View user's profileFind all posts by yfaktorSend private message
objects inside functions not identified
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