From eb889179a6720901185b2d868721daea77c274d8 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 2 Feb 2024 16:41:57 +0900 Subject: [PATCH 1/2] docs: fix incorrect @return type --- system/Database/BaseResult.php | 10 ++++++++-- system/Database/ResultInterface.php | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/system/Database/BaseResult.php b/system/Database/BaseResult.php index 93bb00e4d350..124e19e06fcf 100644 --- a/system/Database/BaseResult.php +++ b/system/Database/BaseResult.php @@ -292,9 +292,15 @@ public function getRow($n = 0, string $type = 'object') /** * Returns a row as a custom class instance. * - * If row doesn't exists, returns null. + * If the row doesn't exist, returns null. * - * @return array|null + * @template T of object + * + * @param int $n The row number of the results + * @phpstan-param class-string $className + * + * @return object|null + * @phpstan-return T|null */ public function getCustomRowObject(int $n, string $className) { diff --git a/system/Database/ResultInterface.php b/system/Database/ResultInterface.php index 82cb7956b22e..49dd49edca4f 100644 --- a/system/Database/ResultInterface.php +++ b/system/Database/ResultInterface.php @@ -69,9 +69,15 @@ public function getRow($n = 0, string $type = 'object'); /** * Returns a row as a custom class instance. * - * If row doesn't exists, returns null. + * If the row doesn't exist, returns null. * - * @return array|null + * @template T of object + * + * @param int $n The row number of the results + * @phpstan-param class-string $className + * + * @return object|null + * @phpstan-return T|null */ public function getCustomRowObject(int $n, string $className); From 6d971afa905f07efc242c57f7010464834428569 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 2 Feb 2024 17:05:06 +0900 Subject: [PATCH 2/2] docs: improve doc comments --- system/Database/BaseResult.php | 14 ++++++++------ system/Database/ResultInterface.php | 14 ++++++++------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/system/Database/BaseResult.php b/system/Database/BaseResult.php index 124e19e06fcf..d7b32218322b 100644 --- a/system/Database/BaseResult.php +++ b/system/Database/BaseResult.php @@ -252,14 +252,16 @@ public function getResultObject(): array * Wrapper object to return a row as either an array, an object, or * a custom class. * - * If row doesn't exist, returns null. + * If the row doesn't exist, returns null. + * + * @template T of object * - * @param int|string $n The index of the results to return, or column name. - * @param string $type The type of result object. 'array', 'object' or class name. - * @phpstan-param class-string|'array'|'object' $type + * @param int|string $n The index of the results to return, or column name. + * @param string $type The type of result object. 'array', 'object' or class name. + * @phpstan-param class-string|'array'|'object' $type * * @return array|object|stdClass|null - * @phpstan-return ($type is 'object' ? stdClass|null : ($type is 'array' ? array|null : object|null)) + * @phpstan-return ($type is 'object' ? stdClass|null : ($type is 'array' ? array|null : T|null)) */ public function getRow($n = 0, string $type = 'object') { @@ -296,7 +298,7 @@ public function getRow($n = 0, string $type = 'object') * * @template T of object * - * @param int $n The row number of the results + * @param int $n The index of the results to return. * @phpstan-param class-string $className * * @return object|null diff --git a/system/Database/ResultInterface.php b/system/Database/ResultInterface.php index 49dd49edca4f..ea5f0de2800f 100644 --- a/system/Database/ResultInterface.php +++ b/system/Database/ResultInterface.php @@ -55,14 +55,16 @@ public function getResultObject(): array; * Wrapper object to return a row as either an array, an object, or * a custom class. * - * If row doesn't exist, returns null. + * If the row doesn't exist, returns null. + * + * @template T of object * - * @param int|string $n The index of the results to return, or column name. - * @param string $type The type of result object. 'array', 'object' or class name. - * @phpstan-param class-string|'array'|'object' $type + * @param int|string $n The index of the results to return, or column name. + * @param string $type The type of result object. 'array', 'object' or class name. + * @phpstan-param class-string|'array'|'object' $type * * @return array|object|stdClass|null - * @phpstan-return ($type is 'object' ? stdClass|null : ($type is 'array' ? array|null : object|null)) + * @phpstan-return ($type is 'object' ? stdClass|null : ($type is 'array' ? array|null : T|null)) */ public function getRow($n = 0, string $type = 'object'); @@ -73,7 +75,7 @@ public function getRow($n = 0, string $type = 'object'); * * @template T of object * - * @param int $n The row number of the results + * @param int $n The index of the results to return. * @phpstan-param class-string $className * * @return object|null