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)
7878 $ ignore = (Tokens::$ methodPrefixes + Tokens::$ phpcsCommentTokens );
7979 $ ignore [T_WHITESPACE ] = T_WHITESPACE ;
8080 $ functionCodeStart = $ stackPtr ;
81+ $ phpstanCommentLines = 0 ;
8182
8283 for ($ commentEnd = ($ stackPtr - 1 ); $ commentEnd >= 0 ; $ commentEnd --) {
8384 if (isset ($ ignore [$ tokens [$ commentEnd ]['code ' ]]) === true ) {
@@ -95,6 +96,15 @@ public function process(File $phpcsFile, $stackPtr)
9596 continue ;
9697 }
9798
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+
98108 break ;
99109 }
100110
@@ -166,7 +176,7 @@ public function process(File $phpcsFile, $stackPtr)
166176 }
167177 }//end foreach
168178
169- if ($ tokens [$ commentEnd ]['line ' ] !== ($ tokens [$ functionCodeStart ]['line ' ] - 1 )) {
179+ if ($ tokens [$ commentEnd ]['line ' ] !== ($ tokens [$ functionCodeStart ]['line ' ] - 1 - $ phpstanCommentLines )) {
170180 $ error = 'There must be no blank lines after the function comment ' ;
171181 $ fix = $ phpcsFile ->addFixableError ($ error , $ commentEnd , 'SpacingAfter ' );
172182 if ($ fix === true ) {
You can’t perform that action at this time.
0 commit comments