Reputation: 344
Is there a way to make Eclipse give code hints to variables created from objects? For example if I create a new variable:
$db = new mysqli('server', 'user', 'pwd', 'database');
then $db->
brings up code hints, but if I do:
$query = 'Select * From thisTable';
$result = $db->query($query);
but then if I use:
$result->
I do not get any code hints.. I'm pretty new to Eclipse and PHP. I have searched around but could not find anything related to this. I did notice while trying out the new version of Dreamweaver CS5.5 it does do code hinting for the above scenario.
Upvotes: 0
Views: 592
Reputation: 3838
Most PHP IDEs rely (mainly) on the PHPDoc when computing the code assist suggestions. This is quite a must for dynamic languages such as PHP, since the type-binding is very 'flexible'.
You may hit some limitations in the IDE capability to assist you in some cases (such as the case you defined). In these cases, some IDE's provide mechanisms to specifically the variable type. In your case, the returned type is 'mixed' (see php.net), so you have to define what it is.
It might be hard to find out in this specific case, but in general, this is how you hint the IDE with a variable type.
In PDT:
$a = callSomeFunction();
/* @var $a PDO */
$a -> // will give you the PDO code assist for $a
Other IDEs also have similar capabilities.
Upvotes: 2