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

PHP 8.0: handle changed tokenization of namespaced names #19

Merged

Conversation

jrfnl
Copy link
Collaborator

@jrfnl jrfnl commented Mar 29, 2021

Tests: add tests covering namespaced names

PHP 8.0: handle changed tokenization of namespaced names

Namespaced names are now represented using the T_NAME_QUALIFIED (Foo\Bar), T_NAME_FULLY_QUALIFIED (\Foo\Bar) and T_NAME_RELATIVE (namespace\Foo\Bar) tokens. T_NS_SEPARATOR is only used for standalone namespace separators, and only syntactially valid in conjunction with group use declarations.

Ref: https://www.php.net/manual/en/migration80.incompatible.php#migration80.incompatible.tokenizer

This commit:

  • Adds recognition for the new PHP 8.0 tokens for namespaced names and highlights these as TOKEN_DEFAULT, same as a non-namespaced T_STRING name.
  • Adjusts the new unit tests to document the different highlighting between PHP < 8.0 and PHP 8.0+.

I've chosen not to make force the same highlighting across versions, but to let the highlighting respect the different tokenization across PHP versions.

> Namespaced names are now represented using the `T_NAME_QUALIFIED` (`Foo\Bar`), `T_NAME_FULLY_QUALIFIED` (`\Foo\Bar`) and `T_NAME_RELATIVE` (`namespace\Foo\Bar`) tokens. `T_NS_SEPARATOR` is only used for standalone namespace separators, and only syntactially valid in conjunction with group use declarations.

Ref: https://www.php.net/manual/en/migration80.incompatible.php#migration80.incompatible.tokenizer

This commit:
* Adds recognition for the new PHP 8.0 tokens for namespaced names and highlights these as `TOKEN_DEFAULT`, same as a non-namespaced `T_STRING` name.
* Adjusts the new unit tests to document the different highlighting between PHP < 8.0 and PHP 8.0+.

I've chosen not to make force the same highlighting across versions, but to let the highlighting respect the different tokenization across PHP versions.
@jrfnl
Copy link
Collaborator Author

jrfnl commented May 8, 2021

@grogy Anything I can do to move this PR forward ?

@grogy
Copy link
Member

grogy commented May 8, 2021

Thank you for create compatible changeset with old PHP versions

@grogy grogy merged commit e0d333f into php-parallel-lint:master May 8, 2021
@jrfnl jrfnl deleted the php-8.0/handle-namespaced-names branch May 8, 2021 05:03
@jrfnl
Copy link
Collaborator Author

jrfnl commented May 8, 2021

You're welcome!

@jrfnl jrfnl added this to the 1.0.0 milestone Dec 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants