Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
natanfelles committed Aug 13, 2024
2 parents 94d095d + 94d99b1 commit 8678949
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ public function fetchAll(string $class = null, mixed ...$constructor) : array
* @param string|null $class
* @param mixed ...$constructor
*
* @return object|null
* @return object
*/
public function fetchRow(int $offset, string $class = null, mixed ...$constructor) : object | null
public function fetchRow(int $offset, string $class = null, mixed ...$constructor) : object
{
$this->checkIsFree();
$this->moveCursor($offset);
Expand All @@ -176,12 +176,12 @@ public function fetchRow(int $offset, string $class = null, mixed ...$constructo
/**
* Fetches the current row as array and move the cursor to the next.
*
* @return array<string,int|string|null>|null
* @return array<string, float|int|string|null>|null
*/
public function fetchArray() : ?array
public function fetchArray() : array | null
{
$this->checkIsFree();
return $this->result->fetch_assoc();
return $this->result->fetch_assoc(); // @phpstan-ignore-line
}

/**
Expand All @@ -200,13 +200,13 @@ public function fetchArrayAll() : array
*
* @param int $offset
*
* @return array<string,int|string|null>
* @return array<string, float|int|string|null>
*/
public function fetchArrayRow(int $offset) : array
{
$this->checkIsFree();
$this->moveCursor($offset);
return $this->result->fetch_assoc();
return $this->result->fetch_assoc(); // @phpstan-ignore-line
}

/**
Expand All @@ -229,10 +229,10 @@ public function numRows() : int | string
public function fetchFields() : array
{
$this->checkIsFree();
$fields = $this->result->fetch_fields();
foreach ($fields as &$field) {
$field = new Field($field);
$fields = [];
foreach ($this->result->fetch_fields() as $field) {
$fields[] = new Field($field);
}
return $fields; // @phpstan-ignore-line
return $fields;
}
}
6 changes: 6 additions & 0 deletions tests/ResultTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ public function testFetchRow() : void
$result = static::$database->query('SELECT * FROM `t1`');
self::assertSame(1, $result->fetchRow(0)->c1);
self::assertSame(4, $result->fetchRow(3)->c1);
$this->expectException(\OutOfRangeException::class);
$this->expectExceptionMessage('Invalid cursor offset: 5');
$result->fetchRow(5);
}

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

public function testFetchArrayRowFree() : void
Expand Down

0 comments on commit 8678949

Please sign in to comment.