src/Fixer/FunctionNotation/VoidReturnFixer.php
protected function applyFix(\SplFileInfo $file, Tokens $tokens)
    {
        // These cause syntax errors.
        static $blacklistFuncNames = [
            [T_STRING, '__construct'],
            [T_STRING, '__destruct'],
            [T_STRING, '__clone'],
        ];

        for ($index = $tokens->count() - 1; 0 <= $index; --$index) {
            if (!$tokens[$index]->isGivenKind(T_FUNCTION)) {
                continue;
            }

            $funcName = $tokens->getNextMeaningfulToken($index);
            if ($tokens[$funcName]->equalsAny($blacklistFuncNames, false)) {
                continue;
            }

            $startIndex = $tokens->getNextTokenOfKind($index, ['{', ';']);

            if ($this->hasReturnTypeHint($tokens, $startIndex)) {
                continue;
            }

            if ($tokens[$startIndex]->equals(';')) {
                // No function body defined, fallback to PHPDoc.
                if ($this->hasVoidReturnAnnotation($tokens, $index)) {
                    $this->fixFunctionDefinition($tokens, $startIndex);
                }

                continue;
            }

            if ($this->hasReturnAnnotation($tokens, $index)) {
                continue;
            }

            $endIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_CURLY_BRACE, $startIndex);

            if ($this->hasVoidReturn($tokens, $startIndex, $endIndex)) {
                $this->fixFunctionDefinition($tokens, $startIndex);
            }
        }
    }
protected function applyFix(\SplFileInfo $file, Tokens $tokens)
    {
        // These cause syntax errors.
        static $blacklistFuncNames = [
            [T_STRING, '__construct'],
            [T_STRING, '__destruct'],
            [T_STRING, '__clone'],
        ];

        for ($index = $tokens->count() - 1; 0 <= $index; --$index) {
            if (!$tokens[$index]->isGivenKind(T_FUNCTION)) {
                continue;
            }

            $funcName = $tokens->getNextMeaningfulToken($index);
            if ($tokens[$funcName]->equalsAny($blacklistFuncNames, false)) {
                continue;
            }

            $startIndex = $tokens->getNextTokenOfKind($index, ['{', ';']);

            if ($this->hasReturnTypeHint($tokens, $startIndex)) {
                continue;
            }

            if ($tokens[$startIndex]->equals(';')) {
                // No function body defined, fallback to PHPDoc.
                if ($this->hasVoidReturnAnnotation($tokens, $index)) {
                    $this->fixFunctionDefinition($tokens, $startIndex);
                }

                continue;
            }

            if ($this->hasReturnAnnotation($tokens, $index)) {
                continue;
            }

            $endIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_CURLY_BRACE, $startIndex);

            if ($this->hasVoidReturn($tokens, $startIndex, $endIndex)) {
                $this->fixFunctionDefinition($tokens, $startIndex);
            }
        }
    }
protected function applyFix ( \ SplFileInfo $ file , Tokens $ tokens ) { // These cause syntax errors. static $ blacklistFuncNames = [ [ T_STRING , '__construct' ] , [ T_STRING , '__destruct' ] , [ T_STRING , '__clone' ] , ] ; for ( $ index = $ tokens -> count ( ) - 1 ; 0 <= $ index ; -- $ index ) { if ( ! $ tokens [ $ index ] -> isGivenKind ( T_FUNCTION ) ) { continue ; } $ funcName = $ tokens -> getNextMeaningfulToken ( $ index ) ; if ( $ tokens [ $ funcName ] -> equalsAny ( $ blacklistFuncNames , false ) ) { continue ; } $ startIndex = $ tokens -> getNextTokenOfKind ( $ index , [ '{' , ';' ] ) ; if ( $ this -> hasReturnTypeHint ( $ tokens , $ startIndex ) ) { continue ; } if ( $ tokens [ $ startIndex ] -> equals ( ';' ) ) { // No function body defined, fallback to PHPDoc. if ( $ this -> hasVoidReturnAnnotation ( $ tokens , $ index ) ) { $ this -> fixFunctionDefinition ( $ tokens , $ startIndex ) ; } continue ; } if ( $ this -> hasReturnAnnotation ( $ tokens , $ index ) ) { continue ; } $ endIndex = $ tokens -> findBlockEnd ( Tokens :: BLOCK_TYPE_CURLY_BRACE , $ startIndex ) ; if ( $ this -> hasVoidReturn ( $ tokens , $ startIndex , $ endIndex ) ) { $ this -> fixFunctionDefinition ( $ tokens , $ startIndex ) ; } } }
{@inheritdoc}
{