Skip to content

Use Tokens::isAnyTokenKindsFound() in SectionComments::isCandidate()#9258

Closed
live627 wants to merge 5 commits into
SimpleMachines:release-3.0from
live627:fixer
Closed

Use Tokens::isAnyTokenKindsFound() in SectionComments::isCandidate()#9258
live627 wants to merge 5 commits into
SimpleMachines:release-3.0from
live627:fixer

Conversation

@live627

@live627 live627 commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

This change replaces manual token iteration in SectionComments::isCandidate() with PHP-CS-Fixer's built-in Tokens::isAnyTokenKindsFound() method.

The previous implementation scanned every token until a class-like structure was found. The new implementation delegates this check to the tokenizer's optimized lookup mechanism, which is just a simple hash lookup. isCandidate( ) is called 34694 times.

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

live627 commented Jun 6, 2026

Copy link
Copy Markdown
Contributor Author

also adding a commit to move regex build to the constructor, which is called 282 times, whereas applyFix() is called 21860 times. Should reduce repetitive work.

@Sesquipedalian

Copy link
Copy Markdown
Member

Merged via the command line in 4ace4cd

@live627 live627 deleted the fixer branch June 9, 2026 18:53
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.

2 participants