Skip to content

Conversation

@alekitto
Copy link
Contributor

As per title, this fixes the bug described in #3294.

Only if the PHP version is less than 8.0 AND the attribute closer token is not found (not being on the same line or placed after a "?>" token which is interpreted as a php close tag for example), the remainder of the file will be re-tokenized and the attribute closed is searched in the new token stream.
If found the new token stream is injected into the token array and parsing continues, otherwise the re-tokenized stream will be ignored.

@gsherwood gsherwood added this to the 3.6.1 milestone Apr 14, 2021
gsherwood added a commit that referenced this pull request Apr 14, 2021
@gsherwood gsherwood merged commit 26a545f into squizlabs:master Apr 14, 2021
@gsherwood
Copy link
Member

Thanks a lot for this fix

jrfnl added a commit to jrfnl/box that referenced this pull request Oct 10, 2021
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

Co-authored-by: Alessandro Chitolina <[email protected]>
jrfnl added a commit to jrfnl/box that referenced this pull request Oct 10, 2021
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

Co-authored-by: Alessandro Chitolina <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants