CodeIgniter Forums
Code completion suggestion - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forum-6.html)
+--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forum-17.html)
+--- Thread: Code completion suggestion (/thread-66692.html)

Pages: 1 2


Code completion suggestion - AmitMY - 11-22-2016

Because CI uses dynamic class members for every loaded thing
PHP Code:
foreach (is_loaded() as $var => $class)
{
    
$this->$var =& load_class($class);


IDEA like PHPStorm have difficulty with code completion, and shows many many warnings, for stuff like "$this->db"

There is an open YouTrack feature request for over 6 years, which testifies how difficault it is to interperate what is and what is not a member of the classes CI_Controller and CI_Model.

The current fix people that use PHPStorm are using, is this. A code completion helper, that adds "properties" to above classes, and makes life coding with CI much more pleasant.

Now, I know it is not technically correct to add those as properties, because they are extremely dynamic, but I think that the CC helpers adds the essentials, that are by default loaded, so I think adding those to the core codebase would be helping, even though not fully correct.


What do you think?
Do you have a better solution for the given problem?


RE: Code completion suggestion - Narf - 11-22-2016

This is not our problem really ...

While it's nice for your tools to work as best as possible, it is the IDE vendor's job to make that work and not ours. Even if it's as easy and harmless as adding docblock comments, we've got enough on our hands already.
Plus, JetBrains (the company behind phpStorm) sell a product (we don't), so they have a monetary incentive to make it work one way or another.


RE: Code completion suggestion - AmitMY - 11-22-2016

(11-22-2016, 06:16 AM)Narf Wrote: This is not our problem really ...

While it's nice for your tools to work as best as possible, it is the IDE vendor's job to make that work and not ours. Even if it's as easy and harmless as adding docblock comments, we've got enough on our hands already.
Plus, JetBrains (the company behind phpStorm) sell a product (we don't), so they have a monetary incentive to make it work one way or another.

Of course, I understand that.
However, the "problem" is not only with JetBrains products. If something like this was built into CI, it would work in all IDEs, while if JetBrains somehow implements it, it will work specifically on their IDE products.

Myself, I have found a solution that works - download the CC helpers every time I use a new version of CI, but not everyone are aware of it, or like to do it this way.

Thanks anyway.


RE: Code completion suggestion - InsiteFX - 11-22-2016

It is suppose to be in the next version of phpStorm.


RE: Code completion suggestion - AmitMY - 11-22-2016

(11-22-2016, 07:17 AM)InsiteFX Wrote: It is suppose to be in the next version of phpStorm.

I was not aware. It is still tagged "Backlog"

Thanks!


RE: Code completion suggestion - InsiteFX - 11-22-2016

PHPSTORM 2016.3 PREVIEW


RE: Code completion suggestion - cartalot - 11-22-2016

yeah i was excited about that announcement from phpstorm but i've tried it and its not doing anything. maybe it only works on certain platforms.

anyway - OP - here's a link to what i use - read the instructions carefully and use this file as application/config/autocomplete.php and your database methods $this->db-> will autocomplete and show you all the options. it will show you ALL the codeigniter code for autocomplete. this is very similar but every other solution i've seen has a bunch of other b.s. you have to do - with this you just drop the file in the folder and it works. the only thing i have not tried to do is find a method for automatically getting the model names, thats why the example file lists some sample model names to make that clear.
http://forum.codeigniter.com/thread-63641-post-325791.html#pid325791


RE: Code completion suggestion - AmitMY - 11-23-2016

(11-22-2016, 11:43 AM)cartalot Wrote: yeah i was excited about that announcement from phpstorm but i've tried it and its not doing anything. maybe it only works on certain platforms.

anyway - OP - here's a link to what i use - read the instructions carefully and use this file as application/config/autocomplete.php and your database methods $this->db-> will autocomplete and show you all the options. it will show you ALL the codeigniter code for autocomplete. this is very similar but every other solution i've seen has a bunch of other b.s. you have to do - with this you just drop the file in the folder and it works. the only thing i have not tried to do is find a method for automatically getting the model names, thats why the example file lists some sample model names to make that clear.
http://forum.codeigniter.com/thread-63641-post-325791.html#pid325791

The current thing I use works just fine, thank you.
My request is not for me, it is for it to work in all editors, not with tricks.


RE: Code completion suggestion - Narf - 11-23-2016

(11-22-2016, 06:48 AM)AmitMY Wrote:
(11-22-2016, 06:16 AM)Narf Wrote: This is not our problem really ...

While it's nice for your tools to work as best as possible, it is the IDE vendor's job to make that work and not ours. Even if it's as easy and harmless as adding docblock comments, we've got enough on our hands already.
Plus, JetBrains (the company behind phpStorm) sell a product (we don't), so they have a monetary incentive to make it work one way or another.

Of course, I understand that.
However, the "problem" is not only with JetBrains products. If something like this was built into CI, it would work in all IDEs, while if JetBrains somehow implements it, it will work specifically on their IDE products.

Myself, I have found a solution that works - download the CC helpers every time I use a new version of CI, but not everyone are aware of it, or like to do it this way.

Thanks anyway.

I didn't say the issue is limited to JetBrains' phpStorm.
That I ended with a note about them having monetary incentive was an extra thought, not my entire argument - don't focus on that just because it's easy to attack it in isolation.

To reiterate my main point - tools are made to help us deal with stuff, not the other way around. In this case, the tools are the IDEs and the stuff is our framework. I have always stood by this principle and always will.


RE: Code completion suggestion - sneakyimp - 11-30-2016

Question for Narf: What IDE to you use when developing in CodeIgniter? Does it offer any autocompletion?