src/Fixer/ClassNotation/OrderedClassElementsFixer.php
private function detectElementType(Tokens $tokens, $index)
    {
        $token = $tokens[$index];

        if ($token->isGivenKind(CT::T_USE_TRAIT)) {
            return 'use_trait';
        }

        if ($token->isGivenKind(T_CONST)) {
            return 'constant';
        }

        if ($token->isGivenKind(T_VARIABLE)) {
            return 'property';
        }

        $nameToken = $tokens[$tokens->getNextMeaningfulToken($index)];

        if ($nameToken->equals([T_STRING, '__construct'], false)) {
            return 'construct';
        }

        if ($nameToken->equals([T_STRING, '__destruct'], false)) {
            return 'destruct';
        }

        if (
            $nameToken->equalsAny([
                [T_STRING, 'setUpBeforeClass'],
                [T_STRING, 'tearDownAfterClass'],
                [T_STRING, 'setUp'],
                [T_STRING, 'tearDown'],
            ], false)
        ) {
            return ['phpunit', strtolower($nameToken->getContent())];
        }

        if ('__' === substr($nameToken->getContent(), 0, 2)) {
            return 'magic';
        }

        return 'method';
    }
private function detectElementType(Tokens $tokens, $index)
    {
        $token = $tokens[$index];

        if ($token->isGivenKind(CT::T_USE_TRAIT)) {
            return 'use_trait';
        }

        if ($token->isGivenKind(T_CONST)) {
            return 'constant';
        }

        if ($token->isGivenKind(T_VARIABLE)) {
            return 'property';
        }

        $nameToken = $tokens[$tokens->getNextMeaningfulToken($index)];

        if ($nameToken->equals([T_STRING, '__construct'], false)) {
            return 'construct';
        }

        if ($nameToken->equals([T_STRING, '__destruct'], false)) {
            return 'destruct';
        }

        if (
            $nameToken->equalsAny([
                [T_STRING, 'setUpBeforeClass'],
                [T_STRING, 'tearDownAfterClass'],
                [T_STRING, 'setUp'],
                [T_STRING, 'tearDown'],
            ], false)
        ) {
            return ['phpunit', strtolower($nameToken->getContent())];
        }

        if ('__' === substr($nameToken->getContent(), 0, 2)) {
            return 'magic';
        }

        return 'method';
    }
private function detectElementType ( Tokens $ tokens , $ index ) { $ token = $ tokens [ $ index ] ; if ( $ token -> isGivenKind ( CT :: T_USE_TRAIT ) ) { return 'use_trait' ; } if ( $ token -> isGivenKind ( T_CONST ) ) { return 'constant' ; } if ( $ token -> isGivenKind ( T_VARIABLE ) ) { return 'property' ; } $ nameToken = $ tokens [ $ tokens -> getNextMeaningfulToken ( $ index ) ] ; if ( $ nameToken -> equals ( [ T_STRING , '__construct' ] , false ) ) { return 'construct' ; } if ( $ nameToken -> equals ( [ T_STRING , '__destruct' ] , false ) ) { return 'destruct' ; } if ( $ nameToken -> equalsAny ( [ [ T_STRING , 'setUpBeforeClass' ] , [ T_STRING , 'tearDownAfterClass' ] , [ T_STRING , 'setUp' ] , [ T_STRING , 'tearDown' ] , ] , false ) ) { return [ 'phpunit' , strtolower ( $ nameToken -> getContent ( ) ) ] ; } if ( '__' === substr ( $ nameToken -> getContent ( ) , 0 , 2 ) ) { return 'magic' ; } return 'method' ; }
@param Tokens $tokens
@param int    $index

@return array|string type or array of type and name
@param Tokens $tokens @param int $index