Skip to content

Commit

Permalink
Fix #514 issue getRecords may return null
Browse files Browse the repository at this point in the history
  • Loading branch information
nyamsprod committed Jan 16, 2024
1 parent fde594f commit 27839e5
Showing 1 changed file with 32 additions and 11 deletions.
43 changes: 32 additions & 11 deletions src/ResultSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,10 @@ public function matchingFirstOrFail(string $expression): TabularDataReader
*/
public function getRecords(array $header = []): Iterator
{
$header = $this->prepareHeader($header);
$iterator = $this->combineHeader($this->prepareHeader($header));
$iterator->rewind();

return $this->combineHeader($header);
return $iterator;
}

/**
Expand All @@ -221,7 +222,7 @@ public function getRecords(array $header = []): Iterator
* @throws MappingFailed
* @throws TypeCastingFailed
*/
public function getObjects(string $className, array $header = []): Iterator
public function getRecordsAsObject(string $className, array $header = []): Iterator
{
$header = $this->prepareHeader($header);

Expand Down Expand Up @@ -434,10 +435,10 @@ public function fetchPairs($offset_index = 0, $value_index = 1): Iterator
}

/**
* @deprecated since version 9.9.0
*
* @see ::nth
* DEPRECATION WARNING! This method will be removed in the next major point release.
*
* @see ResultSet::nth()
* @deprecated since version 9.9.0
* @codeCoverageIgnore
*/
public function fetchOne(int $nth_record = 0): array
Expand All @@ -446,18 +447,38 @@ public function fetchOne(int $nth_record = 0): array
}

/**
* @deprecated since version 9.8.0
*
* @see ::fetchColumnByName
* @see ::fetchColumnByOffset
* DEPRECATION WARNING! This method will be removed in the next major point release.
*
* @see ResultSet::fetchColumnByOffset()
* @see ResultSet::fetchColumnByName()
* @deprecated Since version 9.8.0
* @codeCoverageIgnore
* @throws Exception
*
* @param string|int $index
*/
public function fetchColumn($index = 0): Iterator
{
return $this->yieldColumn(
$this->getColumnIndex($index, 'offset', __METHOD__)
);
}

/**
* DEPRECATION WARNING! This method will be removed in the next major point release.
*
* @see Reader::getRecordsAsObject()
* @deprecated Since version 9.15.0
* @codeCoverageIgnore
*
* @param class-string $className
* @param array<string> $header
*
* @throws Exception
* @throws MappingFailed
* @throws TypeCastingFailed
*/
public function getObjects(string $className, array $header = []): Iterator
{
return $this->getRecordsAsObject($className, $header);
}
}

0 comments on commit 27839e5

Please sign in to comment.