protected function applyFix(\SplFileInfo $file, Tokens $tokens)
    {
        for ($index = $tokens->count() - 1; $index >= 0; --$index) {
            if (!$tokens[$index]->isGivenKind(T_UNSET)) {
                continue;
            }

            $previousUnsetCall = $this->getPreviousUnsetCall($tokens, $index);
            if (\is_int($previousUnsetCall)) {
                $index = $previousUnsetCall;

                continue;
            }

            list($previousUnset, , $previousUnsetBraceEnd) = $previousUnsetCall;

            // Merge the tokens inside the 'unset' call into the previous one 'unset' call.
            $tokensAddCount = $this->moveTokens(
                $tokens,
                $nextUnsetContentStart = $tokens->getNextTokenOfKind($index, ['(']),
                $nextUnsetContentEnd = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $nextUnsetContentStart),
                $previousUnsetBraceEnd - 1
            );

            if (!$tokens[$previousUnsetBraceEnd]->isWhitespace()) {
                $tokens->insertAt($previousUnsetBraceEnd, new Token([T_WHITESPACE, ' ']));
                ++$tokensAddCount;
            }

            $tokens->insertAt($previousUnsetBraceEnd, new Token(','));
            ++$tokensAddCount;

            // Remove 'unset', '(', ')' and (possibly) ';' from the merged 'unset' call.
            $this->clearOffsetTokens($tokens, $tokensAddCount, [$index, $nextUnsetContentStart, $nextUnsetContentEnd]);

            $nextUnsetSemicolon = $tokens->getNextMeaningfulToken($nextUnsetContentEnd);
            if (null !== $nextUnsetSemicolon && $tokens[$nextUnsetSemicolon]->equals(';')) {
                $tokens->clearTokenAndMergeSurroundingWhitespace($nextUnsetSemicolon);
            }

            $index = $previousUnset + 1;
        }
    }
protected function applyFix(\SplFileInfo $file, Tokens $tokens)
    {
        for ($index = $tokens->count() - 1; $index >= 0; --$index) {
            if (!$tokens[$index]->isGivenKind(T_UNSET)) {
                continue;
            }

            $previousUnsetCall = $this->getPreviousUnsetCall($tokens, $index);
            if (\is_int($previousUnsetCall)) {
                $index = $previousUnsetCall;

                continue;
            }

            list($previousUnset, , $previousUnsetBraceEnd) = $previousUnsetCall;

            
            $tokensAddCount = $this->moveTokens(
                $tokens,
                $nextUnsetContentStart = $tokens->getNextTokenOfKind($index, ['(']),
                $nextUnsetContentEnd = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $nextUnsetContentStart),
                $previousUnsetBraceEnd - 1
            );

            if (!$tokens[$previousUnsetBraceEnd]->isWhitespace()) {
                $tokens->insertAt($previousUnsetBraceEnd, new Token([T_WHITESPACE, ' ']));
                ++$tokensAddCount;
            }

            $tokens->insertAt($previousUnsetBraceEnd, new Token(','));
            ++$tokensAddCount;

            
            $this->clearOffsetTokens($tokens, $tokensAddCount, [$index, $nextUnsetContentStart, $nextUnsetContentEnd]);

            $nextUnsetSemicolon = $tokens->getNextMeaningfulToken($nextUnsetContentEnd);
            if (null !== $nextUnsetSemicolon && $tokens[$nextUnsetSemicolon]->equals(';')) {
                $tokens->clearTokenAndMergeSurroundingWhitespace($nextUnsetSemicolon);
            }

            $index = $previousUnset + 1;
        }
    }
protected function applyFix ( \ SplFileInfo $ file , Tokens $ tokens ) { for ( $ index = $ tokens -> count ( ) - 1 ; $ index >= 0 ; -- $ index ) { if ( ! $ tokens [ $ index ] -> isGivenKind ( T_UNSET ) ) { continue ; } $ previousUnsetCall = $ this -> getPreviousUnsetCall ( $ tokens , $ index ) ; if ( \ is_int ( $ previousUnsetCall ) ) { $ index = $ previousUnsetCall ; continue ; } list ( $ previousUnset , , $ previousUnsetBraceEnd ) = $ previousUnsetCall ; // Merge the tokens inside the 'unset' call into the previous one 'unset' call. $ tokensAddCount = $ this -> moveTokens ( $ tokens , $ nextUnsetContentStart = $ tokens -> getNextTokenOfKind ( $ index , [ '(' ] ) , $ nextUnsetContentEnd = $ tokens -> findBlockEnd ( Tokens :: BLOCK_TYPE_PARENTHESIS_BRACE , $ nextUnsetContentStart ) , $ previousUnsetBraceEnd - 1 ) ; if ( ! $ tokens [ $ previousUnsetBraceEnd ] -> isWhitespace ( ) ) { $ tokens -> insertAt ( $ previousUnsetBraceEnd , new Token ( [ T_WHITESPACE , ' ' ] ) ) ; ++ $ tokensAddCount ; } $ tokens -> insertAt ( $ previousUnsetBraceEnd , new Token ( ',' ) ) ; ++ $ tokensAddCount ; // Remove 'unset', '(', ')' and (possibly) ';' from the merged 'unset' call. $ this -> clearOffsetTokens ( $ tokens , $ tokensAddCount , [ $ index , $ nextUnsetContentStart , $ nextUnsetContentEnd ] ) ; $ nextUnsetSemicolon = $ tokens -> getNextMeaningfulToken ( $ nextUnsetContentEnd ) ; if ( null !== $ nextUnsetSemicolon && $ tokens [ $ nextUnsetSemicolon ] -> equals ( ';' ) ) { $ tokens -> clearTokenAndMergeSurroundingWhitespace ( $ nextUnsetSemicolon ) ; } $ index = $ previousUnset + 1 ; } }
{@inheritdoc}
{