Skip to content

Commit 36bc5bf

Browse files
laurensottoLaurens
andauthored
Merge current expirimental rules to main ruleset (#69)
* Merge current expirimental rules to main ruleset * Add allow-plugins preset to composer.json * Solve phpcs errors Co-authored-by: Laurens <laurens.otto@hva.nl>
1 parent 4fa465a commit 36bc5bf

22 files changed

Lines changed: 61 additions & 80 deletions

composer.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@
3131
"config": {
3232
"preferred-install": {
3333
"squizlabs/php_codesniffer": "source"
34+
},
35+
"allow-plugins": {
36+
"composer/*": true,
37+
"hostnet/*": true,
38+
"dealerdirect/phpcodesniffer-composer-installer": false
3439
}
3540
},
3641
"extra": {

src/Hostnet/Component/CodeSniffer/Installer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ public function activate(Composer $composer, IOInterface $io): void
6565
$this->io = $io;
6666
}
6767

68-
public function deactivate(Composer $composer, IOInterface $io)
68+
public function deactivate(Composer $composer, IOInterface $io): void
6969
{
7070
}
7171

72-
public function uninstall(Composer $composer, IOInterface $io)
72+
public function uninstall(Composer $composer, IOInterface $io): void
7373
{
7474
}
7575

src/Hostnet/Sniffs/Classes/NoVerticalWhitespaceBetweenUseStatementsSniff.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ public function register(): array
2525
/**
2626
* @param File $phpcs_file
2727
* @param int|bool $stack_ptr
28-
*
29-
* @return void
3028
*/
3129
public function process(File $phpcs_file, $stack_ptr): void
3230
{

src/Hostnet/Sniffs/Classes/UseStatementsAlphabeticallyOrderedSniff.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ public function register(): array
3737
/**
3838
* @param File $phpcs_file
3939
* @param int|bool $stack_ptr
40-
*
41-
* @return void
4240
*/
4341
public function process(File $phpcs_file, $stack_ptr): void
4442
{
@@ -113,8 +111,6 @@ private function fixUseStatements(File $phpcs_file): void
113111
*
114112
* @param File $phpcs_file The file where the token was found.
115113
* @param int $stack_ptr the current position in the stack
116-
*
117-
* @return void
118114
*/
119115
private function createAndCheckStatements(File $phpcs_file, $stack_ptr): void
120116
{

src/Hostnet/Sniffs/Commenting/AtCoversFullyQualifiedNameSniff.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
*/
1515
class AtCoversFullyQualifiedNameSniff extends FileCommentSniff
1616
{
17-
const ERROR_TYPE = 'AtCoversNeedsFQCN';
18-
const ERROR_MESSAGE = 'Covers annotation should use fully qualified class name (it should start with a "\") "%s"';
17+
private const ERROR_TYPE = 'AtCoversNeedsFQCN';
18+
private const ERROR_MESSAGE =
19+
'Covers annotation should use fully qualified class name (it should start with a "\") "%s"';
1920

2021
/**
2122
* @return int[]

src/Hostnet/Sniffs/Commenting/FileCommentCopyrightSniff.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@ private function getCopyrightLine(): string
115115
* @param File $phpcs_file The file being scanned.
116116
* @param int $stack_ptr The position of the current token in the stack passed in $tokens.
117117
* @param int $comment_start Position in the stack where the comment started.
118-
*
119-
* @return void
120118
*/
121119
private function processCopyrightTags(File $phpcs_file, $stack_ptr, $comment_start): void
122120
{
@@ -275,8 +273,6 @@ public function process(File $phpcs_file, $stack_ptr): int
275273
*
276274
* @param File $phpcs_file
277275
* @param array $tags
278-
*
279-
* @return void
280276
*/
281277
protected function processCopyright(File $phpcs_file, array $tags): void
282278
{

src/Hostnet/ruleset.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,27 @@
201201
<!-- Require use of short versions of scalar types (i.e. int instead of integer) -->
202202
<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints"/>
203203

204+
<rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility"/>
205+
206+
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
207+
<exclude phpcbf-only="true" name="SlevomatCodingStandard.Namespaces.UnusedUses.UnusedUse"/>
208+
<properties>
209+
<property name="searchAnnotations" value="true"/>
210+
</properties>
211+
</rule>
212+
213+
<rule ref="SlevomatCodingStandard.TypeHints">
214+
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint"/>
215+
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint"/>
216+
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification"/>
217+
<exclude name="SlevomatCodingStandard.TypeHints.DisallowArrayTypeHintSyntax.DisallowedArrayTypeHintSyntax"/>
218+
<exclude name="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue.NullabilityTypeMissing"/>
219+
<exclude name="SlevomatCodingStandard.TypeHints.DisallowMixedTypeHint.DisallowedMixedTypeHint"/>
220+
<exclude name="SlevomatCodingStandard.Commenting.UselessFunctionDocComment"/>
221+
</rule>
222+
223+
<rule ref="SlevomatCodingStandard.Commenting.UselessInheritDocComment"/>
224+
204225
<!-- Require one space between typehint and variable, require no space between nullability sign and typehint -->
205226
<rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing">
206227
<properties>
@@ -326,4 +347,6 @@
326347
<property name="ignoreBlankLines" value="false"/>
327348
</properties>
328349
</rule>
350+
351+
<rule ref="Squiz.Strings.DoubleQuoteUsage.NotRequired" />
329352
</ruleset>

src/HostnetExperimental/ruleset.xml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,4 @@
22
<ruleset name="HostnetExperimental">
33
<description>The future Hostnet coding standard.</description>
44
<rule ref="Hostnet"/>
5-
<rule ref="Squiz.Strings.DoubleQuoteUsage.NotRequired" />
6-
<rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility"/>
7-
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
8-
<exclude phpcbf-only="true" name="SlevomatCodingStandard.Namespaces.UnusedUses.UnusedUse"/>
9-
<properties>
10-
<property name="searchAnnotations" value="true"/>
11-
</properties>
12-
</rule>
13-
<rule ref="SlevomatCodingStandard.TypeHints">
14-
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint"/>
15-
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint"/>
16-
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification"/>
17-
<exclude name="SlevomatCodingStandard.TypeHints.DisallowArrayTypeHintSyntax.DisallowedArrayTypeHintSyntax"/>
18-
<exclude name="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue.NullabilityTypeMissing"/>
19-
<exclude name="SlevomatCodingStandard.TypeHints.DisallowMixedTypeHint.DisallowedMixedTypeHint"/>
20-
<exclude name="SlevomatCodingStandard.Commenting.UselessFunctionDocComment"/>
21-
</rule>
22-
<rule ref="SlevomatCodingStandard.Commenting.UselessInheritDocComment"/>
235
</ruleset>

test/Hostnet/Tests/Classes/AbstractClassMustBePrefixedWithAbstractUnitTest.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@ class AbstractClassMustBePrefixedWithAbstractUnitTest extends AbstractSniffUnitT
2020
* should represent the number of errors that should occur on that line.
2121
*
2222
* @param string $filename
23-
*
24-
* @return [int => int]
2523
*/
26-
public function getErrorList($filename = null)
24+
public function getErrorList($filename = null): array
2725
{
2826
switch ($filename) {
2927
case 'AbstractClassMustBePrefixedWithAbstractUnitTest.0.inc':
@@ -44,10 +42,8 @@ public function getErrorList($filename = null)
4442
* should represent the number of warnings that should occur on that line.
4543
*
4644
* @param string $filename
47-
*
48-
* @return [int => int]
4945
*/
50-
public function getWarningList($filename = null)
46+
public function getWarningList($filename = null): array
5147
{
5248
return [];
5349
}

test/Hostnet/Tests/Classes/ClassAndNamespaceMustBeInPascalCaseUnitTest.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@ class ClassAndNamespaceMustBeInPascalCaseUnitTest extends AbstractSniffUnitTest
2020
* should represent the number of errors that should occur on that line.
2121
*
2222
* @param string $filename
23-
*
24-
* @return [int => int]
2523
*/
26-
public function getErrorList($filename = null)
24+
public function getErrorList($filename = null): array
2725
{
2826
switch ($filename) {
2927
case 'ClassAndNamespaceMustBeInPascalCaseUnitTest.0.inc':
@@ -48,10 +46,8 @@ public function getErrorList($filename = null)
4846
* should represent the number of warnings that should occur on that line.
4947
*
5048
* @param string $filename
51-
*
52-
* @return [int => int]
5349
*/
54-
public function getWarningList($filename = null)
50+
public function getWarningList($filename = null): array
5551
{
5652
return [];
5753
}

0 commit comments

Comments
 (0)