Iterates over the token extractors map calling {@see extract()}
until a token is found.

{@inheritdoc}
343957
public function extract(Request $request)
    {
        foreach ($this->getIterator() as $extractor) {
            if ($token = $extractor->extract($request)) {
                return $token;
            }
        }

        return false;
    }
199209
public function applyExtract(IExtractStrategy $extract)
    {
        $found = [];
        foreach($this->tokens as $token) 
        { 
            if($extract->filter($token)) {
                $found[] = $token;
            }
        }
        return $found;
    }
850778
private function grabAttribsBeforeMethodToken(Tokens $tokens, $index)
    {
        static $tokenAttribsMap = [
            T_PRIVATE   => 'visibility',
            T_PROTECTED => 'visibility',
            T_PUBLIC    => null, // destroy T_PUBLIC token. This is literally the only change from the original
            T_ABSTRACT  => 'abstract',
            T_FINAL     => 'final',
            T_STATIC    => 'static',
        ];

        return $this->grabAttribsBeforeToken(
            $tokens,
            $index,
            $tokenAttribsMap,
            [
                'abstract'   => null,
                'final'      => null,
                'visibility' => null,
                'static'     => null,
            ]
        );
    }
1225409
public static function IndexOfSequenceWithCollation( $context, $iter, $value, $collation )
	{
		if ( ! is_null( $collation ) && $collation != XmlReservedNs::collationCodepoint )
		{
			if ( ! setlocale( LC_COLLATE, $collation ) )
			{
				throw XPath2Exception::withErrorCodeAndParam( "FOCH0002", Resources::FOCH0002, $collation );
			}
		}

		return new NodeIterator( function() use( $iter, $value, $collation ) { return ExtFuncs::IndexOfIterator( $iter, $value, $collation ); } );
	}
963409
def something(TokenClass):
    """"""
    def callback(lexer, match, context):
        text = match.group()
        if not text:
            return
        yield match.start(), TokenClass, text
        context.pos = match.end()
    return callback
786652
private function processTokens()
    {
        foreach ($this->getTokensStream() as list($string, $name, $pattern, $default)) {
            if (!\preg_match('/^[a-zA-Z0-9_]+$/', $name)) {
                throw new InvalidArgumentException("Invalid param name “{$name}” (source: {$this->pattern})");
            }

            Patterns::validatePatternName($name);

            $patternName = null;
            if ($patternObj = $this->patterns[$pattern] ?? null) {
                $patternName = $pattern;
                /** @var PatternInterface $patternObj */
                $pattern = $patternObj->getRegex();
            }

            if (!(new RegexTester())->isSubregex($pattern)) {
                throw new InvalidArgumentException("Invalid regex: {$pattern} (source: {$this->pattern})");
            }

            yield [
                $string,
                $name,
                $pattern,
                $default,
                $patternName,
            ];
        }
    }
38395
public Iterator<MtasToken> iterator() throws MtasParserException {
    checkTokenCollectionIndex();
    return new Iterator<MtasToken>() {

      private Iterator<Integer> indexIterator = tokenCollectionIndex.iterator();

      @Override
      public boolean hasNext() {
        return indexIterator.hasNext();
      }

      @Override
      public MtasToken next() {
        return tokenCollection.get(indexIterator.next());
      }

      @Override
      public void remove() {
        throw new UnsupportedOperationException();
      }
    };
  }
977298
private static function seekToNextType(ArrayIterator $tokenIterator, $type)
    {
        while ($tokenIterator->valid()) {
            if (self::isTokenType($tokenIterator->current(), $type)) {
                return;
            }
            $tokenIterator->next();
        }
    }
576908
private Map<String, ParseTreeNode> getTokens() throws GrammarException,
	    TreeException {
	Map<String, ParseTreeNode> tokens = new HashMap<String, ParseTreeNode>();
	ParseTreeNode tokensTree = parserTree.getChild("Tokens");
	ParseTreeNode tokenDefinitions = tokensTree.getChild("TokenDefinitions");
	for (ParseTreeNode tokenDefinition : tokenDefinitions
		.getChildren("TokenDefinition")) {
	    // identifier...
	    String identifier = tokenDefinition.getChild("IDENTIFIER")
		    .getText();
	    // token parts...
	    tokens.put(identifier, tokenDefinition);
	    // visibility...
	    ParseTreeNode visibilityAST = tokenDefinition.getChild("Visibility");
	    if (visibilityAST.hasChild("HIDE")) {
		tokenVisibility.put(identifier, Visibility.HIDDEN);
	    } else if (visibilityAST.hasChild("IGNORE")) {
		tokenVisibility.put(identifier, Visibility.IGNORED);
	    } else {
		tokenVisibility.put(identifier, Visibility.VISIBLE);
	    }
	}
	return tokens;
    }
255328
def extract_lock_token(if_header)
      token = if_header.scan(Calligraphy::LOCK_TOKEN_REGEX)
      token.flatten.first if token.is_a? Array
    end
999317
private function resolveCollection(\ArrayIterator $tokens, Type $classType, Context $context)
    {
        $isArray = ('array' === (string) $classType);

        // allow only "array" or class name before "<"
        if (!$isArray
            && (! $classType instanceof Object_ || $classType->getFqsen() === null)) {
            throw new \RuntimeException(
                $classType . ' is not a collection'
            );
        }

        $tokens->next();

        $valueType = $this->parseTypes($tokens, $context, self::PARSER_IN_COLLECTION_EXPRESSION);
        $keyType = null;

        if ($tokens->current() !== null && trim($tokens->current()) === ',') {
            // if we have a comma, then we just parsed the key type, not the value type
            $keyType = $valueType;
            if ($isArray) {
                // check the key type for an "array" collection. We allow only
                // strings or integers.
                if (! $keyType instanceof String_ &&
                    ! $keyType instanceof Integer &&
                    ! $keyType instanceof Compound
                ) {
                    throw new \RuntimeException(
                        'An array can have only integers or strings as keys'
                    );
                }

                if ($keyType instanceof Compound) {
                    foreach ($keyType->getIterator() as $item) {
                        if (! $item instanceof String_ &&
                            ! $item instanceof Integer
                        ) {
                            throw new \RuntimeException(
                                'An array can have only integers or strings as keys'
                            );
                        }
                    }
                }
            }

            $tokens->next();
            // now let's parse the value type
            $valueType = $this->parseTypes($tokens, $context, self::PARSER_IN_COLLECTION_EXPRESSION);
        }

        if ($tokens->current() !== '>') {
            if (empty($tokens->current())) {
                throw new \RuntimeException(
                    'Collection: ">" is missing'
                );
            }

            throw new \RuntimeException(
                'Unexpected character "' . $tokens->current() . '", ">" is missing'
            );
        }

        if ($isArray) {
            return new Array_($valueType, $keyType);
        }

        if ($classType instanceof Object_) {
            return $this->makeCollectionFromObject($classType, $valueType, $keyType);
        }
    }
1267931
public function extract($source, $target, ExtractionContextInterface $extractionContext)
    {
        if (!$this->canExtract($source, $target, $extractionContext)) {
            throw new ExtractionImpossibleException();
        }


        $metaData = $this->managerRegistry->getManagerForClass($source->name)->getClassMetadata($source->name);
        if (!$metaData instanceof ClassMetadata) {
            return;
        }

        if ($metaData->isInheritanceTypeNone()) {
            return;
        }

        $swagger = $extractionContext->getSwagger();

        if ($metaData->isRootEntity()) {
            $target->discriminator = $metaData->discriminatorColumn['name'];
            $target->required[] = $target->discriminator;
            foreach ($metaData->discriminatorMap as $key => $class) {
                $schema = new Schema();
                $swagger->extract($class, $schema, $extractionContext);
            }
            $target->properties[$metaData->discriminatorColumn['name']] = $property = new Schema();
            $property->type = 'string';
            $property->description = 'The concrete class of the inheritance.';
            $property->enum = array_keys($metaData->discriminatorMap);
        } else {
            if(isset($target->properties[$metaData->discriminatorColumn['name']])) {
                $property = $target->properties[$metaData->discriminatorColumn['name']];
                $property->description = 'Discriminator property. Value will be ';
                $property->type = 'string';
                $property->enum = [$metaData->discriminatorValue];
            }
        }
    }
214089
private function _tokens($source, $offset = 0, $additional = [], $embedded = false)
    {
        $result = new UnprocessedTokens();

        /** @var Language $language */
        foreach ($this->_rules($embedded) as $rule) {
            foreach ($rule->match($source) as $token) {
                $result->add($token, $offset);
            }
        }

        return $result->batch($additional);
    }
479161
private Set<TokenDefinition> extractHiddenAndIgnoredTokensFromGrammar() {
	Set<TokenDefinition> hiddenAndIgnoredTokens = new LinkedHashSet<TokenDefinition>();
	for (TokenDefinition tokenDefinition : grammar.getTokenDefinitions().getDefinitions()) {
	    Visibility visibility = tokenDefinition.getVisibility();
	    if ((visibility == Visibility.HIDDEN) || (visibility == Visibility.IGNORED)) {
		hiddenAndIgnoredTokens.add(tokenDefinition);
	    }
	}
	return hiddenAndIgnoredTokens;
    }
4193
private function extract($data): iterable
    {
        $items = null === $this->extract ? $data : ($this->extract)($data, $this);

        if (null === $items) {
            $items = new \EmptyIterator();
        }

        if (!\is_iterable($items)) {
            throw new EtlException('Could not extract data.');
        }

        try {
            foreach ($items as $key => $item) {
                try {
                    $this->shouldSkip = false;
                    $this->eventDispatcher->dispatch(new ItemEvent(EtlEvents::EXTRACT, $item, $key, $this));
                    yield $key => $item;
                } catch (\Exception $e) {
                    continue;
                }
            }
        } catch (\Throwable $e) {
            /** @var ItemExceptionEvent $event */
            $event = $this->eventDispatcher->dispatch(new ItemExceptionEvent(EtlEvents::EXTRACT_EXCEPTION, $item ?? null, $key ?? null, $this, $e));
            if ($event->shouldThrowException()) {
                throw $e;
            }
        }
    }
129726
public static function tokenHasMultipleBoundaryCharactersTogether($token, &$tokens, $i, &$originalTokens)
    {
        return $token[Tokenizer::TOKEN_TYPE] === Tokenizer::TOKEN_TYPE_BOUNDARY
        && self::tokenPreviousCharacterIsBoundary($tokens, $i)
        && self::tokenPreviousCharacterIsWhiteSpace($token, $originalTokens);
    }
592108
public function extract()
	{
		$this->reader->read($this->file);

		$this->converter
			 ->setExtension($this->extension)
			 ->process($this->reader->getData());
	}