src/Fixer/FunctionNotation/CombineNestedDirnameFixer.php
protected function applyFix(\SplFileInfo $file, Tokens $tokens)
    {
        for ($index = $tokens->count() - 1; 0 <= $index; --$index) {
            $token = $tokens[$index];

            if (!$token->equals([T_STRING, 'dirname'], false)) {
                continue;
            }

            $dirnameInfo = $this->getDirnameInfo($tokens, $index);

            if (!$dirnameInfo) {
                continue;
            }

            $prev = $tokens->getPrevMeaningfulToken($dirnameInfo['indexes'][0]);

            if (!$tokens[$prev]->equals('(')) {
                continue;
            }

            $prev = $tokens->getPrevMeaningfulToken($prev);

            $firstArgumentEnd = $dirnameInfo['end'];

            $dirnameInfoArray = [$dirnameInfo];

            while ($dirnameInfo = $this->getDirnameInfo($tokens, $prev, $firstArgumentEnd)) {
                $dirnameInfoArray[] = $dirnameInfo;

                $prev = $tokens->getPrevMeaningfulToken($dirnameInfo['indexes'][0]);

                if (!$tokens[$prev]->equals('(')) {
                    break;
                }

                $prev = $tokens->getPrevMeaningfulToken($prev);
                $firstArgumentEnd = $dirnameInfo['end'];
            }

            if (\count($dirnameInfoArray) > 1) {
                $this->combineDirnames($tokens, $dirnameInfoArray);
            }

            $index = $prev;
        }
    }
protected function applyFix(\SplFileInfo $file, Tokens $tokens)
    {
        for ($index = $tokens->count() - 1; 0 <= $index; --$index) {
            $token = $tokens[$index];

            if (!$token->equals([T_STRING, 'dirname'], false)) {
                continue;
            }

            $dirnameInfo = $this->getDirnameInfo($tokens, $index);

            if (!$dirnameInfo) {
                continue;
            }

            $prev = $tokens->getPrevMeaningfulToken($dirnameInfo['indexes'][0]);

            if (!$tokens[$prev]->equals('(')) {
                continue;
            }

            $prev = $tokens->getPrevMeaningfulToken($prev);

            $firstArgumentEnd = $dirnameInfo['end'];

            $dirnameInfoArray = [$dirnameInfo];

            while ($dirnameInfo = $this->getDirnameInfo($tokens, $prev, $firstArgumentEnd)) {
                $dirnameInfoArray[] = $dirnameInfo;

                $prev = $tokens->getPrevMeaningfulToken($dirnameInfo['indexes'][0]);

                if (!$tokens[$prev]->equals('(')) {
                    break;
                }

                $prev = $tokens->getPrevMeaningfulToken($prev);
                $firstArgumentEnd = $dirnameInfo['end'];
            }

            if (\count($dirnameInfoArray) > 1) {
                $this->combineDirnames($tokens, $dirnameInfoArray);
            }

            $index = $prev;
        }
    }
protected function applyFix ( \ SplFileInfo $ file , Tokens $ tokens ) { for ( $ index = $ tokens -> count ( ) - 1 ; 0 <= $ index ; -- $ index ) { $ token = $ tokens [ $ index ] ; if ( ! $ token -> equals ( [ T_STRING , 'dirname' ] , false ) ) { continue ; } $ dirnameInfo = $ this -> getDirnameInfo ( $ tokens , $ index ) ; if ( ! $ dirnameInfo ) { continue ; } $ prev = $ tokens -> getPrevMeaningfulToken ( $ dirnameInfo [ 'indexes' ] [ 0 ] ) ; if ( ! $ tokens [ $ prev ] -> equals ( '(' ) ) { continue ; } $ prev = $ tokens -> getPrevMeaningfulToken ( $ prev ) ; $ firstArgumentEnd = $ dirnameInfo [ 'end' ] ; $ dirnameInfoArray = [ $ dirnameInfo ] ; while ( $ dirnameInfo = $ this -> getDirnameInfo ( $ tokens , $ prev , $ firstArgumentEnd ) ) { $ dirnameInfoArray [ ] = $ dirnameInfo ; $ prev = $ tokens -> getPrevMeaningfulToken ( $ dirnameInfo [ 'indexes' ] [ 0 ] ) ; if ( ! $ tokens [ $ prev ] -> equals ( '(' ) ) { break ; } $ prev = $ tokens -> getPrevMeaningfulToken ( $ prev ) ; $ firstArgumentEnd = $ dirnameInfo [ 'end' ] ; } if ( \ count ( $ dirnameInfoArray ) > 1 ) { $ this -> combineDirnames ( $ tokens , $ dirnameInfoArray ) ; } $ index = $ prev ; } }
{@inheritdoc}
{