lib/PublicVisibility.php
private function grabAttribsBeforeToken(Tokens $tokens, $index, array $tokenAttribsMap, array $attribs)
    {
        while (true) {
            $token = $tokens[--$index];

            if (!$token->isArray()) {
                if ($token->equalsAny(['{', '}', '(', ')'])) {
                    break;
                }

                continue;
            }

            // if token is attribute
            if (array_key_exists($token->getId(), $tokenAttribsMap)) {
                // set token attribute if token map defines attribute name for token
                if ($tokenAttribsMap[$token->getId()]) {
                    $attribs[$tokenAttribsMap[$token->getId()]] = clone $token;
                }

                // clear the token and whitespaces after it
                $tokens[$index]->clear();
                $tokens[$index + 1]->clear();

                continue;
            }

            if ($token->isGivenKind([T_WHITESPACE, T_COMMENT, T_DOC_COMMENT])) {
                continue;
            }

            break;
        }

        return $attribs;
    }
private function grabAttribsBeforeToken(Tokens $tokens, $index, array $tokenAttribsMap, array $attribs)
    {
        while (true) {
            $token = $tokens[--$index];

            if (!$token->isArray()) {
                if ($token->equalsAny(['{', '}', '(', ')'])) {
                    break;
                }

                continue;
            }

            // if token is attribute
            if (array_key_exists($token->getId(), $tokenAttribsMap)) {
                // set token attribute if token map defines attribute name for token
                if ($tokenAttribsMap[$token->getId()]) {
                    $attribs[$tokenAttribsMap[$token->getId()]] = clone $token;
                }

                // clear the token and whitespaces after it
                $tokens[$index]->clear();
                $tokens[$index + 1]->clear();

                continue;
            }

            if ($token->isGivenKind([T_WHITESPACE, T_COMMENT, T_DOC_COMMENT])) {
                continue;
            }

            break;
        }

        return $attribs;
    }
private function grabAttribsBeforeToken ( Tokens $ tokens , $ index , array $ tokenAttribsMap , array $ attribs ) { while ( true ) { $ token = $ tokens [ -- $ index ] ; if ( ! $ token -> isArray ( ) ) { if ( $ token -> equalsAny ( [ '{' , '}' , '(' , ')' ] ) ) { break ; } continue ; } // if token is attribute if ( array_key_exists ( $ token -> getId ( ) , $ tokenAttribsMap ) ) { // set token attribute if token map defines attribute name for token if ( $ tokenAttribsMap [ $ token -> getId ( ) ] ) { $ attribs [ $ tokenAttribsMap [ $ token -> getId ( ) ] ] = clone $ token ; } // clear the token and whitespaces after it $ tokens [ $ index ] -> clear ( ) ; $ tokens [ $ index + 1 ] -> clear ( ) ; continue ; } if ( $ token -> isGivenKind ( [ T_WHITESPACE , T_COMMENT , T_DOC_COMMENT ] ) ) { continue ; } break ; } return $ attribs ; }
Grab attributes before token at given index.

Grabbed attributes are cleared by overriding them with empty string and should be manually applied with applyTokenAttribs method.

@param Tokens $tokens          Tokens collection
@param int    $index           token index
@param array  $tokenAttribsMap token to attribute name map
@param array  $attribs         array of token attributes

@return array array of grabbed attributes
Grab attributes before token at given index .