a comment after variable declaration specifiying the type |
|
I thought a lot about the problems of code insight and syntax highlighting when it comes to objects. The way I see it there are basicly two options: The user helps PHPEd to determine the class of a certain variable/property, or PHPEd tries to semi-evaluate the code itself to determine the class.
Both options are very problematic. I think the problems with semi-evaluation are obvious (includes, conditions, startup values/arguments, etc). When it comes to the user helping out, it's also a bit of a problem. First off I don't think "extending" the language is a good idea if it's not done in coordination with other extensions, which might prove to be somewhat of a hassle for nusphere. Second, it also creates a bit of a hassle for the user himself. You need to remember to update your comment hints if you change you code, you need to declare these variables, eventough one of PHP's advantages is not needing to do so. And you need to repeat this for every scope of code. Consider the number of times you are using the same variable in a given block of code, and you realize that that number is close to 1 - if you are capsulating your code correctly. Even if it's 2, for the code insight you need to setup the comment and maintain it in every such block of code, for two usages of it. The time and effort invested might be better off used to simply lookup the method's declaration... A feature I do like in visual C for example, is the ability to right click on a function, and choose "go to defenition of", BTW, but even in visual C that requires you to compile the code first, and that's a language where everything is declared beforehand anyway. I think the best example of always-available code insight is visual basic. but you have to keep in mind that in visual basic the interpreter is constantly working, evaluating the code as you type it, and still you need to declare the types of your variables (eventough it's not really neccessary for the language - you can always resort to using variants. It's basicly there for code insight I think) - A course of action that might not be quite available for nusphere, with all the tweakability of PHP, even if using an external PHP executable. The user would need to make sure his php.exe and php.ini are correct, and even then you have the problem of editing an include file, conditions, and startup variables. Still, it would contribute a whole lot to PHPEd if we did manage to define a way of doing this. That would really put the "I" in "IDE" here... |
||||||||||||
|
Site Admin
|
PHPED v4 supports the following syntax for defining a variable or a property type:
PROPERTIES:
ARGUMENTS:
VARIABLE:
|
||||||||||||||||||
|
|
So PHPEd uses PHPDoc's comments ?
|
||||||||||||
|
Site Admin
|
why not ?
|
||||||||||||
|
|
Using phpdoc comment's solves the first issue in a clean manner. As to the second - consider it as an incentive for your developers . Write phpdoc comments, keep them up-to-date, and you get the benefit of a better code completion . Unfortunately, there's no better way to do it, as PHP is weakly typed (OK, PHP5 introduces type hints). |
||||||||||||||||
|
|
That's very good, I wasn't aware of that. I was thinking of starting to use PHPDoc, so now it's obvious I will. |
||||||||||||||
|
a comment after variable declaration specifiying the type |
|
||
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