Skip to content

Set SectionCommentsFixer priority to 54 to satisfy run-order constraints #9377

Description

@live627

We need to set a safe priority for SectionCommentsFixer so its run order satisfies constraints relative to existing built-in fixers.

Requirements

  • Must run before: IndentationTypeFixer (priority 50), NoExtraBlankLinesFixer (-20), StatementIndentationFixer (-3)
  • Must run after: ClassAttributesSeparationFixer (priority 55), ModifierKeywordsFixer (priority 56), OrderedClassElementsFixer (priority 65)

Analysis

To meet the constraints we need priority p such that:

  • p > 50 (to run before IndentationTypeFixer)
  • p < 55 (to run after ClassAttributesSeparationFixer)

Allowed integer priorities: 51, 52, 53, 54.

Recommendation

Set priority to 54. Rationale:

  • 54 is the highest number in the allowed range so it runs after ClassAttributesSeparationFixer@55 and before IndentationTypeFixer@50.
  • Choosing the highest available value preserves the requested ordering while leaving room for adjacent fixers to be inserted between 54 and 55 if needed in the future.

Example patch (conceptual):

public function getPriority(): int
{
    return 54;
}

Upstream provides integration testing that I use to test these priorities. My tests are at live627/php-cs-fixer-custom-fixers@747a918

That repository might be a good candidate to move to the organization. I might post about this in the team boards one day.

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions