protected function applyFix(\SplFileInfo $file, Tokens $tokens)
    {
        $oneSpaceBefore = 'one' === $this->configuration['space_before'];

        for ($index = 0, $limit = $tokens->count(); $index < $limit; ++$index) {
            if (!$tokens[$index]->isGivenKind(CT::T_TYPE_COLON)) {
                continue;
            }

            $previousIndex = $index - 1;
            $previousToken = $tokens[$previousIndex];

            if ($previousToken->isWhitespace()) {
                if (!$tokens[$tokens->getPrevNonWhitespace($index - 1)]->isComment()) {
                    if ($oneSpaceBefore) {
                        $tokens[$previousIndex] = new Token([T_WHITESPACE, ' ']);
                    } else {
                        $tokens->clearAt($previousIndex);
                    }
                }
            } elseif ($oneSpaceBefore) {
                $tokenWasAdded = $tokens->ensureWhitespaceAtIndex($index, 0, ' ');

                if ($tokenWasAdded) {
                    ++$limit;
                }

                ++$index;
            }

            ++$index;

            $tokenWasAdded = $tokens->ensureWhitespaceAtIndex($index, 0, ' ');

            if ($tokenWasAdded) {
                ++$limit;
            }
        }
    }
protected function applyFix(\SplFileInfo $file, Tokens $tokens)
    {
        $oneSpaceBefore = 'one' === $this->configuration['space_before'];

        for ($index = 0, $limit = $tokens->count(); $index < $limit; ++$index) {
            if (!$tokens[$index]->isGivenKind(CT::T_TYPE_COLON)) {
                continue;
            }

            $previousIndex = $index - 1;
            $previousToken = $tokens[$previousIndex];

            if ($previousToken->isWhitespace()) {
                if (!$tokens[$tokens->getPrevNonWhitespace($index - 1)]->isComment()) {
                    if ($oneSpaceBefore) {
                        $tokens[$previousIndex] = new Token([T_WHITESPACE, ' ']);
                    } else {
                        $tokens->clearAt($previousIndex);
                    }
                }
            } elseif ($oneSpaceBefore) {
                $tokenWasAdded = $tokens->ensureWhitespaceAtIndex($index, 0, ' ');

                if ($tokenWasAdded) {
                    ++$limit;
                }

                ++$index;
            }

            ++$index;

            $tokenWasAdded = $tokens->ensureWhitespaceAtIndex($index, 0, ' ');

            if ($tokenWasAdded) {
                ++$limit;
            }
        }
    }
protected function applyFix ( \ SplFileInfo $ file , Tokens $ tokens ) { $ oneSpaceBefore = 'one' === $ this -> configuration [ 'space_before' ] ; for ( $ index = 0 , $ limit = $ tokens -> count ( ) ; $ index < $ limit ; ++ $ index ) { if ( ! $ tokens [ $ index ] -> isGivenKind ( CT :: T_TYPE_COLON ) ) { continue ; } $ previousIndex = $ index - 1 ; $ previousToken = $ tokens [ $ previousIndex ] ; if ( $ previousToken -> isWhitespace ( ) ) { if ( ! $ tokens [ $ tokens -> getPrevNonWhitespace ( $ index - 1 ) ] -> isComment ( ) ) { if ( $ oneSpaceBefore ) { $ tokens [ $ previousIndex ] = new Token ( [ T_WHITESPACE , ' ' ] ) ; } else { $ tokens -> clearAt ( $ previousIndex ) ; } } } elseif ( $ oneSpaceBefore ) { $ tokenWasAdded = $ tokens -> ensureWhitespaceAtIndex ( $ index , 0 , ' ' ) ; if ( $ tokenWasAdded ) { ++ $ limit ; } ++ $ index ; } ++ $ index ; $ tokenWasAdded = $ tokens -> ensureWhitespaceAtIndex ( $ index , 0 , ' ' ) ; if ( $ tokenWasAdded ) { ++ $ limit ; } } }
{@inheritdoc}
{