Skip to content

Commit c2abf33

Browse files
committed
Update rules
1 parent e4d2c88 commit c2abf33

9 files changed

+109
-14
lines changed

src/Unleashed/ruleset.xml

+56-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@
2626
<exclude name="PSR2.ControlStructures.ControlStructureSpacing.SpacingAfterOpenBrace"/>
2727
</rule>
2828

29+
<!-- Warn about TODOs and FIXMEs in code. -->
30+
<rule ref="Generic.Commenting.Fixme"/>
31+
<rule ref="Generic.Commenting.Todo"/>
32+
33+
<!-- Forbid merge conflict artifacts left in files -->
34+
<rule ref="Generic.VersionControl.GitMergeConflict"/>
35+
2936
<!-- Force array element indentation with 4 spaces -->
3037
<rule ref="Generic.Arrays.ArrayIndent"/>
3138
<!-- Forbid `array(...)` -->
@@ -87,6 +94,14 @@
8794
<element key="show_source" value="highlight_file"/>
8895
<element key="sizeof" value="count"/>
8996
<element key="strchr" value="strstr"/>
97+
<!-- Forbid 'empty()'; use more strict comparison instead -->
98+
<element key="empty" value="null"/>
99+
<!-- Forbid remaining debug functions in the code -->
100+
<element key="d" value="null"/>
101+
<element key="dd" value="null"/>
102+
<element key="dump" value="null"/>
103+
<element key="dump_d" value="null"/>
104+
<element key="var_dump" value="null"/>
90105
</property>
91106
</properties>
92107
</rule>
@@ -121,6 +136,12 @@
121136
<property name="fixable" value="true"/>
122137
</properties>
123138
</rule>
139+
<!-- Require one line between each class member -->
140+
<rule ref="SlevomatCodingStandard.Classes.ClassMemberSpacing">
141+
<properties>
142+
<property name="linesCountBetweenMembers" value="1"/>
143+
</properties>
144+
</rule>
124145
<!-- Forbid LSB for constants (static::FOO) -->
125146
<rule ref="SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants"/>
126147
<!-- Require that true, false, and null are lowercase -->
@@ -165,6 +186,10 @@
165186
@see,
166187
@uses,
167188
"/>
189+
<!-- PHPUnit -->
190+
<element value="@test, @group, @dataProvider, @depends, @doesNotPerformAssertions, @runInSeparateProcess, @runTestsInSeparateProcesses"/>
191+
<element value="@expectedDeprecation, @expectedException, @expectedExceptionCode, @expectedExceptionMessage, @expectedExceptionMessageRegExp"/>
192+
<element value="@covers, @coversNothing, @coversDefaultClass"/>
168193
<!-- Doctrine ORM and Extensions -->
169194
<element value="
170195
@ORM\,
@@ -177,6 +202,23 @@
177202
<element value="@param"/>
178203
<element value="@return"/>
179204
<element value="@throws"/>
205+
<element value="
206+
@psalm-var,
207+
@psalm-param,
208+
@psalm-return,
209+
"/>
210+
<element value="
211+
@property,
212+
@property-read,
213+
@property-write,
214+
@psalm-property,
215+
@psalm-property-read,
216+
@psalm-proprty-write,
217+
"/>
218+
<element value="
219+
@param-out,
220+
"/>
221+
<element value="@phpcsSuppress"/>
180222
</property>
181223
</properties>
182224
</rule>
@@ -253,6 +295,8 @@
253295
</rule>
254296
<!-- Require language constructs without parentheses -->
255297
<rule ref="SlevomatCodingStandard.ControlStructures.LanguageConstructWithParentheses"/>
298+
<!-- Require new instances with parentheses -->
299+
<rule ref="SlevomatCodingStandard.ControlStructures.NewWithParentheses"/>
256300
<!-- Require usage of null coalesce operator when possible -->
257301
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator"/>
258302
<!-- Forbid usage of conditions when a simple return can be used -->
@@ -270,7 +314,12 @@
270314
<!-- Forbid unused variables passed to closures via `use` -->
271315
<rule ref="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure"/>
272316
<!-- Require use statements to be alphabetically sorted -->
273-
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses"/>
317+
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses">
318+
<properties>
319+
<property name="psr12Compatible" value="true"/>
320+
<property name="caseSensitive" value="true"/>
321+
</properties>
322+
</rule>
274323
<!-- Forbid fancy group uses -->
275324
<rule ref="SlevomatCodingStandard.Namespaces.DisallowGroupUse"/>
276325
<!-- Forbid multiple use statements on same line -->
@@ -315,6 +364,12 @@
315364
<rule ref="SlevomatCodingStandard.Operators.RequireCombinedAssignmentOperator"/>
316365
<!-- Require no spacing after spread operator -->
317366
<rule ref="SlevomatCodingStandard.Operators.SpreadOperatorSpacing"/>
367+
<!-- Require 0 spaces after the reference '&' operator -->
368+
<rule ref="SlevomatCodingStandard.PHP.ReferenceSpacing">
369+
<properties>
370+
<property name="spacesCountAfterReference" value="0"/>
371+
</properties>
372+
</rule>
318373
<!-- Forbid argument unpacking for functions specialized by PHP VM -->
319374
<rule ref="SlevomatCodingStandard.PHP.OptimizedFunctionsWithoutUnpacking"/>
320375
<!-- Forbid `list(...)` syntax -->

tests/expected_report.txt

+6-5
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,16 @@ tests/input/duplicate-assignment-variable.php 1 0
1616
tests/input/EarlyReturn.php 6 0
1717
tests/input/example-class.php 38 0
1818
tests/input/forbidden-comments.php 14 0
19-
tests/input/forbidden-functions.php 5 0
19+
tests/input/forbidden-functions.php 13 0
2020
tests/input/fully-qualified-and-fallbacks.php 1 0
2121
tests/input/fully-qualified-without-namespace.php 3 0
2222
tests/input/inline_type_hint_assertions.php 7 0
2323
tests/input/LowCaseTypes.php 3 0
24+
tests/input/merge-conflict.php 6 0
2425
tests/input/namespaces-spacing.php 12 0
2526
tests/input/NamingCamelCase.php 8 0
2627
tests/input/negation-operator.php 2 0
27-
tests/input/new_with_parentheses.php 18 0
28+
tests/input/new_with_parentheses.php 30 0
2829
tests/input/not_spacing.php 8 0
2930
tests/input/null_coalesce_operator.php 3 0
3031
tests/input/optimized-functions.php 1 0
@@ -37,17 +38,17 @@ tests/input/static-closures.php 1 0
3738
tests/input/strict-functions.php 4 0
3839
tests/input/test-case.php 7 0
3940
tests/input/trailing_comma_on_array.php 1 0
40-
tests/input/traits-uses.php 11 0
41+
tests/input/traits-uses.php 12 0
4142
tests/input/type-hints.php 5 0
4243
tests/input/UnusedVariables.php 2 0
4344
tests/input/use-function.php 2 0
4445
tests/input/use-ordering.php 9 0
4546
tests/input/useless-semicolon.php 2 0
4647
tests/input/UselessConditions.php 23 0
4748
----------------------------------------------------------------------
48-
A TOTAL OF 362 ERRORS AND 2 WARNINGS WERE FOUND IN 41 FILES
49+
A TOTAL OF 389 ERRORS AND 2 WARNINGS WERE FOUND IN 42 FILES
4950
----------------------------------------------------------------------
50-
PHPCBF CAN FIX 303 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
51+
PHPCBF CAN FIX 320 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
5152
----------------------------------------------------------------------
5253

5354

tests/fixed/forbidden-functions.php

+8
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,11 @@
2020
\extract($bar);
2121

2222
\compact('foo', 'bar');
23+
24+
echo \empty('0') ? 'y' : 'n';
25+
26+
d('foo');
27+
dd('foo');
28+
dump('foo');
29+
dump_d('foo');
30+
\var_dump('foo');

tests/fixed/merge-conflict.php

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
<< << <<< HEAD
6+
$foo = 'bar';
7+
=======
8+
$bar = 'bar';
9+
>>>>>>> some_other_branch

tests/fixed/test-case.php

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ public function createDependencies(): void
3030
* @uses MyClass::__construct
3131
*
3232
* @test
33+
*
34+
* @expectedException \RuntimeException
35+
*
3336
* @covers MyClass::test
3437
*/
3538
public function methodShouldDoStuff(): void

tests/input/forbidden-functions.php

+8
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,11 @@
2020
\extract($bar);
2121

2222
\compact('foo', 'bar');
23+
24+
echo \empty('0') ? 'y' : 'n';
25+
26+
d('foo');
27+
dd('foo');
28+
dump('foo');
29+
dump_d('foo');
30+
var_dump('foo');

tests/input/merge-conflict.php

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
<<<<<<< HEAD
6+
$foo = 'bar';
7+
=======
8+
$bar = 'bar';
9+
>>>>>>> some_other_branch

tests/input/test-case.php

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ public function createDependencies()
3434
* @covers MyClass::test
3535
*
3636
* @uses MyClass::__construct
37+
*
38+
* @expectedException \RuntimeException
3739
*/
3840
public function methodShouldDoStuff()
3941
{

tests/php-compatibility.patch

+8-8
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ index 71be9a5..f9492c7 100644
3030
'array_key_exists' => true,
3131
'array_slice' => true,
3232
diff --git a/tests/expected_report.txt b/tests/expected_report.txt
33-
index 0ab45ec..fc414f1 100644
33+
index 37294d1..abed1f8 100644
3434
--- a/tests/expected_report.txt
3535
+++ b/tests/expected_report.txt
3636
@@ -14,7 +14,7 @@ tests/input/ControlStructures.php 17 2
@@ -40,12 +40,12 @@ index 0ab45ec..fc414f1 100644
4040
-tests/input/example-class.php 38 0
4141
+tests/input/example-class.php 41 0
4242
tests/input/forbidden-comments.php 14 0
43-
tests/input/forbidden-functions.php 5 0
43+
tests/input/forbidden-functions.php 13 0
4444
tests/input/fully-qualified-and-fallbacks.php 1 0
45-
@@ -38,16 +38,16 @@ tests/input/strict-functions.php 4 0
45+
@@ -39,16 +39,16 @@ tests/input/strict-functions.php 4 0
4646
tests/input/test-case.php 7 0
4747
tests/input/trailing_comma_on_array.php 1 0
48-
tests/input/traits-uses.php 11 0
48+
tests/input/traits-uses.php 12 0
4949
-tests/input/type-hints.php 5 0
5050
+tests/input/type-hints.php 6 0
5151
tests/input/UnusedVariables.php 2 0
@@ -54,11 +54,11 @@ index 0ab45ec..fc414f1 100644
5454
tests/input/useless-semicolon.php 2 0
5555
tests/input/UselessConditions.php 23 0
5656
----------------------------------------------------------------------
57-
-A TOTAL OF 362 ERRORS AND 2 WARNINGS WERE FOUND IN 41 FILES
58-
+A TOTAL OF 366 ERRORS AND 2 WARNINGS WERE FOUND IN 41 FILES
57+
-A TOTAL OF 389 ERRORS AND 2 WARNINGS WERE FOUND IN 42 FILES
58+
+A TOTAL OF 393 ERRORS AND 2 WARNINGS WERE FOUND IN 42 FILES
5959
----------------------------------------------------------------------
60-
-PHPCBF CAN FIX 303 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
61-
+PHPCBF CAN FIX 307 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
60+
-PHPCBF CAN FIX 320 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
61+
+PHPCBF CAN FIX 324 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
6262
----------------------------------------------------------------------
6363

6464

0 commit comments

Comments
 (0)