PHP 7.x added new keywords and language constructs. Some old keywords were also missing. You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany/pull/1547
-- Commit Summary --
* Added missing PHP keywords, especially for PHP 7.x.
-- File Changes --
M data/filedefs/filetypes.html (2)
-- Patch Links --
https://github.com/geany/geany/pull/1547.patch https://github.com/geany/geany/pull/1547.diff
As requested, here is the justification for the additional keywords: 1. PHP7 added new [standard exception types](http://php.net/manual/en/reserved.exceptions.php) (classes). New `Error` objects can also be thrown for non-fatal errors. The geany keyword list already included the old standard `Exception` so it makes sense to also include the new, specialized exceptions and errors (ie. `ArgumentCountError`, `ArithmeticError`, `ErrorException`, etc.) 2. `assert` is now a [language construct](http://php.net/manual/en/function.assert.php) in PHP7. Language constructs like `isset`, `array`, and `unset` were already included in the geany PHP keywords list so it makes sense to add this new one. 3. Some [magic methods](http://php.net/manual/en/language.oop5.magic.php) like `__sleep` and `__wakeup` were already included in the PHP keywords list, but the other magic methods like `__construct`, `__call`, etc. were missing. All magic methods should be included for consistency. 4. PHP7 adds new [interfaces](http://php.net/manual/en/reserved.interfaces.php) and makes better use of old ones. They can be implemented in user classes or used for function argument type hinting: `callable`, `traversable`, `closure`, `iterable` (PHP 7.1), etc. 5. When running PHP in CLI mode, appropriate [streams](http://php.net/manual/en/features.commandline.io-streams.php) are automatically bound to the constants `STDIN`, `STDOUT`, and `STDERR`. Other fundamental constants like `TRUE`/`FALSE` were already in the keyword list. I suggest including the stdio streams too. 6. `void` is a [new return type](http://php.net/manual/en/migration71.new-features.php) in PHP 7.1.
Thanks! However I should have been more clear in #1546 when I said "mention the source of the keywords". What I meant was to add a comment to the file itself with a reference to the source of the keywords.
From your great description above, it seems to me you updated the list manually?
If so, it is fine as it is and your work is much appreciated.
eht16 approved this pull request.
Sorry for the confusion! Yes, I updated the list manually based on the links above (and 20 years PHP experience). Let me know if you need anything else from me. I don't think I have access to merge into master.
Nice description. Looks good to me other than the two below things:
Some of them look like library classes kind of stuff (exceptions), so I'm wondering if the tagging script should/could be updated to pull those in? Should the keywords list only be used for real keywords?
Also, some of the names are all lower case, which seems odd unless PHP has case-insensitive identifiers.
codebrainz approved this pull request.
Looks OK to me, other than the letter casing of some of the keywords, but if it works, OK.
@codebrainz http://pastebin.geany.org/S7qXX/ works, i.e. PHP has case-insensitive identifiers.
@codebrainz 2, do you mind opening a PR for the updated PHP tag file? If not, I could do.
I tried to be as consistent as possible with the list that already existed: 1. All entries were already lowercase, including those that should have caps (ie. Exception). @eht16 mentioned that PHP is case-insensitive. 2. The keywords list already contained more than "real keywords" (ie. unset, exception, etc.). I didn't introduce any new types; I just added missing values for identifiers that were already in the list: keywords, language constructs, errors/exceptions, fundamental constants, magic methods, interfaces/type hints.
It should not surprise me that PHP has case-insensitive functions and classes (but not variables?) :)
@eht16 I wouldn't even bother making a PR for the tags file, it's not really "reviewable" and is completely auto-generated.
@codebrainz I think it wouldn't hurt, just in case. But I can do it as well, no problem.
Back to topic, fine to merge for me.
Merged #1547.
Approved by two devs as ok to merge.
github-comments@lists.geany.org