src/Fixer/DoctrineAnnotation/DoctrineAnnotationIndentationFixer.php
protected function fixAnnotations(Tokens $tokens)
    {
        $annotationPositions = [];
        for ($index = 0, $max = \count($tokens); $index < $max; ++$index) {
            if (!$tokens[$index]->isType(DocLexer::T_AT)) {
                continue;
            }

            $annotationEndIndex = $tokens->getAnnotationEnd($index);
            if (null === $annotationEndIndex) {
                return;
            }

            $annotationPositions[] = [$index, $annotationEndIndex];
            $index = $annotationEndIndex;
        }

        $indentLevel = 0;
        foreach ($tokens as $index => $token) {
            if (!$token->isType(DocLexer::T_NONE) || false === strpos($token->getContent(), "\n")) {
                continue;
            }

            if (!$this->indentationCanBeFixed($tokens, $index, $annotationPositions)) {
                continue;
            }

            $braces = $this->getLineBracesCount($tokens, $index);
            $delta = $braces[0] - $braces[1];
            $mixedBraces = 0 === $delta && $braces[0] > 0;
            $extraIndentLevel = 0;

            if ($indentLevel > 0 && ($delta < 0 || $mixedBraces)) {
                --$indentLevel;

                if ($this->configuration['indent_mixed_lines'] && $this->isClosingLineWithMeaningfulContent($tokens, $index)) {
                    $extraIndentLevel = 1;
                }
            }

            $token->setContent(Preg::replace(
                '/(\n( +\*)?) *$/',
                '$1'.str_repeat(' ', 4 * ($indentLevel + $extraIndentLevel) + 1),
                $token->getContent()
            ));

            if ($delta > 0 || $mixedBraces) {
                ++$indentLevel;
            }
        }
    }
protected function fixAnnotations(Tokens $tokens)
    {
        $annotationPositions = [];
        for ($index = 0, $max = \count($tokens); $index < $max; ++$index) {
            if (!$tokens[$index]->isType(DocLexer::T_AT)) {
                continue;
            }

            $annotationEndIndex = $tokens->getAnnotationEnd($index);
            if (null === $annotationEndIndex) {
                return;
            }

            $annotationPositions[] = [$index, $annotationEndIndex];
            $index = $annotationEndIndex;
        }

        $indentLevel = 0;
        foreach ($tokens as $index => $token) {
            if (!$token->isType(DocLexer::T_NONE) || false === strpos($token->getContent(), "\n")) {
                continue;
            }

            if (!$this->indentationCanBeFixed($tokens, $index, $annotationPositions)) {
                continue;
            }

            $braces = $this->getLineBracesCount($tokens, $index);
            $delta = $braces[0] - $braces[1];
            $mixedBraces = 0 === $delta && $braces[0] > 0;
            $extraIndentLevel = 0;

            if ($indentLevel > 0 && ($delta < 0 || $mixedBraces)) {
                --$indentLevel;

                if ($this->configuration['indent_mixed_lines'] && $this->isClosingLineWithMeaningfulContent($tokens, $index)) {
                    $extraIndentLevel = 1;
                }
            }

            $token->setContent(Preg::replace(
                '/(\n( +\*)?) *$/',
                '$1'.str_repeat(' ', 4 * ($indentLevel + $extraIndentLevel) + 1),
                $token->getContent()
            ));

            if ($delta > 0 || $mixedBraces) {
                ++$indentLevel;
            }
        }
    }
protected function fixAnnotations ( Tokens $ tokens ) { $ annotationPositions = [ ] ; for ( $ index = 0 , $ max = \ count ( $ tokens ) ; $ index < $ max ; ++ $ index ) { if ( ! $ tokens [ $ index ] -> isType ( DocLexer :: T_AT ) ) { continue ; } $ annotationEndIndex = $ tokens -> getAnnotationEnd ( $ index ) ; if ( null === $ annotationEndIndex ) { return ; } $ annotationPositions [ ] = [ $ index , $ annotationEndIndex ] ; $ index = $ annotationEndIndex ; } $ indentLevel = 0 ; foreach ( $ tokens as $ index => $ token ) { if ( ! $ token -> isType ( DocLexer :: T_NONE ) || false === strpos ( $ token -> getContent ( ) , "\n" ) ) { continue ; } if ( ! $ this -> indentationCanBeFixed ( $ tokens , $ index , $ annotationPositions ) ) { continue ; } $ braces = $ this -> getLineBracesCount ( $ tokens , $ index ) ; $ delta = $ braces [ 0 ] - $ braces [ 1 ] ; $ mixedBraces = 0 === $ delta && $ braces [ 0 ] > 0 ; $ extraIndentLevel = 0 ; if ( $ indentLevel > 0 && ( $ delta < 0 || $ mixedBraces ) ) { -- $ indentLevel ; if ( $ this -> configuration [ 'indent_mixed_lines' ] && $ this -> isClosingLineWithMeaningfulContent ( $ tokens , $ index ) ) { $ extraIndentLevel = 1 ; } } $ token -> setContent ( Preg :: replace ( '/(\n( +\*)?) *$/' , '$1' . str_repeat ( ' ' , 4 * ( $ indentLevel + $ extraIndentLevel ) + 1 ) , $ token -> getContent ( ) ) ) ; if ( $ delta > 0 || $ mixedBraces ) { ++ $ indentLevel ; } } }
{@inheritdoc}
{