@@ -150,14 +150,16 @@ public function process(File $phpcsFile, $stackPtr) {
150150 $ shortContent = $ tokens [$ short ]['content ' ];
151151 $ shortEnd = $ short ;
152152 for ($ i = ($ short + 1 ); $ i < $ commentEnd ; $ i ++) {
153- if ($ tokens [$ i ]['code ' ] === T_DOC_COMMENT_STRING ) {
154- if ($ tokens [$ i ]['line ' ] === ($ tokens [$ shortEnd ]['line ' ] + 1 )) {
155- $ shortContent .= $ tokens [$ i ]['content ' ];
156- $ shortEnd = $ i ;
157- } else {
158- break ;
159- }
153+ if ($ tokens [$ i ]['code ' ] !== T_DOC_COMMENT_STRING ) {
154+ continue ;
155+ }
156+
157+ if ($ tokens [$ i ]['line ' ] !== ($ tokens [$ shortEnd ]['line ' ] + 1 )) {
158+ break ;
160159 }
160+
161+ $ shortContent .= $ tokens [$ i ]['content ' ];
162+ $ shortEnd = $ i ;
161163 }
162164
163165 if (empty ($ tokens [$ commentStart ]['comment_tags ' ]) === true ) {
@@ -171,24 +173,28 @@ public function process(File $phpcsFile, $stackPtr) {
171173 }
172174
173175 $ prev = $ phpcsFile ->findPrevious ($ empty , $ firstTag - 1 , $ stackPtr , true );
174- if ($ tokens [$ firstTag ]['line ' ] !== ($ tokens [$ prev ]['line ' ] + 2 )) {
175- $ error = 'There must be exactly one blank line before the tags in a doc comment ' ;
176- $ fix = $ phpcsFile ->addFixableError ($ error , $ firstTag , 'SpacingBeforeTags ' );
177- if ($ fix === true ) {
178- $ phpcsFile ->fixer ->beginChangeset ();
179- for ($ i = ($ prev + 1 ); $ i < $ firstTag ; $ i ++) {
180- if ($ tokens [$ i ]['line ' ] === $ tokens [$ firstTag ]['line ' ]) {
181- break ;
182- }
176+ if ($ tokens [$ firstTag ]['line ' ] === ($ tokens [$ prev ]['line ' ] + 2 )) {
177+ return ;
178+ }
183179
184- $ phpcsFile ->fixer ->replaceToken ($ i , '' );
185- }
180+ $ error = 'There must be exactly one blank line before the tags in a doc comment ' ;
181+ $ fix = $ phpcsFile ->addFixableError ($ error , $ firstTag , 'SpacingBeforeTags ' );
182+ if ($ fix !== true ) {
183+ return ;
184+ }
186185
187- $ indent = str_repeat ("\t" , $ tokens [$ stackPtr ]['column ' ] - 1 ) . ' ' ;
188- $ phpcsFile ->fixer ->addContent ($ prev , $ phpcsFile ->eolChar . $ indent . '* ' . $ phpcsFile ->eolChar );
189- $ phpcsFile ->fixer ->endChangeset ();
186+ $ phpcsFile ->fixer ->beginChangeset ();
187+ for ($ i = ($ prev + 1 ); $ i < $ firstTag ; $ i ++) {
188+ if ($ tokens [$ i ]['line ' ] === $ tokens [$ firstTag ]['line ' ]) {
189+ break ;
190190 }
191+
192+ $ phpcsFile ->fixer ->replaceToken ($ i , '' );
191193 }
194+
195+ $ indent = str_repeat ("\t" , $ tokens [$ stackPtr ]['column ' ] - 1 ) . ' ' ;
196+ $ phpcsFile ->fixer ->addContent ($ prev , $ phpcsFile ->eolChar . $ indent . '* ' . $ phpcsFile ->eolChar );
197+ $ phpcsFile ->fixer ->endChangeset ();
192198 }
193199
194200}
0 commit comments