src/Fixer/ClassNotation/ClassAttributesSeparationFixer.php
protected function applyFix(SplFileInfo $file, Tokens $tokens)
    {
        $tokensAnalyzer = new TokensAnalyzer($tokens);
        $class = $classStart = $classEnd = false;

        foreach (array_reverse($tokensAnalyzer->getClassyElements(), true) as $index => $element) {
            if (!isset($this->classElementTypes[$element['type']])) {
                continue; // not configured to be fixed
            }

            if ($element['classIndex'] !== $class) {
                $class = $element['classIndex'];
                $classStart = $tokens->getNextTokenOfKind($class, ['{']);
                $classEnd = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_CURLY_BRACE, $classStart);
            }

            if ('method' === $element['type'] && !$tokens[$class]->isGivenKind(T_INTERFACE)) {
                // method of class or trait
                $attributes = $tokensAnalyzer->getMethodAttributes($index);

                $methodEnd = true === $attributes['abstract']
                    ? $tokens->getNextTokenOfKind($index, [';'])
                    : $tokens->findBlockEnd(Tokens::BLOCK_TYPE_CURLY_BRACE, $tokens->getNextTokenOfKind($index, ['{']))
                ;

                $this->fixSpaceBelowClassMethod($tokens, $classEnd, $methodEnd);
                $this->fixSpaceAboveClassElement($tokens, $classStart, $index);

                continue;
            }

            // `const`, `property` or `method` of an `interface`
            $this->fixSpaceBelowClassElement($tokens, $classEnd, $tokens->getNextTokenOfKind($index, [';']));
            $this->fixSpaceAboveClassElement($tokens, $classStart, $index);
        }
    }
protected function applyFix(SplFileInfo $file, Tokens $tokens)
    {
        $tokensAnalyzer = new TokensAnalyzer($tokens);
        $class = $classStart = $classEnd = false;

        foreach (array_reverse($tokensAnalyzer->getClassyElements(), true) as $index => $element) {
            if (!isset($this->classElementTypes[$element['type']])) {
                continue; // not configured to be fixed
            }

            if ($element['classIndex'] !== $class) {
                $class = $element['classIndex'];
                $classStart = $tokens->getNextTokenOfKind($class, ['{']);
                $classEnd = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_CURLY_BRACE, $classStart);
            }

            if ('method' === $element['type'] && !$tokens[$class]->isGivenKind(T_INTERFACE)) {
                // method of class or trait
                $attributes = $tokensAnalyzer->getMethodAttributes($index);

                $methodEnd = true === $attributes['abstract']
                    ? $tokens->getNextTokenOfKind($index, [';'])
                    : $tokens->findBlockEnd(Tokens::BLOCK_TYPE_CURLY_BRACE, $tokens->getNextTokenOfKind($index, ['{']))
                ;

                $this->fixSpaceBelowClassMethod($tokens, $classEnd, $methodEnd);
                $this->fixSpaceAboveClassElement($tokens, $classStart, $index);

                continue;
            }

            // `const`, `property` or `method` of an `interface`
            $this->fixSpaceBelowClassElement($tokens, $classEnd, $tokens->getNextTokenOfKind($index, [';']));
            $this->fixSpaceAboveClassElement($tokens, $classStart, $index);
        }
    }
protected function applyFix ( SplFileInfo $ file , Tokens $ tokens ) { $ tokensAnalyzer = new TokensAnalyzer ( $ tokens ) ; $ class = $ classStart = $ classEnd = false ; foreach ( array_reverse ( $ tokensAnalyzer -> getClassyElements ( ) , true ) as $ index => $ element ) { if ( ! isset ( $ this -> classElementTypes [ $ element [ 'type' ] ] ) ) { continue ; // not configured to be fixed } if ( $ element [ 'classIndex' ] !== $ class ) { $ class = $ element [ 'classIndex' ] ; $ classStart = $ tokens -> getNextTokenOfKind ( $ class , [ '{' ] ) ; $ classEnd = $ tokens -> findBlockEnd ( Tokens :: BLOCK_TYPE_CURLY_BRACE , $ classStart ) ; } if ( 'method' === $ element [ 'type' ] && ! $ tokens [ $ class ] -> isGivenKind ( T_INTERFACE ) ) { // method of class or trait $ attributes = $ tokensAnalyzer -> getMethodAttributes ( $ index ) ; $ methodEnd = true === $ attributes [ 'abstract' ] ? $ tokens -> getNextTokenOfKind ( $ index , [ ';' ] ) : $ tokens -> findBlockEnd ( Tokens :: BLOCK_TYPE_CURLY_BRACE , $ tokens -> getNextTokenOfKind ( $ index , [ '{' ] ) ) ; $ this -> fixSpaceBelowClassMethod ( $ tokens , $ classEnd , $ methodEnd ) ; $ this -> fixSpaceAboveClassElement ( $ tokens , $ classStart , $ index ) ; continue ; } // `const`, `property` or `method` of an `interface` $ this -> fixSpaceBelowClassElement ( $ tokens , $ classEnd , $ tokens -> getNextTokenOfKind ( $ index , [ ';' ] ) ) ; $ this -> fixSpaceAboveClassElement ( $ tokens , $ classStart , $ index ) ; } }
{@inheritdoc}
{