Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the list of PHP keywords #1689

Closed
ghost opened this issue Jan 3, 2019 · 2 comments
Closed

Update the list of PHP keywords #1689

ghost opened this issue Jan 3, 2019 · 2 comments

Comments

@ghost
Copy link

ghost commented Jan 3, 2019

Here are some suggestions:

Presently, empty(), eval(), exit(), isset(), list(), unset() are recognized as functions because of braces. But __halt_compiler(), array(), die(), empty(), eval(), exit(), isset(), list(), unset() are not functions: they are keywords.

Depending on your decision, I can make a PR with the appropriate RegExp. An example:

/\b(?:__halt_compiler|abstract|and|array|as|break|callable|case|catch|cfunction|class|clone|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|eval|exit|extends|final|finally|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|namespace|new|null|old_function|or|parent|print|private|protected|public|require|require_once|return|static|switch|throw|trait|try|unset|use|var|while|xor|yield)\b/i

Is it alright to arrange keywords in alphabetical order? Is there a meaning in the current order? Is it connected with optimization?

I also have suggestions regarding null and parent, but it’s better to start a separate topic for that.

@RunDevelopment
Copy link
Member

It's a good idea to update the PHP keyword. I think we can copy the keyword list you linked to as is (including empty, eval, and so on).

Regex looks good (sans the PHP 4 keywords). I'm looking forward to the PR.

remove cfunction or add old_function. Both are defined in PHP 4 only.

I think it's ok to remove the keywords of a PHP version for which support has ended a decade ago.

Is it alright to arrange keywords in alphabetical order? Is there a meaning in the current order? Is it connected with optimization?

Alphabetic order is very much appreciated because it makes it easy to spot missing/duplicate keyword (yes, that happens). Apart from that, the order doesn't matter in this case.

@ghost
Copy link
Author

ghost commented Jan 3, 2019

Great, I’ll make this PR today.

I’ll keep null and parent (which are not in the list of keywords) in the RegExp until the next my PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant