diff --git a/src/Doctrine/Annotation/DocLexer.php b/src/Doctrine/Annotation/DocLexer.php index b451d00bfac..ef1878ea241 100644 --- a/src/Doctrine/Annotation/DocLexer.php +++ b/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 { diff --git a/src/Fixer/Alias/BacktickToShellExecFixer.php b/src/Fixer/Alias/BacktickToShellExecFixer.php index 351cdad72a1..b59457eae9b 100644 --- a/src/Fixer/Alias/BacktickToShellExecFixer.php +++ b/src/Fixer/Alias/BacktickToShellExecFixer.php @@ -96,8 +96,7 @@ private function fixBackticks(Tokens $tokens, array $backtickTokens): void // 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); diff --git a/src/Tokenizer/Analyzer/Analysis/TypeAnalysis.php b/src/Tokenizer/Analyzer/Analysis/TypeAnalysis.php index a332b244271..27bf893f384 100644 --- a/src/Tokenizer/Analyzer/Analysis/TypeAnalysis.php +++ b/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); diff --git a/tests/Runner/RunnerTest.php b/tests/Runner/RunnerTest.php index 13c9c57516f..c1195119a21 100644 --- a/tests/Runner/RunnerTest.php +++ b/tests/Runner/RunnerTest.php @@ -166,7 +166,7 @@ public function testThatDiffedFileIsPassedToDiffer(): void 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 { diff --git a/tests/Test/AbstractFixerTestCase.php b/tests/Test/AbstractFixerTestCase.php index ed699561e73..01269dc6a6a 100644 --- a/tests/Test/AbstractFixerTestCase.php +++ b/tests/Test/AbstractFixerTestCase.php @@ -207,8 +207,7 @@ final public function testFixerDefinitions(): void 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)); }