Repository navigation
fix: stop class constant attributes leaking onto the next member - #2559
Open
benjaminkincses wants to merge 3 commits into
Open
benjaminkincses wants to merge 3 commits into
benjaminkincses wants to merge 3 commits into
Conversation
benjaminkincses
marked this pull request as ready for review
November 25, 2026 19:21
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.
Fixes #2436.
An attribute on a class constant is printed again on the next class member:
php-parser does not clear the attribute groups of a class constant, so the next member reuses the same attrgroup object. The parser wrapper now drops every attrgroup occurrence after the first one, ordered by source position. Two attribute groups written in the source are always distinct objects, so a repeated object can only come from this parser bug.
Verified with the repro from #2436 (attribute printed once, on the constant) and by formatting all 437 test fixtures before and after: only the new fixture output changes. The new fixture also covers a constant attribute leaking onto a method.