packages/TokenRunner/src/Naming/Name/NameFactory.php
public function createFromTokensAndStart(Tokens $tokens, int $start): Name
    {
        $nameTokens = [];

        $nextTokenPointer = $start;

        $prependNamespace = $this->shouldPrependNamespace($tokens, $nextTokenPointer);

        while ($tokens[$nextTokenPointer]->isGivenKind([T_NS_SEPARATOR, T_STRING])) {
            $nameTokens[] = $tokens[$nextTokenPointer];
            ++$nextTokenPointer;
        }

        /** @var Token[] $nameTokens */
        if ($nameTokens[0]->isGivenKind(T_NS_SEPARATOR)) {
            unset($nameTokens[0]);
            // reset array keys
            $nameTokens = array_values($nameTokens);

            // move start pointer after "\"
            --$nextTokenPointer;
        }

        if (! $tokens[$nextTokenPointer]->isGivenKind([T_STRING, T_NS_SEPARATOR])) {
            --$nextTokenPointer;
        }

        $name = '';
        foreach ($nameTokens as $nameToken) {
            $name .= $nameToken->getContent();
        }

        // resolve fully qualified name - as argument?
        $name = $this->resolveForName($tokens, $name, $prependNamespace);

        return new Name($nextTokenPointer, $start, $name, $tokens);
    }
public function createFromTokensAndStart(Tokens $tokens, int $start): Name
    {
        $nameTokens = [];

        $nextTokenPointer = $start;

        $prependNamespace = $this->shouldPrependNamespace($tokens, $nextTokenPointer);

        while ($tokens[$nextTokenPointer]->isGivenKind([T_NS_SEPARATOR, T_STRING])) {
            $nameTokens[] = $tokens[$nextTokenPointer];
            ++$nextTokenPointer;
        }

        /** @var Token[] $nameTokens */
        if ($nameTokens[0]->isGivenKind(T_NS_SEPARATOR)) {
            unset($nameTokens[0]);
            // reset array keys
            $nameTokens = array_values($nameTokens);

            // move start pointer after "\"
            --$nextTokenPointer;
        }

        if (! $tokens[$nextTokenPointer]->isGivenKind([T_STRING, T_NS_SEPARATOR])) {
            --$nextTokenPointer;
        }

        $name = '';
        foreach ($nameTokens as $nameToken) {
            $name .= $nameToken->getContent();
        }

        // resolve fully qualified name - as argument?
        $name = $this->resolveForName($tokens, $name, $prependNamespace);

        return new Name($nextTokenPointer, $start, $name, $tokens);
    }
public function createFromTokensAndStart ( Tokens $ tokens , int $ start ) : Name { $ nameTokens = [ ] ; $ nextTokenPointer = $ start ; $ prependNamespace = $ this -> shouldPrependNamespace ( $ tokens , $ nextTokenPointer ) ; while ( $ tokens [ $ nextTokenPointer ] -> isGivenKind ( [ T_NS_SEPARATOR , T_STRING ] ) ) { $ nameTokens [ ] = $ tokens [ $ nextTokenPointer ] ; ++ $ nextTokenPointer ; } /** @var Token[] $nameTokens */ if ( $ nameTokens [ 0 ] -> isGivenKind ( T_NS_SEPARATOR ) ) { unset ( $ nameTokens [ 0 ] ) ; // reset array keys $ nameTokens = array_values ( $ nameTokens ) ; // move start pointer after "\" -- $ nextTokenPointer ; } if ( ! $ tokens [ $ nextTokenPointer ] -> isGivenKind ( [ T_STRING , T_NS_SEPARATOR ] ) ) { -- $ nextTokenPointer ; } $ name = '' ; foreach ( $ nameTokens as $ nameToken ) { $ name .= $ nameToken -> getContent ( ) ; } // resolve fully qualified name - as argument? $ name = $ this -> resolveForName ( $ tokens , $ name , $ prependNamespace ) ; return new Name ( $ nextTokenPointer , $ start , $ name , $ tokens ) ; }
Inverse direction to @see createFromTokensAndEnd()
Inverse direction to