Browse Source

Use @PHP71Migration rules

Kuba Werłos 3 years ago
parent
commit
229b44c3d5

+ 1 - 0
.php-cs-fixer.dist.php

@@ -36,6 +36,7 @@ $config = new PhpCsFixer\Config();
 $config
     ->setRiskyAllowed(true)
     ->setRules([
+        '@PHP71Migration' => true,
         '@PHP71Migration:risky' => true,
         '@PHPUnit75Migration:risky' => true,
         '@PhpCsFixer' => true,

+ 1 - 1
src/AbstractFunctionReferenceFixer.php

@@ -52,7 +52,7 @@ abstract class AbstractFunctionReferenceFixer extends AbstractFixer
         }
 
         // translate results for humans
-        list($functionName, $openParenthesis) = array_keys($matches);
+        [$functionName, $openParenthesis] = array_keys($matches);
 
         $functionsAnalyzer = new FunctionsAnalyzer();
 

+ 1 - 1
src/AbstractNoUselessElseFixer.php

@@ -37,7 +37,7 @@ abstract class AbstractNoUselessElseFixer extends AbstractFixer
         do {
             // Check if all 'if', 'else if ' and 'elseif' blocks above this 'else' always end,
             // if so this 'else' is overcomplete.
-            list($previousBlockStart, $previousBlockEnd) = $this->getPreviousBlock($tokens, $previousBlockStart);
+            [$previousBlockStart, $previousBlockEnd] = $this->getPreviousBlock($tokens, $previousBlockStart);
 
             // short 'if' detection
             $previous = $previousBlockEnd;

+ 1 - 1
src/Cache/FileHandler.php

@@ -99,7 +99,7 @@ final class FileHandler implements FileHandlerInterface
             $error = error_get_last();
 
             throw new IOException(
-                sprintf('Failed to write file "%s", "%s".', $this->file, isset($error['message']) ? $error['message'] : 'no reason available'),
+                sprintf('Failed to write file "%s", "%s".', $this->file, $error['message'] ?? 'no reason available'),
                 0,
                 null,
                 $this->file

+ 2 - 2
src/DocBlock/DocBlock.php

@@ -86,7 +86,7 @@ final class DocBlock
      */
     public function getLine(int $pos): ?Line
     {
-        return isset($this->lines[$pos]) ? $this->lines[$pos] : null;
+        return $this->lines[$pos] ?? null;
     }
 
     /**
@@ -182,7 +182,7 @@ final class DocBlock
     {
         $annotations = $this->getAnnotations();
 
-        return isset($annotations[$pos]) ? $annotations[$pos] : null;
+        return $annotations[$pos] ?? null;
     }
 
     /**

+ 1 - 1
src/Doctrine/Annotation/Tokens.php

@@ -248,7 +248,7 @@ final class Tokens extends \SplFixedArray
         $this->setSize($this->getSize() + 1);
 
         for ($i = $this->getSize() - 1; $i > $index; --$i) {
-            $this[$i] = isset($this[$i - 1]) ? $this[$i - 1] : new Token();
+            $this[$i] = $this[$i - 1] ?? new Token();
         }
 
         $this[$index] = $token;

+ 1 - 1
src/Fixer/Alias/MbStrFunctionsFixer.php

@@ -117,7 +117,7 @@ $a = substr_count($a, $b);
                     continue 2;
                 }
 
-                list($functionName, $openParenthesis, $closeParenthesis) = $boundaries;
+                [$functionName, $openParenthesis, $closeParenthesis] = $boundaries;
                 $count = $argumentsAnalyzer->countArguments($tokens, $openParenthesis, $closeParenthesis);
                 if (!\in_array($count, $functionReplacement['argumentCount'], true)) {
                     continue 2;

+ 1 - 1
src/Fixer/Alias/NoAliasFunctionsFixer.php

@@ -229,7 +229,7 @@ mbereg_search_getregs();
             }
 
             if (\is_array($this->aliases[$tokenContent])) {
-                list($alias, $numberOfArguments) = $this->aliases[$tokenContent];
+                [$alias, $numberOfArguments] = $this->aliases[$tokenContent];
 
                 $count = $argumentsAnalyzer->countArguments($tokens, $openParenthesis, $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $openParenthesis));
 

+ 1 - 1
src/Fixer/Alias/RandomApiMigrationFixer.php

@@ -112,7 +112,7 @@ final class RandomApiMigrationFixer extends AbstractFunctionReferenceFixer imple
                     continue 2;
                 }
 
-                list($functionName, $openParenthesis, $closeParenthesis) = $boundaries;
+                [$functionName, $openParenthesis, $closeParenthesis] = $boundaries;
                 $count = $argumentsAnalyzer->countArguments($tokens, $openParenthesis, $closeParenthesis);
 
                 if (!\in_array($count, $functionReplacement['argumentCount'], true)) {

+ 1 - 1
src/Fixer/Basic/NonPrintableCharacterFixer.php

@@ -128,7 +128,7 @@ final class NonPrintableCharacterFixer extends AbstractFixer implements Configur
         $replacements = [];
         $escapeSequences = [];
 
-        foreach ($this->symbolsReplace as $character => list($replacement, $codepoint)) {
+        foreach ($this->symbolsReplace as $character => [$replacement, $codepoint]) {
             $replacements[$character] = $replacement;
             $escapeSequences[$character] = '\u{'.$codepoint.'}';
         }

Some files were not shown because too many files changed in this diff