Skip to content

Commit

Permalink
fix: the return type hint was incorrect here and would cause an error…
Browse files Browse the repository at this point in the history
… e.g. when mapping records to objects
  • Loading branch information
mindplay-dk committed Oct 27, 2024
1 parent 548da07 commit fd6f68b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/framework/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public function __construct(PreparedStatement $statement, int $batch_size, array
}

/**
* @return array<string,mixed>|null first record of the record-set (or NULL, if the record-set is empty)
* @return mixed|null first record of the record-set (or NULL, if the record-set is empty)
*/
public function firstRow(): array|null
public function firstRow(): mixed
{
foreach ($this->createIterator(1) as $record) {
return $record; // break from loop immediately after fetching the first record
Expand Down
4 changes: 2 additions & 2 deletions test/test-unit.php
Original file line number Diff line number Diff line change
Expand Up @@ -696,14 +696,14 @@ function () {
$mappers = [new RecordMapper(function (array $record) use (&$calls) {
$calls[] = $record;

return $record;
return (object) $record;
})];

$result = new Result($mock_statement, 20, $mappers);

$record = $result->firstRow();

eq($record, ['id' => 1], 'should return first row');
eq($record->id, 1, 'should return first result');

eq($calls, [['id' => 1]], 'should process precisely one record (disregarding batch size)');
}
Expand Down

0 comments on commit fd6f68b

Please sign in to comment.