Skip to content

Conversation

gharlan
Copy link
Member

@gharlan gharlan commented Jul 11, 2025

Blackfire comparison for running the fixer on this repo with config:

return (new Config())
    ->setUsingCache(false)
    ->setRules([
        'fully_qualified_strict_types' => [
            'import_symbols' => true,
        ],
    ])
    // ..
Bildschirmfoto 2025-07-11 um 19 48 08

@coveralls
Copy link

Coverage Status

coverage: 94.806%. remained the same
when pulling 0b6fe34 on gharlan:fqstf-improve
into 64e69dd on PHP-CS-Fixer:master.

++$openedCurlyBrackets;
} if ($tokens[$index]->equals('}')) {
} elseif ($token->equals('}')) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else was missing here

} elseif ($tokens[$index]->isGivenKind([T_INSTANCEOF, T_NEW, CT::T_USE_TRAIT, CT::T_TYPE_COLON])) {
$this->fixNextName($tokens, $index, $uses, $namespaceName);
} elseif ($tokens[$index]->isGivenKind(T_VARIABLE)) {
} elseif ($token->isGivenKind(T_VARIABLE)) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

elseif checks reordered..
In most files there are many more T_VARIABLE tokens than T_CLASS etc. So it makes sense to check T_VARIABLE first.
Before the change for every variable all the other isGivenKind checks were done. This is the reason for the reduced function calls.

$typeStartIndex = $index;
if (null === $typeEndIndex) {
$typeEndIndex = $index;
}
} else {
if (null !== $typeEndIndex) {
$index += $this->shortenClassIfPossible($tokens, $typeStartIndex, $typeEndIndex, $uses, $namespaceName);
$this->shortenClassIfPossible($tokens, $typeStartIndex, $typeEndIndex, $uses, $namespaceName);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not fast-forward the index anymore ?

Copy link
Member Author

@gharlan gharlan Jul 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not used here. After the if the break finishes the foreach loop and the function ends.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense 👍🏻
(pssst, consider to have dedicated commit with commit-log describing that, you would avoid such question during review ;) )

@keradus
Copy link
Member

keradus commented Jul 12, 2025

❤️

@keradus keradus merged commit 19e1957 into PHP-CS-Fixer:master Jul 12, 2025
29 checks passed
@gharlan gharlan deleted the fqstf-improve branch July 12, 2025 12:54
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.

3 participants