Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions system/Database/BaseResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,6 @@ public function setRow($key, $value = null)

/**
* Returns the "first" row of the current results.
*
* @return array|object|null
*/
public function getFirstRow(string $type = 'object')
{
Expand All @@ -399,8 +397,6 @@ public function getFirstRow(string $type = 'object')

/**
* Returns the "last" row of the current results.
*
* @return array|object|null
*/
public function getLastRow(string $type = 'object')
{
Expand All @@ -411,8 +407,6 @@ public function getLastRow(string $type = 'object')

/**
* Returns the "next" row of the current results.
*
* @return array|object|null
*/
public function getNextRow(string $type = 'object')
{
Expand All @@ -426,8 +420,6 @@ public function getNextRow(string $type = 'object')

/**
* Returns the "previous" row of the current results.
*
* @return array|object|null
*/
public function getPreviousRow(string $type = 'object')
{
Expand Down
24 changes: 20 additions & 4 deletions system/Database/ResultInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,28 +113,44 @@ public function setRow($key, $value = null);
/**
* Returns the "first" row of the current results.
*
* @return array|object|null
* @template T of object
*
* @param 'array'|'object'|class-string<T> $type The type of result object. 'array', 'object' or class name.
*
* @return ($type is 'object' ? stdClass|null : ($type is 'array' ? array|null : T|null))
*/
public function getFirstRow(string $type = 'object');

/**
* Returns the "last" row of the current results.
*
* @return array|object|null
* @template T of object
*
* @param 'array'|'object'|class-string<T> $type The type of result object. 'array', 'object' or class name.
*
* @return ($type is 'object' ? stdClass|null : ($type is 'array' ? array|null : T|null))
*/
public function getLastRow(string $type = 'object');

/**
* Returns the "next" row of the current results.
*
* @return array|object|null
* @template T of object
*
* @param 'array'|'object'|class-string<T> $type The type of result object. 'array', 'object' or class name.
*
* @return ($type is 'object' ? stdClass|null : ($type is 'array' ? array|null : T|null))
*/
public function getNextRow(string $type = 'object');

/**
* Returns the "previous" row of the current results.
*
* @return array|object|null
* @template T of object
*
* @param 'array'|'object'|class-string<T> $type The type of result object. 'array', 'object' or class name.
*
* @return ($type is 'object' ? stdClass|null : ($type is 'array' ? array|null : T|null))
*/
public function getPreviousRow(string $type = 'object');

Expand Down
2 changes: 1 addition & 1 deletion system/Test/Mock/MockConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public function error(): array

public function insertID(): int
{
return $this->connID->insert_id;
return 0;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions tests/system/Database/Live/FabricatorLiveTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use CodeIgniter\Test\DatabaseTestTrait;
use CodeIgniter\Test\Fabricator;
use PHPUnit\Framework\Attributes\Group;
use stdClass;
use Tests\Support\Models\UserModel;
use Tests\Support\Models\ValidModel;

Expand All @@ -39,6 +40,7 @@ public function testCreateAddsToDatabase(): void
$fabricator->setOverrides(['country' => 'Spain']);

$result = $fabricator->create();
$this->assertInstanceOf(stdClass::class, $result);

$this->seeInDatabase('user', ['name' => $result->name]);
}
Expand Down
5 changes: 3 additions & 2 deletions tests/system/Database/Live/GetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace CodeIgniter\Database\Live;

use CodeIgniter\Database\BaseResult;
use CodeIgniter\Database\Exceptions\DatabaseException;
use CodeIgniter\Test\CIUnitTestCase;
use CodeIgniter\Test\DatabaseTestTrait;
Expand Down Expand Up @@ -227,13 +228,12 @@ public function testGetAnotherDataSeek(): void
public function testFreeResult(): void
{
$data = $this->db->table('job')->where('id', 4)->get();
$this->assertInstanceOf(BaseResult::class, $data);

$details = $data->getResult();

$this->assertSame('Musician', $details[0]->name);

$data->freeResult();

$this->assertFalse($data->resultID);
}

Expand Down Expand Up @@ -292,6 +292,7 @@ public function testGetNextRow(): void
public function testGetPreviousRow(): void
{
$user = $this->db->table('user')->get();
$this->assertInstanceOf(BaseResult::class, $user);

$user->currentRow = 3;

Expand Down
2 changes: 2 additions & 0 deletions tests/system/Test/FabricatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use CodeIgniter\Config\Factories;
use CodeIgniter\Model;
use PHPUnit\Framework\Attributes\Group;
use stdClass;
use Tests\Support\Models\EntityModel;
use Tests\Support\Models\EventModel;
use Tests\Support\Models\FabricatorModel;
Expand Down Expand Up @@ -410,6 +411,7 @@ public function testCreateMockSetsDatabaseFields(): void
$fabricator = new Fabricator(FabricatorModel::class);

$result = $fabricator->create(null, true);
$this->assertInstanceOf(stdClass::class, $result);

$this->assertIsInt($result->id);
$this->assertIsInt($result->created_at);
Expand Down
3 changes: 1 addition & 2 deletions utils/phpstan-baseline/loader.neon
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# total 1446 errors
# total 1434 errors

includes:
- argument.type.neon
Expand All @@ -13,7 +13,6 @@ includes:
- missingType.iterableValue.neon
- missingType.parameter.neon
- property.defaultValue.neon
- property.nonObject.neon
- property.notFound.neon
- property.phpDocType.neon
- staticMethod.notFound.neon
48 changes: 0 additions & 48 deletions utils/phpstan-baseline/property.nonObject.neon

This file was deleted.

Loading