Skip to content

Commit 4af0413

Browse files
committed
Upgrade base standard to 7.0.1
1 parent e338998 commit 4af0413

File tree

6 files changed

+51
-34
lines changed

6 files changed

+51
-34
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
"require": {
3434
"php": "^7.1 || ^8.0",
3535
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
36-
"slevomat/coding-standard": "~6.4.1",
37-
"squizlabs/php_codesniffer": "^3.5.8"
36+
"slevomat/coding-standard": "^7.0.1",
37+
"squizlabs/php_codesniffer": "^3.6.0"
3838
},
3939
"require-dev": {
4040
"symfony/phpunit-bridge": "^5.1"

src/Unleashed/ruleset.xml

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@
163163
</rule>
164164
<!-- Require usage of ::class instead of __CLASS__, get_class(), get_class($this), get_called_class() and get_parent_class() -->
165165
<rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference"/>
166+
<!-- Require usage of constructor property promotion -->
167+
<rule ref="SlevomatCodingStandard.Classes.RequireConstructorPropertyPromotion"/>
166168
<!-- Forbid uses of multiple traits separated by comma -->
167169
<rule ref="SlevomatCodingStandard.Classes.TraitUseDeclaration"/>
168170
<!-- Require no spaces before trait use, between trait uses and one space after trait uses -->
@@ -174,8 +176,6 @@
174176
<property name="linesCountBetweenUses" value="0"/>
175177
</properties>
176178
</rule>
177-
<!-- Forbid dead code -->
178-
<rule ref="SlevomatCodingStandard.Classes.UnusedPrivateElements"/>
179179
<!-- Require specific order of phpDoc annotations with empty newline between specific groups -->
180180
<rule ref="SlevomatCodingStandard.Commenting.DocCommentSpacing">
181181
<properties>
@@ -306,15 +306,15 @@
306306
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeControlStructure" />
307307
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeFirstControlStructure" />
308308
<properties>
309-
<property name="tokensToCheck" type="array">
310-
<element value="T_IF" />
311-
<element value="T_DO" />
312-
<element value="T_WHILE" />
313-
<element value="T_FOR" />
314-
<element value="T_FOREACH" />
315-
<element value="T_SWITCH" />
316-
<element value="T_TRY" />
317-
<element value="T_DEFAULT" />
309+
<property name="controlStructures" type="array">
310+
<element value="if" />
311+
<element value="do" />
312+
<element value="while" />
313+
<element value="for" />
314+
<element value="foreach" />
315+
<element value="switch" />
316+
<element value="try" />
317+
<element value="default" />
318318
</property>
319319
</properties>
320320
</rule>
@@ -329,11 +329,11 @@
329329
<!-- Require consistent spacing for jump statements -->
330330
<rule ref="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing">
331331
<properties>
332-
<property name="tokensToCheck" type="array">
333-
<element value="T_RETURN" />
334-
<element value="T_THROW" />
335-
<element value="T_YIELD" />
336-
<element value="T_YIELD_FROM" />
332+
<property name="jumpStatements" type="array">
333+
<element value="return" />
334+
<element value="throw" />
335+
<element value="yield" />
336+
<element value="yield_from" />
337337
</property>
338338
</properties>
339339
</rule>
@@ -343,6 +343,8 @@
343343
<rule ref="SlevomatCodingStandard.ControlStructures.NewWithParentheses"/>
344344
<!-- Require usage of null coalesce operator when possible -->
345345
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator"/>
346+
<!-- Require usage of null safe object operator when possible -->
347+
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullSafeObjectOperator"/>
346348
<!-- Forbid usage of conditions when a simple return can be used -->
347349
<rule ref="SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn"/>
348350
<!-- Forbid usage of boolean-only ternary operator usage (e.g. $foo ? true : false) -->
@@ -351,10 +353,14 @@
351353
<rule ref="SlevomatCodingStandard.Exceptions.DeadCatch"/>
352354
<!-- Require using Throwable instead of Exception -->
353355
<rule ref="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly"/>
356+
<!-- Require non-capturing catch when the variable with exception is not used -->
357+
<rule ref="SlevomatCodingStandard.Exceptions.RequireNonCapturingCatch"/>
354358
<!-- Require closures not referencing $this be static -->
355359
<rule ref="SlevomatCodingStandard.Functions.StaticClosure"/>
356360
<!-- Require calls to PHP functions that have a `$strict` parameter to always set that to `true` -->
357361
<rule ref="SlevomatCodingStandard.Functions.StrictCall"/>
362+
<!-- Require trailing commas in multi-line declarations -->
363+
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInDeclaration"/>
358364
<!-- Forbid unused variables passed to closures via `use` -->
359365
<rule ref="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure"/>
360366
<!-- Check the formatting of "fn" arrow functions -->
@@ -426,16 +432,20 @@
426432
<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
427433
<properties>
428434
<property
429-
name="newlinesCountBetweenOpenTagAndDeclare"
430-
value="2"
435+
name="declareOnFirstLine"
436+
value="false"
437+
/>
438+
<property
439+
name="linesCountBeforeDeclare"
440+
value="1"
431441
/>
432442
<property
433443
name="spacesCountAroundEqualsSign"
434444
value="0"
435445
/>
436446
<property
437-
name="newlinesCountAfterDeclare"
438-
value="2"
447+
name="linesCountAfterDeclare"
448+
value="1"
439449
/>
440450
</properties>
441451
</rule>
@@ -489,6 +499,13 @@
489499
</property>
490500
</properties>
491501
</rule>
502+
<rule ref="SlevomatCodingStandard.TypeHints.UnionTypeHintFormat">
503+
<properties>
504+
<property name="withSpaces" value="no"/>
505+
<property name="shortNullable" value="no"/>
506+
<property name="nullPosition" value="last"/>
507+
</properties>
508+
</rule>
492509
<!-- Forbid useless @var for constants -->
493510
<rule ref="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint"/>
494511
<!-- Forbid useless phpDocs for functions -->

tests/expected_report.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ tests/input/inline_type_hint_assertions.php 7 0
2525
tests/input/LowCaseTypes.php 3 0
2626
tests/input/merge-conflict.php 6 0
2727
tests/input/namespaces-spacing.php 12 0
28-
tests/input/NamingCamelCase.php 8 0
28+
tests/input/NamingCamelCase.php 7 0
2929
tests/input/negation-operator.php 2 0
3030
tests/input/new_with_parentheses.php 30 0
3131
tests/input/not_spacing.php 8 0
@@ -48,7 +48,7 @@ tests/input/use-ordering.php 9 0
4848
tests/input/useless-semicolon.php 2 0
4949
tests/input/UselessConditions.php 23 0
5050
----------------------------------------------------------------------
51-
A TOTAL OF 418 ERRORS AND 8 WARNINGS WERE FOUND IN 44 FILES
51+
A TOTAL OF 417 ERRORS AND 8 WARNINGS WERE FOUND IN 44 FILES
5252
----------------------------------------------------------------------
5353
PHPCBF CAN FIX 334 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
5454
----------------------------------------------------------------------

tests/fixed/doc-comment-spacing.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99

1010
/**
1111
* @template T
12-
* @template-covariant
12+
* @template-covariant T
1313
* @extends
1414
* @implements
1515
*
16-
* @phpstan-template
17-
* @phpstan-template-covariant
16+
* @phpstan-template T
17+
* @phpstan-template-covariant T
1818
* @phpstan-extends
1919
* @phpstan-implements T
2020
*/

tests/input/doc-comment-spacing.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
* @implements
1212
* @extends
1313
* @template T
14-
* @template-covariant
14+
* @template-covariant T
1515
* @phpstan-implements T
1616
* @phpstan-extends
17-
* @phpstan-template
18-
* @phpstan-template-covariant
17+
* @phpstan-template T
18+
* @phpstan-template-covariant T
1919
*/
2020
class Test
2121
{

tests/php-compatibility.patch

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ index 80a42a6..dd2fcb7 100644
6868
/**
6969
* Returns an array of tokens this test wants to listen for.
7070
diff --git a/tests/expected_report.txt b/tests/expected_report.txt
71-
index cc0cd5a..c3ebeb0 100644
71+
index 94f1b60..fa0a0f9 100644
7272
--- a/tests/expected_report.txt
7373
+++ b/tests/expected_report.txt
7474
@@ -11,11 +11,11 @@ tests/input/concatenation_spacing.php 49 0
@@ -97,16 +97,16 @@ index cc0cd5a..c3ebeb0 100644
9797
tests/input/useless-semicolon.php 2 0
9898
tests/input/UselessConditions.php 23 0
9999
----------------------------------------------------------------------
100-
-A TOTAL OF 418 ERRORS AND 8 WARNINGS WERE FOUND IN 44 FILES
101-
+A TOTAL OF 423 ERRORS AND 8 WARNINGS WERE FOUND IN 44 FILES
100+
-A TOTAL OF 417 ERRORS AND 8 WARNINGS WERE FOUND IN 44 FILES
101+
+A TOTAL OF 422 ERRORS AND 8 WARNINGS WERE FOUND IN 44 FILES
102102
----------------------------------------------------------------------
103103
-PHPCBF CAN FIX 334 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
104104
+PHPCBF CAN FIX 339 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
105105
----------------------------------------------------------------------
106106

107107

108108
diff --git a/tests/fixed/doc-comment-spacing.php b/tests/fixed/doc-comment-spacing.php
109-
index 7798686..bb40667 100644
109+
index 2f53db0..728e7f0 100644
110110
--- a/tests/fixed/doc-comment-spacing.php
111111
+++ b/tests/fixed/doc-comment-spacing.php
112112
@@ -25,7 +25,7 @@ class Test

0 commit comments

Comments
 (0)