Skip to content

Commit 27839e5

Browse files
committed
Fix #514 issue getRecords may return null
1 parent fde594f commit 27839e5

File tree

1 file changed

+32
-11
lines changed

1 file changed

+32
-11
lines changed

src/ResultSet.php

+32-11
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,10 @@ public function matchingFirstOrFail(string $expression): TabularDataReader
208208
*/
209209
public function getRecords(array $header = []): Iterator
210210
{
211-
$header = $this->prepareHeader($header);
211+
$iterator = $this->combineHeader($this->prepareHeader($header));
212+
$iterator->rewind();
212213

213-
return $this->combineHeader($header);
214+
return $iterator;
214215
}
215216

216217
/**
@@ -221,7 +222,7 @@ public function getRecords(array $header = []): Iterator
221222
* @throws MappingFailed
222223
* @throws TypeCastingFailed
223224
*/
224-
public function getObjects(string $className, array $header = []): Iterator
225+
public function getRecordsAsObject(string $className, array $header = []): Iterator
225226
{
226227
$header = $this->prepareHeader($header);
227228

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

436437
/**
437-
* @deprecated since version 9.9.0
438-
*
439-
* @see ::nth
438+
* DEPRECATION WARNING! This method will be removed in the next major point release.
440439
*
440+
* @see ResultSet::nth()
441+
* @deprecated since version 9.9.0
441442
* @codeCoverageIgnore
442443
*/
443444
public function fetchOne(int $nth_record = 0): array
@@ -446,18 +447,38 @@ public function fetchOne(int $nth_record = 0): array
446447
}
447448

448449
/**
449-
* @deprecated since version 9.8.0
450-
*
451-
* @see ::fetchColumnByName
452-
* @see ::fetchColumnByOffset
450+
* DEPRECATION WARNING! This method will be removed in the next major point release.
453451
*
452+
* @see ResultSet::fetchColumnByOffset()
453+
* @see ResultSet::fetchColumnByName()
454+
* @deprecated Since version 9.8.0
454455
* @codeCoverageIgnore
455-
* @throws Exception
456+
*
457+
* @param string|int $index
456458
*/
457459
public function fetchColumn($index = 0): Iterator
458460
{
459461
return $this->yieldColumn(
460462
$this->getColumnIndex($index, 'offset', __METHOD__)
461463
);
462464
}
465+
466+
/**
467+
* DEPRECATION WARNING! This method will be removed in the next major point release.
468+
*
469+
* @see Reader::getRecordsAsObject()
470+
* @deprecated Since version 9.15.0
471+
* @codeCoverageIgnore
472+
*
473+
* @param class-string $className
474+
* @param array<string> $header
475+
*
476+
* @throws Exception
477+
* @throws MappingFailed
478+
* @throws TypeCastingFailed
479+
*/
480+
public function getObjects(string $className, array $header = []): Iterator
481+
{
482+
return $this->getRecordsAsObject($className, $header);
483+
}
463484
}

0 commit comments

Comments
 (0)