diff --git a/src/AbstractNoUselessElseFixer.php b/src/AbstractNoUselessElseFixer.php index ea38102027c..96f6bb09f65 100644 --- a/src/AbstractNoUselessElseFixer.php +++ b/src/AbstractNoUselessElseFixer.php @@ -68,7 +68,7 @@ protected function isSuperfluousElse(Tokens $tokens, int $index): bool return false; } - if ($tokens[$candidateIndex]->equals([T_THROW])) { + if ($tokens[$candidateIndex]->isGivenKind(T_THROW)) { $previousIndex = $tokens->getPrevMeaningfulToken($candidateIndex); if (!$tokens[$previousIndex]->equalsAny([';', '{'])) { diff --git a/src/Fixer/ArrayNotation/NoWhitespaceBeforeCommaInArrayFixer.php b/src/Fixer/ArrayNotation/NoWhitespaceBeforeCommaInArrayFixer.php index 6d1206bcbd1..3bf8dfd3cd2 100644 --- a/src/Fixer/ArrayNotation/NoWhitespaceBeforeCommaInArrayFixer.php +++ b/src/Fixer/ArrayNotation/NoWhitespaceBeforeCommaInArrayFixer.php @@ -121,7 +121,7 @@ private function fixSpacing(int $index, Tokens $tokens): void if ( $currentToken->equals(',') && !$tokens[$prevIndex]->isComment() - && (true === $this->configuration['after_heredoc'] || !$tokens[$prevIndex]->equals([T_END_HEREDOC])) + && (true === $this->configuration['after_heredoc'] || !$tokens[$prevIndex]->isGivenKind(T_END_HEREDOC)) ) { $tokens->removeLeadingWhitespace($i); } diff --git a/src/Fixer/Casing/ClassReferenceNameCasingFixer.php b/src/Fixer/Casing/ClassReferenceNameCasingFixer.php index f17f2ba8c8c..11b70ac41a3 100644 --- a/src/Fixer/Casing/ClassReferenceNameCasingFixer.php +++ b/src/Fixer/Casing/ClassReferenceNameCasingFixer.php @@ -78,6 +78,7 @@ private function getClassReference(Tokens $tokens, NamespaceAnalysis $namespace) T_CASE, // PHP 8.1 trait enum-case T_CLASS, T_CONST, + T_DOUBLE_ARROW, T_DOUBLE_COLON, T_FUNCTION, T_INTERFACE, @@ -120,7 +121,7 @@ private function getClassReference(Tokens $tokens, NamespaceAnalysis $namespace) continue; } - if (!$tokens[$prevIndex]->isGivenKind([T_NEW]) && $tokens[$nextIndex]->equals('(')) { + if (!$tokens[$prevIndex]->isGivenKind(T_NEW) && $tokens[$nextIndex]->equals('(')) { continue; } diff --git a/src/Fixer/ControlStructure/NoBreakCommentFixer.php b/src/Fixer/ControlStructure/NoBreakCommentFixer.php index 2a29fa25d52..dfcb208804f 100644 --- a/src/Fixer/ControlStructure/NoBreakCommentFixer.php +++ b/src/Fixer/ControlStructure/NoBreakCommentFixer.php @@ -154,7 +154,7 @@ private function fixCase(Tokens $tokens, int $casePosition): void continue; } - if ($tokens[$i]->isGivenKind([T_THROW])) { + if ($tokens[$i]->isGivenKind(T_THROW)) { $previousIndex = $tokens->getPrevMeaningfulToken($i); if ($previousIndex === $casePosition || $tokens[$previousIndex]->equalsAny(['{', ';', '}', [T_OPEN_TAG]])) { diff --git a/src/Fixer/Import/SingleImportPerStatementFixer.php b/src/Fixer/Import/SingleImportPerStatementFixer.php index 684a4ae8370..ce4aa66cf50 100644 --- a/src/Fixer/Import/SingleImportPerStatementFixer.php +++ b/src/Fixer/Import/SingleImportPerStatementFixer.php @@ -130,7 +130,7 @@ private function getGroupStatements(Tokens $tokens, string $groupPrefix, int $gr for ($i = $groupOpenIndex + 1; $i <= $groupCloseIndex; ++$i) { $token = $tokens[$i]; - if ($token->equals(',') && $tokens[$tokens->getNextMeaningfulToken($i)]->equals([CT::T_GROUP_IMPORT_BRACE_CLOSE])) { + if ($token->equals(',') && $tokens[$tokens->getNextMeaningfulToken($i)]->isGivenKind(CT::T_GROUP_IMPORT_BRACE_CLOSE)) { continue; } diff --git a/src/Fixer/PhpUnit/PhpUnitDedicateAssertInternalTypeFixer.php b/src/Fixer/PhpUnit/PhpUnitDedicateAssertInternalTypeFixer.php index 271b1a60c20..e8365c4b23f 100644 --- a/src/Fixer/PhpUnit/PhpUnitDedicateAssertInternalTypeFixer.php +++ b/src/Fixer/PhpUnit/PhpUnitDedicateAssertInternalTypeFixer.php @@ -169,7 +169,7 @@ protected function applyPhpUnitClassFix(Tokens $tokens, int $startIndex, int $en $expectedTypeTokenIndex = $tokens->getNextMeaningfulToken($bracketTokenIndex); $expectedTypeToken = $tokens[$expectedTypeTokenIndex]; - if (!$expectedTypeToken->equals([T_CONSTANT_ENCAPSED_STRING])) { + if (!$expectedTypeToken->isGivenKind(T_CONSTANT_ENCAPSED_STRING)) { continue; } diff --git a/src/Tokenizer/AbstractTypeTransformer.php b/src/Tokenizer/AbstractTypeTransformer.php index 9e938189a16..53fa51355f6 100644 --- a/src/Tokenizer/AbstractTypeTransformer.php +++ b/src/Tokenizer/AbstractTypeTransformer.php @@ -56,7 +56,7 @@ protected function doProcess(Tokens $tokens, int $index, $originalToken): void $prevPrevTokenIndex = $tokens->getPrevMeaningfulToken($prevIndex); - if ($tokens[$prevPrevTokenIndex]->isGivenKind([T_CATCH])) { + if ($tokens[$prevPrevTokenIndex]->isGivenKind(T_CATCH)) { $this->replaceToken($tokens, $index); return; diff --git a/src/Tokenizer/Transformer/BraceClassInstantiationTransformer.php b/src/Tokenizer/Transformer/BraceClassInstantiationTransformer.php index 00be8d743f5..2736c83c259 100644 --- a/src/Tokenizer/Transformer/BraceClassInstantiationTransformer.php +++ b/src/Tokenizer/Transformer/BraceClassInstantiationTransformer.php @@ -51,7 +51,7 @@ public function getRequiredPhpVersionId(): int */ public function process(Tokens $tokens, Token $token, int $index): void { - if (!$tokens[$index]->equals('(') || !$tokens[$tokens->getNextMeaningfulToken($index)]->equals([T_NEW])) { + if (!$tokens[$index]->equals('(') || !$tokens[$tokens->getNextMeaningfulToken($index)]->isGivenKind(T_NEW)) { return; } diff --git a/tests/Fixer/Casing/ClassReferenceNameCasingFixerTest.php b/tests/Fixer/Casing/ClassReferenceNameCasingFixerTest.php index f1da8b11725..9a213c691e0 100644 --- a/tests/Fixer/Casing/ClassReferenceNameCasingFixerTest.php +++ b/tests/Fixer/Casing/ClassReferenceNameCasingFixerTest.php @@ -137,6 +137,10 @@ public function provideFixCases(): \Generator ' exception];', + ]; + yield [ ' null, null, new class {}); + \Closure::bind(fn () => null, null, new class {}); + + Foo\Bar::bind(fn () => null, null, new class {}); + \A\B\\Bar::bind(fn () => null, null, new class {}); + ', + ' null, null, new class {}); + \CLOSURE::bind(fn () => null, null, new class {}); + + Foo\Bar::bind(fn () => null, null, new class {}); + \A\B\\Bar::bind(fn () => null, null, new class {}); + ', + ]; } /**