diff --git a/system/Database/BaseResult.php b/system/Database/BaseResult.php index 93bb00e4d350..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') { @@ -292,9 +294,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 index of the results to return. + * @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..ea5f0de2800f 100644 --- a/system/Database/ResultInterface.php +++ b/system/Database/ResultInterface.php @@ -55,23 +55,31 @@ 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'); /** * 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 index of the results to return. + * @phpstan-param class-string $className + * + * @return object|null + * @phpstan-return T|null */ public function getCustomRowObject(int $n, string $className);