protected function parseTokens(array $tokens): array
    {
        $tokenIterator = new ArrayIterator($tokens);
        $messages      = [];

        for ($key = 0; $key < $tokenIterator->count(); $key++) {
            foreach ($this->sequences as $sequence) {
                $message = '';
                $domain  = $this->defaultDomain;
                $tokenIterator->seek($key);

                foreach ($sequence as $sequenceKey => $item) {
                    $this->seekToNextRelevantToken($tokenIterator);

                    if ($this->normalizeToken($tokenIterator->current()) === $item) {
                        $tokenIterator->next();

                        continue;
                    }

                    if (self::MESSAGE_TOKEN === $item) {
                        $message = $this->getValue($tokenIterator);

                        if (\count($sequence) === ($sequenceKey + 1)) {
                            break;
                        }
                    } elseif (self::METHOD_ARGUMENTS_TOKEN === $item) {
                        $this->skipMethodArgument($tokenIterator);
                    } elseif (self::DOMAIN_TOKEN === $item) {
                        $domain = $this->getValue($tokenIterator);

                        break;
                    } else {
                        break;
                    }
                }

                if ($message) {
                    $messages[$domain][\trim($message)] = $this->prefix . \trim($message);

                    break;
                }
            }
        }

        return $messages;
    }
protected function parseTokens(array $tokens): array
    {
        $tokenIterator = new ArrayIterator($tokens);
        $messages      = [];

        for ($key = 0; $key < $tokenIterator->count(); $key++) {
            foreach ($this->sequences as $sequence) {
                $message = '';
                $domain  = $this->defaultDomain;
                $tokenIterator->seek($key);

                foreach ($sequence as $sequenceKey => $item) {
                    $this->seekToNextRelevantToken($tokenIterator);

                    if ($this->normalizeToken($tokenIterator->current()) === $item) {
                        $tokenIterator->next();

                        continue;
                    }

                    if (self::MESSAGE_TOKEN === $item) {
                        $message = $this->getValue($tokenIterator);

                        if (\count($sequence) === ($sequenceKey + 1)) {
                            break;
                        }
                    } elseif (self::METHOD_ARGUMENTS_TOKEN === $item) {
                        $this->skipMethodArgument($tokenIterator);
                    } elseif (self::DOMAIN_TOKEN === $item) {
                        $domain = $this->getValue($tokenIterator);

                        break;
                    } else {
                        break;
                    }
                }

                if ($message) {
                    $messages[$domain][\trim($message)] = $this->prefix . \trim($message);

                    break;
                }
            }
        }

        return $messages;
    }
protected function parseTokens ( array $ tokens ) : array { $ tokenIterator = new ArrayIterator ( $ tokens ) ; $ messages = [ ] ; for ( $ key = 0 ; $ key < $ tokenIterator -> count ( ) ; $ key ++ ) { foreach ( $ this -> sequences as $ sequence ) { $ message = '' ; $ domain = $ this -> defaultDomain ; $ tokenIterator -> seek ( $ key ) ; foreach ( $ sequence as $ sequenceKey => $ item ) { $ this -> seekToNextRelevantToken ( $ tokenIterator ) ; if ( $ this -> normalizeToken ( $ tokenIterator -> current ( ) ) === $ item ) { $ tokenIterator -> next ( ) ; continue ; } if ( self :: MESSAGE_TOKEN === $ item ) { $ message = $ this -> getValue ( $ tokenIterator ) ; if ( \ count ( $ sequence ) === ( $ sequenceKey + 1 ) ) { break ; } } elseif ( self :: METHOD_ARGUMENTS_TOKEN === $ item ) { $ this -> skipMethodArgument ( $ tokenIterator ) ; } elseif ( self :: DOMAIN_TOKEN === $ item ) { $ domain = $ this -> getValue ( $ tokenIterator ) ; break ; } else { break ; } } if ( $ message ) { $ messages [ $ domain ] [ \ trim ( $ message ) ] = $ this -> prefix . \ trim ( $ message ) ; break ; } } } return $ messages ; }
Extracts trans message from PHP tokens.

@param array $tokens

@return array
Extracts trans message from PHP tokens .