Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"nikic/php-parser": "^4.18",
"php-di/php-di": "^7.0.1",
"slevomat/coding-standard": "^8.10.0",
"squizlabs/php_codesniffer": "^3.7.2",
"squizlabs/php_codesniffer": "^3.9.0",
"symfony/console": " ^6.2.8",
"symfony/event-dispatcher": "^6.2.2",
"symfony/filesystem": " ^6.2.0",
Expand Down
45 changes: 16 additions & 29 deletions config/phpcs/ZooRoyal/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,13 @@
<rule ref="PEAR.WhiteSpace.ScopeClosingBrace"/>

<rule ref="SlevomatCodingStandard.Arrays.TrailingArrayComma"/>
<rule ref="SlevomatCodingStandard.Attributes.AttributeAndTargetSpacing"/>
<rule ref="SlevomatCodingStandard.Attributes.DisallowAttributesJoining"/>
<rule ref="SlevomatCodingStandard.Attributes.DisallowMultipleAttributesPerLine"/>
<rule ref="SlevomatCodingStandard.Attributes.RequireAttributeAfterDocComment"/>
<rule ref="SlevomatCodingStandard.Classes.BackedEnumTypeSpacing"/>
<rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility"/>
<rule ref="SlevomatCodingStandard.Classes.ClassMemberSpacing"/>
<!--<rule ref="SlevomatCodingStandard.Classes.RequireConstructorPropertyPromotion"/>-->
<rule ref="SlevomatCodingStandard.Classes.ClassStructure">
<properties>
<property name="groups" type="array">
Expand All @@ -139,6 +140,7 @@
</rule>
<rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference"/>
<rule ref="SlevomatCodingStandard.Classes.PropertyDeclaration"/>
<rule ref="SlevomatCodingStandard.Classes.RequireConstructorPropertyPromotion"/>
<rule ref="SlevomatCodingStandard.Commenting.DeprecatedAnnotationDeclaration"/>
<rule ref="SlevomatCodingStandard.Commenting.DisallowCommentAfterCode"/>
<rule ref="SlevomatCodingStandard.Commenting.EmptyComment"/>
Expand Down Expand Up @@ -171,10 +173,11 @@
<rule ref="SlevomatCodingStandard.ControlStructures.LanguageConstructWithParentheses"/>
<rule ref="SlevomatCodingStandard.ControlStructures.NewWithParentheses"/>
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceEqualOperator"/>
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullSafeObjectOperator"/>
<rule ref="SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn"/>
<rule ref="SlevomatCodingStandard.Exceptions.DeadCatch"/>
<!--<rule ref="SlevomatCodingStandard.Exceptions.RequireNonCapturingCatch"/>-->
<rule ref="SlevomatCodingStandard.Functions.ArrowFunctionDeclaration">
<rule ref="SlevomatCodingStandard.Exceptions.RequireNonCapturingCatch"/>
<rule ref="SlevomatCodingStandard.Functions.ArrowFunctionDeclaration">
<properties>
<property name="spacesCountAfterKeyword" value="0"/>
<property name="spacesCountBeforeArrow" value="1"/>
Expand All @@ -183,7 +186,7 @@
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Functions.DisallowEmptyFunction"/>
<!-- <rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInCall"/>-->
<!--<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInCall"/>-->
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInClosureUse"/>
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInDeclaration"/>
<rule ref="SlevomatCodingStandard.Functions.StaticClosure"/>
Expand All @@ -206,6 +209,7 @@
<rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash"/>
<rule ref="SlevomatCodingStandard.Namespaces.UseFromSameNamespace"/>
<rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators"/>
<rule ref="SlevomatCodingStandard.PHP.UselessSemicolon"/>
<rule ref="SlevomatCodingStandard.TypeHints.DisallowArrayTypeHintSyntax"/>
<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
<properties>
Expand All @@ -217,34 +221,17 @@
<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints"/>
<rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"/>
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing"/>
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint">
<properties>
<property name="enableMixedTypeHint" type="bool" value="false"/>
<property name="enableUnionTypeHint" type="bool" value="false"/>
<property name="enableIntersectionTypeHint" type="bool" value="false"/>
<property name="enableStandaloneNullTrueFalseTypeHints" type="bool" value="false"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint">
<properties>
<property name="enableMixedTypeHint" type="bool" value="false"/>
<property name="enableUnionTypeHint" type="bool" value="false"/>
<property name="enableIntersectionTypeHint" type="bool" value="false"/>
<property name="enableStandaloneNullTrueFalseTypeHints" type="bool" value="false"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint">
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint"/>
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint"/>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint"/>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing"/>
<rule ref="SlevomatCodingStandard.TypeHints.UnionTypeHintFormat">
<properties>
<property name="enableStaticTypeHint" type="bool" value="false"/>
<property name="enableMixedTypeHint" type="bool" value="false"/>
<property name="enableUnionTypeHint" type="bool" value="false"/>
<property name="enableIntersectionTypeHint" type="bool" value="false"/>
<property name="enableIntersectionTypeHint" type="bool" value="false"/>
<property name="enableNeverTypeHint" type="bool" value="false"/>
<property name="enableStandaloneNullTrueFalseTypeHints" type="bool" value="false"/>
<property name="withSpaces" type="bool" value="false"/>
<property name="shortNullable" type="bool" value="true"/>
<property name="nullPosition" type="bool" value="last"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing"/>
<!--
https://packagist.org/packages/bmitch/codor are planed for PHP > 7.0

Expand Down
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
Loading