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
29 changes: 18 additions & 11 deletions system/Database/BaseResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace CodeIgniter\Database;

use CodeIgniter\Entity\Entity;
use stdClass;

/**
* @template TConnection of object|resource
Expand Down Expand Up @@ -116,7 +117,9 @@ public function getResult(string $type = 'object'): array
/**
* Returns the results as an array of custom objects.
*
* @return mixed
* @phpstan-param class-string $className
*
* @return array
*/
public function getCustomResultObject(string $className)
{
Expand Down Expand Up @@ -205,6 +208,9 @@ public function getResultArray(): array
* Returns the results as an array of objects.
*
* If no results, an empty array is returned.
*
* @return array<int, stdClass>
* @phpstan-return list<stdClass>
*/
public function getResultObject(): array
{
Expand Down Expand Up @@ -248,10 +254,11 @@ public function getResultObject(): array
*
* If row doesn't exist, returns null.
*
* @param mixed $n The index of the results to return
* @param int $n The index of the results to return
* @param string $type The type of result object. 'array', 'object' or class name.
*
* @return mixed
* @return array|object|stdClass|null
* @phpstan-return ($type is 'object' ? stdClass|null : ($type is 'array' ? array|null : object|null))
*/
public function getRow($n = 0, string $type = 'object')
{
Expand Down Expand Up @@ -285,7 +292,7 @@ public function getRow($n = 0, string $type = 'object')
*
* If row doesn't exists, returns null.
*
* @return mixed
* @return array|null
*/
public function getCustomRowObject(int $n, string $className)
{
Expand All @@ -309,7 +316,7 @@ public function getCustomRowObject(int $n, string $className)
*
* If row doesn't exist, returns null.
*
* @return mixed
* @return array|null
*/
public function getRowArray(int $n = 0)
{
Expand All @@ -330,7 +337,7 @@ public function getRowArray(int $n = 0)
*
* If row doesn't exist, returns null.
*
* @return mixed
* @return object|stdClass|null
*/
public function getRowObject(int $n = 0)
{
Expand Down Expand Up @@ -377,7 +384,7 @@ public function setRow($key, $value = null)
/**
* Returns the "first" row of the current results.
*
* @return mixed
* @return array|object|null
*/
public function getFirstRow(string $type = 'object')
{
Expand All @@ -389,7 +396,7 @@ public function getFirstRow(string $type = 'object')
/**
* Returns the "last" row of the current results.
*
* @return mixed
* @return array|object|null
*/
public function getLastRow(string $type = 'object')
{
Expand All @@ -401,7 +408,7 @@ public function getLastRow(string $type = 'object')
/**
* Returns the "next" row of the current results.
*
* @return mixed
* @return array|object|null
*/
public function getNextRow(string $type = 'object')
{
Expand All @@ -416,7 +423,7 @@ public function getNextRow(string $type = 'object')
/**
* Returns the "previous" row of the current results.
*
* @return mixed
* @return array|object|null
*/
public function getPreviousRow(string $type = 'object')
{
Expand All @@ -435,7 +442,7 @@ public function getPreviousRow(string $type = 'object')
/**
* Returns an unbuffered row and move the pointer to the next row.
*
* @return mixed
* @return array|object|null
*/
public function getUnbufferedRow(string $type = 'object')
{
Expand Down
2 changes: 1 addition & 1 deletion system/Database/MySQLi/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ protected function fetchAssoc()
*
* Overridden by child classes.
*
* @return bool|Entity|object
* @return Entity|false|object|stdClass
*/
protected function fetchObject(string $className = 'stdClass')
{
Expand Down
2 changes: 1 addition & 1 deletion system/Database/OCI8/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ protected function fetchAssoc()
*
* Overridden by child classes.
*
* @return bool|Entity|object
* @return Entity|false|object|stdClass
*/
protected function fetchObject(string $className = 'stdClass')
{
Expand Down
2 changes: 1 addition & 1 deletion system/Database/Postgre/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ protected function fetchAssoc()
*
* Overridden by child classes.
*
* @return bool|Entity|object
* @return Entity|false|object|stdClass
*/
protected function fetchObject(string $className = 'stdClass')
{
Expand Down
2 changes: 1 addition & 1 deletion system/Database/SQLSRV/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ protected function fetchAssoc()
/**
* Returns the result set as an object.
*
* @return bool|Entity|object
* @return Entity|false|object|stdClass
*/
protected function fetchObject(string $className = 'stdClass')
{
Expand Down
2 changes: 1 addition & 1 deletion system/Database/SQLite3/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ protected function fetchAssoc()
*
* Overridden by child classes.
*
* @return bool|object
* @return Entity|false|object|stdClass
*/
protected function fetchObject(string $className = 'stdClass')
{
Expand Down
3 changes: 2 additions & 1 deletion system/Test/Mock/MockResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace CodeIgniter\Test\Mock;

use CodeIgniter\Database\BaseResult;
use stdClass;

/**
* @extends BaseResult<object|resource, object|resource>
Expand Down Expand Up @@ -82,7 +83,7 @@ protected function fetchAssoc()
*
* @param string $className
*
* @return object
* @return object|stdClass
*/
protected function fetchObject($className = 'stdClass')
{
Expand Down