Skip to content

Commit d6d571b

Browse files
authored
Merge pull request #8503 from kenjis/fix-docs-ResultInterface-getCustomRowObject
docs: fix incorrect @return type in `ResultInterface-getCustomRowObject()`
2 parents c3f646c + 6d971af commit d6d571b

File tree

2 files changed

+30
-14
lines changed

2 files changed

+30
-14
lines changed

system/Database/BaseResult.php

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -252,14 +252,16 @@ public function getResultObject(): array
252252
* Wrapper object to return a row as either an array, an object, or
253253
* a custom class.
254254
*
255-
* If row doesn't exist, returns null.
255+
* If the row doesn't exist, returns null.
256+
*
257+
* @template T of object
256258
*
257-
* @param int|string $n The index of the results to return, or column name.
258-
* @param string $type The type of result object. 'array', 'object' or class name.
259-
* @phpstan-param class-string|'array'|'object' $type
259+
* @param int|string $n The index of the results to return, or column name.
260+
* @param string $type The type of result object. 'array', 'object' or class name.
261+
* @phpstan-param class-string<T>|'array'|'object' $type
260262
*
261263
* @return array|object|stdClass|null
262-
* @phpstan-return ($type is 'object' ? stdClass|null : ($type is 'array' ? array|null : object|null))
264+
* @phpstan-return ($type is 'object' ? stdClass|null : ($type is 'array' ? array|null : T|null))
263265
*/
264266
public function getRow($n = 0, string $type = 'object')
265267
{
@@ -292,9 +294,15 @@ public function getRow($n = 0, string $type = 'object')
292294
/**
293295
* Returns a row as a custom class instance.
294296
*
295-
* If row doesn't exists, returns null.
297+
* If the row doesn't exist, returns null.
296298
*
297-
* @return array|null
299+
* @template T of object
300+
*
301+
* @param int $n The index of the results to return.
302+
* @phpstan-param class-string<T> $className
303+
*
304+
* @return object|null
305+
* @phpstan-return T|null
298306
*/
299307
public function getCustomRowObject(int $n, string $className)
300308
{

system/Database/ResultInterface.php

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,23 +55,31 @@ public function getResultObject(): array;
5555
* Wrapper object to return a row as either an array, an object, or
5656
* a custom class.
5757
*
58-
* If row doesn't exist, returns null.
58+
* If the row doesn't exist, returns null.
59+
*
60+
* @template T of object
5961
*
60-
* @param int|string $n The index of the results to return, or column name.
61-
* @param string $type The type of result object. 'array', 'object' or class name.
62-
* @phpstan-param class-string|'array'|'object' $type
62+
* @param int|string $n The index of the results to return, or column name.
63+
* @param string $type The type of result object. 'array', 'object' or class name.
64+
* @phpstan-param class-string<T>|'array'|'object' $type
6365
*
6466
* @return array|object|stdClass|null
65-
* @phpstan-return ($type is 'object' ? stdClass|null : ($type is 'array' ? array|null : object|null))
67+
* @phpstan-return ($type is 'object' ? stdClass|null : ($type is 'array' ? array|null : T|null))
6668
*/
6769
public function getRow($n = 0, string $type = 'object');
6870

6971
/**
7072
* Returns a row as a custom class instance.
7173
*
72-
* If row doesn't exists, returns null.
74+
* If the row doesn't exist, returns null.
7375
*
74-
* @return array|null
76+
* @template T of object
77+
*
78+
* @param int $n The index of the results to return.
79+
* @phpstan-param class-string<T> $className
80+
*
81+
* @return object|null
82+
* @phpstan-return T|null
7583
*/
7684
public function getCustomRowObject(int $n, string $className);
7785

0 commit comments

Comments
 (0)