Repository navigation
Conversation
read_class_body reset the attribute list after enum cases, methods and properties, but not after constants, so the member following an attributed constant got the same attributes. The location snapshot had recorded the leaked attribute on `$bar`.
read_inner_statement read the attributes but did not pass them on to class and interface declarations, and did not accept readonly classes at all.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Two attribute bugs that show up as wrong output in
@prettier/plugin-php:Attributes of a class constant leak into the next member.
read_class_bodyresetsattrsafter enum cases, methods and properties, but not after constants, so inf()also gets#[Deprecated], and Prettier prints it there. nette/utils hits this inStrings::checkEncoding(). This is what prettier/plugin-php#2436 reports; #1225 fixed the location but not the leak. The existing location snapshot had recorded it on$bar, so that snapshot changes too.Attributes on a class or interface declared in a block are dropped.
read_inner_statementreads them but doesn't pass them toread_class_declaration_statement/read_interface_declaration_statement, and it doesn't acceptreadonly classat all (syntax error). Symfony's polyfill stubs are written like this:and Prettier currently removes the
#[Attribute]line.Each fix is its own commit with a test in
attributes.test.js; both tests fail without the change.CI=1 yarn jestpasses (1570 tests, coverage thresholds included). I also formattednette/utilsStrings.phpand the six Symfony polyfill stubs with@prettier/plugin-php0.26.0 on top of this branch, and the result has the same AST as the input (checked with nikic/php-parser).