Browse Source

chore: minor code cleanup (#7607)

Dariusz Rumiński 1 year ago
parent
commit
56b8635b08

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

@@ -75,7 +75,7 @@ final class DocLexer
 
     private int $peek = 0;
 
-    private ?string $regex;
+    private ?string $regex = null;
 
     public function setInput(string $input): void
     {

+ 1 - 2
src/Fixer/Alias/BacktickToShellExecFixer.php

@@ -96,8 +96,7 @@ final class BacktickToShellExecFixer extends AbstractFixer
         // Track indices for final override
         ksort($backtickTokens);
         $openingBacktickIndex = key($backtickTokens);
-        end($backtickTokens);
-        $closingBacktickIndex = key($backtickTokens);
+        $closingBacktickIndex = array_key_last($backtickTokens);
 
         // Strip enclosing backticks
         array_shift($backtickTokens);

+ 1 - 2
src/Tokenizer/Analyzer/Analysis/TypeAnalysis.php

@@ -57,7 +57,7 @@ final class TypeAnalysis implements StartEndTokenAwareAnalysis
 
     private int $endIndex;
 
-    private bool $nullable;
+    private bool $nullable = false;
 
     /**
      * @param ($startIndex is null ? null : int) $endIndex
@@ -65,7 +65,6 @@ final class TypeAnalysis implements StartEndTokenAwareAnalysis
     public function __construct(string $name, int $startIndex = null, int $endIndex = null)
     {
         $this->name = $name;
-        $this->nullable = false;
 
         if (str_starts_with($name, '?')) {
             $this->name = substr($name, 1);

+ 1 - 1
tests/Runner/RunnerTest.php

@@ -166,7 +166,7 @@ final class RunnerTest extends TestCase
     private function createDifferDouble(): DifferInterface
     {
         return new class() implements DifferInterface {
-            public ?\SplFileInfo $passedFile;
+            public ?\SplFileInfo $passedFile = null;
 
             public function diff(string $old, string $new, \SplFileInfo $file = null): string
             {

+ 1 - 2
tests/Test/AbstractFixerTestCase.php

@@ -207,8 +207,7 @@ abstract class AbstractFixerTestCase extends TestCase
 
         if ($fixerIsConfigurable) {
             if (isset($configSamplesProvided['default'])) {
-                reset($configSamplesProvided);
-                self::assertSame('default', key($configSamplesProvided), sprintf('[%s] First sample must be for the default configuration.', $fixerName));
+                self::assertSame('default', array_key_first($configSamplesProvided), sprintf('[%s] First sample must be for the default configuration.', $fixerName));
             } elseif (!isset($this->allowedFixersWithoutDefaultCodeSample[$fixerName])) {
                 self::assertArrayHasKey($fixerName, $this->allowedRequiredOptions, sprintf('[%s] Has no sample for default configuration.', $fixerName));
             }