Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can you get eclipse code complete for CI when using &get_instance()?

I'm currently using Eclipse PDT and CodeIgniter, is it possible to get code-completion for the sessions library like so:

$CI = &get_instance();
$CI->session->se   (No auto-completion here.)

Also, is there some sort of plug-in (or just a method) that would allow eclipse to do this for all my CodeIgniter libraries.

Note: I already have support in most contexts courtesy of this tutorial, however I am looking specifically for when I am using a variable to reference CodeIgniter instead of

$this->

Thanks,

Lemiant

like image 727
lemiant Avatar asked Nov 06 '22 09:11

lemiant


1 Answers

Since there seems to be a reasonable amount of interest in this; I thought I'd share my solution to this problem. Using the method from this tutorial I mentioned above, you can use PHPDoc to tell the compiler that a variable is a reference to some object in your project. In this case I want $CI to reference the CI_Base object. so I declare my variable like this:

/**
 * @var CI_Base
 */
private $CI;

and voila, I have code complete (NOTE: you have to use the tutorial above to get code complete from $this->CI-> to anything else.)

Hope this helps somebody,

Lemiant

like image 192
lemiant Avatar answered Nov 09 '22 08:11

lemiant