UtilityMethodTestCase: new usesPhp8NameTokens()
method
#200
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In PHP 8.0 identifier name tokenization will change as outline in the accepted RFC "Treat namespaced names as single token".
When the PHP 8.0 identifier name tokenization is used, the target token to find for some tests will need to be a different token - for instance:
T_STRING
vsT_FULLY_QUALIFIED_NAME
-.Along the same lines, the expected token positions in the return value of various functions will also be different when the PHP < 8.0 tokenization is used as certain tokens will be "squashed" into one token.
This commit adds a test helper method to allow tests to "know" whether or not to expect the PHP 8.0 identifier name tokenization, so the test setup/expectations can be adjusted based on the expected tokenization.
The method is based on the current reality.
At this time the PHP 8 tokenization should be expected on all PHPCS versions when run on PHP 8.
However, this is expected to change in the near future and the method will be adjusted when it is.
A PR to implement this is currently open: PHP 8.0 | "undo" namespaced names as single token squizlabs/PHP_CodeSniffer#3063 and is expected to be merged in PHPCS 3.5.7.
Once the above mentioned PRs have been merged, the matrix of when to expect which tokenization will change to this:
Refs: