From f5043f5469e1a2ccce5bdca31cecd00dd65075f2 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 25 Mar 2023 14:38:51 +0900 Subject: [PATCH 1/2] docs: fix PHPDoc types --- system/Database/BaseResult.php | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/system/Database/BaseResult.php b/system/Database/BaseResult.php index 511c4f92af2a..2f073fd3151c 100644 --- a/system/Database/BaseResult.php +++ b/system/Database/BaseResult.php @@ -12,6 +12,7 @@ namespace CodeIgniter\Database; use CodeIgniter\Entity\Entity; +use stdClass; /** * @template TConnection of object|resource @@ -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) { @@ -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 + * @phpstan-return list */ public function getResultObject(): array { @@ -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') { @@ -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) { @@ -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) { @@ -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) { @@ -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') { @@ -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') { @@ -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') { @@ -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') { @@ -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') { From df8f305f4fc89775b3da9473f7f9d462d53c94c5 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 25 Mar 2023 14:39:07 +0900 Subject: [PATCH 2/2] docs: fix PHPDoc types in Result --- system/Database/MySQLi/Result.php | 2 +- system/Database/OCI8/Result.php | 2 +- system/Database/Postgre/Result.php | 2 +- system/Database/SQLSRV/Result.php | 2 +- system/Database/SQLite3/Result.php | 2 +- system/Test/Mock/MockResult.php | 3 ++- 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/system/Database/MySQLi/Result.php b/system/Database/MySQLi/Result.php index 550fc0abf835..358a400ca9fe 100644 --- a/system/Database/MySQLi/Result.php +++ b/system/Database/MySQLi/Result.php @@ -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') { diff --git a/system/Database/OCI8/Result.php b/system/Database/OCI8/Result.php index cb192de325f1..f345cb7bd73a 100644 --- a/system/Database/OCI8/Result.php +++ b/system/Database/OCI8/Result.php @@ -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') { diff --git a/system/Database/Postgre/Result.php b/system/Database/Postgre/Result.php index c3fce412223d..e81250c660df 100644 --- a/system/Database/Postgre/Result.php +++ b/system/Database/Postgre/Result.php @@ -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') { diff --git a/system/Database/SQLSRV/Result.php b/system/Database/SQLSRV/Result.php index 6e172d8ac770..174b146aab44 100755 --- a/system/Database/SQLSRV/Result.php +++ b/system/Database/SQLSRV/Result.php @@ -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') { diff --git a/system/Database/SQLite3/Result.php b/system/Database/SQLite3/Result.php index 05994469e5eb..d033b65891be 100644 --- a/system/Database/SQLite3/Result.php +++ b/system/Database/SQLite3/Result.php @@ -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') { diff --git a/system/Test/Mock/MockResult.php b/system/Test/Mock/MockResult.php index ff40c9449c1b..689a1392ec14 100644 --- a/system/Test/Mock/MockResult.php +++ b/system/Test/Mock/MockResult.php @@ -12,6 +12,7 @@ namespace CodeIgniter\Test\Mock; use CodeIgniter\Database\BaseResult; +use stdClass; /** * @extends BaseResult @@ -82,7 +83,7 @@ protected function fetchAssoc() * * @param string $className * - * @return object + * @return object|stdClass */ protected function fetchObject($className = 'stdClass') {