keyword highlighting
keyword highlighting
There is a question about the advisability of using keywords as variable names. I did stumble onto this when I had an $old value and then an updated, $new value.
Lou
Say what you will about Sisyphus. He always has work.
Say what you will about Sisyphus. He always has work.
- Albert Wiersch
- Site Admin
- Posts: 3824
- Joined: Sat Dec 11, 2004 9:23 am
- Location: Near Dallas, TX
- Contact:
Re: keyword highlighting
I'd advise against this.
I assume you have PHP installed and checking PHP syntax with CSS HTML Validator?
It may be worth looking at the options PHP provides in the syntax check. Do you want to be warned or notified of using keywords as variable names? If so, then that would need to be something PHP's syntax checker would need to support, not CSS HTML Validator.
When CSS HTML Validator calls PHP to syntax check only (lint), it uses "-l -d display_errors=on".
Unfortunately I don't know how to get PHP to also output warnings or suggestions that might aid in development. There is an error_reporting option that might be useful. I'll investigate and update this post later if I find that it is.
I assume you have PHP installed and checking PHP syntax with CSS HTML Validator?
It may be worth looking at the options PHP provides in the syntax check. Do you want to be warned or notified of using keywords as variable names? If so, then that would need to be something PHP's syntax checker would need to support, not CSS HTML Validator.
When CSS HTML Validator calls PHP to syntax check only (lint), it uses "-l -d display_errors=on".
Unfortunately I don't know how to get PHP to also output warnings or suggestions that might aid in development. There is an error_reporting option that might be useful. I'll investigate and update this post later if I find that it is.
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
Re: keyword highlighting
Sorry Albert, yes I have XAMPP (8.2.12) Apache installed locally to process the php and am using CSS HTML Validator (23.0400) for editing and syntax checking of the php and resulting html.
Everything works fine. I see no restrictions preventing the use of keywords as a variable name, starting with a $ of course as in my examples.
A warning or suggestion maybe ~ as a matter of style maybe. My real point was that the variable name need not (should not) be highlighted as if it was a keyword.
Everything works fine. I see no restrictions preventing the use of keywords as a variable name, starting with a $ of course as in my examples.
A warning or suggestion maybe ~ as a matter of style maybe. My real point was that the variable name need not (should not) be highlighted as if it was a keyword.
Lou
Say what you will about Sisyphus. He always has work.
Say what you will about Sisyphus. He always has work.
- Albert Wiersch
- Site Admin
- Posts: 3824
- Joined: Sat Dec 11, 2004 9:23 am
- Location: Near Dallas, TX
- Contact:
Re: keyword highlighting
Ahhh! Gotcha.
Yes, that makes sense... however, I let the editor component manage the highlighting and I am not sure this would be an easy change or not without its side-effects. Also, it might be good to highlight the keywords like that to make people aware that they are using a keyword for a variable name when it's probably not a good idea to do so.
It would be nice if the PHP linter would warn about this or generate a message about it but unfortunately I do not see any option for it to generate such messages.
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
Re: keyword highlighting
Agree really down in the weeds. Just playing around with it I notice that the editor handles things like $new_foobar or $foo_new without highlights. But as you suggest depending on how the editor strips the '$' off the variable name and then handle the remainder of the token, other (more important) features could be lost.
Been using your tool for years. Don't know how you manage to control price creep and glad for it!
Been using your tool for years. Don't know how you manage to control price creep and glad for it!
Lou
Say what you will about Sisyphus. He always has work.
Say what you will about Sisyphus. He always has work.