Fix AlphabeticalUseStatements sorting trait use statements#235
Merged
mmoll merged 1 commit intomayflower:masterfrom Mar 15, 2026
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #235 +/- ##
===========================================
Coverage 100.00% 100.00%
Complexity 143 143
===========================================
Files 8 8
Lines 661 652 -9
===========================================
- Hits 661 652 -9 ☔ View full report in Codecov by Sentry. |
85c8916 to
a783507
Compare
The sniff was incorrectly processing trait use statements inside class/trait/enum bodies. The parent class's private shouldIgnoreUse() filtered them out, but the child class continued executing its own sorting logic. Add a hasCondition() check to also ignore trait use. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
a783507 to
f498320
Compare
|
mmoll
reviewed
Mar 10, 2026
mmoll
approved these changes
Mar 10, 2026
Contributor
|
@xalopp WDYT? |
mmoll
approved these changes
Mar 10, 2026
Collaborator
|
@mmoll it looks good at first sight, but I need some time for testing. Give me 48h to check ;-) |
xalopp
approved these changes
Mar 13, 2026
Contributor
|
Merged and released in v11.0.2, thanks @Khartir! |
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.



Type of PR
Description
The sniff was incorrectly processing trait use statements inside class/trait/enum bodies. The parent class's private shouldIgnoreUse() filtered them out, but the child class continued executing its own sorting logic. Add a hasCondition() check to also ignore trait use.
In theory, this would sort trait use statements as well, but it does not handle traits with docblocks (generic traits are a thing).
I assume the entire handling of traits was a bug.
I thought about adding https://github.com/slevomat/coding-standard/blob/master/doc/classes.md#slevomatcodingstandardclassestraituseorder- and maybe https://github.com/slevomat/coding-standard/blob/master/doc/classes.md#slevomatcodingstandardclassestraitusespacing- but those have also issues with docblocks on traits.