Skip to content

Commit 7ab7f06

Browse files
committed
added many sniffs from slevomat/coding-standard
1 parent a177fd4 commit 7ab7f06

File tree

3 files changed

+131
-68
lines changed

3 files changed

+131
-68
lines changed

ForwardMedia/Sniffs/CodeAnalysis/EmptyStatementSniff.php

-60
This file was deleted.

ForwardMedia/ruleset.xml

+120-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,130 @@
55
<exclude-pattern>*/typo3/sysext/*</exclude-pattern>
66
<exclude-pattern>*/typo3conf/ext/crawler/*</exclude-pattern>
77
<exclude-pattern>*/typo3conf/ext/direct_mail/*</exclude-pattern>
8+
<exclude-pattern>*/typo3conf/ext/extension_builder/*</exclude-pattern>
89
<exclude-pattern>*/typo3conf/ext/gridelements/*</exclude-pattern>
10+
<exclude-pattern>*/typo3conf/ext/l10nmgr/*</exclude-pattern>
911
<exclude-pattern>*/typo3conf/ext/powermail/*</exclude-pattern>
1012
<exclude-pattern>*/typo3conf/ext/realurl/*</exclude-pattern>
1113

14+
15+
<rule ref="SlevomatCodingStandard.Arrays" />
16+
17+
18+
<rule ref="SlevomatCodingStandard.Commenting">
19+
<!-- TYPO3 extension builder generates multiline doc-comments -->
20+
<exclude name="SlevomatCodingStandard.Commenting.RequireOneLinePropertyDocComment" />
21+
22+
<exclude name="SlevomatCodingStandard.Commenting.DocCommentSpacing" />
23+
</rule>
24+
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenAnnotations">
25+
<properties>
26+
<property name="forbiddenAnnotations" type="array">
27+
<element value="@author" />
28+
<element value="@copyright" />
29+
<element value="@license" />
30+
<element value="@package" />
31+
<element value="@throws" />
32+
<element value="@version" />
33+
</property>
34+
</properties>
35+
</rule>
36+
37+
38+
<rule ref="SlevomatCodingStandard.ControlStructures">
39+
<exclude name="SlevomatCodingStandard.ControlStructures.ControlStructureSpacing" />
40+
<exclude name="SlevomatCodingStandard.ControlStructures.DisallowEmpty" />
41+
<exclude name="SlevomatCodingStandard.ControlStructures.DisallowShortTernaryOperator" />
42+
<exclude name="SlevomatCodingStandard.ControlStructures.NewWithoutParentheses" />
43+
<exclude name="SlevomatCodingStandard.ControlStructures.RequireMultiLineTernaryOperator" />
44+
<exclude name="SlevomatCodingStandard.ControlStructures.RequireYodaComparison" />
45+
</rule>
46+
47+
48+
<rule ref="SlevomatCodingStandard.Classes">
49+
<!-- We use the name suffixes -->
50+
<exclude name="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming" />
51+
<exclude name="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming" />
52+
<exclude name="SlevomatCodingStandard.Classes.SuperfluousExceptionNaming" />
53+
<exclude name="SlevomatCodingStandard.Classes.SuperfluousTraitNaming" />
54+
55+
<!-- This only works in PHP >=7.1 -->
56+
<exclude name="SlevomatCodingStandard.Classes.ClassConstantVisibility" />
57+
</rule>
58+
59+
60+
<rule ref="SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces">
61+
<properties>
62+
<property name="linesCountBeforeClosingBrace" value="0" />
63+
</properties>
64+
</rule>
65+
66+
67+
<rule ref="SlevomatCodingStandard.Exceptions" />
68+
69+
70+
<rule ref="SlevomatCodingStandard.Functions">
71+
<exclude name="SlevomatCodingStandard.Functions.StaticClosure" />
72+
73+
<exclude name="SlevomatCodingStandard.Functions.TrailingCommaInCall" />
74+
75+
<!-- too many occurences because it does not check overwritten methods -->
76+
<exclude name="SlevomatCodingStandard.Functions.UnusedParameter" />
77+
</rule>
78+
79+
80+
<rule ref="SlevomatCodingStandard.Namespaces">
81+
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameInAnnotation" />
82+
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedExceptions" />
83+
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalConstants" />
84+
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalFunctions" />
85+
<exclude name="SlevomatCodingStandard.Namespaces.UseOnlyWhitelistedNamespaces" />
86+
<exclude name="SlevomatCodingStandard.Namespaces.UseSpacing" />
87+
</rule>
88+
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
89+
<properties>
90+
<property name="searchAnnotations" value="true" />
91+
</properties>
92+
</rule>
93+
<rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly">
94+
<properties>
95+
<property name="allowFullyQualifiedNameForCollidingClasses" value="true" />
96+
<property name="allowFullyQualifiedNameForCollidingFunctions" value="true" />
97+
<property name="allowFullyQualifiedNameForCollidingConstants" value="true" />
98+
<property name="allowFullyQualifiedGlobalClasses" value="true" />
99+
<property name="allowFallbackGlobalFunctions" value="true" />
100+
<property name="allowFallbackGlobalConstants" value="true" />
101+
</properties>
102+
</rule>
103+
104+
105+
<rule ref="SlevomatCodingStandard.Operators.SpreadOperatorSpacing" />
106+
107+
108+
<rule ref="SlevomatCodingStandard.PHP" />
109+
110+
111+
<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints" />
112+
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing" />
113+
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing" />
114+
115+
116+
<rule ref="SlevomatCodingStandard.Variables">
117+
<!--
118+
This Sniff disallows
119+
$a = 1;
120+
return $a;
121+
But two individial statements might make the code easier to understand
122+
-->
123+
<exclude name="SlevomatCodingStandard.Variables.UselessVariable" />
124+
</rule>
125+
<rule ref="SlevomatCodingStandard.Variables.UnusedVariable">
126+
<properties>
127+
<property name="ignoreUnusedValuesWhenOnlyKeysAreUsedInForeach" value="true" />
128+
</properties>
129+
</rule>
130+
131+
12132
<!-- check for usage of undefined variables -->
13133
<rule ref="VariableAnalysis">
14134
<!--
@@ -104,7 +224,6 @@
104224

105225
<rule ref="Squiz.Commenting.DocCommentAlignment" />
106226
<rule ref="Squiz.Commenting.EmptyCatchComment" />
107-
<rule ref="Squiz.Commenting.FunctionCommentThrowTag" />
108227

109228
<rule ref="Squiz.Scope.StaticThisUsage" />
110229

@@ -131,6 +250,4 @@
131250
</properties>
132251
</rule>
133252
<rule ref="Squiz.WhiteSpace.SemicolonSpacing" />
134-
135-
<rule ref="ForwardMedia.CodeAnalysis.EmptyStatement" />
136253
</ruleset>

composer.json

+11-5
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
"description": "Coding standard used by FORWARD MEDIA",
44
"keywords": ["phpcs", "standards"],
55
"type": "phpcodesniffer-standard",
6-
"require": {
7-
"squizlabs/php_codesniffer": "^3.2",
8-
"sirbrillig/phpcs-variable-analysis": "^2.0"
9-
},
106
"suggest" : {
117
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.4"
128
},
@@ -16,5 +12,15 @@
1612
"name": "Robert Vock",
1713
"email": "[email protected]"
1814
}
19-
]
15+
],
16+
"require": {
17+
"squizlabs/php_codesniffer": "^3.2",
18+
"sirbrillig/phpcs-variable-analysis": "^2.0",
19+
"slevomat/coding-standard": "^5.0"
20+
},
21+
"autoload": {
22+
"psr-4": {
23+
"ForwardMedia\\": "ForwardMedia"
24+
}
25+
}
2026
}

0 commit comments

Comments
 (0)