Repository: FriendsOfPHP/PHP-CS-Fixer (php)

Issue:
Should SingleSpaceAfterConstructFixer fix "if(" ? BracesFixer does.
## Support question

I was surprise when I saw a PR from a fellow colleague pass the build with `if(` in the codebase, while we're using PSR-12 as a coding standard. I expected EasyCodingStandard (and the underlying PHP-CS-Fixer) to report it as wrong and propose `if (` with a space instead.

So I looked at SingleSpaceAfterConstructFixer, tried to include it explicitly in my project, and it still doesn't report any errors. Why is that ?

Thanks for your insights.
gnutix

Pull request:
SingleSpaceAfterConstructFixer - improve comma handling
fixes #5904

Patch:
diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php
index 29df7d8e5..6c4889c90 100644
--- a/.php-cs-fixer.dist.php
+++ b/.php-cs-fixer.dist.php
@@ -36,7 +36,6 @@
 $config
     ->setRiskyAllowed(true)
     ->setRules([
-        '@PHP71Migration' => true,
         '@PHP71Migration:risky' => true,
         '@PHPUnit75Migration:risky' => true,
         '@PhpCsFixer' => true,
diff --git a/src/AbstractFunctionReferenceFixer.php b/src/AbstractFunctionReferenceFixer.php
index 8b2ded48f..9e81193a3 100644
--- a/src/AbstractFunctionReferenceFixer.php
+++ b/src/AbstractFunctionReferenceFixer.php
@@ -52,7 +52,7 @@ protected function find(string $functionNameToSearch, Tokens $tokens, int $start
         }
 
         // translate results for humans
-        [$functionName, $openParenthesis] = array_keys($matches);
+        list($functionName, $openParenthesis) = array_keys($matches);
 
         $functionsAnalyzer = new FunctionsAnalyzer();
 
diff --git a/src/AbstractNoUselessElseFixer.php b/src/AbstractNoUselessElseFixer.php
index 2f6747d2b..338d709ae 100644
--- a/src/AbstractNoUselessElseFixer.php
+++ b/src/AbstractNoUselessElseFixer.php
@@ -37,7 +37,7 @@ protected function isSuperfluousElse(Tokens $tokens, int $index): bool
         do {
             // Check if all 'if', 'else if ' and 'elseif' blocks above this 'else' always end,
             // if so this 'else' is overcomplete.
-            [$previousBlockStart, $previousBlockEnd] = $this->getPreviousBlock($tokens, $previousBlockStart);
+            list($previousBlockStart, $previousBlockEnd) = $this->getPreviousBlock($tokens, $previousBlockStart);
 
             // short 'if' detection
             $previous = $previousBlockEnd;
diff --git a/src/Cache/FileHandler.php b/src/Cache/FileHandler.php
index 1a4727e0f..0f8833f4f 100644
--- a/src/Cache/FileHandler.php
+++ b/src/Cache/FileHandler.php
@@ -99,7 +99,7 @@ public function write(CacheInterface $cache): void
             $error = error_get_last();
 
             throw new IOException(
-                sprintf('Failed to write file "%s", "%s".', $this->file, $error['message'] ?? 'no reason available'),
+                sprintf('Failed to write file "%s", "%s".', $this->file, isset($error['message']) ? $error['message'] : 'no reason available'),
                 0,
                 null,
                 $this->file
diff --git a/src/DocBlock/DocBlock.php b/src/DocBlock/DocBlock.php
index 96353e69c..4d00a17de 100644
--- a/src/DocBlock/DocBlock.php
+++ b/src/DocBlock/DocBlock.php
@@ -86,7 +86,7 @@ public function getLines(): array
      */
     public function getLine(int $pos): ?Line
     {
-        return $this->lines[$pos] ?? null;
+        return isset($this->lines[$pos]) ? $this->lines[$pos] : null;
     }
 
     /**
@@ -182,7 +182,7 @@ public function getAnnotation(int $pos): ?Annotation
     {
         $annotations = $this->getAnnotations();
 
-        return $annotations[$pos] ?? null;
+        return isset($annotations[$pos]) ? $annotations[$pos] : null;
     }
 
     /**
diff --git a/src/Doctrine/Annotation/Tokens.php b/src/Doctrine/Annotation/Tokens.php
index d2c579b6f..fcbf04be5 100644
--- a/src/Doctrine/Annotation/Tokens.php
+++ b/src/Doctrine/Annotation/Tokens.php
@@ -248,7 +248,7 @@ public function insertAt(int $index, Token $token): void
         $this->setSize($this->getSize() + 1);
 
         for ($i = $this->getSize() - 1; $i > $index; --$i) {
-            $this[$i] = $this[$i - 1] ?? new Token();
+            $this[$i] = isset($this[$i - 1]) ? $this[$i - 1] : new Token();
         }
 
         $this[$index] = $token;
diff --git a/src/Fixer/Alias/MbStrFunctionsFixer.php b/src/Fixer/Alias/MbStrFunctionsFixer.php
index b925b9fa6..e37cb9612 100644
--- a/src/Fixer/Alias/MbStrFunctionsFixer.php
+++ b/src/Fixer/Alias/MbStrFunctionsFixer.php
@@ -117,7 +117,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
                     continue 2;
                 }
 
-                [$functionName, $openParenthesis, $closeParenthesis] = $boundaries;
+                list($functionName, $openParenthesis, $closeParenthesis) = $boundaries;
                 $count = $argumentsAnalyzer->countArguments($tokens, $openParenthesis, $closeParenthesis);
                 if (!\in_array($count, $functionReplacement['argumentCount'], true)) {
                     continue 2;
diff --git a/src/Fixer/Alias/NoAliasFunctionsFixer.php b/src/Fixer/Alias/NoAliasFunctionsFixer.php
index af15d9731..566ed0c70 100644
--- a/src/Fixer/Alias/NoAliasFunctionsFixer.php
+++ b/src/Fixer/Alias/NoAliasFunctionsFixer.php
@@ -229,7 +229,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
             }
 
             if (\is_array($this->aliases[$tokenContent])) {
-                [$alias, $numberOfArguments] = $this->aliases[$tokenContent];
+                list($alias, $numberOfArguments) = $this->aliases[$tokenContent];
 
                 $count = $argumentsAnalyzer->countArguments($tokens, $openParenthesis, $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $openParenthesis));
 
diff --git a/src/Fixer/Alias/RandomApiMigrationFixer.php b/src/Fixer/Alias/RandomApiMigrationFixer.php
index 7626db97c..d88d1f615 100644
--- a/src/Fixer/Alias/RandomApiMigrationFixer.php
+++ b/src/Fixer/Alias/RandomApiMigrationFixer.php
@@ -112,7 +112,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
                     continue 2;
                 }
 
-                [$functionName, $openParenthesis, $closeParenthesis] = $boundaries;
+                list($functionName, $openParenthesis, $closeParenthesis) = $boundaries;
                 $count = $argumentsAnalyzer->countArguments($tokens, $openParenthesis, $closeParenthesis);
 
                 if (!\in_array($count, $functionReplacement['argumentCount'], true)) {
diff --git a/src/Fixer/Basic/NonPrintableCharacterFixer.php b/src/Fixer/Basic/NonPrintableCharacterFixer.php
index c965828bc..12be23d80 100644
--- a/src/Fixer/Basic/NonPrintableCharacterFixer.php
+++ b/src/Fixer/Basic/NonPrintableCharacterFixer.php
@@ -128,7 +128,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
         $replacements = [];
         $escapeSequences = [];
 
-        foreach ($this->symbolsReplace as $character => [$replacement, $codepoint]) {
+        foreach ($this->symbolsReplace as $character => list($replacement, $codepoint)) {
             $replacements[$character] = $replacement;
             $escapeSequences[$character] = '\u{'.$codepoint.'}';
         }
diff --git a/src/Fixer/CastNotation/ModernizeTypesCastingFixer.php b/src/Fixer/CastNotation/ModernizeTypesCastingFixer.php
index 99e51c06f..2ebb286a6 100644
--- a/src/Fixer/CastNotation/ModernizeTypesCastingFixer.php
+++ b/src/Fixer/CastNotation/ModernizeTypesCastingFixer.php
@@ -84,7 +84,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
                     continue 2;
                 }
 
-                [$functionName, $openParenthesis, $closeParenthesis] = $boundaries;
+                list($functionName, $openParenthesis, $closeParenthesis) = $boundaries;
 
                 // analysing cursor shift
                 $currIndex = $openParenthesis;
diff --git a/src/Fixer/ClassNotation/NoPhp4ConstructorFixer.php b/src/Fixer/ClassNotation/NoPhp4ConstructorFixer.php
index 423c4095f..14ee1b25d 100644
--- a/src/Fixer/ClassNotation/NoPhp4ConstructorFixer.php
+++ b/src/Fixer/ClassNotation/NoPhp4ConstructorFixer.php
@@ -167,7 +167,7 @@ private function fixConstructor(Tokens $tokens, string $className, int $classSta
         }
 
         // does the PHP4-constructor only call $this->__construct($args, ...)?
-        [$sequences, $case] = $this->getWrapperMethodSequence($tokens, '__construct', $php4['startIndex'], $php4['bodyIndex']);
+        list($sequences, $case) = $this->getWrapperMethodSequence($tokens, '__construct', $php4['startIndex'], $php4['bodyIndex']);
         foreach ($sequences as $seq) {
             if (null !== $tokens->findSequence($seq, $php4['bodyIndex'] - 1, $php4['endIndex'], $case)) {
                 // good, delete it!
@@ -180,7 +180,7 @@ private function fixConstructor(Tokens $tokens, string $className, int $classSta
         }
 
         // does __construct only call the PHP4-constructor (with the same args)?
-        [$sequences, $case] = $this->getWrapperMethodSequence($tokens, $className, $php4['startIndex'], $php4['bodyIndex']);
+        list($sequences, $case) = $this->getWrapperMethodSequence($tokens, $className, $php4['startIndex'], $php4['bodyIndex']);
         foreach ($sequences as $seq) {
             if (null !== $tokens->findSequence($seq, $php5['bodyIndex'] - 1, $php5['endIndex'], $case)) {
                 // that was a weird choice, but we can safely delete it and...
diff --git a/src/Fixer/Comment/HeaderCommentFixer.php b/src/Fixer/Comment/HeaderCommentFixer.php
index cae05c740..53d32ba10 100644
--- a/src/Fixer/Comment/HeaderCommentFixer.php
+++ b/src/Fixer/Comment/HeaderCommentFixer.php
@@ -436,7 +436,7 @@ private function removeHeader(Tokens $tokens, int $index): void
         }
 
         $nextIndex = $index + 1;
-        $nextToken = $tokens[$nextIndex] ?? null;
+        $nextToken = isset($tokens[$nextIndex]) ? $tokens[$nextIndex] : null;
 
         if (!$newlineRemoved && null !== $nextToken && $nextToken->isWhitespace()) {
             $content = Preg::replace('/^\R/', '', $nextToken->getContent());
diff --git a/src/Fixer/Comment/NoEmptyCommentFixer.php b/src/Fixer/Comment/NoEmptyCommentFixer.php
index c2a3c0e03..dde77e79f 100644
--- a/src/Fixer/Comment/NoEmptyCommentFixer.php
+++ b/src/Fixer/Comment/NoEmptyCommentFixer.php
@@ -72,7 +72,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
                 continue;
             }
 
-            [$blockStart, $index, $isEmpty] = $this->getCommentBlock($tokens, $index);
+            list($blockStart, $index, $isEmpty) = $this->getCommentBlock($tokens, $index);
             if (false === $isEmpty) {
                 continue;
             }
diff --git a/src/Fixer/FunctionNotation/ImplodeCallFixer.php b/src/Fixer/FunctionNotation/ImplodeCallFixer.php
index 166482d61..6ac1e19b4 100644
--- a/src/Fixer/FunctionNotation/ImplodeCallFixer.php
+++ b/src/Fixer/FunctionNotation/ImplodeCallFixer.php
@@ -101,7 +101,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
             }
 
             if (2 === \count($argumentsIndices)) {
-                [$firstArgumentIndex, $secondArgumentIndex] = array_keys($argumentsIndices);
+                list($firstArgumentIndex, $secondArgumentIndex) = array_keys($argumentsIndices);
 
                 // If the first argument is string we have nothing to do
                 if ($tokens[$firstArgumentIndex]->isGivenKind(T_CONSTANT_ENCAPSED_STRING)) {
diff --git a/src/Fixer/FunctionNotation/PhpdocToParamTypeFixer.php b/src/Fixer/FunctionNotation/PhpdocToParamTypeFixer.php
index 6a1f7bdc9..06e36dc80 100644
--- a/src/Fixer/FunctionNotation/PhpdocToParamTypeFixer.php
+++ b/src/Fixer/FunctionNotation/PhpdocToParamTypeFixer.php
@@ -143,7 +143,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
                     continue;
                 }
 
-                [$paramType, $isNullable] = $typeInfo;
+                list($paramType, $isNullable) = $typeInfo;
 
                 $startIndex = $tokens->getNextTokenOfKind($index, ['(']);
                 $variableIndex = $this->findCorrectVariable($tokens, $startIndex, $paramTypeAnnotation);
diff --git a/src/Fixer/FunctionNotation/PhpdocToPropertyTypeFixer.php b/src/Fixer/FunctionNotation/PhpdocToPropertyTypeFixer.php
index be041cd7e..d3506c203 100644
--- a/src/Fixer/FunctionNotation/PhpdocToPropertyTypeFixer.php
+++ b/src/Fixer/FunctionNotation/PhpdocToPropertyTypeFixer.php
@@ -143,7 +143,7 @@ private function fixClass(Tokens $tokens, int $index): void
                 continue;
             }
 
-            [$propertyType, $isNullable] = $typeInfo;
+            list($propertyType, $isNullable) = $typeInfo;
 
             if (\in_array($propertyType, ['void', 'callable'], true)) {
                 continue;
diff --git a/src/Fixer/FunctionNotation/PhpdocToReturnTypeFixer.php b/src/Fixer/FunctionNotation/PhpdocToReturnTypeFixer.php
index 8b85b0681..38e15cb29 100644
--- a/src/Fixer/FunctionNotation/PhpdocToReturnTypeFixer.php
+++ b/src/Fixer/FunctionNotation/PhpdocToReturnTypeFixer.php
@@ -178,7 +178,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
                 continue;
             }
 
-            [$returnType, $isNullable] = $typeInfo;
+            list($returnType, $isNullable) = $typeInfo;
 
             $startIndex = $tokens->getNextTokenOfKind($index, ['{', ';']);
 
diff --git a/src/Fixer/Import/GlobalNamespaceImportFixer.php b/src/Fixer/Import/GlobalNamespaceImportFixer.php
index 198ecd123..bf6abc987 100644
--- a/src/Fixer/Import/GlobalNamespaceImportFixer.php
+++ b/src/Fixer/Import/GlobalNamespaceImportFixer.php
@@ -176,7 +176,7 @@ protected function createConfigurationDefinition(): FixerConfigurationResolverIn
      */
     private function importConstants(Tokens $tokens, array $useDeclarations): array
     {
-        [$global, $other] = $this->filterUseDeclarations($useDeclarations, static function (NamespaceUseAnalysis $declaration) {
+        list($global, $other) = $this->filterUseDeclarations($useDeclarations, static function (NamespaceUseAnalysis $declaration) {
             return $declaration->isConstant();
         }, true);
 
@@ -248,7 +248,7 @@ private function importConstants(Tokens $tokens, array $useDeclarations): array
      */
     private function importFunctions(Tokens $tokens, array $useDeclarations): array
     {
-        [$global, $other] = $this->filterUseDeclarations($useDeclarations, static function (NamespaceUseAnalysis $declaration) {
+        list($global, $other) = $this->filterUseDeclarations($useDeclarations, static function (NamespaceUseAnalysis $declaration) {
             return $declaration->isFunction();
         }, false);
 
@@ -299,7 +299,7 @@ private function importFunctions(Tokens $tokens, array $useDeclarations): array
      */
     private function importClasses(Tokens $tokens, array $useDeclarations): array
     {
-        [$global, $other] = $this->filterUseDeclarations($useDeclarations, static function (NamespaceUseAnalysis $declaration) {
+        list($global, $other) = $this->filterUseDeclarations($useDeclarations, static function (NamespaceUseAnalysis $declaration) {
             return $declaration->isClass();
         }, false);
 
@@ -490,7 +490,7 @@ private function fullyQualifyConstants(Tokens $tokens, array $useDeclarations):
             return;
         }
 
-        [$global] = $this->filterUseDeclarations($useDeclarations, static function (NamespaceUseAnalysis $declaration) {
+        list($global) = $this->filterUseDeclarations($useDeclarations, static function (NamespaceUseAnalysis $declaration) {
             return $declaration->isConstant() && !$declaration->isAliased();
         }, true);
 
@@ -532,7 +532,7 @@ private function fullyQualifyFunctions(Tokens $tokens, array $useDeclarations):
             return;
         }
 
-        [$global] = $this->filterUseDeclarations($useDeclarations, static function (NamespaceUseAnalysis $declaration) {
+        list($global) = $this->filterUseDeclarations($useDeclarations, static function (NamespaceUseAnalysis $declaration) {
             return $declaration->isFunction() && !$declaration->isAliased();
         }, false);
 
@@ -574,7 +574,7 @@ private function fullyQualifyClasses(Tokens $tokens, array $useDeclarations): vo
             return;
         }
 
-        [$global] = $this->filterUseDeclarations($useDeclarations, static function (NamespaceUseAnalysis $declaration) {
+        list($global) = $this->filterUseDeclarations($useDeclarations, static function (NamespaceUseAnalysis $declaration) {
             return $declaration->isClass() && !$declaration->isAliased();
         }, false);
 
@@ -723,7 +723,7 @@ private function traverseDocBlockTypes(DocBlock $doc, callable $callback): bool
 
                 Preg::matchAll('/[\\\\\w]+/', $fullType, $matches, PREG_OFFSET_CAPTURE);
 
-                foreach (array_reverse($matches[0]) as [$type, $offset]) {
+                foreach (array_reverse($matches[0]) as list($type, $offset)) {
                     $newType = $callback($type);
 
                     if (null !== $newType && $type !== $newType) {
diff --git a/src/Fixer/Import/SingleImportPerStatementFixer.php b/src/Fixer/Import/SingleImportPerStatementFixer.php
index 36fb2f5f6..c941f5cf9 100644
--- a/src/Fixer/Import/SingleImportPerStatementFixer.php
+++ b/src/Fixer/Import/SingleImportPerStatementFixer.php
@@ -173,7 +173,7 @@ private function getGroupStatements(Tokens $tokens, string $groupPrefix, int $gr
 
     private function fixGroupUse(Tokens $tokens, int $index, int $endIndex): void
     {
-        [$groupPrefix, $groupOpenIndex, $groupCloseIndex, $comment] = $this->getGroupDeclaration($tokens, $index);
+        list($groupPrefix, $groupOpenIndex, $groupCloseIndex, $comment) = $this->getGroupDeclaration($tokens, $index);
         $statements = $this->getGroupStatements($tokens, $groupPrefix, $groupOpenIndex, $groupCloseIndex, $comment);
 
         if (\count($statements) < 2) {
diff --git a/src/Fixer/LanguageConstruct/CombineConsecutiveUnsetsFixer.php b/src/Fixer/LanguageConstruct/CombineConsecutiveUnsetsFixer.php
index 007550f57..68055a975 100644
--- a/src/Fixer/LanguageConstruct/CombineConsecutiveUnsetsFixer.php
+++ b/src/Fixer/LanguageConstruct/CombineConsecutiveUnsetsFixer.php
@@ -73,7 +73,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
                 continue;
             }
 
-            [$previousUnset, , $previousUnsetBraceEnd] = $previousUnsetCall;
+            list($previousUnset, , $previousUnsetBraceEnd) = $previousUnsetCall;
 
             // Merge the tokens inside the 'unset' call into the previous one 'unset' call.
             $tokensAddCount = $this->moveTokens(
diff --git a/src/Fixer/LanguageConstruct/DirConstantFixer.php b/src/Fixer/LanguageConstruct/DirConstantFixer.php
index 96e029383..59e67e5cd 100644
--- a/src/Fixer/LanguageConstruct/DirConstantFixer.php
+++ b/src/Fixer/LanguageConstruct/DirConstantFixer.php
@@ -69,7 +69,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
                 return;
             }
 
-            [$functionNameIndex, $openParenthesis, $closeParenthesis] = $boundaries;
+            list($functionNameIndex, $openParenthesis, $closeParenthesis) = $boundaries;
 
             // analysing cursor shift, so nested expressions kept processed
             $currIndex = $openParenthesis;
diff --git a/src/Fixer/LanguageConstruct/IsNullFixer.php b/src/Fixer/LanguageConstruct/IsNullFixer.php
index 747347f64..784a92629 100644
--- a/src/Fixer/LanguageConstruct/IsNullFixer.php
+++ b/src/Fixer/LanguageConstruct/IsNullFixer.php
@@ -89,7 +89,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
             $matches = array_keys($matches);
 
             // move the cursor just after the sequence
-            [$isNullIndex, $currIndex] = $matches;
+            list($isNullIndex, $currIndex) = $matches;
 
             if (!$functionsAnalyzer->isGlobalFunctionCall($tokens, $matches[0])) {
                 continue;
diff --git a/src/Fixer/LanguageConstruct/SingleSpaceAfterConstructFixer.php b/src/Fixer/LanguageConstruct/SingleSpaceAfterConstructFixer.php
index b0f0e67c7..5bd6290ed 100644
--- a/src/Fixer/LanguageConstruct/SingleSpaceAfterConstructFixer.php
+++ b/src/Fixer/LanguageConstruct/SingleSpaceAfterConstructFixer.php
@@ -209,7 +209,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
 
             $whitespaceTokenIndex = $index + 1;
 
-            if ($tokens[$whitespaceTokenIndex]->equalsAny([';', ')', [CT::T_ARRAY_SQUARE_BRACE_CLOSE]])) {
+            if ($tokens[$whitespaceTokenIndex]->equalsAny([',', ';', ')', [CT::T_ARRAY_SQUARE_BRACE_CLOSE]])) {
                 continue;
             }
 
diff --git a/src/Fixer/Naming/NoHomoglyphNamesFixer.php b/src/Fixer/Naming/NoHomoglyphNamesFixer.php
index 0f16b0790..35c18e0d0 100644
--- a/src/Fixer/Naming/NoHomoglyphNamesFixer.php
+++ b/src/Fixer/Naming/NoHomoglyphNamesFixer.php
@@ -233,7 +233,9 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
             }
 
             $replaced = Preg::replaceCallback('/[^[:ascii:]]/u', static function (array $matches) {
-                return self::$replacements[$matches[0]] ?? $matches[0]
+                return isset(self::$replacements[$matches[0]])
+                    ? self::$replacements[$matches[0]]
+                    : $matches[0]
                 ;
             }, $token->getContent(), -1, $count);
 
diff --git a/src/Fixer/PhpUnit/PhpUnitExpectationFixer.php b/src/Fixer/PhpUnit/PhpUnitExpectationFixer.php
index 4bb800134..0f15868d7 100644
--- a/src/Fixer/PhpUnit/PhpUnitExpectationFixer.php
+++ b/src/Fixer/PhpUnit/PhpUnitExpectationFixer.php
@@ -207,7 +207,7 @@ private function applyPhpUnitClassFixWithObjectOperator(Tokens $tokens, int $sta
                 return;
             }
 
-            [$thisIndex, , $index] = array_keys($match);
+            list($thisIndex, , $index) = array_keys($match);
 
             if (!isset($this->methodMap[$tokens[$index]->getContent()])) {
                 continue;
diff --git a/src/Fixer/Phpdoc/PhpdocReturnSelfReferenceFixer.php b/src/Fixer/Phpdoc/PhpdocReturnSelfReferenceFixer.php
index bdf7a2468..015f7bdde 100644
--- a/src/Fixer/Phpdoc/PhpdocReturnSelfReferenceFixer.php
+++ b/src/Fixer/Phpdoc/PhpdocReturnSelfReferenceFixer.php
@@ -219,7 +219,7 @@ private function fixMethod(Tokens $tokens, int $index): void
         $newTypes = [];
         foreach ($types as $type) {
             $lower = strtolower($type);
-            $newTypes[] = $this->configuration['replacements'][$lower] ?? $type;
+            $newTypes[] = isset($this->configuration['replacements'][$lower]) ? $this->configuration['replacements'][$lower] : $type;
         }
 
         if ($types === $newTypes) {
diff --git a/src/Tokenizer/Token.php b/src/Tokenizer/Token.php
index 12d7af4e4..c178d7d22 100644
--- a/src/Tokenizer/Token.php
+++ b/src/Tokenizer/Token.php
@@ -212,7 +212,7 @@ public function equalsAny(array $others, bool $caseSensitive = true): bool
     public static function isKeyCaseSensitive($caseSensitive, int $key): bool
     {
         if (\is_array($caseSensitive)) {
-            return $caseSensitive[$key] ?? true;
+            return isset($caseSensitive[$key]) ? $caseSensitive[$key] : true;
         }
 
         return $caseSensitive;
diff --git a/src/Tokenizer/Tokens.php b/src/Tokenizer/Tokens.php
index 37ff4b574..f19aae0ba 100644
--- a/src/Tokenizer/Tokens.php
+++ b/src/Tokenizer/Tokens.php
@@ -1062,7 +1062,7 @@ public function isTokenKindFound($tokenKind): bool
      */
     public function countTokenKind($tokenKind): int
     {
-        return $this->foundTokenKinds[$tokenKind] ?? 0;
+        return isset($this->foundTokenKinds[$tokenKind]) ? $this->foundTokenKinds[$tokenKind] : 0;
     }
 
     /**
@@ -1167,7 +1167,7 @@ private function removeWhitespaceSafely(int $index, int $direction, ?string $whi
 
             // if the token candidate to remove is preceded by single line comment we do not consider the new line after this comment as part of T_WHITESPACE
             if (isset($this[$whitespaceIndex - 1]) && $this[$whitespaceIndex - 1]->isComment() && '/*' !== substr($this[$whitespaceIndex - 1]->getContent(), 0, 2)) {
-                [$emptyString, $newContent, $whitespacesToCheck] = Preg::split('/^(\R)/', $this[$whitespaceIndex]->getContent(), -1, PREG_SPLIT_DELIM_CAPTURE);
+                list($emptyString, $newContent, $whitespacesToCheck) = Preg::split('/^(\R)/', $this[$whitespaceIndex]->getContent(), -1, PREG_SPLIT_DELIM_CAPTURE);
 
                 if ('' === $whitespacesToCheck) {
                     return;
@@ -1217,7 +1217,7 @@ private function findOppositeBlockEdge(int $type, int $searchIndex, bool $findEn
         $indexOffset = 1;
 
         if (!$findEnd) {
-            [$startEdge, $endEdge] = [$endEdge, $startEdge];
+            list($startEdge, $endEdge) = [$endEdge, $startEdge];
             $indexOffset = -1;
             $endIndex = 0;
         }
diff --git a/src/Tokenizer/TokensAnalyzer.php b/src/Tokenizer/TokensAnalyzer.php
index 43bb54668..9ab225a65 100644
--- a/src/Tokenizer/TokensAnalyzer.php
+++ b/src/Tokenizer/TokensAnalyzer.php
@@ -57,7 +57,7 @@ public function getClassyElements(): array
 
         for ($index = 1, $count = \count($this->tokens) - 2; $index < $count; ++$index) {
             if ($this->tokens[$index]->isClassy()) {
-                [$index, $newElements] = $this->findClassyElements($index, $index);
+                list($index, $newElements) = $this->findClassyElements($index, $index);
                 $elements += $newElements;
             }
         }
@@ -672,7 +672,7 @@ private function findClassyElements(int $classIndex, int $index): array
                             --$nestedBracesLevel;
 
                             if (0 === $nestedBracesLevel) {
-                                [$index, $newElements] = $this->findClassyElements($nestedClassIndex, $index);
+                                list($index, $newElements) = $this->findClassyElements($nestedClassIndex, $index);
                                 $elements += $newElements;
 
                                 break;
@@ -682,12 +682,12 @@ private function findClassyElements(int $classIndex, int $index): array
                         }
 
                         if ($token->isClassy()) { // anonymous class in class
-                            [$index, $newElements] = $this->findClassyElements($index, $index);
+                            list($index, $newElements) = $this->findClassyElements($index, $index);
                             $elements += $newElements;
                         }
                     }
                 } else {
-                    [$index, $newElements] = $this->findClassyElements($nestedClassIndex, $nestedClassIndex);
+                    list($index, $newElements) = $this->findClassyElements($nestedClassIndex, $nestedClassIndex);
                     $elements += $newElements;
                 }
 
diff --git a/src/ToolInfo.php b/src/ToolInfo.php
index 554f9f4ca..3a675a71b 100644
--- a/src/ToolInfo.php
+++ b/src/ToolInfo.php
@@ -48,7 +48,7 @@ public function getComposerInstallationDetails(): array
         if (null === $this->composerInstallationDetails) {
             $composerInstalled = json_decode(file_get_contents($this->getComposerInstalledFile()), true);
 
-            $packages = $composerInstalled['packages'] ?? $composerInstalled;
+            $packages = isset($composerInstalled['packages']) ? $composerInstalled['packages'] : $composerInstalled;
 
             foreach ($packages as $package) {
                 if (\in_array($package['name'], [self::COMPOSER_PACKAGE_NAME, self::COMPOSER_LEGACY_PACKAGE_NAME], true)) {


Test patch:
diff --git a/tests/AutoReview/CiConfigurationTest.php b/tests/AutoReview/CiConfigurationTest.php
index ece4c406d..ad01b08e3 100644
--- a/tests/AutoReview/CiConfigurationTest.php
+++ b/tests/AutoReview/CiConfigurationTest.php
@@ -208,7 +208,7 @@ private function getPhpVersionsUsedByGitHub()
     {
         $yaml = Yaml::parse(file_get_contents(__DIR__.'/../../.github/workflows/ci.yml'));
 
-        $phpVersions = $yaml['jobs']['tests']['strategy']['matrix']['php-version'] ?? [];
+        $phpVersions = isset($yaml['jobs']['tests']['strategy']['matrix']['php-version']) ? $yaml['jobs']['tests']['strategy']['matrix']['php-version'] : [];
 
         foreach ($yaml['jobs']['tests']['strategy']['matrix']['include'] as $job) {
             $phpVersions[] = $job['php-version'];
diff --git a/tests/AutoReview/FixerFactoryTest.php b/tests/AutoReview/FixerFactoryTest.php
index 10a54eb0f..df3316323 100644
--- a/tests/AutoReview/FixerFactoryTest.php
+++ b/tests/AutoReview/FixerFactoryTest.php
@@ -519,7 +519,7 @@ public function testFixerPriorityComment(): void
         $map = [];
 
         foreach ($cases as $beforeAfter) {
-            [$before, $after] = $beforeAfter;
+            list($before, $after) = $beforeAfter;
 
             $beforeClass = \get_class($before);
             $afterClass = \get_class($after);
diff --git a/tests/AutoReview/ProjectCodeTest.php b/tests/AutoReview/ProjectCodeTest.php
index 41376af9a..a4a7010df 100644
--- a/tests/AutoReview/ProjectCodeTest.php
+++ b/tests/AutoReview/ProjectCodeTest.php
@@ -167,7 +167,7 @@ public function testThatSrcClassesNotExposeProperties(string $className): void
         $extraProps = array_diff(
             $definedProps,
             $allowedProps,
-            $exceptionPropsPerClass[$className] ?? []
+            isset($exceptionPropsPerClass[$className]) ? $exceptionPropsPerClass[$className] : []
         );
 
         sort($extraProps);
diff --git a/tests/AutoReview/TransformerTest.php b/tests/AutoReview/TransformerTest.php
index f2aa1700a..a7dcd11fd 100644
--- a/tests/AutoReview/TransformerTest.php
+++ b/tests/AutoReview/TransformerTest.php
@@ -58,7 +58,7 @@ public function testTransformerPriorityIsListed(TransformerInterface $transforme
         $name = $transformer->getName();
 
         foreach ($this->provideTransformerPriorityCases() as $pair) {
-            [$first, $second] = $pair;
+            list($first, $second) = $pair;
 
             if ($name === $first->getName() || $name === $second->getName()) {
                 $this->addToAssertionCount(1);
@@ -74,7 +74,7 @@ public function provideTransformerPriorityCases()
     {
         $transformers = [];
 
-        foreach ($this->provideTransformerCases() as [$transformer]) {
+        foreach ($this->provideTransformerCases() as list($transformer)) {
             $transformers[$transformer->getName()] = $transformer;
         }
 
diff --git a/tests/Console/Output/ErrorOutputTest.php b/tests/Console/Output/ErrorOutputTest.php
index 17b1d835f..e08258330 100644
--- a/tests/Console/Output/ErrorOutputTest.php
+++ b/tests/Console/Output/ErrorOutputTest.php
@@ -86,7 +86,7 @@ public function testErrorOutput(Error $error, int $verbosityLevel, int $lineNumb
     public function provideTestCases()
     {
         $lineNumber = __LINE__;
-        [$exceptionLineNumber, $error] = $this->getErrorAndLineNumber(); // note: keep call and __LINE__ separated with one line break
+        list($exceptionLineNumber, $error) = $this->getErrorAndLineNumber(); // note: keep call and __LINE__ separated with one line break
         ++$lineNumber;
 
         return [
diff --git a/tests/Console/Output/ProcessOutputTest.php b/tests/Console/Output/ProcessOutputTest.php
index 118267412..aad482a95 100644
--- a/tests/Console/Output/ProcessOutputTest.php
+++ b/tests/Console/Output/ProcessOutputTest.php
@@ -179,7 +179,7 @@ public function provideProcessProgressOutputCases()
     private function foreachStatus(array $statuses, \Closure $action): void
     {
         foreach ($statuses as $status) {
-            $multiplier = $status[1] ?? 1;
+            $multiplier = isset($status[1]) ? $status[1] : 1;
             $status = $status[0];
 
             for ($i = 0; $i < $multiplier; ++$i) {
diff --git a/tests/Fixer/Comment/NoEmptyCommentFixerTest.php b/tests/Fixer/Comment/NoEmptyCommentFixerTest.php
index 0d0cbbc56..6e575f945 100644
--- a/tests/Fixer/Comment/NoEmptyCommentFixerTest.php
+++ b/tests/Fixer/Comment/NoEmptyCommentFixerTest.php
@@ -267,7 +267,7 @@ public function testGetCommentBlock(string $source, int $startIndex, int $endInd
         $method = new \ReflectionMethod($this->fixer, 'getCommentBlock');
         $method->setAccessible(true);
 
-        [$foundStart, $foundEnd, $foundIsEmpty] = $method->invoke($this->fixer, $tokens, $startIndex);
+        list($foundStart, $foundEnd, $foundIsEmpty) = $method->invoke($this->fixer, $tokens, $startIndex);
 
         static::assertSame($startIndex, $foundStart, 'Find start index of block failed.');
         static::assertSame($endIndex, $foundEnd, 'Find end index of block failed.');
diff --git a/tests/Fixer/LanguageConstruct/SingleSpaceAfterConstructFixerTest.php b/tests/Fixer/LanguageConstruct/SingleSpaceAfterConstructFixerTest.php
index 80cc31de0..22598f8ad 100644
--- a/tests/Fixer/LanguageConstruct/SingleSpaceAfterConstructFixerTest.php
+++ b/tests/Fixer/LanguageConstruct/SingleSpaceAfterConstructFixerTest.php
@@ -2941,6 +2941,7 @@ public function provideCommentsCases()
 new Dummy(/* a */);
 new Dummy(/** b */);
 foo(/* c */);
+foo($a /* d */, $b);
 $arr = [/* empty */];
 ',
         ];
diff --git a/tests/Tokenizer/TokensTest.php b/tests/Tokenizer/TokensTest.php
index c85cfa39a..b71280377 100644
--- a/tests/Tokenizer/TokensTest.php
+++ b/tests/Tokenizer/TokensTest.php
@@ -337,7 +337,7 @@ public function bar()
 PHP;
 
         $tokens = Tokens::fromCode($source);
-        [$fooIndex, $barIndex] = array_keys($tokens->findGivenKind(T_PUBLIC));
+        list($fooIndex, $barIndex) = array_keys($tokens->findGivenKind(T_PUBLIC));
 
         $tokens->clearRange($fooIndex, $barIndex - 1);