@@ -50,9 +50,28 @@ public function process(File $phpcsFile, $stackPtr)
50
50
{
51
51
$ tokens = $ phpcsFile ->getTokens ();
52
52
$ 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
+ }
54
74
55
- $ commentEnd = $ phpcsFile ->findPrevious ($ find , ($ stackPtr - 1 ), null , true );
56
75
if ($ tokens [$ commentEnd ]['code ' ] !== T_DOC_COMMENT_CLOSE_TAG
57
76
&& $ tokens [$ commentEnd ]['code ' ] !== T_COMMENT
58
77
) {
@@ -69,7 +88,7 @@ public function process(File $phpcsFile, $stackPtr)
69
88
return ;
70
89
}
71
90
72
- if ($ tokens [$ commentEnd ]['line ' ] !== ($ tokens [$ stackPtr ]['line ' ] - 1 )) {
91
+ if ($ tokens [$ previousContent ]['line ' ] !== ($ tokens [$ stackPtr ]['line ' ] - 1 )) {
73
92
$ error = 'There must be no blank lines after the class comment ' ;
74
93
$ phpcsFile ->addError ($ error , $ commentEnd , 'SpacingAfter ' );
75
94
}
0 commit comments