Skip to content

SwitchContinueToBreakFixer - Fix candidate check #6004

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

Merged
merged 1 commit into from
Sep 13, 2021
Merged

SwitchContinueToBreakFixer - Fix candidate check #6004

merged 1 commit into from
Sep 13, 2021

Conversation

SpacePossum
Copy link
Contributor

No description provided.

@@ -78,7 +78,7 @@ public function getDefinition(): FixerDefinitionInterface
*/
public function isCandidate(Tokens $tokens): bool
{
return $tokens->isAnyTokenKindsFound([T_CASE, T_DEFAULT]);
return $tokens->isTokenKindFound(T_SWITCH);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

not a bug, but on PHP8.1 and up case and default can be used outside switch statements, as such this check is better

@@ -79,7 +79,7 @@ public function getPriority(): int
*/
public function isCandidate(Tokens $tokens): bool
{
return $tokens->isAllTokenKindsFound([T_SWITCH, T_CONTINUE, T_LNUMBER]) && !$tokens->hasAlternativeSyntax();
return $tokens->isAllTokenKindsFound([T_SWITCH, T_CONTINUE]) && !$tokens->hasAlternativeSyntax();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

bug, prove can be found in the test

@coveralls
Copy link

Coverage Status

Coverage remained the same at 92.096% when pulling 3247c37 on SpacePossum:master_SwitchContinueToBreakFixer_candidate_fix into 52b69d1 on FriendsOfPHP:master.

@SpacePossum SpacePossum merged commit fcdbb86 into PHP-CS-Fixer:master Sep 13, 2021
@SpacePossum SpacePossum deleted the master_SwitchContinueToBreakFixer_candidate_fix branch September 13, 2021 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants