Skip to content

Commit

Permalink
Merge pull request #8503 from kenjis/fix-docs-ResultInterface-getCust…
Browse files Browse the repository at this point in the history
…omRowObject

docs: fix incorrect @return type in `ResultInterface-getCustomRowObject()`
  • Loading branch information
kenjis authored Feb 4, 2024
2 parents c3f646c + 6d971af commit d6d571b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
22 changes: 15 additions & 7 deletions system/Database/BaseResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>|'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')
{
Expand Down Expand Up @@ -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<T> $className
*
* @return object|null
* @phpstan-return T|null
*/
public function getCustomRowObject(int $n, string $className)
{
Expand Down
22 changes: 15 additions & 7 deletions system/Database/ResultInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>|'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<T> $className
*
* @return object|null
* @phpstan-return T|null
*/
public function getCustomRowObject(int $n, string $className);

Expand Down

0 comments on commit d6d571b

Please sign in to comment.