-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
chore: FullyQualifiedStrictTypesFixer
- reduce function calls
#8834
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
++$openedCurlyBrackets; | ||
} if ($tokens[$index]->equals('}')) { | ||
} elseif ($token->equals('}')) { |
There was a problem hiding this comment.
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)) { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ;) )
❤️ |
Blackfire comparison for running the fixer on this repo with config: