File tree Expand file tree Collapse file tree 4 files changed +29
-27
lines changed Expand file tree Collapse file tree 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)
4343 }
4444 }
4545
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 ' ];
6648
6749 if ($ hasComment ) {
6850 if (T_COMMENT === $ tokens [$ commentEnd ]['code ' ]) {
Original file line number Diff line number Diff line change @@ -94,3 +94,12 @@ function testToIgnore2()
9494{
9595 $ test = 42 ;
9696}
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()
9797{
9898 $test = 42;
9999}
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
2222 public function getErrorList ()
2323 {
2424 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 ,
3233 );
3334 }
3435
You can’t perform that action at this time.
0 commit comments