Skip to content

Commit f6bf798

Browse files
authored
Merge pull request #7381 from kenjis/fix-phpdoc-Database-Results
docs: fix PHPDoc types in Database Results
2 parents 70c768d + df8f305 commit f6bf798

7 files changed

Lines changed: 25 additions & 17 deletions

File tree

system/Database/BaseResult.php

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace CodeIgniter\Database;
1313

1414
use CodeIgniter\Entity\Entity;
15+
use stdClass;
1516

1617
/**
1718
* @template TConnection of object|resource
@@ -116,7 +117,9 @@ public function getResult(string $type = 'object'): array
116117
/**
117118
* Returns the results as an array of custom objects.
118119
*
119-
* @return mixed
120+
* @phpstan-param class-string $className
121+
*
122+
* @return array
120123
*/
121124
public function getCustomResultObject(string $className)
122125
{
@@ -205,6 +208,9 @@ public function getResultArray(): array
205208
* Returns the results as an array of objects.
206209
*
207210
* If no results, an empty array is returned.
211+
*
212+
* @return array<int, stdClass>
213+
* @phpstan-return list<stdClass>
208214
*/
209215
public function getResultObject(): array
210216
{
@@ -248,10 +254,11 @@ public function getResultObject(): array
248254
*
249255
* If row doesn't exist, returns null.
250256
*
251-
* @param mixed $n The index of the results to return
257+
* @param int $n The index of the results to return
252258
* @param string $type The type of result object. 'array', 'object' or class name.
253259
*
254-
* @return mixed
260+
* @return array|object|stdClass|null
261+
* @phpstan-return ($type is 'object' ? stdClass|null : ($type is 'array' ? array|null : object|null))
255262
*/
256263
public function getRow($n = 0, string $type = 'object')
257264
{
@@ -285,7 +292,7 @@ public function getRow($n = 0, string $type = 'object')
285292
*
286293
* If row doesn't exists, returns null.
287294
*
288-
* @return mixed
295+
* @return array|null
289296
*/
290297
public function getCustomRowObject(int $n, string $className)
291298
{
@@ -309,7 +316,7 @@ public function getCustomRowObject(int $n, string $className)
309316
*
310317
* If row doesn't exist, returns null.
311318
*
312-
* @return mixed
319+
* @return array|null
313320
*/
314321
public function getRowArray(int $n = 0)
315322
{
@@ -330,7 +337,7 @@ public function getRowArray(int $n = 0)
330337
*
331338
* If row doesn't exist, returns null.
332339
*
333-
* @return mixed
340+
* @return object|stdClass|null
334341
*/
335342
public function getRowObject(int $n = 0)
336343
{
@@ -377,7 +384,7 @@ public function setRow($key, $value = null)
377384
/**
378385
* Returns the "first" row of the current results.
379386
*
380-
* @return mixed
387+
* @return array|object|null
381388
*/
382389
public function getFirstRow(string $type = 'object')
383390
{
@@ -389,7 +396,7 @@ public function getFirstRow(string $type = 'object')
389396
/**
390397
* Returns the "last" row of the current results.
391398
*
392-
* @return mixed
399+
* @return array|object|null
393400
*/
394401
public function getLastRow(string $type = 'object')
395402
{
@@ -401,7 +408,7 @@ public function getLastRow(string $type = 'object')
401408
/**
402409
* Returns the "next" row of the current results.
403410
*
404-
* @return mixed
411+
* @return array|object|null
405412
*/
406413
public function getNextRow(string $type = 'object')
407414
{
@@ -416,7 +423,7 @@ public function getNextRow(string $type = 'object')
416423
/**
417424
* Returns the "previous" row of the current results.
418425
*
419-
* @return mixed
426+
* @return array|object|null
420427
*/
421428
public function getPreviousRow(string $type = 'object')
422429
{
@@ -435,7 +442,7 @@ public function getPreviousRow(string $type = 'object')
435442
/**
436443
* Returns an unbuffered row and move the pointer to the next row.
437444
*
438-
* @return mixed
445+
* @return array|object|null
439446
*/
440447
public function getUnbufferedRow(string $type = 'object')
441448
{

system/Database/MySQLi/Result.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ protected function fetchAssoc()
141141
*
142142
* Overridden by child classes.
143143
*
144-
* @return bool|Entity|object
144+
* @return Entity|false|object|stdClass
145145
*/
146146
protected function fetchObject(string $className = 'stdClass')
147147
{

system/Database/OCI8/Result.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ protected function fetchAssoc()
9292
*
9393
* Overridden by child classes.
9494
*
95-
* @return bool|Entity|object
95+
* @return Entity|false|object|stdClass
9696
*/
9797
protected function fetchObject(string $className = 'stdClass')
9898
{

system/Database/Postgre/Result.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ protected function fetchAssoc()
107107
*
108108
* Overridden by child classes.
109109
*
110-
* @return bool|Entity|object
110+
* @return Entity|false|object|stdClass
111111
*/
112112
protected function fetchObject(string $className = 'stdClass')
113113
{

system/Database/SQLSRV/Result.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ protected function fetchAssoc()
147147
/**
148148
* Returns the result set as an object.
149149
*
150-
* @return bool|Entity|object
150+
* @return Entity|false|object|stdClass
151151
*/
152152
protected function fetchObject(string $className = 'stdClass')
153153
{

system/Database/SQLite3/Result.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ protected function fetchAssoc()
124124
*
125125
* Overridden by child classes.
126126
*
127-
* @return bool|object
127+
* @return Entity|false|object|stdClass
128128
*/
129129
protected function fetchObject(string $className = 'stdClass')
130130
{

system/Test/Mock/MockResult.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace CodeIgniter\Test\Mock;
1313

1414
use CodeIgniter\Database\BaseResult;
15+
use stdClass;
1516

1617
/**
1718
* @extends BaseResult<object|resource, object|resource>
@@ -82,7 +83,7 @@ protected function fetchAssoc()
8283
*
8384
* @param string $className
8485
*
85-
* @return object
86+
* @return object|stdClass
8687
*/
8788
protected function fetchObject($className = 'stdClass')
8889
{

0 commit comments

Comments
 (0)