Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions src/ResultSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,24 @@
namespace ipl\Orm;

use ArrayIterator;
use Generator;
use Iterator;
use Traversable;

class ResultSet implements Iterator
{
protected $cache;
protected ArrayIterator $cache;

/** @var bool Whether cache is disabled */
protected $isCacheDisabled = false;
protected bool $isCacheDisabled = false;

protected $generator;
protected Generator $generator;

protected $limit;
protected ?int $limit;

protected $position;
protected ?int $position = null;

public function __construct(Traversable $traversable, $limit = null)
public function __construct(Traversable $traversable, ?int $limit = null)
{
$this->cache = new ArrayIterator();
$this->generator = $this->yieldTraversable($traversable);
Expand All @@ -45,19 +46,19 @@ public static function fromQuery(Query $query)
*
* @return $this
*/
public function disableCache()
public function disableCache(): static
{
$this->isCacheDisabled = true;

return $this;
}

public function hasMore()
public function hasMore(): bool
{
return $this->generator->valid();
}

public function hasResult()
public function hasResult(): bool
{
return $this->generator->valid();
}
Expand Down Expand Up @@ -117,7 +118,7 @@ public function rewind(): void
}
}

protected function advance()
protected function advance(): void
{
if (! $this->generator->valid()) {
return;
Expand Down
Loading