Skip to content

Blink parity: honor order option in OrderedClassElements; gate to 0.2% - #140

Merged
TomasVotruba merged 1 commit into
mainfrom
tv-blink-parity-reorder
Oct 5, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
tv-blink-parity-reorder

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Makes OrderedClassElements honor its order config. Measured drop: 10 to 8 differing files of 4527 (0.18%), 2 files fixed with zero regressions - now under 0.2%.

The issue

blink's OrderedClassElements ignored its configuration and always applied the full default grouping (trait use, constants, properties, methods). The mautic config sets order: ["use_trait"] (group trait uses first, leave everything else in source order), so blink wrongly moved a property below a constant:

final class DncSearchFunctionalTest extends MauticMysqlTestCase
{
    protected $useCleanupRollback = false;   // blink moved this below the const
    private const MESSAGE_... = '...';

The fix

WithConfig ranks each group from the order list: a listed group keeps its index, every unlisted group shares the next index (count(order)). A stable sort by rank then moves only the listed groups and leaves the rest in source order - matching php-cs-fixer's configurePostNormalisation (listed types get their position, unlisted collapse to lastPosition, stable sort with sort_algorithm: none). Unconfigured behavior is unchanged (the default group order).

Gate

MAX_DIFF_PERCENT lowered 0.25 to 0.2; actual is 0.18% (8 of 4527).

Fixed: DncSearchFunctionalTest, LeadFieldRepositoryFunctionalTest. Unit test covers order=["use_trait"] (only trait moves, const stays after property) and the no-trait no-op. Full blink suite, go vet, golangci-lint green; strict rector-src 1:1 gate stays 0-diff.

OrderedClassElements ignored its "order" config and always applied the full
default grouping, reordering const/property even when the mautic config orders
only ["use_trait"]. WithConfig now ranks each group from the order list (a
listed group keeps its index, unlisted groups share the next index) and a
stable sort moves only the listed groups, leaving the rest in source order.
@TomasVotruba
TomasVotruba merged commit 896ad6a into main Oct 5, 2026
18 checks passed
@TomasVotruba
TomasVotruba deleted the tv-blink-parity-reorder branch October 5, 2026 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant