src/Fixer/ControlStructure/NoAlternativeSyntaxFixer.php
private function addBraces(Tokens $tokens, Token $token, $index, $colonIndex)
    {
        $items = [
            new Token('}'),
            new Token([T_WHITESPACE, ' ']),
            $token,
        ];
        if (!$tokens[$index + 1]->isWhitespace()) {
            $items[] = new Token([T_WHITESPACE, ' ']);
        }
        $tokens->clearAt($index);
        $tokens->insertAt(
            $index,
            $items
        );

        // increment the position of the colon by number of items inserted
        $colonIndex += \count($items);

        $items = [new Token('{')];
        if (!$tokens[$colonIndex + 1]->isWhitespace()) {
            $items[] = new Token([T_WHITESPACE, ' ']);
        }

        $tokens->clearAt($colonIndex);
        $tokens->insertAt(
            $colonIndex,
            $items
        );
    }
private function addBraces(Tokens $tokens, Token $token, $index, $colonIndex)
    {
        $items = [
            new Token('}'),
            new Token([T_WHITESPACE, ' ']),
            $token,
        ];
        if (!$tokens[$index + 1]->isWhitespace()) {
            $items[] = new Token([T_WHITESPACE, ' ']);
        }
        $tokens->clearAt($index);
        $tokens->insertAt(
            $index,
            $items
        );

        // increment the position of the colon by number of items inserted
        $colonIndex += \count($items);

        $items = [new Token('{')];
        if (!$tokens[$colonIndex + 1]->isWhitespace()) {
            $items[] = new Token([T_WHITESPACE, ' ']);
        }

        $tokens->clearAt($colonIndex);
        $tokens->insertAt(
            $colonIndex,
            $items
        );
    }
private function addBraces ( Tokens $ tokens , Token $ token , $ index , $ colonIndex ) { $ items = [ new Token ( '}' ) , new Token ( [ T_WHITESPACE , ' ' ] ) , $ token , ] ; if ( ! $ tokens [ $ index + 1 ] -> isWhitespace ( ) ) { $ items [ ] = new Token ( [ T_WHITESPACE , ' ' ] ) ; } $ tokens -> clearAt ( $ index ) ; $ tokens -> insertAt ( $ index , $ items ) ; // increment the position of the colon by number of items inserted $ colonIndex += \ count ( $ items ) ; $ items = [ new Token ( '{' ) ] ; if ( ! $ tokens [ $ colonIndex + 1 ] -> isWhitespace ( ) ) { $ items [ ] = new Token ( [ T_WHITESPACE , ' ' ] ) ; } $ tokens -> clearAt ( $ colonIndex ) ; $ tokens -> insertAt ( $ colonIndex , $ items ) ; }
Add opening and closing braces to the else: and elseif: .

@param Tokens $tokens     the tokens collection
@param Token  $token      the current token
@param int    $index      the current token index
@param int    $colonIndex the index of the colon
Add opening and closing braces to the else : and elseif : .