Skip to content

Commit

Permalink
chore: minor code cleanup (PHP-CS-Fixer#7607)
Browse files Browse the repository at this point in the history
  • Loading branch information
keradus authored and danog committed Feb 2, 2024
1 parent 5ef4303 commit da3118e
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Doctrine/Annotation/DocLexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ final class DocLexer

private int $peek = 0;

private ?string $regex;
private ?string $regex = null;

public function setInput(string $input): void
{
Expand Down
3 changes: 1 addition & 2 deletions src/Fixer/Alias/BacktickToShellExecFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions src/Tokenizer/Analyzer/Analysis/TypeAnalysis.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,14 @@ final class TypeAnalysis implements StartEndTokenAwareAnalysis

private int $endIndex;

private bool $nullable;
private bool $nullable = false;

/**
* @param ($startIndex is null ? null : int) $endIndex
*/
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);
Expand Down
2 changes: 1 addition & 1 deletion tests/Runner/RunnerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
3 changes: 1 addition & 2 deletions tests/Test/AbstractFixerTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down

0 comments on commit da3118e

Please sign in to comment.