src/QueryResult.php
public function yieldObject(string $fetchClassName)
    {
        if (!count($this->data)) {
            yield;
        }
        $column = $this->getColumns();
        $columnCount = count($column);
        foreach ($this->data as $data) {
            $reflectionClass = new \ReflectionClass($fetchClassName);
            $newInstance = $reflectionClass->newInstanceWithoutConstructor();
            for ($i = 0; $i < $columnCount; $i++) {
                if ($reflectionClass->hasProperty($column[$i]->getName())) {
                    $property = $reflectionClass->getProperty($column[$i]->getName());
                    $property->setAccessible(true);
                    $property->setValue($newInstance, $data[$i]);
                }
            }
            yield $newInstance;
        }
    }
public function yieldObject(string $fetchClassName)
    {
        if (!count($this->data)) {
            yield;
        }
        $column = $this->getColumns();
        $columnCount = count($column);
        foreach ($this->data as $data) {
            $reflectionClass = new \ReflectionClass($fetchClassName);
            $newInstance = $reflectionClass->newInstanceWithoutConstructor();
            for ($i = 0; $i < $columnCount; $i++) {
                if ($reflectionClass->hasProperty($column[$i]->getName())) {
                    $property = $reflectionClass->getProperty($column[$i]->getName());
                    $property->setAccessible(true);
                    $property->setValue($newInstance, $data[$i]);
                }
            }
            yield $newInstance;
        }
    }
@param string $fetchClassName

@return \Generator