protected function detectReturnTypeVoid(File $phpcsFile, int $index): ?string
    {
        $tokens = $phpcsFile->getTokens();

        $type = 'void';

        $methodStartIndex = $tokens[$index]['scope_opener'];
        $methodEndIndex = $tokens[$index]['scope_closer'];

        for ($i = $methodStartIndex + 1; $i < $methodEndIndex; ++$i) {
            if ($this->isGivenKind([T_FUNCTION], $tokens[$i])) {
                $endIndex = $tokens[$i]['scope_closer'];
                $i = $endIndex;
                continue;
            }

            if (!$this->isGivenKind([T_RETURN], $tokens[$i])) {
                continue;
            }

            $nextIndex = $phpcsFile->findNext(Tokens::$emptyTokens, $i + 1, null, true);
            if (!$this->isGivenKind(T_SEMICOLON, $tokens[$nextIndex])) {
                return null;
            }
        }

        return $type;
    }
protected function detectReturnTypeVoid(File $phpcsFile, int $index): ?string
    {
        $tokens = $phpcsFile->getTokens();

        $type = 'void';

        $methodStartIndex = $tokens[$index]['scope_opener'];
        $methodEndIndex = $tokens[$index]['scope_closer'];

        for ($i = $methodStartIndex + 1; $i < $methodEndIndex; ++$i) {
            if ($this->isGivenKind([T_FUNCTION], $tokens[$i])) {
                $endIndex = $tokens[$i]['scope_closer'];
                $i = $endIndex;
                continue;
            }

            if (!$this->isGivenKind([T_RETURN], $tokens[$i])) {
                continue;
            }

            $nextIndex = $phpcsFile->findNext(Tokens::$emptyTokens, $i + 1, null, true);
            if (!$this->isGivenKind(T_SEMICOLON, $tokens[$nextIndex])) {
                return null;
            }
        }

        return $type;
    }
protected function detectReturnTypeVoid ( File $ phpcsFile , int $ index ) : ? string { $ tokens = $ phpcsFile -> getTokens ( ) ; $ type = 'void' ; $ methodStartIndex = $ tokens [ $ index ] [ 'scope_opener' ] ; $ methodEndIndex = $ tokens [ $ index ] [ 'scope_closer' ] ; for ( $ i = $ methodStartIndex + 1 ; $ i < $ methodEndIndex ; ++ $ i ) { if ( $ this -> isGivenKind ( [ T_FUNCTION ] , $ tokens [ $ i ] ) ) { $ endIndex = $ tokens [ $ i ] [ 'scope_closer' ] ; $ i = $ endIndex ; continue ; } if ( ! $ this -> isGivenKind ( [ T_RETURN ] , $ tokens [ $ i ] ) ) { continue ; } $ nextIndex = $ phpcsFile -> findNext ( Tokens :: $ emptyTokens , $ i + 1 , null , true ) ; if ( ! $ this -> isGivenKind ( T_SEMICOLON , $ tokens [ $ nextIndex ] ) ) { return null ; } } return $ type ; }
For right now we only try to detect void.

@param \PHP_CodeSniffer\Files\File $phpcsFile
@param int $index

@return string|null
For right now we only try to detect void .