src/Tokenizer/Transformer/BraceClassInstantiationTransformer.php
public function process(Tokens $tokens, Token $token, $index)
    {
        if (!$tokens[$index]->equals('(') || !$tokens[$tokens->getNextMeaningfulToken($index)]->equals([T_NEW])) {
            return;
        }

        if ($tokens[$tokens->getPrevMeaningfulToken($index)]->equalsAny([
            ']',
            [CT::T_ARRAY_INDEX_CURLY_BRACE_CLOSE],
            [CT::T_ARRAY_SQUARE_BRACE_CLOSE],
            [T_ARRAY],
            [T_CLASS],
            [T_ELSEIF],
            [T_FOR],
            [T_FOREACH],
            [T_IF],
            [T_STATIC],
            [T_STRING],
            [T_SWITCH],
            [T_VARIABLE],
            [T_WHILE],
        ])) {
            return;
        }

        $closeIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $index);

        $tokens[$index] = new Token([CT::T_BRACE_CLASS_INSTANTIATION_OPEN, '(']);
        $tokens[$closeIndex] = new Token([CT::T_BRACE_CLASS_INSTANTIATION_CLOSE, ')']);
    }
public function process(Tokens $tokens, Token $token, $index)
    {
        if (!$tokens[$index]->equals('(') || !$tokens[$tokens->getNextMeaningfulToken($index)]->equals([T_NEW])) {
            return;
        }

        if ($tokens[$tokens->getPrevMeaningfulToken($index)]->equalsAny([
            ']',
            [CT::T_ARRAY_INDEX_CURLY_BRACE_CLOSE],
            [CT::T_ARRAY_SQUARE_BRACE_CLOSE],
            [T_ARRAY],
            [T_CLASS],
            [T_ELSEIF],
            [T_FOR],
            [T_FOREACH],
            [T_IF],
            [T_STATIC],
            [T_STRING],
            [T_SWITCH],
            [T_VARIABLE],
            [T_WHILE],
        ])) {
            return;
        }

        $closeIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $index);

        $tokens[$index] = new Token([CT::T_BRACE_CLASS_INSTANTIATION_OPEN, '(']);
        $tokens[$closeIndex] = new Token([CT::T_BRACE_CLASS_INSTANTIATION_CLOSE, ')']);
    }
{@inheritdoc}