|
21 | 21 | use const T_ABSTRACT; |
22 | 22 | use const T_ANON_CLASS; |
23 | 23 | use const T_AS; |
| 24 | +use const T_ATTRIBUTE_END; |
24 | 25 | use const T_CLOSE_CURLY_BRACKET; |
25 | 26 | use const T_CONST; |
26 | 27 | use const T_FINAL; |
@@ -194,19 +195,31 @@ private function getMemberStartPointer(File $phpcsFile, int $memberPointer): int |
194 | 195 | $tokens = $phpcsFile->getTokens(); |
195 | 196 |
|
196 | 197 | $memberFirstCodePointer = $this->getMemberFirstCodePointer($phpcsFile, $memberPointer); |
197 | | - $pointerBefore = TokenHelper::findPreviousExcluding($phpcsFile, T_WHITESPACE, $memberFirstCodePointer - 1); |
198 | | - |
199 | | - if ( |
200 | | - in_array($tokens[$pointerBefore]['code'], Tokens::$commentTokens, true) |
201 | | - && $tokens[$pointerBefore]['line'] + 1 === $tokens[$memberFirstCodePointer]['line'] |
202 | | - ) { |
203 | | - $pointerBeforeComment = TokenHelper::findPreviousEffective($phpcsFile, $pointerBefore - 1); |
204 | | - if ($tokens[$pointerBeforeComment]['line'] !== $tokens[$pointerBefore]['line']) { |
205 | | - return array_key_exists('comment_opener', $tokens[$pointerBefore]) |
206 | | - ? $tokens[$pointerBefore]['comment_opener'] |
207 | | - : CommentHelper::getMultilineCommentStartPointer($phpcsFile, $pointerBefore); |
| 198 | + |
| 199 | + do { |
| 200 | + $pointerBefore = TokenHelper::findPreviousExcluding($phpcsFile, T_WHITESPACE, $memberFirstCodePointer - 1); |
| 201 | + |
| 202 | + if ($tokens[$pointerBefore]['code'] === T_ATTRIBUTE_END) { |
| 203 | + $memberFirstCodePointer = $tokens[$pointerBefore]['attribute_opener']; |
| 204 | + continue; |
208 | 205 | } |
209 | | - } |
| 206 | + |
| 207 | + if ( |
| 208 | + in_array($tokens[$pointerBefore]['code'], Tokens::$commentTokens, true) |
| 209 | + && $tokens[$pointerBefore]['line'] + 1 === $tokens[$memberFirstCodePointer]['line'] |
| 210 | + ) { |
| 211 | + $pointerBeforeComment = TokenHelper::findPreviousEffective($phpcsFile, $pointerBefore - 1); |
| 212 | + if ($tokens[$pointerBeforeComment]['line'] !== $tokens[$pointerBefore]['line']) { |
| 213 | + $memberFirstCodePointer = array_key_exists('comment_opener', $tokens[$pointerBefore]) |
| 214 | + ? $tokens[$pointerBefore]['comment_opener'] |
| 215 | + : CommentHelper::getMultilineCommentStartPointer($phpcsFile, $pointerBefore); |
| 216 | + continue; |
| 217 | + } |
| 218 | + } |
| 219 | + |
| 220 | + break; |
| 221 | + |
| 222 | + } while (true); |
210 | 223 |
|
211 | 224 | return $memberFirstCodePointer; |
212 | 225 | } |
|
0 commit comments