Skip to content

Commit 9388922

Browse files
committed
Squiz/DocCommentAlignment: add support for final classes and final properties
If a class or property used the `final` keyword, the docblock would not be recognized as one which needed examining. Fixed now. Includes tests.
1 parent 174dbb5 commit 9388922

File tree

4 files changed

+53
-20
lines changed

4 files changed

+53
-20
lines changed

src/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public function process(File $phpcsFile, $stackPtr)
5555
T_PROTECTED => true,
5656
T_STATIC => true,
5757
T_ABSTRACT => true,
58+
T_FINAL => true,
5859
T_PROPERTY => true,
5960
T_OBJECT => true,
6061
T_PROTOTYPE => true,

src/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.inc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,16 @@ enum Suits: string
101101
* Example with no errors.
102102
**************************************************************************/
103103
function example() {}
104+
105+
/**
106+
* Some info about the class here.
107+
*/
108+
final class FinalClassWithFinalProp
109+
{
110+
/**
111+
*Some info about the property here.
112+
*
113+
* @var int
114+
*/
115+
final $property = 10;
116+
}

src/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.inc.fixed

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,16 @@ enum Suits: string
101101
* Example with no errors.
102102
**************************************************************************/
103103
function example() {}
104+
105+
/**
106+
* Some info about the class here.
107+
*/
108+
final class FinalClassWithFinalProp
109+
{
110+
/**
111+
* Some info about the property here.
112+
*
113+
* @var int
114+
*/
115+
final $property = 10;
116+
}

src/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.php

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,32 @@ final class DocCommentAlignmentUnitTest extends AbstractSniffUnitTest
3131
public function getErrorList()
3232
{
3333
return [
34-
3 => 1,
35-
11 => 1,
36-
17 => 1,
37-
18 => 1,
38-
19 => 1,
39-
23 => 2,
40-
24 => 1,
41-
25 => 2,
42-
26 => 1,
43-
32 => 1,
44-
33 => 1,
45-
38 => 1,
46-
39 => 1,
47-
75 => 1,
48-
83 => 1,
49-
84 => 1,
50-
90 => 1,
51-
91 => 1,
52-
95 => 1,
53-
96 => 1,
34+
3 => 1,
35+
11 => 1,
36+
17 => 1,
37+
18 => 1,
38+
19 => 1,
39+
23 => 2,
40+
24 => 1,
41+
25 => 2,
42+
26 => 1,
43+
32 => 1,
44+
33 => 1,
45+
38 => 1,
46+
39 => 1,
47+
75 => 1,
48+
83 => 1,
49+
84 => 1,
50+
90 => 1,
51+
91 => 1,
52+
95 => 1,
53+
96 => 1,
54+
106 => 1,
55+
107 => 1,
56+
111 => 2,
57+
112 => 1,
58+
113 => 1,
59+
114 => 1,
5460
];
5561

5662
}//end getErrorList()

0 commit comments

Comments
 (0)