File tree 4 files changed +29
-27
lines changed
4 files changed +29
-27
lines changed Original file line number Diff line number Diff line change @@ -43,26 +43,8 @@ public function process(File $phpcsFile, $stackPtr)
43
43
}
44
44
}
45
45
46
- $ name = $ phpcsFile ->getDeclarationName ($ stackPtr );
47
- $ isTestFunction = strpos ($ name , 'test ' ) === 0 ;
48
- $ isAllowedFunction = in_array ($ name , ['setUp ' , 'tearDown ' ]);
49
- $ commentRequired = !$ isTestFunction && !$ isAllowedFunction ;
50
-
51
- if (T_DOC_COMMENT_CLOSE_TAG !== $ tokens [$ commentEnd ]['code ' ]
52
- && T_COMMENT !== $ tokens [$ commentEnd ]['code ' ]
53
- ) {
54
- $ hasComment = false ;
55
- $ phpcsFile ->recordMetric ($ stackPtr , 'Function has doc comment ' , 'no ' );
56
-
57
- if ($ commentRequired ) {
58
- $ phpcsFile ->addError ('Missing function doc comment ' , $ stackPtr , 'Missing ' );
59
-
60
- return ;
61
- }
62
- } else {
63
- $ hasComment = true ;
64
- $ phpcsFile ->recordMetric ($ stackPtr , 'Function has doc comment ' , 'yes ' );
65
- }
46
+ $ hasComment = T_DOC_COMMENT_CLOSE_TAG === $ tokens [$ commentEnd ]['code ' ]
47
+ || T_COMMENT === $ tokens [$ commentEnd ]['code ' ];
66
48
67
49
if ($ hasComment ) {
68
50
if (T_COMMENT === $ tokens [$ commentEnd ]['code ' ]) {
Original file line number Diff line number Diff line change @@ -94,3 +94,12 @@ function testToIgnore2()
94
94
{
95
95
$ test = 42 ;
96
96
}
97
+
98
+ function toIgnore1 ()
99
+ {
100
+ $ test = 42 ;
101
+ }
102
+ function toIgnore2 ()
103
+ {
104
+ $ test = 42 ;
105
+ }
Original file line number Diff line number Diff line change @@ -97,3 +97,13 @@ function testToIgnore2()
97
97
{
98
98
$test = 42;
99
99
}
100
+
101
+ function toIgnore1()
102
+ {
103
+ $test = 42;
104
+ }
105
+
106
+ function toIgnore2()
107
+ {
108
+ $test = 42;
109
+ }
Original file line number Diff line number Diff line change @@ -22,13 +22,14 @@ class FunctionCommentUnitTest extends AbstractSniffUnitTest
22
22
public function getErrorList ()
23
23
{
24
24
return array (
25
- 5 => 1 ,
26
- 10 => 2 ,
27
- 43 => 1 ,
28
- 48 => 2 ,
29
- 76 => 2 ,
30
- 83 => 1 ,
31
- 93 => 1 ,
25
+ 5 => 1 ,
26
+ 10 => 2 ,
27
+ 43 => 1 ,
28
+ 48 => 2 ,
29
+ 76 => 2 ,
30
+ 83 => 1 ,
31
+ 93 => 1 ,
32
+ 102 => 1 ,
32
33
);
33
34
}
34
35
You can’t perform that action at this time.
0 commit comments