@@ -50,9 +50,28 @@ public function process(File $phpcsFile, $stackPtr)
5050 {
5151 $ tokens = $ phpcsFile ->getTokens ();
5252 $ find = Tokens::$ methodPrefixes ;
53- $ find [] = T_WHITESPACE ;
53+ $ find [T_WHITESPACE ] = T_WHITESPACE ;
54+
55+ $ previousContent = null ;
56+ for ($ commentEnd = ($ stackPtr - 1 ); $ commentEnd >= 0 ; $ commentEnd --) {
57+ if (isset ($ find [$ tokens [$ commentEnd ]['code ' ]]) === true ) {
58+ continue ;
59+ }
60+
61+ if ($ previousContent === null ) {
62+ $ previousContent = $ commentEnd ;
63+ }
64+
65+ if ($ tokens [$ commentEnd ]['code ' ] === T_ATTRIBUTE_END
66+ && isset ($ tokens [$ commentEnd ]['attribute_opener ' ]) === true
67+ ) {
68+ $ commentEnd = $ tokens [$ commentEnd ]['attribute_opener ' ];
69+ continue ;
70+ }
71+
72+ break ;
73+ }
5474
55- $ commentEnd = $ phpcsFile ->findPrevious ($ find , ($ stackPtr - 1 ), null , true );
5675 if ($ tokens [$ commentEnd ]['code ' ] !== T_DOC_COMMENT_CLOSE_TAG
5776 && $ tokens [$ commentEnd ]['code ' ] !== T_COMMENT
5877 ) {
@@ -69,7 +88,7 @@ public function process(File $phpcsFile, $stackPtr)
6988 return ;
7089 }
7190
72- if ($ tokens [$ commentEnd ]['line ' ] !== ($ tokens [$ stackPtr ]['line ' ] - 1 )) {
91+ if ($ tokens [$ previousContent ]['line ' ] !== ($ tokens [$ stackPtr ]['line ' ] - 1 )) {
7392 $ error = 'There must be no blank lines after the class comment ' ;
7493 $ phpcsFile ->addError ($ error , $ commentEnd , 'SpacingAfter ' );
7594 }
0 commit comments