Skip to content

Commit bff4f83

Browse files
committed
feat: enable parent call spacing
1 parent 7903671 commit bff4f83

File tree

8 files changed

+50
-31
lines changed

8 files changed

+50
-31
lines changed

lib/Doctrine/ruleset.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@
135135
<property name="linesCountBeforeClosingBrace" value="0"/>
136136
</properties>
137137
</rule>
138+
<!-- Add one line around parent call in order to improve readability -->
139+
<rule ref="SlevomatCodingStandard.Classes.ParentCallSpacing"/>
138140
<!-- Require usage of ::class instead of __CLASS__, get_class(), get_class($this), get_called_class() and get_parent_class() -->
139141
<rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference"/>
140142
<!-- https://github.com/slevomat/coding-standard#slevomatcodingstandardclassespropertydeclaration- -->

tests/expected_report.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ tests/input/ControlStructures.php 28 0
1515
tests/input/doc-comment-spacing.php 11 0
1616
tests/input/duplicate-assignment-variable.php 1 0
1717
tests/input/EarlyReturn.php 7 0
18-
tests/input/example-class.php 44 0
18+
tests/input/example-class.php 47 0
1919
tests/input/ExampleBackedEnum.php 3 0
2020
tests/input/Exceptions.php 1 0
2121
tests/input/forbidden-comments.php 14 0
@@ -50,9 +50,9 @@ tests/input/use-ordering.php 1 0
5050
tests/input/useless-semicolon.php 2 0
5151
tests/input/UselessConditions.php 21 0
5252
----------------------------------------------------------------------
53-
A TOTAL OF 429 ERRORS AND 0 WARNINGS WERE FOUND IN 46 FILES
53+
A TOTAL OF 432 ERRORS AND 0 WARNINGS WERE FOUND IN 46 FILES
5454
----------------------------------------------------------------------
55-
PHPCBF CAN FIX 364 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
55+
PHPCBF CAN FIX 365 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
5656
----------------------------------------------------------------------
5757

5858

tests/fixed/example-class.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,14 @@
1818
use const PHP_RELEASE_VERSION as PHP_PATCH_VERSION;
1919
use const PHP_VERSION;
2020

21+
class ParentClass
22+
{
23+
}
24+
2125
/**
2226
* Description
2327
*/
24-
class Example implements IteratorAggregate
28+
class Example extends ParentClass implements IteratorAggregate
2529
{
2630
private const VERSION = PHP_VERSION - (PHP_MINOR_VERSION * 100) - PHP_PATCH_VERSION;
2731

@@ -30,6 +34,8 @@ class Example implements IteratorAggregate
3034
public function __construct(private int|null $foo = null, private array $bar = [], private bool $baz = false, $baxBax = 'unused')
3135
{
3236
$this->baxBax = $baxBax;
37+
38+
parent::__construct();
3339
}
3440

3541
/**

tests/input/example-class.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,16 @@
1414

1515
use Doctrine\Sniffs\Spacing\ControlStructureSniff;
1616

17+
class ParentClass
18+
{
19+
}
20+
1721
/**
1822
* Description
1923
* @author Invalid
2024
* @since 0.1
2125
*/
22-
class Example implements \IteratorAggregate
26+
class Example extends ParentClass implements \IteratorAggregate
2327
{
2428
private const VERSION = \PHP_VERSION - (PHP_MINOR_VERSION * 100) - PHP_PATCH_VERSION;
2529

@@ -41,6 +45,7 @@ public function __construct(int $foo = null, array $bar = [], bool $baz = false,
4145
$this->bar = $bar;
4246
$this->baz = $baz;
4347
$this->baxBax = $baxBax;
48+
parent::__construct();
4449
}
4550

4651
/**

tests/php72-compatibility.patch

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ index 5110131..53dada5 100644
77
tests/input/doc-comment-spacing.php 11 0
88
tests/input/duplicate-assignment-variable.php 1 0
99
-tests/input/EarlyReturn.php 7 0
10-
-tests/input/example-class.php 44 0
10+
-tests/input/example-class.php 47 0
1111
-tests/input/ExampleBackedEnum.php 3 0
1212
-tests/input/Exceptions.php 1 0
1313
+tests/input/EarlyReturn.php 6 0
14-
+tests/input/example-class.php 38 0
14+
+tests/input/example-class.php 41 0
1515
tests/input/forbidden-comments.php 14 0
1616
tests/input/forbidden-functions.php 6 0
1717
tests/input/inline_type_hint_assertions.php 7 0
@@ -51,11 +51,11 @@ index 5110131..53dada5 100644
5151
-tests/input/UselessConditions.php 21 0
5252
+tests/input/UselessConditions.php 20 0
5353
----------------------------------------------------------------------
54-
-A TOTAL OF 429 ERRORS AND 0 WARNINGS WERE FOUND IN 46 FILES
55-
+A TOTAL OF 382 ERRORS AND 0 WARNINGS WERE FOUND IN 42 FILES
54+
-A TOTAL OF 432 ERRORS AND 0 WARNINGS WERE FOUND IN 46 FILES
55+
+A TOTAL OF 385 ERRORS AND 0 WARNINGS WERE FOUND IN 42 FILES
5656
----------------------------------------------------------------------
57-
-PHPCBF CAN FIX 364 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
58-
+PHPCBF CAN FIX 317 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
57+
-PHPCBF CAN FIX 365 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
58+
+PHPCBF CAN FIX 318 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
5959
----------------------------------------------------------------------
6060

6161

@@ -218,7 +218,7 @@ diff --git a/tests/fixed/example-class.php b/tests/fixed/example-class.php
218218
index 7d27825..998e51d 100644
219219
--- a/tests/fixed/example-class.php
220220
+++ b/tests/fixed/example-class.php
221-
@@ -25,17 +25,30 @@ class Example implements IteratorAggregate
221+
@@ -29,19 +29,32 @@ class Example extends ParentClass implements IteratorAggregate
222222
{
223223
private const VERSION = PHP_VERSION - (PHP_MINOR_VERSION * 100) - PHP_PATCH_VERSION;
224224

@@ -242,6 +242,8 @@ index 7d27825..998e51d 100644
242242
+ $this->bar = $bar;
243243
+ $this->baz = $baz;
244244
$this->baxBax = $baxBax;
245+
246+
parent::__construct();
245247
}
246248

247249
/**

tests/php73-compatibility.patch

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ index 5110131..5616fdf 100644
77
tests/input/doc-comment-spacing.php 11 0
88
tests/input/duplicate-assignment-variable.php 1 0
99
-tests/input/EarlyReturn.php 7 0
10-
-tests/input/example-class.php 44 0
10+
-tests/input/example-class.php 47 0
1111
-tests/input/ExampleBackedEnum.php 3 0
1212
-tests/input/Exceptions.php 1 0
1313
+tests/input/EarlyReturn.php 6 0
14-
+tests/input/example-class.php 38 0
14+
+tests/input/example-class.php 41 0
1515
tests/input/forbidden-comments.php 14 0
1616
tests/input/forbidden-functions.php 6 0
1717
tests/input/inline_type_hint_assertions.php 7 0
@@ -52,11 +52,11 @@ index 5110131..5616fdf 100644
5252
-tests/input/UselessConditions.php 21 0
5353
+tests/input/UselessConditions.php 20 0
5454
----------------------------------------------------------------------
55-
-A TOTAL OF 429 ERRORS AND 0 WARNINGS WERE FOUND IN 46 FILES
56-
+A TOTAL OF 384 ERRORS AND 0 WARNINGS WERE FOUND IN 43 FILES
55+
-A TOTAL OF 432 ERRORS AND 0 WARNINGS WERE FOUND IN 46 FILES
56+
+A TOTAL OF 387 ERRORS AND 0 WARNINGS WERE FOUND IN 43 FILES
5757
----------------------------------------------------------------------
58-
-PHPCBF CAN FIX 364 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
59-
+PHPCBF CAN FIX 319 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
58+
-PHPCBF CAN FIX 365 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
59+
+PHPCBF CAN FIX 320 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
6060
----------------------------------------------------------------------
6161

6262

@@ -191,7 +191,7 @@ diff --git a/tests/fixed/example-class.php b/tests/fixed/example-class.php
191191
index 7d27825..998e51d 100644
192192
--- a/tests/fixed/example-class.php
193193
+++ b/tests/fixed/example-class.php
194-
@@ -25,17 +25,30 @@ class Example implements IteratorAggregate
194+
@@ -29,19 +29,32 @@ class Example extends ParentClass implements IteratorAggregate
195195
{
196196
private const VERSION = PHP_VERSION - (PHP_MINOR_VERSION * 100) - PHP_PATCH_VERSION;
197197

@@ -215,6 +215,8 @@ index 7d27825..998e51d 100644
215215
+ $this->bar = $bar;
216216
+ $this->baz = $baz;
217217
$this->baxBax = $baxBax;
218+
219+
parent::__construct();
218220
}
219221

220222
/**

tests/php74-compatibility.patch

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ index 5110131..dc2cf18 100644
77
tests/input/doc-comment-spacing.php 11 0
88
tests/input/duplicate-assignment-variable.php 1 0
99
-tests/input/EarlyReturn.php 7 0
10-
-tests/input/example-class.php 44 0
10+
-tests/input/example-class.php 47 0
1111
-tests/input/ExampleBackedEnum.php 3 0
1212
-tests/input/Exceptions.php 1 0
1313
+tests/input/EarlyReturn.php 6 0
14-
+tests/input/example-class.php 41 0
14+
+tests/input/example-class.php 44 0
1515
tests/input/forbidden-comments.php 14 0
1616
tests/input/forbidden-functions.php 6 0
1717
tests/input/inline_type_hint_assertions.php 7 0
@@ -50,11 +50,11 @@ index 5110131..dc2cf18 100644
5050
-tests/input/UselessConditions.php 21 0
5151
+tests/input/UselessConditions.php 20 0
5252
----------------------------------------------------------------------
53-
-A TOTAL OF 429 ERRORS AND 0 WARNINGS WERE FOUND IN 46 FILES
54-
+A TOTAL OF 393 ERRORS AND 0 WARNINGS WERE FOUND IN 43 FILES
53+
-A TOTAL OF 432 ERRORS AND 0 WARNINGS WERE FOUND IN 46 FILES
54+
+A TOTAL OF 396 ERRORS AND 0 WARNINGS WERE FOUND IN 43 FILES
5555
----------------------------------------------------------------------
56-
-PHPCBF CAN FIX 364 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
57-
+PHPCBF CAN FIX 328 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
56+
-PHPCBF CAN FIX 365 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
57+
+PHPCBF CAN FIX 329 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
5858
----------------------------------------------------------------------
5959

6060

@@ -189,7 +189,7 @@ diff --git a/tests/fixed/example-class.php b/tests/fixed/example-class.php
189189
index 7d27825..7866379 100644
190190
--- a/tests/fixed/example-class.php
191191
+++ b/tests/fixed/example-class.php
192-
@@ -25,17 +25,28 @@ class Example implements IteratorAggregate
192+
@@ -29,19 +29,30 @@ class Example extends ParentClass implements IteratorAggregate
193193
{
194194
private const VERSION = PHP_VERSION - (PHP_MINOR_VERSION * 100) - PHP_PATCH_VERSION;
195195

@@ -211,6 +211,8 @@ index 7d27825..7866379 100644
211211
+ $this->bar = $bar;
212212
+ $this->baz = $baz;
213213
$this->baxBax = $baxBax;
214+
215+
parent::__construct();
214216
}
215217

216218
/**

tests/php80-compatibility.patch

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ index 5110131..f0a3fc9 100644
55
@@ -16,7 +16,6 @@ tests/input/doc-comment-spacing.php 11 0
66
tests/input/duplicate-assignment-variable.php 1 0
77
tests/input/EarlyReturn.php 7 0
8-
tests/input/example-class.php 44 0
8+
tests/input/example-class.php 47 0
99
-tests/input/ExampleBackedEnum.php 3 0
1010
tests/input/Exceptions.php 1 0
1111
tests/input/forbidden-comments.php 14 0
@@ -23,11 +23,11 @@ index 5110131..f0a3fc9 100644
2323
tests/input/useless-semicolon.php 2 0
2424
tests/input/UselessConditions.php 21 0
2525
----------------------------------------------------------------------
26-
-A TOTAL OF 429 ERRORS AND 0 WARNINGS WERE FOUND IN 46 FILES
27-
+A TOTAL OF 423 ERRORS AND 0 WARNINGS WERE FOUND IN 45 FILES
26+
-A TOTAL OF 432 ERRORS AND 0 WARNINGS WERE FOUND IN 46 FILES
27+
+A TOTAL OF 426 ERRORS AND 0 WARNINGS WERE FOUND IN 45 FILES
2828
----------------------------------------------------------------------
29-
-PHPCBF CAN FIX 364 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
30-
+PHPCBF CAN FIX 358 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
29+
-PHPCBF CAN FIX 365 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
30+
+PHPCBF CAN FIX 359 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
3131
----------------------------------------------------------------------
3232

3333

0 commit comments

Comments
 (0)