Skip to content

Further improves SectionComments#9265

Open
live627 wants to merge 1 commit into
SimpleMachines:release-3.0from
live627:fixer
Open

Further improves SectionComments#9265
live627 wants to merge 1 commit into
SimpleMachines:release-3.0from
live627:fixer

Conversation

@live627

@live627 live627 commented Jun 11, 2026

Copy link
Copy Markdown
Contributor
  • Use a more forgiving regex to detect slightly malformed section comments. Idea for further improvement: Use Utils::buildRegex() if available, because each comment is stripped to the bare words before building the final regex.
  • Avoids removing and reinserting section comments that are already correct and in the proper location. This is explicitly checked for in the vendor-provided test suite.
  • Defers removal of obsolete section comments until after analysis, reducing token stream mutations during processing. This improves fixer idempotency by avoiding unnecessary token modifications when no changes are required.
  • Correctly preserves valid section comments while removing duplicates and misplaced comments.

My tests https://github.com/live627/php-cs-fixer-custom-fixers/blob/main/tests/SectionCommentsFixerTest.php

@live627 live627 added the Meta Repository tools label Jun 11, 2026
@live627

live627 commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author
Case                                       Tokens
-------------------------------------------------
all sections with phpdocs and enum            401
all sections and enum                         341
section comments missing a space              361
misplaced and duplicate section comments       93
completely wrong section comments              34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Meta Repository tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant