diff --git a/WordPress/AbstractClassRestrictionsSniff.php b/WordPress/AbstractClassRestrictionsSniff.php index e41cd3631..89dce6b85 100644 --- a/WordPress/AbstractClassRestrictionsSniff.php +++ b/WordPress/AbstractClassRestrictionsSniff.php @@ -128,8 +128,10 @@ public function is_targetted_token( $stackPtr ) { $nameEnd = ( $this->phpcsFile->findNext( array( \T_CLOSE_CURLY_BRACKET, \T_WHITESPACE ), ( $stackPtr + 2 ) ) - 1 ); } - $classname = GetTokensAsString::noEmpties( $this->phpcsFile, ( $stackPtr + 2 ), $nameEnd ); - $classname = $this->get_namespaced_classname( $classname, ( $stackPtr - 1 ) ); + if ( isset( $this->tokens[ $stackPtr + 2 ] ) && false !== $nameEnd ) { + $classname = GetTokensAsString::noEmpties( $this->phpcsFile, ( $stackPtr + 2 ), $nameEnd ); + $classname = $this->get_namespaced_classname( $classname, ( $stackPtr - 1 ) ); + } } if ( \T_DOUBLE_COLON === $token['code'] ) {