src/Fixer/CastNotation/CastSpacesFixer.php
protected function applyFix(\SplFileInfo $file, Tokens $tokens)
    {
        foreach ($tokens as $index => $token) {
            if (!$token->isCast()) {
                continue;
            }

            $tokens[$index] = new Token([
                $token->getId(),
                strtr($token->getContent(), self::INSIDE_CAST_SPACE_REPLACE_MAP),
            ]);

            if ('single' === $this->configuration['space']) {
                // force single whitespace after cast token:
                if ($tokens[$index + 1]->isWhitespace(" \t")) {
                    // - if next token is whitespaces that contains only spaces and tabs - override next token with single space
                    $tokens[$index + 1] = new Token([T_WHITESPACE, ' ']);
                } elseif (!$tokens[$index + 1]->isWhitespace()) {
                    // - if next token is not whitespaces that contains spaces, tabs and new lines - append single space to current token
                    $tokens->insertAt($index + 1, new Token([T_WHITESPACE, ' ']));
                }

                continue;
            }

            // force no whitespace after cast token:
            if ($tokens[$index + 1]->isWhitespace()) {
                $tokens->clearAt($index + 1);
            }
        }
    }
protected function applyFix(\SplFileInfo $file, Tokens $tokens)
    {
        foreach ($tokens as $index => $token) {
            if (!$token->isCast()) {
                continue;
            }

            $tokens[$index] = new Token([
                $token->getId(),
                strtr($token->getContent(), self::INSIDE_CAST_SPACE_REPLACE_MAP),
            ]);

            if ('single' === $this->configuration['space']) {
                // force single whitespace after cast token:
                if ($tokens[$index + 1]->isWhitespace(" \t")) {
                    // - if next token is whitespaces that contains only spaces and tabs - override next token with single space
                    $tokens[$index + 1] = new Token([T_WHITESPACE, ' ']);
                } elseif (!$tokens[$index + 1]->isWhitespace()) {
                    // - if next token is not whitespaces that contains spaces, tabs and new lines - append single space to current token
                    $tokens->insertAt($index + 1, new Token([T_WHITESPACE, ' ']));
                }

                continue;
            }

            // force no whitespace after cast token:
            if ($tokens[$index + 1]->isWhitespace()) {
                $tokens->clearAt($index + 1);
            }
        }
    }
protected function applyFix ( \ SplFileInfo $ file , Tokens $ tokens ) { foreach ( $ tokens as $ index => $ token ) { if ( ! $ token -> isCast ( ) ) { continue ; } $ tokens [ $ index ] = new Token ( [ $ token -> getId ( ) , strtr ( $ token -> getContent ( ) , self :: INSIDE_CAST_SPACE_REPLACE_MAP ) , ] ) ; if ( 'single' === $ this -> configuration [ 'space' ] ) { // force single whitespace after cast token: if ( $ tokens [ $ index + 1 ] -> isWhitespace ( " \t" ) ) { // - if next token is whitespaces that contains only spaces and tabs - override next token with single space $ tokens [ $ index + 1 ] = new Token ( [ T_WHITESPACE , ' ' ] ) ; } elseif ( ! $ tokens [ $ index + 1 ] -> isWhitespace ( ) ) { // - if next token is not whitespaces that contains spaces, tabs and new lines - append single space to current token $ tokens -> insertAt ( $ index + 1 , new Token ( [ T_WHITESPACE , ' ' ] ) ) ; } continue ; } // force no whitespace after cast token: if ( $ tokens [ $ index + 1 ] -> isWhitespace ( ) ) { $ tokens -> clearAt ( $ index + 1 ) ; } } }
{@inheritdoc}
{