File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -78,6 +78,7 @@ public function process(File $phpcsFile, $stackPtr)
78
78
$ ignore = (Tokens::$ methodPrefixes + Tokens::$ phpcsCommentTokens );
79
79
$ ignore [T_WHITESPACE ] = T_WHITESPACE ;
80
80
$ functionCodeStart = $ stackPtr ;
81
+ $ phpstanCommentLines = 0 ;
81
82
82
83
for ($ commentEnd = ($ stackPtr - 1 ); $ commentEnd >= 0 ; $ commentEnd --) {
83
84
if (isset ($ ignore [$ tokens [$ commentEnd ]['code ' ]]) === true ) {
@@ -95,6 +96,15 @@ public function process(File $phpcsFile, $stackPtr)
95
96
continue ;
96
97
}
97
98
99
+ // If there is a phpstan-ignore inline comment disregard it and continue searching backwards
100
+ // to find the function comment.
101
+ if ($ tokens [$ commentEnd ]['code ' ] === T_COMMENT
102
+ && preg_match ('/\@xphpstan-ignore/ ' , $ tokens [$ commentEnd ]['content ' ])
103
+ ) {
104
+ $ phpstanCommentLines += 1 ;
105
+ continue ;
106
+ }
107
+
98
108
break ;
99
109
}
100
110
@@ -166,7 +176,7 @@ public function process(File $phpcsFile, $stackPtr)
166
176
}
167
177
}//end foreach
168
178
169
- if ($ tokens [$ commentEnd ]['line ' ] !== ($ tokens [$ functionCodeStart ]['line ' ] - 1 )) {
179
+ if ($ tokens [$ commentEnd ]['line ' ] !== ($ tokens [$ functionCodeStart ]['line ' ] - 1 - $ phpstanCommentLines )) {
170
180
$ error = 'There must be no blank lines after the function comment ' ;
171
181
$ fix = $ phpcsFile ->addFixableError ($ error , $ commentEnd , 'SpacingAfter ' );
172
182
if ($ fix === true ) {
You can’t perform that action at this time.
0 commit comments