Compactor\Php: add support for PHP 8.0+ attributes + small other fix #568
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.
Compactor\Php: add tests with trailing comments
Compactor\Php: fix stray whitespace at start of line after removal trailing comment
The tokens for comments in
#
and//
format include the new line character at the end of the comment in PHP < 8.0.This would lead to the "is this leading whitespace at the start of a line" check, not trimming leading whitespace on the line after a (trimmed) comment.
Fixed now.
Compactor\Php: add tests with PHP 8.0 attributes
Compactor\Php: add support for PHP 8.0+ attributes
Up to now, when a Phar was being created using PHP < 8.0 with the PHP compactor enabled, PHP 8.0+ attributes would be incorrectly removed as if they were comments.
This has now been fixed.
Both the solution implemented, as well as the unit tests, are largely inspired by the solution for handling attributes when code is being tokenized on PHP < 8.0, as implemented in
PHP_CodeSniffer
in squizlabs/PHP_CodeSniffer#3203 and squizlabs/PHP_CodeSniffer#3299. Props to @alekitto.Fixes #567