src/Tokenizer/Transformer/TypeColonTransformer.php
public function process(Tokens $tokens, Token $token, $index)
    {
        if (!$token->equals(':')) {
            return;
        }

        $endIndex = $tokens->getPrevMeaningfulToken($index);

        if (!$tokens[$endIndex]->equals(')')) {
            return;
        }

        $startIndex = $tokens->findBlockStart(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $endIndex);
        $prevIndex = $tokens->getPrevMeaningfulToken($startIndex);
        $prevToken = $tokens[$prevIndex];

        // if this could be a function name we need to take one more step
        if ($prevToken->isGivenKind(T_STRING)) {
            $prevIndex = $tokens->getPrevMeaningfulToken($prevIndex);
            $prevToken = $tokens[$prevIndex];
        }

        if ($prevToken->isGivenKind([T_FUNCTION, CT::T_RETURN_REF, CT::T_USE_LAMBDA])) {
            $tokens[$index] = new Token([CT::T_TYPE_COLON, ':']);
        }
    }
public function process(Tokens $tokens, Token $token, $index)
    {
        if (!$token->equals(':')) {
            return;
        }

        $endIndex = $tokens->getPrevMeaningfulToken($index);

        if (!$tokens[$endIndex]->equals(')')) {
            return;
        }

        $startIndex = $tokens->findBlockStart(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $endIndex);
        $prevIndex = $tokens->getPrevMeaningfulToken($startIndex);
        $prevToken = $tokens[$prevIndex];

        // if this could be a function name we need to take one more step
        if ($prevToken->isGivenKind(T_STRING)) {
            $prevIndex = $tokens->getPrevMeaningfulToken($prevIndex);
            $prevToken = $tokens[$prevIndex];
        }

        if ($prevToken->isGivenKind([T_FUNCTION, CT::T_RETURN_REF, CT::T_USE_LAMBDA])) {
            $tokens[$index] = new Token([CT::T_TYPE_COLON, ':']);
        }
    }
public function process ( Tokens $ tokens , Token $ token , $ index ) { if ( ! $ token -> equals ( ':' ) ) { return ; } $ endIndex = $ tokens -> getPrevMeaningfulToken ( $ index ) ; if ( ! $ tokens [ $ endIndex ] -> equals ( ')' ) ) { return ; } $ startIndex = $ tokens -> findBlockStart ( Tokens :: BLOCK_TYPE_PARENTHESIS_BRACE , $ endIndex ) ; $ prevIndex = $ tokens -> getPrevMeaningfulToken ( $ startIndex ) ; $ prevToken = $ tokens [ $ prevIndex ] ; // if this could be a function name we need to take one more step if ( $ prevToken -> isGivenKind ( T_STRING ) ) { $ prevIndex = $ tokens -> getPrevMeaningfulToken ( $ prevIndex ) ; $ prevToken = $ tokens [ $ prevIndex ] ; } if ( $ prevToken -> isGivenKind ( [ T_FUNCTION , CT :: T_RETURN_REF , CT :: T_USE_LAMBDA ] ) ) { $ tokens [ $ index ] = new Token ( [ CT :: T_TYPE_COLON , ':' ] ) ; } }
{@inheritdoc}
{