Skip to content

Commit

Permalink
Merge pull request #7437 from ping-yee/replace-type-db-result
Browse files Browse the repository at this point in the history
docs: fix PHPDoc types in Database Result.
  • Loading branch information
kenjis authored Apr 25, 2023
2 parents 8606a6b + 4de207d commit 6c346b6
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 29 deletions.
10 changes: 5 additions & 5 deletions system/Database/BaseResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,10 @@ public function getRowObject(int $n = 0)
/**
* Assigns an item into a particular column slot.
*
* @param mixed $key
* @param mixed $value
* @param array|string $key
* @param array|object|stdClass|null $value
*
* @return mixed
* @return void
*/
public function setRow($key, $value = null)
{
Expand Down Expand Up @@ -507,7 +507,7 @@ abstract public function freeResult();
* internally before fetching results to make sure the result set
* starts at zero.
*
* @return mixed
* @return bool
*/
abstract public function dataSeek(int $n = 0);

Expand All @@ -516,7 +516,7 @@ abstract public function dataSeek(int $n = 0);
*
* Overridden by driver classes.
*
* @return mixed
* @return array|false|null
*/
abstract protected function fetchAssoc();

Expand Down
4 changes: 2 additions & 2 deletions system/Database/MySQLi/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function freeResult()
* internally before fetching results to make sure the result set
* starts at zero.
*
* @return mixed
* @return bool
*/
public function dataSeek(int $n = 0)
{
Expand All @@ -129,7 +129,7 @@ public function dataSeek(int $n = 0)
*
* Overridden by driver classes.
*
* @return mixed
* @return array|false|null
*/
protected function fetchAssoc()
{
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 @@ -80,7 +80,7 @@ public function dataSeek(int $n = 0)
*
* Overridden by driver classes.
*
* @return mixed
* @return array|false
*/
protected function fetchAssoc()
{
Expand Down
4 changes: 2 additions & 2 deletions system/Database/Postgre/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function freeResult()
* internally before fetching results to make sure the result set
* starts at zero.
*
* @return mixed
* @return bool
*/
public function dataSeek(int $n = 0)
{
Expand All @@ -95,7 +95,7 @@ public function dataSeek(int $n = 0)
*
* Overridden by driver classes.
*
* @return mixed
* @return array|false
*/
protected function fetchAssoc()
{
Expand Down
33 changes: 18 additions & 15 deletions system/Database/ResultInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

namespace CodeIgniter\Database;

use stdClass;

/**
* @template TConnection of object|resource
* @template TResult of object|resource
Expand All @@ -31,7 +33,7 @@ public function getResult(string $type = 'object'): array;
*
* @param string $className The name of the class to use.
*
* @return mixed
* @return array
*/
public function getCustomResultObject(string $className);

Expand All @@ -55,10 +57,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 All @@ -67,7 +70,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 @@ -76,7 +79,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 @@ -85,45 +88,45 @@ 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);

/**
* Assigns an item into a particular column slot.
*
* @param string $key
* @param mixed $value
* @param array|string $key
* @param array|object|stdClass|null $value
*
* @return mixed
* @return void
*/
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');

/**
* Returns the "last" row of the current results.
*
* @return mixed
* @return array|object|null
*/
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');

/**
* Returns the "previous" row of the current results.
*
* @return mixed
* @return array|object|null
*/
public function getPreviousRow(string $type = 'object');

Expand All @@ -135,7 +138,7 @@ public function getNumRows(): int;
/**
* 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 Expand Up @@ -164,7 +167,7 @@ public function freeResult();
* internally before fetching results to make sure the result set
* starts at zero.
*
* @return mixed
* @return bool
*/
public function dataSeek(int $n = 0);
}
4 changes: 2 additions & 2 deletions system/Database/SQLSRV/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function freeResult()
* internally before fetching results to make sure the result set
* starts at zero.
*
* @return mixed
* @return bool
*/
public function dataSeek(int $n = 0)
{
Expand All @@ -137,7 +137,7 @@ public function dataSeek(int $n = 0)
*
* Overridden by driver classes.
*
* @return mixed
* @return array|false|null
*/
protected function fetchAssoc()
{
Expand Down
4 changes: 2 additions & 2 deletions system/Database/SQLite3/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function freeResult()
* internally before fetching results to make sure the result set
* starts at zero.
*
* @return mixed
* @return bool
*
* @throws DatabaseException
*/
Expand All @@ -112,7 +112,7 @@ public function dataSeek(int $n = 0)
*
* Overridden by driver classes.
*
* @return mixed
* @return array|false
*/
protected function fetchAssoc()
{
Expand Down

0 comments on commit 6c346b6

Please sign in to comment.