Skip to content

Commit 98eaf51

Browse files
committed
refactor: reduce PHPStan child return type baseline
Signed-off-by: memleakd <121398829+memleakd@users.noreply.github.com>
1 parent 6c4acef commit 98eaf51

16 files changed

Lines changed: 36 additions & 167 deletions

system/Database/BasePreparedQuery.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ abstract public function _execute(array $data): bool;
192192
/**
193193
* Returns the result object for the prepared query.
194194
*
195-
* @return object|resource|null
195+
* @return false|object|resource|null
196196
*/
197197
abstract public function _getResult();
198198

system/Database/ConnectionInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function getDatabase(): string;
7878
* Must return this format: ['code' => string|int, 'message' => string]
7979
* intval(code) === 0 means "no error".
8080
*
81-
* @return array<string, int|string>
81+
* @return array{code: int|string|null, message: string|null}
8282
*/
8383
public function error(): array;
8484

system/Database/MySQLi/Connection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ protected function _enableForeignKeyChecks()
573573
* Must return this format: ['code' => string|int, 'message' => string]
574574
* intval(code) === 0 means "no error".
575575
*
576-
* @return array<string, int|string>
576+
* @return array{code: int|string|null, message: string|null}
577577
*/
578578
public function error(): array
579579
{

system/Database/OCI8/Builder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ protected function _truncate(string $table): string
152152
*
153153
* @param mixed $where
154154
*
155-
* @return mixed
155+
* @return bool|string
156156
*
157157
* @throws DatabaseException
158158
*/

system/Database/Postgre/Builder.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
namespace CodeIgniter\Database\Postgre;
1515

1616
use CodeIgniter\Database\BaseBuilder;
17+
use CodeIgniter\Database\BaseResult;
1718
use CodeIgniter\Database\Exceptions\DatabaseException;
19+
use CodeIgniter\Database\Query;
1820
use CodeIgniter\Database\RawSql;
1921
use CodeIgniter\Exceptions\InvalidArgumentException;
2022

@@ -64,7 +66,7 @@ protected function compileIgnore(string $statement)
6466
*
6567
* @param string $direction ASC, DESC or RANDOM
6668
*
67-
* @return BaseBuilder
69+
* @return $this
6870
*/
6971
public function orderBy(string $orderBy, string $direction = '', ?bool $escape = null)
7072
{
@@ -89,7 +91,7 @@ public function orderBy(string $orderBy, string $direction = '', ?bool $escape =
8991
/**
9092
* Increments a numeric column by the specified value.
9193
*
92-
* @return mixed
94+
* @return bool
9395
*
9496
* @throws DatabaseException
9597
*/
@@ -111,7 +113,7 @@ public function increment(string $column, int $value = 1)
111113
/**
112114
* Decrements a numeric column by the specified value.
113115
*
114-
* @return mixed
116+
* @return bool
115117
*
116118
* @throws DatabaseException
117119
*/
@@ -138,7 +140,7 @@ public function decrement(string $column, int $value = 1)
138140
*
139141
* @param array|null $set An associative array of insert values
140142
*
141-
* @return mixed
143+
* @return BaseResult|false|Query|string
142144
*
143145
* @throws DatabaseException
144146
*/
@@ -225,7 +227,7 @@ protected function _insertBatch(string $table, array $keys, array $values): stri
225227
*
226228
* @param mixed $where
227229
*
228-
* @return mixed
230+
* @return bool|string
229231
*
230232
* @throws DatabaseException
231233
*/
@@ -303,7 +305,7 @@ protected function _like_statement(?string $prefix, string $column, ?string $not
303305
*
304306
* @param RawSql|string $cond
305307
*
306-
* @return BaseBuilder
308+
* @return $this
307309
*/
308310
public function join(string $table, $cond, string $type = '', ?bool $escape = null)
309311
{

system/Database/Postgre/Connection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ protected function _enableForeignKeyChecks()
469469
* Must return this format: ['code' => string|int, 'message' => string]
470470
* intval(code) === 0 means "no error".
471471
*
472-
* @return array<string, int|string>
472+
* @return array{code: int|string|null, message: string|null}
473473
*/
474474
public function error(): array
475475
{

system/Database/SQLSRV/Builder.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
namespace CodeIgniter\Database\SQLSRV;
1515

1616
use CodeIgniter\Database\BaseBuilder;
17+
use CodeIgniter\Database\BaseResult;
1718
use CodeIgniter\Database\Exceptions\DatabaseException;
1819
use CodeIgniter\Database\Exceptions\DataException;
20+
use CodeIgniter\Database\Query;
1921
use CodeIgniter\Database\RawSql;
2022
use CodeIgniter\Database\ResultInterface;
2123
use Config\Feature;
@@ -358,7 +360,7 @@ protected function _limit(string $sql, bool $offsetIgnore = false): string
358360
/**
359361
* Compiles a replace into string and runs the query
360362
*
361-
* @return mixed
363+
* @return BaseResult|false|Query|string
362364
*
363365
* @throws DatabaseException
364366
*/
@@ -462,7 +464,7 @@ protected function _replace(string $table, array $keys, array $values): string
462464
*
463465
* Handle float return value
464466
*
465-
* @return BaseBuilder
467+
* @return $this
466468
*/
467469
protected function maxMinAvgSum(string $select = '', string $alias = '', string $type = 'MAX')
468470
{
@@ -538,7 +540,7 @@ protected function _delete(string $table): string
538540
*
539541
* @param mixed $where
540542
*
541-
* @return mixed
543+
* @return bool|string
542544
*
543545
* @throws DatabaseException
544546
*/

system/Database/SQLSRV/Connection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ protected function _transRollback(): bool
441441
* Must return this format: ['code' => string|int, 'message' => string]
442442
* intval(code) === 0 means "no error".
443443
*
444-
* @return array<string, int|string>
444+
* @return array{code: int|string|null, message: string|null}
445445
*/
446446
public function error(): array
447447
{

system/Database/SQLite3/Connection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ protected function _enableForeignKeyChecks()
428428
* Must return this format: ['code' => string|int, 'message' => string]
429429
* intval(code) === 0 means "no error".
430430
*
431-
* @return array<string, int|string>
431+
* @return array{code: int|string|null, message: string|null}
432432
*/
433433
public function error(): array
434434
{

system/HTTP/DownloadResponse.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ public function setStatusCode(int $code, string $reason = '')
216216
* Sets the Content Type header for this response with the mime type
217217
* and, optionally, the charset.
218218
*
219-
* @return ResponseInterface
219+
* @return $this
220220
*/
221221
public function setContentType(string $mime, string $charset = 'UTF-8')
222222
{
@@ -286,7 +286,7 @@ public function buildHeaders()
286286
/**
287287
* output download file text.
288288
*
289-
* @return DownloadResponse
289+
* @return $this
290290
*
291291
* @throws DownloadException
292292
*/
@@ -306,7 +306,7 @@ public function sendBody()
306306
/**
307307
* output download text by file.
308308
*
309-
* @return DownloadResponse
309+
* @return $this
310310
*/
311311
private function sendBodyByFilePath()
312312
{
@@ -324,7 +324,7 @@ private function sendBodyByFilePath()
324324
/**
325325
* output download text by binary
326326
*
327-
* @return DownloadResponse
327+
* @return $this
328328
*/
329329
private function sendBodyByBinary()
330330
{

0 commit comments

Comments
 (0)