Multiple Declarations and Kohana

I'm testing PHPStorm with a project that uses Kohana3.   
In Kohana you have some feature called "transparent extension" which uses a Cascade File System to extend any class on the system or modules very easily and without breaking anything.   
But if you do that, then you will have two classes with the same name (that's why is called transparent extension).   
And PHPStorm gets confused by that, I'm getting this warning:  

Multiple Declarations: this version of IDE will have problems with completion member resolution and inheritance anallysis for all classes that have multiple definitions in project files (regardles of includes)

Is possible to solve that? or at least help a bit to PHPStorm to find the right class?

This is a huge problem when working on projects with Kohana, Zend Studio for example, even in the version 7, finds it correctly.

Thanks !

13 comments

Hi Enrique,

No -- It cannot be solved with a single click -- check this ticket: WI-2760

Yes -- you should be able to fix this by locating 2nd file for the same class in Project View panel, right click on it and choose "Mark as plain text" -- this will treat that particular file as plain text and therefore will ignore any PHP code in it. It's inconvenient, you will need to do this for every new standard class that you will override in this manner, but at least it is possible (well -- as I have mentioned on the beginning -- it should work like that as I have not tried this on Kohana framework myself).

0

wow, that's really disappointing :( , I think PHPStorm has many features much better than Zend Studio, but I this only bug is enough for letting it outside.    
I can't understand how this fix was requested from version 1.x and now the team says even in 3.0.x is impossible to solve.   
I think you really don't understand how important it is when you are working with a Framework like Kohana,Yii, Cake and many others.
And the fix is so easy !
just mix the two declarations (that's better than nothing at least!) or let the user define a folder or regular expression for helping phpstorm to decide what definitions it should use.   

Is possible to develop a custom plugin at least for this?

0

Do you really believe that if this would be a 1 hour job to fix devs would postpone it for such a long time especially if it affects so many frameworks and people who are using them???

As far as I'm aware it's a architecture limitation (the whole IDEA platform) where you can have 1 uniquely named entity (class) per project (the way how code completion, code analyzing stuff works or whatever other reason). I can be wrong here .. but AFAIK other products/languiages have no such issue, only PHP/PhpStorm.

0

what I'm saying is that maybe solving it "right" could be difficult, but making a rude "patch" or temporal even ugly fix would be enough !
For example, just make a plugin for setting automatically "plain text" on duplicated classes that are inside a specific (and customizable) folder, etc etc.
I can't see how can that be so difficult for people who developed the IDE.
But If the team has some reason for not doing even a temporal fix, do you know if it's possible to develop custom plugins for PHPStorm? maybe I can make my own ugly fix.

0

Doubt it -- there is no public documentation (for PHP parser/implementation) available and no certain or even approx date given when it will be made available. Therefore I do not think that it is possible to do such plugin ATM (so far I have not seen ANY php-specific 3rd party plugin available).

0

mmm... is not possible to make a plugin that sets a file as plain text?
or, where is saving PHPStorm the info that marks a file as plain text? maybe a XML file or something like that?

0

mmm... is not possible to make a plugin that sets a file as plain text?
or, where is saving PHPStorm the info that marks a file as plain text? maybe a XML file or something like that?

Please explain what you want to achieve here .. and why my suggestion is not good?

0

These are my fallback of options:  

1) Make a plugin which automatically detects duplicated classes and then automatically set one of them as plain text (the rules for choosing what class should set as plain text is very easy with Kohana).  
Also, for this I don't need any PHP parser, I need only:
a) detect when a file is created, deleted or renamed
b) check the existence of a file
c) change to plain text any file
If we can do that, then we can make the plugin.

2) The same idea from above, but not as a plugin, as a standalone application, running as some type of deamon, controlling when a file is created. For this I need to know how PHPStorm saves the "plain text" on the project (for example if it's an XML maybe I can edit that XML with an external app).


3) Make a button for setting as Plain Text a file opened in the editor (or an option for that when we right click the tab), so at least we don't need to open and search the the file on the explorer and right click on it for marking as plain text

What do you think? is possible some of those?

0

I'm not JB dev -- cannot advise any further on this.

Let's hope that this ticket will actually be fixed in v4.0 (first EAP build should be available within a week or two) and it will be done in one of those first builds (I really hope for this).

In mean time -- you may proceed with your idea.

List of files marked as Plain Text is IDE-wide (unfortunately -- see WI-9630 ) and should be loaded on startup only. The file is located in IDE config folder: on Windows 7 it will be C:\Users\USERNAME\.WebIde10\config\options\plainTextFiles.xml

P.S.
I do not think that external app will work here ... as from my observations IDE does not reload config files if they were modified outside.

0

ah, OK, they are making it hard intentionally then :p
We can't share the plain text config with VCS, we can't change it from outside the IDE neither.  

I'm really surprised for the first, why they putted the plain text config outside the project folder? that doesn't make any sense to me ?:|
mmm.. maybe for getting the config for global libraries outside the project folder...
but then we should be able to use a local plainTextFiles.xml as well

I hope someone from the team can tell me if it's possible to set as plain text a file with a plugin.   

Do you know if ther's a shortcut or something for setting the current file (opened in the editor) as plain text?

0

if it's possible to set as plain text a file with a plugin.

If this functionality is available in IntelliJ IDEA Community Edition, then I'm pretty sure that you can invoke such action in your plugin.

0
If this functionality is available in IntelliJ IDEA Community Edition, then I'm pretty sure that you can invoke such action in your plugin.

I'm searching for it right now, but I'm completely new on IDEA's plugin development, it would be much easier and faster if someone of the team can give me some help / link.

0

Good News !!!! :)
We can set a keymap (shortcut) for mark as plain text
and you can use it on the current file (editor tab), and it works !
So at least we can set as plain text faster now, because Go to Declaration works with Multiple Declarations too.

Also, I found this at SO:
http://stackoverflow.com/questions/6573364/how-to-detect-file-changes-in-intellij-idea
now we need to know how to set as plain text a custom file, or how to force a reload of .WebIde10\config\options\plainTextFiles.xml

0

Please sign in to leave a comment.