Skip to content

Commit c2190f2

Browse files
committed
PHPCS 4.0 compat
1 parent 1282222 commit c2190f2

File tree

7 files changed

+20
-12
lines changed

7 files changed

+20
-12
lines changed

Proton/Sniffs/Spacing/ArrowFunctionSpacingSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ public function process(File $phpcsFile, $stackPtr): void
2424
{
2525
$tokens = $phpcsFile->getTokens();
2626

27-
if ($tokens[$stackPtr]['code'] === T_FN && $tokens[$stackPtr + 1]['code'] !== T_WHITESPACE) {
27+
if ($tokens[$stackPtr]['code'] === T_FN && $tokens[$stackPtr + 1]['code'] !== T_OPEN_PARENTHESIS) {
2828
$phpcsFile->addError(
29-
'The fn arrow function token should always be followed by a space.',
29+
'The fn arrow function token should never be followed by a space.',
3030
$stackPtr,
3131
'Found',
3232
);

Proton/ruleset.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<?xml version="1.0"?>
2-
<ruleset name="Proton">
2+
<ruleset
3+
name="Proton"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:noNamespaceSchemaLocation="../../vendor/squizlabs/php_codesniffer/phpcs.xsd"
6+
>
37
<description>
48
Proton PHP Coding Standard
59
</description>
@@ -123,7 +127,6 @@
123127

124128
<!-- # Slevomat Coding Standard -->
125129
<!-- https://github.com/slevomat/coding-standard -->
126-
<config name="installed_paths" value="../../slevomat/coding-standard"/>
127130

128131
<rule ref="SlevomatCodingStandard.PHP.TypeCast"/>
129132
<rule ref="SlevomatCodingStandard.PHP.ShortList"/>
@@ -133,6 +136,7 @@
133136
<property name="ignoreComplexTernaryConditions" value="1"/>
134137
</properties>
135138
</rule>
139+
<rule ref="SlevomatCodingStandard.PHP.UselessParentheses"/>
136140
<!-- Require usage of constructor property promotion -->
137141
<rule ref="SlevomatCodingStandard.Classes.RequireConstructorPropertyPromotion"/>
138142
<!-- Forbid uses of multiple traits separated by comma -->

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
},
1818
"require": {
1919
"php": "^8.0",
20-
"slevomat/coding-standard": "^8.0",
21-
"squizlabs/php_codesniffer": "^3.7"
20+
"slevomat/coding-standard": "^8.22",
21+
"squizlabs/php_codesniffer": "^4.0"
2222
},
2323
"license": "MIT",
2424
"config": {

phpcs.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Proton PHP Coding Standard
55
</description>
66

7-
<config name="installed_paths" value="Proton"/>
7+
<arg name="basepath" value="." />
88

99
<rule ref="Proton"/>
1010

tests/correct/ClassOk.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function __construct(array $config)
3737

3838
phpinfo2();
3939

40-
call_user_func(fn () => {});
40+
call_user_func(fn() => {});
4141
}
4242

4343
public function ping(Request $request): mixed

tests/expected_csv.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
Line,Column,Type,Source
2+
7,1,error,Generic.NamingConventions.TraitNameSuffix.Missing
3+
7,1,error,Generic.NamingConventions.InterfaceNameSuffix.Missing
24
4,10,error,PSR2.Files.EndFileNewline.NoneFound
35
3,1,error,SlevomatCodingStandard.Commenting.EmptyComment.EmptyComment
46
1,1,error,SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing
5-
7,1,error,Generic.NamingConventions.TraitNameSuffix.Missing
6-
7,1,error,Generic.NamingConventions.InterfaceNameSuffix.Missing
77
6,9,error,Generic.Arrays.ArrayIndent.KeyIncorrect
88
21,1,error,Generic.Files.InlineHTML.Found
99
17,17,error, use === instead."
@@ -16,6 +16,7 @@ Line,Column,Type,Source
1616
53,9,error,SlevomatCodingStandard.Commenting.EmptyComment.EmptyComment
1717
52,9,error,Proton.Commenting.InlineCommentStartsWithSpace.WrongStyle
1818
51,9,error,SlevomatCodingStandard.Commenting.EmptyComment.EmptyComment
19+
49,9,error,Proton.Commenting.InlineCommentStartsWithSpace.WrongStyle
1920
49,9,error,SlevomatCodingStandard.Commenting.EmptyComment.EmptyComment
2021
48,9,error,SlevomatCodingStandard.Commenting.EmptyComment.EmptyComment
2122
47,9,error,PEAR.Commenting.InlineComment.WrongStyle
@@ -24,6 +25,7 @@ Line,Column,Type,Source
2425
44,9,error,Proton.Commenting.InlineCommentStartsWithSpace.WrongStyle
2526
40,37,error,SlevomatCodingStandard.Attributes.RequireAttributeAfterDocComment.AttributeBeforeDocComment
2627
34,5,error,SlevomatCodingStandard.Attributes.RequireAttributeAfterDocComment.AttributeBeforeDocComment
28+
3,24,error,PSR12.Files.FileHeader.SpacingAfterDeclareBlock
2729
3,1,error, found 2."
2830
29,9,error,Proton.Commenting.InlineCommentStartsWithSpace.WrongStyle
2931
24,8,error,SlevomatCodingStandard.Commenting.ForbiddenComments.CommentForbidden
@@ -57,7 +59,7 @@ Line,Column,Type,Source
5759
64,27,error,Squiz.PHP.DisallowMultipleAssignments.FoundInControlStructure
5860
64,16,error, use === instead."
5961
63,62,error,Squiz.Functions.MultiLineFunctionDeclaration.BraceOnSameLine
60-
6,18,error,PSR12.Files.FileHeader.SpacingInsideBlock
62+
6,18,error,PSR12.Files.FileHeader.SpacingInsideUseBlock
6163
6,1,error,SlevomatCodingStandard.Namespaces.UnusedUses.UnusedUse
6264
58,60,error,SlevomatCodingStandard.TypeHints.DNFTypeHintFormat.NullTypeHintNotOnLastPosition
6365
58,32,error,SlevomatCodingStandard.TypeHints.DNFTypeHintFormat.NullTypeHintNotOnLastPosition
@@ -102,10 +104,12 @@ Line,Column,Type,Source
102104
16,16,error,PSR12.Traits.UseDeclaration.MultipleImport
103105
14,5,warning,PSR12.Properties.ConstantVisibility.NotFound
104106
12,13,error,SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingAnyTypeHint
107+
12,13,error,SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingAnyTypeHint
105108
12,13,error,Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
106109
12,1,error,Generic.WhiteSpace.DisallowTabIndent.TabsUsed
107110
10,27,error,SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces.IncorrectEmptyLinesAfterOpeningBrace
108111
10,27,error,PSR2.Classes.ClassDeclaration.OpenBraceNewLine
109112
10,27,error,PSR12.Classes.OpeningBraceSpace.Found
110113
10,16,error,Generic.NamingConventions.AbstractClassNamePrefix.Missing
111114
1,1,error,SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing
115+
1,1,error,PSR12.Files.FileHeader.SpacingAfterTagBlock

tests/wrong/Class1.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function __construct()
2828
$this->test = new class() {
2929
};
3030

31-
call_user_func(fn() => {});
31+
call_user_func(fn () => {});
3232
}
3333

3434
private function unused() {

0 commit comments

Comments
 (0)