Required function for any class that implements IteratorAggregate.  Will
yield documents as they become available.  If cursors are returned
then subsequent requests will be made, yielding more documents.

@return \Generator
@throws MontageException
326579
public function getIterator()
    {
        //Run the query
        $resp = $this->query->execute();

        //Return the documents as an ArrayIterator to satisfy the requirements
        //of the getIterator function.
        foreach ($resp->data as $document)
        {
            yield $document;
        }

        while ($resp->cursors->next) {
            //send a new request, resetting $resp
            $resp = $this->query->execute($resp->cursors->next);

            foreach ($resp->data as $document)
            {
                yield $document;
            }
        }
    }
283635
public function getIterator()
    {
        $header = $this->getHeader();

        while ($data = $this->getNextDataSet()) {
            $headerColumns = count($header);
            $dataColumns   = count($data);

            if ($headerColumns > $dataColumns && $this->appendRowsColumns) {
                $data = array_pad($data, $headerColumns, '');
                $this->malformedStatistic['appended']++;
            } elseif ($headerColumns < $dataColumns && $this->truncateRowsColumns) {
                $data = array_slice($data, 0, $headerColumns);
                $this->malformedStatistic['truncated']++;
            } elseif ($headerColumns != $dataColumns) {
                if ($this->ignoreMalformed) {
                    $this->malformedStatistic['malformed']++;
                    continue;
                }
                throw new Exception("Count mismatch in line {$this->getLineNumber()}, expected: {$headerColumns}, got: {$dataColumns}");
            }

            $set = array_combine($header, $data);
            yield $set;
        }
    }
279682
public function getGenerator()
    {
        $query = $this->dataQuery->query()->execute();

        while ($row = $query->record()) {
            yield $this->createDataObject($row);
        }
    }
1092831
public function convertGenerator() : \Generator {
		yield 1 => $this->generatorPrefix . __( 'Initializing', 'pressbooks' );

		yield from $this->transformGenerator();

		if ( ! $this->transformOutput ) {
			throw new \Exception();
		}

		yield 75 => $this->generatorPrefix . __( 'Saving file to exports folder', 'pressbooks' );
		$filename = $this->timestampedFileName( '.html' );
		\Pressbooks\Utility\put_contents( $filename, $this->transformOutput );
		$this->outputPath = $filename;
		yield 80 => $this->generatorPrefix . __( 'Export successful', 'pressbooks' );
	}
1001755
public function generated(): ?GeneratorVerifier
    {
        $cardinality = $this->cardinality;

        if ($result = $this->checkGenerated()) {
            return $result;
        }

        return $this->assertionRecorder->createFailure(
            $this->assertionRenderer->renderGenerated($this->spy, $cardinality)
        );
    }
138955
public function getGenerator(): \Generator
    {
        if ($this->generator instanceof ArrayyRewindableGenerator) {
            yield from $this->generator;
        }

        yield from $this->array;
    }
976694
public function getIterator() {
        $ret = array();
        foreach (get_object_vars($this) as $key => $value) {
            if (substr($key, 0, 1) == '_') {
                if (method_exists($this, 'get'.$key)) {
                    $ret[substr($key, 1)] = $this->{'get'.$key}();
                } else {
                    $ret[substr($key, 1)] = $this->$key;
                }
            }
        }
        $ret['sequence'] = $this->get_sequence();
        $ret['course'] = $this->get_course();
        $ret = array_merge($ret, course_get_format($this->modinfo->get_course())->get_format_options($this->_section));
        return new ArrayIterator($ret);
    }
603873
public function parametric() : Generator
    {
        foreach ($this->hidden as $layer) {
            if ($layer instanceof Parametric) {
                yield $layer;
            }
        }

        if ($this->output instanceof Parametric) {
            yield $this->output;
        }
    }
1146098
public function generate()
    {
        $indentation = $this->getIndentation();

        $docLines = array();

        $docLines[] = $indentation . '/**';
        $spaceBeforeAnnotation = false;

        if ($this->shortDescription !== null) {
            $docLines[] = $indentation . ' * ' . $this->shortDescription;
            $spaceBeforeAnnotation = true;
        }

        if ($this->shortDescription !== null && $this->longDescription !== null) {
            $docLines[] = $indentation . ' *';
        }

        if ($this->longDescription !== null) {
            $description = preg_split('/\n|\r/', $this->longDescription, -1, PREG_SPLIT_NO_EMPTY);
            foreach ($description as $desc) {
                $docLines[] = $indentation . ' * ' . trim($desc);
            }

            $spaceBeforeAnnotation = true;
        }

        $this->annotationGenerator->setIndentationLevel($this->getIndentationLevel());
        $this->annotationGenerator->setIndentationString($this->getIndentationString());
        $annotations = $this->annotationGenerator->generate();
        if ($annotations !== '') {
            if ($spaceBeforeAnnotation === true) {
                $docLines[] = $indentation . ' *';
            }

            $docLines[] = $annotations;
        }

        $docLines[] = $indentation . ' */';

        return implode($this->getLineFeed(), $docLines);
    }
1209414
public function generateClass(): ClassGenerator
    {
        $interfaces = $this->getInterfaces();
        foreach ($interfaces as $interface) {
            $this->classGenerator->addUse($interface);
        }
        $this->classGenerator->setImplementedInterfaces($interfaces);

        $traits = $this->getTraits();
        foreach ($traits as $trait) {
            $this->classGenerator->addUse($trait);
            $this->classGenerator->addTrait((new \ReflectionClass($trait))->getShortName());
        }

        foreach ($this->metadata->getFieldsMetadata() as $fieldMetadata) {
            $fieldMetadata->generateProxy($this);
        }

        $this->generateBsonUnserializeMethod();

        return $this->classGenerator;
    }
565724
public function find()
    {
        foreach ($this->file->tokens as $i => $t) {
            if (TokenUtils::isTokenType($t, array(T_NEW))) {
                // +2 to consume whitespace
                $c = self::findClassInNextTokens($this->file->tokens, $i + 2);
                if ($c) {
                    yield $c;
                }
            } elseif (TokenUtils::isTokenType($t, array(T_IMPLEMENTS, T_EXTENDS))) {
                // +2 to consume whitespace
                $c = self::findClassInNextTokens($this->file->tokens, $i + 2);
                if ($c) {
                    yield $c;
                }
                $j = $c->to + 1;
                while ($this->file->tokens[$j] === ',') {
                    // +2 to consume comma and whitespace
                    $c = self::findClassInNextTokens($this->file->tokens, $j + 2);
                    if ($c) {
                        yield $c;
                        $j = $c->to;
                    }
                    $j++;
                }
            } elseif (TokenUtils::isTokenType($t, array(T_USE))) {
                $c = self::findClassInNextTokens($this->file->tokens, $i + 2);
                // Check if use statement is after class opening bracket
                if ($c && $this->isAfterOpeningBracket($c)) {
                    yield $c;
                }
            } elseif (TokenUtils::isTokenType($t, array(T_PAAMAYIM_NEKUDOTAYIM, T_DOUBLE_COLON))) {
                $c = self::findClassInPreviousTokens($this->file->tokens, $i - 1);
                if ($c) {
                    yield $c;
                }
            } elseif (TokenUtils::isTokenType($t, array(T_CATCH))) {
                // +3 to consume brace and whitespace
                $c = self::findClassInNextTokens($this->file->tokens, $i + 3);
                if ($c) {
                    yield $c;
                }
            } elseif (TokenUtils::isTokenType($t, array(T_INSTANCEOF))) {
                $c = self::findClassInNextTokens($this->file->tokens, $i + 2);
                if ($c) {
                    yield $c;
                }
            } elseif (TokenUtils::isTokenType($t, array(T_FUNCTION))) {
                $j = $i + 4;
                $j = TokenUtils::isTokenType($this->file->tokens[$j], T_WHITESPACE) ? $j + 1 : $j;

                // +4 to consume whitespace, name, open brace
                $c = self::findClassInNextTokens($this->file->tokens, $j);
                if ($c) {
                    yield $c;
                    $j = $c->to;
                }

                while ($this->file->tokens[$j] != ")") {
                    if ($this->file->tokens[$j] == ',') {
                        // +2 to consume comma and whitespace
                        $c = self::findClassInNextTokens($this->file->tokens, $j + 2);
                        if ($c) {
                            yield $c;
                            $j = $c->to;
                        }
                    }
                    $j++;
                }

            }
        }
    }
250525
public function getArticle(): Generator
    {
        yield from $this->sendCommand(new Command('ARTICLE'));

        $data = yield from $this->encoder->readData($this->stream);
        return Article::parse($data);
    }
1050585
private function createAggregate()
    {
        $pipeline = $this->pipeline;
        array_unshift($pipeline, ['$changeStream' => (object) $this->changeStreamOptions]);

        return new Aggregate($this->databaseName, $this->collectionName, $pipeline, $this->aggregateOptions);
    }
1089494
public function getIterator() {
		$fileIterator = new FileIterator(
			$this->getFile(),
			$this->delimiter,
			$this->partsNames
		);
		
		if ($this->delimiter === null) {
			return $fileIterator;
		}
		
		return $this->createIterator($fileIterator);
	}
38869
public function yieldLists(): \Generator
    {
        if (!isset($this->dataObjectFactory)) {
            throw new \LogicException('setDataObjectFactory must be called before calling nextList.');
        }

        if (!isset($this->objectListQuery)) {
            throw new \LogicException('setByFields must be called before calling nextList.');
        }

        // We need to yield ourselves first.
        $thisList = new Promise();
        $thisList->resolve($this);
        yield $thisList;

        $ranges = Range::nextRanges($this);
        foreach ($ranges as $range) {
            $byFields = clone $this->objectListQuery;
            $byFields->setRange($range);
            yield $this->dataObjectFactory->selectRequest($byFields);
        }
    }
649482
public function getIterator()
    {
        $csv = fopen($this->getConfig('file'), 'r');
        if ($csv === false) {
            throw new \RuntimeException('Unable to open file: ' . $this->getConfig('file'));
        }
        while (true) {
            $fields = fgetcsv(
                $csv,
                0,
                $this->getConfig('delimiter'),
                $this->getConfig('quote'),
                $this->getConfig('escape')
            );
            if ($fields === false) {
                break;
            }
            ++$this->line;
            if ($this->columns === null && $this->getConfig('header') === true) {
                $this->columns = array_map(function ($field) { return trim($field); }, $fields);
                if (count($this->columns) !== count(array_unique($this->columns))) {
                    throw new \RuntimeException(
                        'File does not have unique column headers: ' . $this->getConfig('file')
                    );
                }
            } else {
                $row = $this->getConfig('header') === true ? $this->map($fields) : $fields;
                yield empty($this->getConfig('callbacks')) === true ? $row : $this->callback($row);
            }
        }
        fclose($csv);
    }
1056499
public function transpose()
    {
        return new Enumerator(
            function () {
                $ret = [];
                foreach ($this->each() as $row) {
                    foreach ($row as $k => $col) {
                        $ret[$k][] = $col;
                    }
                }

                foreach ($ret as $k => $r) {
                    yield $k => $r;
                }
            }
        );
    }