Code hint question (codeinsight to include specific files) |
Veteran
|
Ok I have tried to include the directory that holds the language files in the project property settings.
But that did not make code insight work on these language variables. I have looked in the explorer, and I can find the variables there, so PHPed knows about their existence, but it does not show them on the code insight lookup. ??? |
||||||||||||
|
Veteran
|
Ok I don't understand this.
The language files used to be english.php DEFINE('LANGUAGE_HOUSE','House'); danish.php DEFINE('LANGUAGE_HOUSE','Hus'); And when I used DEFINES the code completion worked. Now I have changed it to variables instead of defines, and now code completion does not work??? The files now look like this. english.php $LANGUAGE_HOUSE = 'House'; danish.php $LANGUAGE_HOUSE = 'Hus'; And I honestly don't understand why code completion worked when it was DEFINE's and now that it is variables it does not? If I create a new file, the code completion works fine. Even with the new variables. But in one specific file it does not work on these variables. Normally this can be because of a syntax error, but the rest of code completion works, just not these variables. I am still able to code complete on the rest of the code, just not these variables. ?? |
||||||||||||
|
Veteran
|
Ok I think this is a standard feature / Annoyance or bug.
Code completion works if I access the variables outside a class. Look at the first image. I know that the names are not the once that I wrote in my previous post, but anyhow. Notice that the $BIZ_* variables are visible in code completion outside an class But the second I use it inside a class it stops working. In some silly way it makes sense, because the variable is not declared GLOBAL so they are treated like local variables, so in other words they do not have scope inside a class, but the trouble is that if this is the reason, they notice the include("c:/blalbal"); on the line above, that will include the variables, and that gives them scope inside the class so it should work. These are my settings. I noticed that only Global variables, DEFINES and local variables has a setting and so it works. Which is great because you do not want code completion to display too much. But it also makes it impossible to include a file with variables inside a class and still have code completion working. So I think its an annoyance in PHPed, and I am back to my initial post. Is there a way that I can force PHPed to include specific files so code completion can work inside classes, on variables defined in external files but included by code??? I really hope there is some sort of code hint, cause I use these language files alot, everything has to be I18N. Hope to hear from you soon, cause I am unable to solve it. |
||||||||||||
|
Site Admin
|
correct. When PhpED parses a file, it does not know how this file is used in the project. Generally speaking it can be included in a global context, in a function, in a class method, or not included at all. First and last cases are the most common and they make global all the variables out of functions/methods. Hence, we made a decision to consider all the variables out of the functions and methods as global and once they are considered global, Code Insight won't show them until you add global keyword and list all the names. It works just like you include the language file out of the method in your sample. |
||||||||||||||
_________________ The PHP IDE team |
Veteran
|
Hi Dmitri.
Is there some way to solve this, some other way than to use global variables to get code insight to show the variables. Like the "Code Insight Includes" in the property settings? I use this feature to get PDO code completion to work, so I thought that If I add the directory where my language files where kept, it would always include the files in that directory as well, but it does not. Actually I do not know if there is a bug in there, because I am not able to add more than one folder to the "Code Insight Includes" field. If I add additional directories, it just ignore them when the Project properties window is closed. See the attached images. 1. I open the project properties. 2. I add the folder where my language files are kept. 3. The project properties before it is saved. It shows the new folder as added to the code insight. 4. I reopen the project properties to find that the added folder is not saved. I hope it can be possible to use this feature to get the code insight to work like I need it. |
||||||||||||
|
Site Admin
|
I'd tell you so. No, there is no way. Sorry if I did not make it clear. Once again, as of PhpED version 5.2: if you have variables in the global scope of a script, code insight has no clue that they may be local in some functions. |
||||||||||||||
_________________ The PHP IDE team |
Veteran
|
Hi Dmitri, what about my comments regarding the "code insight includes" is that not a possible way? and Have I discovered a bug there?
Not to piss you off, I understand the word (NO WAY ) I am only trying to find a way of working effective with localized php development, without using global variables, or constants like DEFINE, in the interest, of saving memory on the server. |
||||||||||||
|
Site Admin
|
DEFINE takes exactly the same amount of memory as a regular variable.
Regarding code insight includes, I can't reproduce any problems. Make sure that all the directories you added exist. |
||||||||||||
_________________ The PHP IDE team |
Veteran
|
Ok.
So if I could get the "code insight Includes" to include more directories, then it will work? I don't understand why it does not work. I am not writing the paths by hand, but are using the GUI tools in PHPed to include the folder? And Yes, Defines take up the exact number of bytes. However, Defines will stay in memory, while the variables will be removed from memory when your class gets garbage collected. I used to use DEFINE, but what is the point in having constants in memory that are not used. So I decided to create files with variables and then include the files in the classes where they are used. But this has the cost that I can't use code insight, which is a shame, because if I write the variables wrongly, PHP will just create a local empty variable. So it gets harder to find my mistakes, because there is no runtime error. It is strange that there is no "best practice" when it comes to i18n in PHP. PHP does not have any real build in support of creating multi language scripts, and because of this, there is no great support for it in any development environment. Strange that this is such an uncommon problem in PHP. |
||||||||||||
|
Site Admin
|
I did not notice any problems when checked this functionality. Please check if project file <project name>.ppj is not readonly.
if you need the messages defined only during class instance life-time, why don't you use class constants then?
Including a file in a function or method is a bit quirky. Global variables appear local, global functions stay global, etc.
I'd just point to gettext php extension. All magic happens inside _() function call and it works quite fast:
(certainly you have to prepare translation files with gettext tools) |
||||||||||||||||||||||
_________________ The PHP IDE team |
Code hint question (codeinsight to include specific files) |
|
||
Content © NuSphere Corp., PHP IDE team
Powered by phpBB © phpBB Group, Design by phpBBStyles.com | Styles Database.
Powered by
Powered by phpBB © phpBB Group, Design by phpBBStyles.com | Styles Database.
Powered by