Skip to content

Commit 521fe5c

Browse files
committed
Clean up order of Psalm and PHPStan docblock comments
1 parent c56ed37 commit 521fe5c

File tree

5 files changed

+112
-15
lines changed

5 files changed

+112
-15
lines changed

src/Unleashed/ruleset.xml

+31-6
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,12 @@
176176
<property name="linesCountBetweenDescriptionAndAnnotations" value="1"/>
177177
<property name="linesCountBetweenAnnotationsGroups" value="1"/>
178178
<property name="annotationsGroups" type="array">
179+
<!-- Important annotations -->
179180
<element value="
180181
@internal,
181182
@deprecated,
182183
"/>
183-
<element value="@var"/>
184+
<!-- References -->
184185
<element value="
185186
@link,
186187
@see,
@@ -190,6 +191,27 @@
190191
<element value="@test, @group, @dataProvider, @depends, @doesNotPerformAssertions, @runInSeparateProcess, @runTestsInSeparateProcesses"/>
191192
<element value="@expectedDeprecation, @expectedException, @expectedExceptionCode, @expectedExceptionMessage, @expectedExceptionMessageRegExp"/>
192193
<element value="@covers, @coversNothing, @coversDefaultClass"/>
194+
<!-- Variable types -->
195+
<element value="
196+
@var,
197+
@psalm-var,
198+
@phpstan-var,
199+
"/>
200+
<!-- Generics -->
201+
<element value="
202+
@template,
203+
@template-covariant,
204+
@extends,
205+
@template-extends,
206+
@implements,
207+
@template-implements,
208+
"/>
209+
<element value="
210+
@phpstan-template,
211+
@phpstan-template-covariant,
212+
@phpstan-extends,
213+
@phpstan-implements,
214+
"/>
193215
<!-- Doctrine ORM and Extensions -->
194216
<element value="
195217
@ORM\,
@@ -199,14 +221,14 @@
199221
"/>
200222
<!-- Symfony validation -->
201223
<element value="@Assert\"/>
224+
<!-- Types -->
202225
<element value="@param"/>
226+
<element value="@psalm-param"/>
227+
<element value="@phpstan-param"/>
203228
<element value="@return"/>
229+
<element value="@psalm-return"/>
230+
<element value="@phpstan-return"/>
204231
<element value="@throws"/>
205-
<element value="
206-
@psalm-var,
207-
@psalm-param,
208-
@psalm-return,
209-
"/>
210232
<element value="
211233
@property,
212234
@property-read,
@@ -218,6 +240,9 @@
218240
<element value="
219241
@param-out,
220242
"/>
243+
<!-- Misc -->
244+
<element value="@psalm-"/>
245+
<element value="@phpstan-"/>
221246
<element value="@phpcsSuppress"/>
222247
</property>
223248
</properties>

tests/expected_report.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ tests/input/concatenation_spacing.php 49 0
1111
tests/input/constants-no-lsb.php 2 0
1212
tests/input/constants-var.php 4 0
1313
tests/input/ControlStructures.php 17 2
14-
tests/input/doc-comment-spacing.php 12 0
14+
tests/input/doc-comment-spacing.php 16 0
1515
tests/input/doctrine-migration.php 18 6
1616
tests/input/duplicate-assignment-variable.php 1 0
1717
tests/input/EarlyReturn.php 6 0
@@ -47,9 +47,9 @@ tests/input/use-ordering.php 9 0
4747
tests/input/useless-semicolon.php 2 0
4848
tests/input/UselessConditions.php 23 0
4949
----------------------------------------------------------------------
50-
A TOTAL OF 407 ERRORS AND 8 WARNINGS WERE FOUND IN 43 FILES
50+
A TOTAL OF 411 ERRORS AND 8 WARNINGS WERE FOUND IN 43 FILES
5151
----------------------------------------------------------------------
52-
PHPCBF CAN FIX 330 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
52+
PHPCBF CAN FIX 334 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
5353
----------------------------------------------------------------------
5454

5555

tests/fixed/doc-comment-spacing.php

+29
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,26 @@
77
use BarException;
88
use FooException;
99

10+
/**
11+
* @template T
12+
* @template-covariant
13+
* @extends
14+
* @implements
15+
*
16+
* @phpstan-template
17+
* @phpstan-template-covariant
18+
* @phpstan-extends
19+
* @phpstan-implements T
20+
*/
1021
class Test
1122
{
23+
/**
24+
* @var array<mixed>
25+
* @psalm-var list<mixed>
26+
* @phpstan-var array<mixed>
27+
*/
28+
public $foo = [];
29+
1230
/**
1331
* Description
1432
*/
@@ -59,10 +77,21 @@ public function c(iterable $foo): void
5977
* @param int[] $foo
6078
* @param int[] $bar
6179
*
80+
* @psalm-param list<int>
81+
*
82+
* @phpstan-param int[]
83+
*
6284
* @return int[]
6385
*
86+
* @psalm-return list<int>
87+
*
88+
* @phpstan-return int[]
89+
*
6490
* @throws FooException
6591
* @throws BarException
92+
*
93+
* @psalm-internal
94+
* @psalm-pure
6695
*/
6796
public function d(iterable $foo, iterable $bar): iterable
6897
{

tests/input/doc-comment-spacing.php

+25
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,27 @@
77
use BarException;
88
use FooException;
99

10+
/**
11+
* @implements
12+
* @extends
13+
* @template T
14+
* @template-covariant
15+
* @phpstan-implements T
16+
* @phpstan-extends
17+
* @phpstan-template
18+
* @phpstan-template-covariant
19+
*/
1020
class Test
1121
{
22+
/**
23+
* @var array<mixed>
24+
*
25+
* @phpstan-var array<mixed>
26+
*
27+
* @psalm-var list<mixed>
28+
*/
29+
public $foo = [];
30+
1231
/**
1332
*
1433
* Description
@@ -55,6 +74,12 @@ public function c(iterable $foo) : void
5574
* @PHPCR\Uuid
5675
* @param int[] $bar
5776
* @PHPCR\Field
77+
* @psalm-internal
78+
* @psalm-param list<int>
79+
* @psalm-return list<int>
80+
* @psalm-pure
81+
* @phpstan-param int[]
82+
* @phpstan-return int[]
5883
* @ODM\Column
5984
* @ORM\Column
6085
* @see other

tests/php-compatibility.patch

+24-6
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,15 @@ index 71be9a5..f9492c7 100644
4343
'array_key_exists' => true,
4444
'array_slice' => true,
4545
diff --git a/tests/expected_report.txt b/tests/expected_report.txt
46-
index 827fedc..fe8f917 100644
46+
index c07423b..9b0ebf0 100644
4747
--- a/tests/expected_report.txt
4848
+++ b/tests/expected_report.txt
49-
@@ -15,7 +15,7 @@ tests/input/doc-comment-spacing.php 12 0
49+
@@ -11,11 +11,11 @@ tests/input/concatenation_spacing.php 49 0
50+
tests/input/constants-no-lsb.php 2 0
51+
tests/input/constants-var.php 4 0
52+
tests/input/ControlStructures.php 17 2
53+
-tests/input/doc-comment-spacing.php 16 0
54+
+tests/input/doc-comment-spacing.php 17 0
5055
tests/input/doctrine-migration.php 18 6
5156
tests/input/duplicate-assignment-variable.php 1 0
5257
tests/input/EarlyReturn.php 6 0
@@ -67,14 +72,27 @@ index 827fedc..fe8f917 100644
6772
tests/input/useless-semicolon.php 2 0
6873
tests/input/UselessConditions.php 23 0
6974
----------------------------------------------------------------------
70-
-A TOTAL OF 407 ERRORS AND 8 WARNINGS WERE FOUND IN 43 FILES
71-
+A TOTAL OF 411 ERRORS AND 8 WARNINGS WERE FOUND IN 43 FILES
75+
-A TOTAL OF 411 ERRORS AND 8 WARNINGS WERE FOUND IN 43 FILES
76+
+A TOTAL OF 416 ERRORS AND 8 WARNINGS WERE FOUND IN 43 FILES
7277
----------------------------------------------------------------------
73-
-PHPCBF CAN FIX 330 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
74-
+PHPCBF CAN FIX 334 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
78+
-PHPCBF CAN FIX 334 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
79+
+PHPCBF CAN FIX 339 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
7580
----------------------------------------------------------------------
7681

7782

83+
diff --git a/tests/fixed/doc-comment-spacing.php b/tests/fixed/doc-comment-spacing.php
84+
index 7798686..bb40667 100644
85+
--- a/tests/fixed/doc-comment-spacing.php
86+
+++ b/tests/fixed/doc-comment-spacing.php
87+
@@ -25,7 +25,7 @@ class Test
88+
* @psalm-var list<mixed>
89+
* @phpstan-var array<mixed>
90+
*/
91+
- public $foo = [];
92+
+ public array $foo = [];
93+
94+
/**
95+
* Description
7896
diff --git a/tests/fixed/example-class.php b/tests/fixed/example-class.php
7997
index 0f98ce6..050d89c 100644
8098
--- a/tests/fixed/example-class.php

0 commit comments

Comments
 (0)