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.
New Tokens\TokenHelper class
As of PHPUnit 9.3, PHPUnit started using PHP-Parser as a basis to calculate code coverage.
The problem with this is that PHP-Parser backfills new PHP native tokens, while the code in this repo contains logic which checks for the existence of tokens using
defined()
. That logic breaks with PHP-Parser in play.An external PHPCS standard may also be using PHP-Parser, but as Parser doesn't fix the tokenization of files, the tokens polyfilled by PHP-Parser would still cause interference.
To work round this, I'm introducing a
TokenHelper::tokenExists()
method which can distinguish tokens defined by PHP and PHPCS from tokens defined by PHP-Parser.This should solve the issue in most cases, though in edge-cases, PHP-Parser could still prevent the PHPCS native
Tokenizer\PHP
class from providing polyfills when it should.For external standards which want to use PHPUnit 9.3+ for calculating code coverage, warming the cache is also still recommended, though it shouldn't necessarily be needed anymore if the standard implements the use of the
TokenHelper::tokenExists()
method in all the appropriate places.Includes unit tests.
Refs:
Note: while
Helper
would have been the more intuitive name for the class, as there is also aBackCompat\Helper
class, this would meanuse
aliases would need to be used a lot, so instead, I've elected to name the classTokenHelper
.Implement use of the new TokenHelper::tokenExists() method
... in all the appropriate places.