Skip to content

Commit 09f4257

Browse files
committed
Updated rulesets for ForwardMedia, added ForwardMediaModern which also enforces some rules for PHP 7
1 parent 7ab7f06 commit 09f4257

File tree

3 files changed

+150
-1124
lines changed

3 files changed

+150
-1124
lines changed

ForwardMedia/ruleset.xml

+68-7
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,29 @@
1111
<exclude-pattern>*/typo3conf/ext/powermail/*</exclude-pattern>
1212
<exclude-pattern>*/typo3conf/ext/realurl/*</exclude-pattern>
1313

14+
<exclude-pattern>*/typo3conf/LocalConfiguration.php</exclude-pattern>
15+
<exclude-pattern>*/typo3conf/PackageStates.php</exclude-pattern>
16+
<!-- TCA files directly in TCA are generated by extension builder -->
17+
<exclude-pattern>*/Configuration/TCA/[^/]+.php</exclude-pattern>
18+
<!--
19+
<exclude-pattern>*/typo3conf/ext/*/ext_*.php</exclude-pattern>
20+
<exclude-pattern>*/typo3conf/ext/*/Configuration/RequestMiddlewares.php</exclude-pattern>
21+
<exclude-pattern>*/typo3conf/AdditionalConfiguration*.php</exclude-pattern>
22+
-->
23+
<!-- TODO: Check https://github.com/consistence/coding-standard/blob/master/Consistence/ruleset.xml -->
1424

1525
<rule ref="SlevomatCodingStandard.Arrays" />
26+
<rule ref="SlevomatCodingStandard.Arrays.DisallowImplicitArrayCreation">
27+
<exclude-pattern>*/ext_emconf.php</exclude-pattern>
28+
</rule>
1629

1730

1831
<rule ref="SlevomatCodingStandard.Commenting">
1932
<!-- TYPO3 extension builder generates multiline doc-comments -->
2033
<exclude name="SlevomatCodingStandard.Commenting.RequireOneLinePropertyDocComment" />
2134

2235
<exclude name="SlevomatCodingStandard.Commenting.DocCommentSpacing" />
36+
<exclude name="SlevomatCodingStandard.Commenting.DisallowOneLinePropertyDocComment" />
2337
</rule>
2438
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenAnnotations">
2539
<properties>
@@ -39,13 +53,27 @@
3953
<exclude name="SlevomatCodingStandard.ControlStructures.ControlStructureSpacing" />
4054
<exclude name="SlevomatCodingStandard.ControlStructures.DisallowEmpty" />
4155
<exclude name="SlevomatCodingStandard.ControlStructures.DisallowShortTernaryOperator" />
56+
<exclude name="SlevomatCodingStandard.ControlStructures.DisallowYodaComparison" />
57+
<exclude name="SlevomatCodingStandard.ControlStructures.EarlyExit" />
4258
<exclude name="SlevomatCodingStandard.ControlStructures.NewWithoutParentheses" />
4359
<exclude name="SlevomatCodingStandard.ControlStructures.RequireMultiLineTernaryOperator" />
60+
<exclude name="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator" />
61+
<exclude name="SlevomatCodingStandard.ControlStructures.RequireTernaryOperator" />
4462
<exclude name="SlevomatCodingStandard.ControlStructures.RequireYodaComparison" />
63+
64+
<!-- sometimes it is better to explicitly return true after a set of conditions which all return false... -->
65+
<exclude name="SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn" />
66+
</rule>
67+
<rule ref="SlevomatCodingStandard.ControlStructures.LanguageConstructWithParentheses">
68+
<!-- Autogenerated code includes die() -->
69+
<exclude-pattern>*/typo3conf/*/TCA/*.php</exclude-pattern>
4570
</rule>
4671

4772

4873
<rule ref="SlevomatCodingStandard.Classes">
74+
<!-- Empty classes give an errors -->
75+
<exclude name="SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces" />
76+
4977
<!-- We use the name suffixes -->
5078
<exclude name="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming" />
5179
<exclude name="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming" />
@@ -54,17 +82,21 @@
5482

5583
<!-- This only works in PHP >=7.1 -->
5684
<exclude name="SlevomatCodingStandard.Classes.ClassConstantVisibility" />
85+
86+
<!-- private methods can be called via magic __call or with a string... -->
87+
<exclude name="SlevomatCodingStandard.Classes.UnusedPrivateElements" />
88+
89+
<!-- ok, get_class($this) is ugly, but __CLASS__ is ok, I think -->
90+
<!-- SlevomatCodingStandard.Classes.ModernClassNameReference -->
5791
</rule>
5892

5993

60-
<rule ref="SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces">
94+
<!-- Empty classes give an errors -->
95+
<!-- <rule ref="SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces">
6196
<properties>
6297
<property name="linesCountBeforeClosingBrace" value="0" />
6398
</properties>
64-
</rule>
65-
66-
67-
<rule ref="SlevomatCodingStandard.Exceptions" />
99+
</rule> -->
68100

69101

70102
<rule ref="SlevomatCodingStandard.Functions">
@@ -84,6 +116,9 @@
84116
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalFunctions" />
85117
<exclude name="SlevomatCodingStandard.Namespaces.UseOnlyWhitelistedNamespaces" />
86118
<exclude name="SlevomatCodingStandard.Namespaces.UseSpacing" />
119+
120+
<!-- Normally I would agree, but I like built-in names first (ZipArchive before user-land classes) -->
121+
<exclude name="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses" />
87122
</rule>
88123
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
89124
<properties>
@@ -99,13 +134,23 @@
99134
<property name="allowFallbackGlobalFunctions" value="true" />
100135
<property name="allowFallbackGlobalConstants" value="true" />
101136
</properties>
137+
138+
<!-- TCA Code should use Fully-Qualified-ClassNames -->
139+
<exclude-pattern>*/Configuration/TCA/*.php</exclude-pattern>
140+
<exclude-pattern>*/ext_localconf.php</exclude-pattern>
141+
<exclude-pattern>*/ext_tables.php</exclude-pattern>
142+
<exclude-pattern>*/AdditionalConfiguration.php</exclude-pattern>
143+
<exclude-pattern>*/AdditionalConfiguration.sample.php</exclude-pattern>
144+
<exclude-pattern>*/database/*.php</exclude-pattern>
102145
</rule>
103146

104147

105148
<rule ref="SlevomatCodingStandard.Operators.SpreadOperatorSpacing" />
106149

107150

108-
<rule ref="SlevomatCodingStandard.PHP" />
151+
<rule ref="SlevomatCodingStandard.PHP">
152+
<exclude name="SlevomatCodingStandard.PHP.ShortList" />
153+
</rule>
109154

110155

111156
<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints" />
@@ -123,9 +168,16 @@
123168
<exclude name="SlevomatCodingStandard.Variables.UselessVariable" />
124169
</rule>
125170
<rule ref="SlevomatCodingStandard.Variables.UnusedVariable">
171+
<!--
172+
TODO: Modify this rule to also ignore variables assigned in list():
173+
`list($unused, $type) = explode(':', $string);`
174+
This can be used to document, what the first part contains
175+
-->
126176
<properties>
127177
<property name="ignoreUnusedValuesWhenOnlyKeysAreUsedInForeach" value="true" />
128178
</properties>
179+
180+
<exclude-pattern>*/database/*.php</exclude-pattern>
129181
</rule>
130182

131183

@@ -139,6 +191,12 @@
139191
<exclude name="VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable" />
140192
<exclude name="VariableAnalysis.CodeAnalysis.VariableAnalysis.StaticOutsideClass" />
141193
</rule>
194+
<rule ref="VariableAnalysis.CodeAnalysis.VariableAnalysis">
195+
<!-- $_EXTKEY is pre-defined -->
196+
<properties>
197+
<property name="validUndefinedVariableNames" value="_EXTKEY EM_CONF TYPO3_CONF_VARS" />
198+
</properties>
199+
</rule>
142200

143201
<!-- <rule ref="Generic.Arrays.DisallowLongArraySyntax" /> -->
144202
<!-- <rule ref="Generic.CodeAnalysis.EmptyStatement" /> -->
@@ -177,7 +235,10 @@
177235
</properties>
178236
</rule> -->
179237
<rule ref="Generic.NamingConventions.ConstructorName" />
180-
<rule ref="Generic.NamingConventions.UpperCaseConstantName" />
238+
<rule ref="Generic.NamingConventions.UpperCaseConstantName">
239+
<exclude-pattern>*/Configuration/TCA/*.php</exclude-pattern>
240+
<exclude-pattern>*/database/*.php</exclude-pattern>
241+
</rule>
181242

182243
<rule ref="Generic.PHP.CharacterBeforePHPOpeningTag" />
183244
<rule ref="Generic.PHP.DeprecatedFunctions" />

ForwardMediaModern/ruleset.xml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="Forward">
3+
<description>PHP Coding Standard for FORWARD MEDIA</description>
4+
5+
<exclude-pattern>*/typo3/sysext/*</exclude-pattern>
6+
<exclude-pattern>*/typo3conf/ext/crawler/*</exclude-pattern>
7+
<exclude-pattern>*/typo3conf/ext/direct_mail/*</exclude-pattern>
8+
<exclude-pattern>*/typo3conf/ext/extension_builder/*</exclude-pattern>
9+
<exclude-pattern>*/typo3conf/ext/gridelements/*</exclude-pattern>
10+
<exclude-pattern>*/typo3conf/ext/l10nmgr/*</exclude-pattern>
11+
<exclude-pattern>*/typo3conf/ext/powermail/*</exclude-pattern>
12+
<exclude-pattern>*/typo3conf/ext/realurl/*</exclude-pattern>
13+
14+
<exclude-pattern>*/typo3conf/LocalConfiguration.php</exclude-pattern>
15+
<exclude-pattern>*/typo3conf/PackageStates.php</exclude-pattern>
16+
<!-- TCA files directly in TCA are generated by extension builder -->
17+
<exclude-pattern>*/Configuration/TCA/[^/]+.php</exclude-pattern>
18+
<!--
19+
<exclude-pattern>*/typo3conf/ext/*/ext_*.php</exclude-pattern>
20+
<exclude-pattern>*/typo3conf/ext/*/Configuration/RequestMiddlewares.php</exclude-pattern>
21+
<exclude-pattern>*/typo3conf/AdditionalConfiguration*.php</exclude-pattern>
22+
-->
23+
<!-- TODO: Check https://github.com/consistence/coding-standard/blob/master/Consistence/ruleset.xml -->
24+
25+
<rule ref="ForwardMedia" />
26+
27+
<rule ref="SlevomatCodingStandard.PHP" />
28+
29+
<!-- Throwable only exists with PHP 7 -->
30+
<rule ref="SlevomatCodingStandard.Exceptions" />
31+
</ruleset>

0 commit comments

Comments
 (0)