Skip to content

Commit 8678949

Browse files
committed
Merge branch 'development'
2 parents 94d095d + 94d99b1 commit 8678949

2 files changed

Lines changed: 17 additions & 11 deletions

File tree

src/Result.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ public function fetchAll(string $class = null, mixed ...$constructor) : array
164164
* @param string|null $class
165165
* @param mixed ...$constructor
166166
*
167-
* @return object|null
167+
* @return object
168168
*/
169-
public function fetchRow(int $offset, string $class = null, mixed ...$constructor) : object | null
169+
public function fetchRow(int $offset, string $class = null, mixed ...$constructor) : object
170170
{
171171
$this->checkIsFree();
172172
$this->moveCursor($offset);
@@ -176,12 +176,12 @@ public function fetchRow(int $offset, string $class = null, mixed ...$constructo
176176
/**
177177
* Fetches the current row as array and move the cursor to the next.
178178
*
179-
* @return array<string,int|string|null>|null
179+
* @return array<string, float|int|string|null>|null
180180
*/
181-
public function fetchArray() : ?array
181+
public function fetchArray() : array | null
182182
{
183183
$this->checkIsFree();
184-
return $this->result->fetch_assoc();
184+
return $this->result->fetch_assoc(); // @phpstan-ignore-line
185185
}
186186

187187
/**
@@ -200,13 +200,13 @@ public function fetchArrayAll() : array
200200
*
201201
* @param int $offset
202202
*
203-
* @return array<string,int|string|null>
203+
* @return array<string, float|int|string|null>
204204
*/
205205
public function fetchArrayRow(int $offset) : array
206206
{
207207
$this->checkIsFree();
208208
$this->moveCursor($offset);
209-
return $this->result->fetch_assoc();
209+
return $this->result->fetch_assoc(); // @phpstan-ignore-line
210210
}
211211

212212
/**
@@ -229,10 +229,10 @@ public function numRows() : int | string
229229
public function fetchFields() : array
230230
{
231231
$this->checkIsFree();
232-
$fields = $this->result->fetch_fields();
233-
foreach ($fields as &$field) {
234-
$field = new Field($field);
232+
$fields = [];
233+
foreach ($this->result->fetch_fields() as $field) {
234+
$fields[] = new Field($field);
235235
}
236-
return $fields; // @phpstan-ignore-line
236+
return $fields;
237237
}
238238
}

tests/ResultTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ public function testFetchRow() : void
9494
$result = static::$database->query('SELECT * FROM `t1`');
9595
self::assertSame(1, $result->fetchRow(0)->c1);
9696
self::assertSame(4, $result->fetchRow(3)->c1);
97+
$this->expectException(\OutOfRangeException::class);
98+
$this->expectExceptionMessage('Invalid cursor offset: 5');
99+
$result->fetchRow(5);
97100
}
98101

99102
public function testFetchRowFree() : void
@@ -106,6 +109,9 @@ public function testFetchArrayRow() : void
106109
$result = static::$database->query('SELECT * FROM `t1`');
107110
self::assertSame(1, $result->fetchArrayRow(0)['c1']);
108111
self::assertSame(4, $result->fetchArrayRow(3)['c1']);
112+
$this->expectException(\OutOfRangeException::class);
113+
$this->expectExceptionMessage('Invalid cursor offset: 5');
114+
$result->fetchArrayRow(5);
109115
}
110116

111117
public function testFetchArrayRowFree() : void

0 commit comments

Comments
 (0)