@@ -456,19 +456,30 @@ protected function documentedReturnType(array $tokens, int $docBlockReturnIndex)
456456 protected function hasReturnType (File $ phpcsFile , int $ stackPtr ): bool
457457 {
458458 $ tokens = $ phpcsFile ->getTokens ();
459- if (empty ($ tokens [$ stackPtr ]['parenthesis_closer ' ]) || empty ( $ tokens [ $ stackPtr ][ ' scope_opener ' ]) ) {
459+ if (empty ($ tokens [$ stackPtr ]['parenthesis_closer ' ])) {
460460 return false ;
461461 }
462462
463463 $ parenthesisCloserIndex = $ tokens [$ stackPtr ]['parenthesis_closer ' ];
464- $ scopeOpenerIndex = $ tokens [$ stackPtr ]['scope_opener ' ];
465- $ nextIndex = $ phpcsFile ->findNext (Tokens::$ emptyTokens , $ parenthesisCloserIndex + 1 , $ scopeOpenerIndex , true );
466464
467- if ($ tokens [$ nextIndex ]['code ' ] !== T_COLON ) {
465+ // For interface/abstract methods, there's no scope_opener - look for semicolon instead
466+ if (empty ($ tokens [$ stackPtr ]['scope_opener ' ])) {
467+ $ endIndex = $ phpcsFile ->findNext (T_SEMICOLON , $ parenthesisCloserIndex + 1 );
468+ } else {
469+ $ endIndex = $ tokens [$ stackPtr ]['scope_opener ' ];
470+ }
471+
472+ if (!$ endIndex ) {
468473 return false ;
469474 }
470475
471- $ typeHintIndex = $ phpcsFile ->findNext (Tokens::$ emptyTokens , $ nextIndex + 1 , $ scopeOpenerIndex , true );
476+ $ nextIndex = $ phpcsFile ->findNext (Tokens::$ emptyTokens , $ parenthesisCloserIndex + 1 , $ endIndex , true );
477+
478+ if ($ nextIndex === false || $ tokens [$ nextIndex ]['code ' ] !== T_COLON ) {
479+ return false ;
480+ }
481+
482+ $ typeHintIndex = $ phpcsFile ->findNext (Tokens::$ emptyTokens , $ nextIndex + 1 , $ endIndex , true );
472483 if (!$ typeHintIndex ) {
473484 return false ;
474485 }
0 commit comments