diff --git a/src/framework/Result.php b/src/framework/Result.php index ebd6fe8..a01b4a7 100644 --- a/src/framework/Result.php +++ b/src/framework/Result.php @@ -39,9 +39,9 @@ public function __construct(PreparedStatement $statement, int $batch_size, array } /** - * @return array|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 diff --git a/test/test-unit.php b/test/test-unit.php index c3a2db6..015d1d5 100644 --- a/test/test-unit.php +++ b/test/test-unit.php @@ -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)'); }