@@ -92,6 +92,8 @@ public function process(File $phpcsFile, $stackPtr)
9292 $ nsSep = $ phpcsFile ->findNext ($ scanTokens , ($ stackPtr + 1 ));
9393
9494 while ($ nsSep !== false ) {
95+ $ nsSep = (int ) $ nsSep ;
96+
9597 $ classNameEnd = $ phpcsFile ->findNext (
9698 $ this ->classNameTokens ,
9799 $ nsSep ,
@@ -126,7 +128,8 @@ public function process(File $phpcsFile, $stackPtr)
126128 continue ;
127129 }
128130
129- $ next = ($ tag + 1 );
131+ $ next = ($ tag + 1 );
132+ // PHP Code Sniffer will magically add T_DOC_COMMENT_CLOSE_TAG with empty string content.
130133 $ lineEnd = $ phpcsFile ->findNext (
131134 array (
132135 T_DOC_COMMENT_CLOSE_TAG ,
@@ -138,13 +141,15 @@ public function process(File $phpcsFile, $stackPtr)
138141 $ docCommentStringPtr = $ phpcsFile ->findNext (
139142 array (T_DOC_COMMENT_STRING ),
140143 $ next ,
141- $ lineEnd
144+ ( int ) $ lineEnd
142145 );
143146
144147 if ($ docCommentStringPtr === false ) {
145148 continue ;
146149 }
147150
151+ $ docCommentStringPtr = (int ) $ docCommentStringPtr ;
152+
148153 $ docLine = $ tokens [$ docCommentStringPtr ]['content ' ];
149154
150155 $ docLineTokens = preg_split (
@@ -210,13 +215,13 @@ protected function getUseStatements(
210215 $ useTokenPtr = $ phpcsFile ->findNext (T_USE , $ i , $ end );
211216
212217 while ($ useTokenPtr !== false ) {
213- $ classNameStart = $ phpcsFile ->findNext (
218+ $ classNameStart = ( int ) $ phpcsFile ->findNext (
214219 PHP_CodeSniffer_Tokens::$ emptyTokens ,
215220 ($ useTokenPtr + 1 ),
216221 $ end ,
217222 true
218223 );
219- $ classNameEnd = $ phpcsFile ->findNext (
224+ $ classNameEnd = ( int ) $ phpcsFile ->findNext (
220225 $ this ->classNameTokens ,
221226 ($ classNameStart + 1 ),
222227 $ end ,
@@ -230,7 +235,12 @@ protected function getUseStatements(
230235 $ classNameEnd ,
231236 $ end
232237 );
233- $ aliasNamePtr = $ phpcsFile ->findPrevious (
238+ // Prevent endless loop when 'use ;' is the last use statement.
239+ if ($ useEnd === false ) {
240+ break ;
241+ }
242+
243+ $ aliasNamePtr = $ phpcsFile ->findPrevious (
234244 PHP_CodeSniffer_Tokens::$ emptyTokens ,
235245 ($ useEnd - 1 ),
236246 null ,
@@ -279,6 +289,8 @@ protected function getNamespace(File $phpcsFile, $start, $end)
279289 return '' ;
280290 }
281291
292+ $ namespaceStart = (int ) $ namespaceStart ;
293+
282294 $ namespaceEnd = $ phpcsFile ->findNext (
283295 $ this ->classNameTokens ,
284296 ($ namespaceStart + 1 ),
0 commit comments