Skip to content

Commit

Permalink
Apply rules to coding-standard
Browse files Browse the repository at this point in the history
  • Loading branch information
rdss-sknott committed Feb 19, 2024
1 parent 9cf1564 commit d1efee1
Show file tree
Hide file tree
Showing 15 changed files with 47 additions and 47 deletions.
6 changes: 3 additions & 3 deletions src/main/php/CommandLine/FileSearch/FastCachedFileSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function listFolderFiles(
$dir = $path->getPathname();
$exclusionPaths = array_map(
static fn(EnhancedFileInfo $exclusion) => $exclusion->getPathname(),
$exclusions
$exclusions,
);

$resultingPathnames = $this->doTheSearch($fileName, $dir, $exclusionPaths, $minDepth, $maxDepth, 0);
Expand Down Expand Up @@ -100,7 +100,7 @@ private function writeDirectoryToCache(string $dir): void

unset(
$filenamesInDirectory[array_search('.', $filenamesInDirectory, true)],
$filenamesInDirectory[array_search('..', $filenamesInDirectory, true)]
$filenamesInDirectory[array_search('..', $filenamesInDirectory, true)],
);

$this->fileSystemCache[$dir] = $filenamesInDirectory;
Expand Down Expand Up @@ -148,7 +148,7 @@ private function searchForFileInCache(
$exclusions,
$minDepth,
$maxDepth,
$depthNow + 1
$depthNow + 1,
);

$result = [...$result, ...$subFolderResults];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function getLocalPhpVersionConstraint(): string
$composerConfig = json_decode(
file_get_contents($composerFile->getRealPath()),
associative: true,
flags: JSON_THROW_ON_ERROR
flags: JSON_THROW_ON_ERROR,
);

$phpVersionConstraint = $composerConfig['config']['platform']['php']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected function compile(): void
$this->buildTargetingString(),
$this->buildVerbosityString(),
$this->buildFixingString(),
$this->buildPrefixString()
$this->buildPrefixString(),
);

$this->command = $sprintfCommand;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected function compile(): void
$this->buildTargetingString(),
$this->buildVerbosityString(),
$this->buildFixingString(),
$this->buildPrefixString()
$this->buildPrefixString(),
);

$this->command = $sprintfCommand;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct()
try {
// phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
$filesUnfiltered = @scandir($path);
} catch (DirException $exception) {
} catch (DirException) {
return;
}

Expand Down Expand Up @@ -85,7 +85,7 @@ public function process(File $phpcsFile, $stackPtr): void
if (!isset($this->functionNames)) {
throw new AssertionException(
'No function names found! Did you forget to install thecodingmachine/Safe?',
1684240278
1684240278,
);
}

Expand All @@ -97,7 +97,7 @@ public function process(File $phpcsFile, $stackPtr): void
$this->assertGlobalFunctionCall($phpcsFile, $stackPtr);
$this->assertFunctionProvidedBySafe($tokens[$stackPtr]['content']);
$this->assertFunctionUnused($phpcsFile, $functionName);
} catch (AssertionException $exception) {
} catch (AssertionException) {
// If this is the case we found no Safe function. Continue...
return;
}
Expand Down Expand Up @@ -127,7 +127,7 @@ private function assertGlobalFunctionCall(File $phpcsFile, int $stackPtr): void
in_array(
$phpcsFile->getTokens()[$previousPointer]['code'],
[T_OBJECT_OPERATOR, T_DOUBLE_COLON, T_FUNCTION],
true
true,
)
) {
throw new AssertionException('Token is not a global function call!', 1684230171);
Expand Down Expand Up @@ -163,7 +163,7 @@ private function addErrorToPhpcsFile(File $phpcsFile, int $stackPtr, string $fun
'Function \'' . $functionName . '\' is not imported from Safe! Add \'' . $missingUseStatement
. '\' to your uses.',
$stackPtr,
'FunctionNotImported'
'FunctionNotImported',
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public function searchForFiles(): void
'tests/Functional/Sniffs/Rdss/Standards/ZooRoyal/Sniffs/TypeHints/Fixtures/ReturnType/.dontSniffPHP',
'tests/Functional/Sniffs/Rdss/Standards/ZooRoyal/Sniffs/Safe/fixtures/.dontSniffPHP',
'tests/System/fixtures/complete/.dontSniffPHP',
])
)
]),
),
);
}

Expand Down Expand Up @@ -79,9 +79,9 @@ public function searchForFilesIgnoringExcludedDirs(): void
'tests/Functional/Sniffs/Rdss/Standards/ZooRoyal/Sniffs/TypeHints/Fixtures/ReturnType/.dontSniffPHP',
'tests/Functional/Sniffs/Rdss/Standards/ZooRoyal/Sniffs/Safe/fixtures/.dontSniffPHP',
'tests/System/fixtures/complete/.dontSniffPHP',
])
)
)
]),
),
),
);
}

Expand All @@ -100,7 +100,7 @@ public function searchForFilesIgnoringBelowMinDepth(): void
Matchers::not(
Matchers::containsInAnyOrder([
'tests/System/fixtures/complete/.dontSniffPHP',
])
]),
),
);
MatcherAssert::assertThat(
Expand All @@ -111,7 +111,7 @@ public function searchForFilesIgnoringBelowMinDepth(): void
'tests/Functional/Sniffs/Rdss/Standards/ZooRoyal/Sniffs/TypeHints/Fixtures/ReturnType/.dontSniffPHP',
'tests/Functional/Sniffs/Rdss/Standards/ZooRoyal/Sniffs/Safe/fixtures/.dontSniffPHP',
'src/main/php/Sniffs/PHPCodeSniffer/.dontSniffPHP',
)
),
);
}

Expand Down Expand Up @@ -147,8 +147,8 @@ public function searchForFilesExcludedByPreviousSearch(): void
MatcherAssert::assertThat(
$result,
Matchers::hasValue(
HasProperty::hasProperty('relativePathname', 'tests/System/fixtures/complete/.dontSniffPHP')
)
HasProperty::hasProperty('relativePathname', 'tests/System/fixtures/complete/.dontSniffPHP'),
),
);
}

Expand All @@ -166,7 +166,7 @@ public function searchStopsAtMaxDepth(): void
$resultPaths,
Matchers::containsInAnyOrder([
'tests/System/fixtures/complete/.dontSniffPHP',
])
]),
);
MatcherAssert::assertThat(
$resultPaths,
Expand All @@ -177,8 +177,8 @@ public function searchStopsAtMaxDepth(): void
'tests/Functional/Sniffs/Rdss/Standards/ZooRoyal/Sniffs/TypeHints/Fixtures/ReturnType/.dontSniffPHP',
'tests/Functional/Sniffs/Rdss/Standards/ZooRoyal/Sniffs/Safe/fixtures/.dontSniffPHP',
'src/main/php/Sniffs/PHPCodeSniffer/.dontSniffPHP',
)
)
),
),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ public function nagIfSafeIsNotInstalled(): void

$this->filesystem->copy(
__DIR__ . '/fixtures/GoodPhp.php',
$installationPath . '/src/GoodPhp.php'
$installationPath . '/src/GoodPhp.php',
);

$realpath = realpath(__DIR__ . '/../../../../../../../');
$processCodingStandard = new Process(
['bash', $realpath . '/run-coding-standard.sh', 'sca:sniff'],
$installationPath
$installationPath,
);
$processCodingStandard->setTimeout(480);
$processCodingStandard->setIdleTimeout(120);
Expand Down
2 changes: 1 addition & 1 deletion tests/System/Stylelint/RunStylelintWithConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function makeSureGoodScssPasses(): iterable
__DIR__ . '/../../../node_modules/.bin/stylelint',
'--config=' . __DIR__ . '/../../../config/stylelint/.stylelintrc',
__DIR__ . '/../fixtures/stylelint/GoodCode.scss',
]
],
);

yield $process->start();
Expand Down
2 changes: 1 addition & 1 deletion tests/Tools/TestEnvironmentInstallation.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private function installComposer(): void
if ($this->filesystem->exists($vendorBinSourceDirectory)) {
$this->filesystem->mirror(
$vendorBinSourceDirectory,
$this->installationPath . '/vendor-bin'
$this->installationPath . '/vendor-bin',
);

(new Process(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function findFilesWithInvalidTargetThrowsException(): void
{
$mockedTargetBranchInput = 'blaaaa';
$this->expectExceptionObject(
new InvalidArgumentException('Target ' . $mockedTargetBranchInput . ' is no valid commit-ish.', 1553766210)
new InvalidArgumentException('Target ' . $mockedTargetBranchInput . ' is no valid commit-ish.', 1553766210),
);
$this->subjectParameters[GitInputValidator::class]->shouldReceive('isCommitishValid')
->with($mockedTargetBranchInput)->andReturn(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected function setUp(): void
$this->subject = new ComposerInterpreter(
$this->mockedEnvironment,
$this->mockedEnhancedFileInfoFactory,
$this->mockedConstraintToVersionConverter
$this->mockedConstraintToVersionConverter,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function setUp(): void

$this->subject = new MinimalVersionDecorator(
$this->mockedConstraintToVersionConverter,
$this->mockedComposerInterpreter
$this->mockedComposerInterpreter,
);
}

Expand Down Expand Up @@ -82,7 +82,7 @@ public function decorate(): void
$this->mockedTerminalCommand->expects()->setMinimalPhpVersion('7.4.33')->twice();
$this->mockedOutput->expects()->writeln(
'<info>Targeted minimal PHP version is 7.4.33</info>' . PHP_EOL,
OutputInterface::VERBOSITY_VERBOSE
OutputInterface::VERBOSITY_VERBOSE,
)->twice();

$this->subject->decorate($this->mockedEvent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,23 +112,23 @@ public function terminalCommandCompilationDataProvider(): array
'excluded' => [
new EnhancedFileInfo(
self::FORGED_ABSOLUTE_ROOT . '/a',
self::FORGED_ABSOLUTE_ROOT
self::FORGED_ABSOLUTE_ROOT,
),
new EnhancedFileInfo(
self::FORGED_ABSOLUTE_ROOT . '/b',
self::FORGED_ABSOLUTE_ROOT
self::FORGED_ABSOLUTE_ROOT,
),
],
'extensions' => ['qweasd', 'argh'],
'fixingMode' => true,
'targets' => [
new EnhancedFileInfo(
self::FORGED_ABSOLUTE_ROOT . '/c',
self::FORGED_ABSOLUTE_ROOT
self::FORGED_ABSOLUTE_ROOT,
),
new EnhancedFileInfo(
self::FORGED_ABSOLUTE_ROOT . '/d',
self::FORGED_ABSOLUTE_ROOT
self::FORGED_ABSOLUTE_ROOT,
),
],
'verbosityLevel' => OutputInterface::VERBOSITY_QUIET,
Expand All @@ -155,11 +155,11 @@ public function terminalCommandCompilationDataProvider(): array
'excluded' => [
new EnhancedFileInfo(
self::FORGED_ABSOLUTE_ROOT . '/a',
self::FORGED_ABSOLUTE_ROOT
self::FORGED_ABSOLUTE_ROOT,
),
new EnhancedFileInfo(
self::FORGED_ABSOLUTE_ROOT . '/b',
self::FORGED_ABSOLUTE_ROOT
self::FORGED_ABSOLUTE_ROOT,
),
],
],
Expand Down Expand Up @@ -197,11 +197,11 @@ public function terminalCommandCompilationDataProvider(): array
'targets' => [
new EnhancedFileInfo(
self::FORGED_ABSOLUTE_ROOT . '/c',
self::FORGED_ABSOLUTE_ROOT
self::FORGED_ABSOLUTE_ROOT,
),
new EnhancedFileInfo(
self::FORGED_ABSOLUTE_ROOT . '/d',
self::FORGED_ABSOLUTE_ROOT
self::FORGED_ABSOLUTE_ROOT,
),
],
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected function setUp(): void
$this->subject = new PHPStanConfigGenerator(
$this->mockedFilesystem,
$mockedEnvironment,
$this->mockedPhpVersionConverter
$this->mockedPhpVersionConverter,
);
}

Expand Down Expand Up @@ -112,7 +112,7 @@ private function buildConfigMatcher(): Matcher
H::hasItems(
$this->mockedVendorDirectory . '/hamcrest/hamcrest-php/hamcrest/Hamcrest.php',
$this->mockedVendorDirectory . '/sebastianknott/hamcrest-object-accessor/src/functions.php',
$this->mockedVendorDirectory . '/mockery/mockery/library/helpers.php'
$this->mockedVendorDirectory . '/mockery/mockery/library/helpers.php',
),
);

Expand Down Expand Up @@ -151,7 +151,7 @@ private function prepareMockedFilesystem(): void
$this->mockedRootDirectory . '/custom/plugins',
$this->mockedVendorDirectory . '/deployer/deployer',
$this->mockedVendorDirectory . '-bin',
)
),
)->andReturn(false);

$this->mockedFilesystem->shouldReceive('exists')->times(6)
Expand All @@ -162,8 +162,8 @@ private function prepareMockedFilesystem(): void
$this->mockedVendorDirectory,
$this->mockedVendorDirectory . '/hamcrest/hamcrest-php',
$this->mockedVendorDirectory . '/sebastianknott/hamcrest-object-accessor',
$this->mockedVendorDirectory . '/mockery/mockery'
)
$this->mockedVendorDirectory . '/mockery/mockery',
),
)->andReturn(true);

$this->mockedFilesystem->shouldReceive('dumpFile')->once()
Expand All @@ -173,7 +173,7 @@ private function prepareMockedFilesystem(): void
$configuration = Neon::decode($parameter);
MatcherAssert::assertThat($configuration, $this->buildConfigMatcher());
return true;
})
}),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public function notFoundSafeLibrarySkippsProcess(): void
$this->expectExceptionObject(
new RuntimeException(
'No function names found! Did you forget to install thecodingmachine/Safe?',
1684240278
)
1684240278,
),
);

$subject = new CheckSafeFunctionUsageSniff();
Expand Down

0 comments on commit d1efee1

Please sign in to comment.