protected function applyFix(\SplFileInfo $file, Tokens $tokens)
    {
        $lineEnding = $this->whitespacesConfig->getLineEnding();
        foreach ($tokens as $index => $token) {
            if (!$token->isGivenKind($this->tokenKinds)) {
                continue;
            }

            $whitespace = '';
            $previousIndex = $index - 1;
            if ($tokens[$previousIndex]->isWhitespace()) {
                $whitespace = $tokens[$previousIndex]->getContent();
                --$previousIndex;
            }
            if ($tokens[$previousIndex]->isGivenKind(T_OPEN_TAG)) {
                $whitespace = Preg::replace('/\S/', '', $tokens[$previousIndex]->getContent()).$whitespace;
            }

            if (1 !== Preg::match('/\R([ \t]*)$/', $whitespace, $matches)) {
                continue;
            }

            if ($token->isGivenKind(T_COMMENT) && 'all_multiline' !== $this->configuration['comment_type'] && 1 === Preg::match('/\R(?:\R|\s*[^\s\*])/', $token->getContent())) {
                continue;
            }

            $indentation = $matches[1];
            $lines = Preg::split('/\R/u', $token->getContent());

            foreach ($lines as $lineNumber => $line) {
                if (0 === $lineNumber) {
                    continue;
                }

                $line = ltrim($line);
                if ($token->isGivenKind(T_COMMENT) && (!isset($line[0]) || '*' !== $line[0])) {
                    continue;
                }

                if (!isset($line[0])) {
                    $line = '*';
                } elseif ('*' !== $line[0]) {
                    $line = '* '.$line;
                }

                $lines[$lineNumber] = $indentation.' '.$line;
            }

            $tokens[$index] = new Token([$token->getId(), implode($lineEnding, $lines)]);
        }
    }
protected function applyFix(\SplFileInfo $file, Tokens $tokens)
    {
        $lineEnding = $this->whitespacesConfig->getLineEnding();
        foreach ($tokens as $index => $token) {
            if (!$token->isGivenKind($this->tokenKinds)) {
                continue;
            }

            $whitespace = '';
            $previousIndex = $index - 1;
            if ($tokens[$previousIndex]->isWhitespace()) {
                $whitespace = $tokens[$previousIndex]->getContent();
                --$previousIndex;
            }
            if ($tokens[$previousIndex]->isGivenKind(T_OPEN_TAG)) {
                $whitespace = Preg::replace('/\S/', '', $tokens[$previousIndex]->getContent()).$whitespace;
            }

            if (1 !== Preg::match('/\R([ \t]*)$/', $whitespace, $matches)) {
                continue;
            }

            if ($token->isGivenKind(T_COMMENT) && 'all_multiline' !== $this->configuration['comment_type'] && 1 === Preg::match('/\R(?:\R|\s*[^\s\*])/', $token->getContent())) {
                continue;
            }

            $indentation = $matches[1];
            $lines = Preg::split('/\R/u', $token->getContent());

            foreach ($lines as $lineNumber => $line) {
                if (0 === $lineNumber) {
                    continue;
                }

                $line = ltrim($line);
                if ($token->isGivenKind(T_COMMENT) && (!isset($line[0]) || '*' !== $line[0])) {
                    continue;
                }

                if (!isset($line[0])) {
                    $line = '*';
                } elseif ('*' !== $line[0]) {
                    $line = '* '.$line;
                }

                $lines[$lineNumber] = $indentation.' '.$line;
            }

            $tokens[$index] = new Token([$token->getId(), implode($lineEnding, $lines)]);
        }
    }
protected function applyFix ( \ SplFileInfo $ file , Tokens $ tokens ) { $ lineEnding = $ this -> whitespacesConfig -> getLineEnding ( ) ; foreach ( $ tokens as $ index => $ token ) { if ( ! $ token -> isGivenKind ( $ this -> tokenKinds ) ) { continue ; } $ whitespace = '' ; $ previousIndex = $ index - 1 ; if ( $ tokens [ $ previousIndex ] -> isWhitespace ( ) ) { $ whitespace = $ tokens [ $ previousIndex ] -> getContent ( ) ; -- $ previousIndex ; } if ( $ tokens [ $ previousIndex ] -> isGivenKind ( T_OPEN_TAG ) ) { $ whitespace = Preg :: replace ( '/\S/' , '' , $ tokens [ $ previousIndex ] -> getContent ( ) ) . $ whitespace ; } if ( 1 !== Preg :: match ( '/\R([ \t]*)$/' , $ whitespace , $ matches ) ) { continue ; } if ( $ token -> isGivenKind ( T_COMMENT ) && 'all_multiline' !== $ this -> configuration [ 'comment_type' ] && 1 === Preg :: match ( '/\R(?:\R|\s*[^\s\*])/' , $ token -> getContent ( ) ) ) { continue ; } $ indentation = $ matches [ 1 ] ; $ lines = Preg :: split ( '/\R/u' , $ token -> getContent ( ) ) ; foreach ( $ lines as $ lineNumber => $ line ) { if ( 0 === $ lineNumber ) { continue ; } $ line = ltrim ( $ line ) ; if ( $ token -> isGivenKind ( T_COMMENT ) && ( ! isset ( $ line [ 0 ] ) || '*' !== $ line [ 0 ] ) ) { continue ; } if ( ! isset ( $ line [ 0 ] ) ) { $ line = '*' ; } elseif ( '*' !== $ line [ 0 ] ) { $ line = '* ' . $ line ; } $ lines [ $ lineNumber ] = $ indentation . ' ' . $ line ; } $ tokens [ $ index ] = new Token ( [ $ token -> getId ( ) , implode ( $ lineEnding , $ lines ) ] ) ; } }
{@inheritdoc}
{