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

Add support for reserved words used as method names #120

Closed
pkopi opened this issue Sep 14, 2021 · 3 comments
Closed

Add support for reserved words used as method names #120

pkopi opened this issue Sep 14, 2021 · 3 comments

Comments

@pkopi
Copy link

pkopi commented Sep 14, 2021

Prior to PHP 7, reserved keywords can be used as class method names.

When using patchwork for unit tests(using phpunit and symfony) following error occured:

During class fetch: Uncaught ParseError: syntax error, unexpected '\' (T_NS_SEPARATOR), expecting function (T_FUNCTION) or const (T_CONST) in vendor/symfony/dependency-injection/Loader/Configurator/Traits/ClassTrait.php:26

Temporary workaround for this issue is to load ClassTrait before the patchwork library is loaded, but I would appreciate if support for reserved keywords as method names will be added to the library. Thank you!

@jrfnl
Copy link
Collaborator

jrfnl commented Oct 5, 2021

Related to #104

@antecedent
Copy link
Owner

Thank you for the report, @pkopi! And apologies for the delay. It was quite a surprise to me that token_get_all() has a flag, TOKEN_PARSE, that should solve all of this. It even had it for quite a while already. I will try switching it on.

@jrfnl
Copy link
Collaborator

jrfnl commented Jan 17, 2022

@antecedent Just for your information - TOKEN_PARSE also makes token_get_all() parse error intolerant, which depending on the use-case, can be problematic if code suitable for different PHP versions needs to be tokenized. (I'm not 100% sure where token_get_all() is used here, but just so you know)

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

No branches or pull requests

3 participants