diff --git a/system/Database/BasePreparedQuery.php b/system/Database/BasePreparedQuery.php index f2ee6b3ed6a4..540e9c15161c 100644 --- a/system/Database/BasePreparedQuery.php +++ b/system/Database/BasePreparedQuery.php @@ -192,7 +192,7 @@ abstract public function _execute(array $data): bool; /** * Returns the result object for the prepared query. * - * @return object|resource|null + * @return false|object|resource|null */ abstract public function _getResult(); diff --git a/system/Database/ConnectionInterface.php b/system/Database/ConnectionInterface.php index 3c43b173fc4e..97c8fa0bbcba 100644 --- a/system/Database/ConnectionInterface.php +++ b/system/Database/ConnectionInterface.php @@ -78,7 +78,7 @@ public function getDatabase(): string; * Must return this format: ['code' => string|int, 'message' => string] * intval(code) === 0 means "no error". * - * @return array + * @return array{code: int|string|null, message: string|null} */ public function error(): array; diff --git a/system/Database/MySQLi/Connection.php b/system/Database/MySQLi/Connection.php index b38ef3349eaa..116acb7eaf9e 100644 --- a/system/Database/MySQLi/Connection.php +++ b/system/Database/MySQLi/Connection.php @@ -573,7 +573,7 @@ protected function _enableForeignKeyChecks() * Must return this format: ['code' => string|int, 'message' => string] * intval(code) === 0 means "no error". * - * @return array + * @return array{code: int|string|null, message: string|null} */ public function error(): array { diff --git a/system/Database/OCI8/Builder.php b/system/Database/OCI8/Builder.php index 2e62b3121cbd..0bbf4283d056 100644 --- a/system/Database/OCI8/Builder.php +++ b/system/Database/OCI8/Builder.php @@ -152,7 +152,7 @@ protected function _truncate(string $table): string * * @param mixed $where * - * @return mixed + * @return bool|string * * @throws DatabaseException */ diff --git a/system/Database/Postgre/Builder.php b/system/Database/Postgre/Builder.php index 126ab5741892..ebaa79eed538 100644 --- a/system/Database/Postgre/Builder.php +++ b/system/Database/Postgre/Builder.php @@ -14,7 +14,9 @@ namespace CodeIgniter\Database\Postgre; use CodeIgniter\Database\BaseBuilder; +use CodeIgniter\Database\BaseResult; use CodeIgniter\Database\Exceptions\DatabaseException; +use CodeIgniter\Database\Query; use CodeIgniter\Database\RawSql; use CodeIgniter\Exceptions\InvalidArgumentException; @@ -64,7 +66,7 @@ protected function compileIgnore(string $statement) * * @param string $direction ASC, DESC or RANDOM * - * @return BaseBuilder + * @return $this */ public function orderBy(string $orderBy, string $direction = '', ?bool $escape = null) { @@ -89,7 +91,7 @@ public function orderBy(string $orderBy, string $direction = '', ?bool $escape = /** * Increments a numeric column by the specified value. * - * @return mixed + * @return bool * * @throws DatabaseException */ @@ -111,7 +113,7 @@ public function increment(string $column, int $value = 1) /** * Decrements a numeric column by the specified value. * - * @return mixed + * @return bool * * @throws DatabaseException */ @@ -138,7 +140,7 @@ public function decrement(string $column, int $value = 1) * * @param array|null $set An associative array of insert values * - * @return mixed + * @return BaseResult|false|Query|string * * @throws DatabaseException */ @@ -225,7 +227,7 @@ protected function _insertBatch(string $table, array $keys, array $values): stri * * @param mixed $where * - * @return mixed + * @return bool|string * * @throws DatabaseException */ @@ -303,7 +305,7 @@ protected function _like_statement(?string $prefix, string $column, ?string $not * * @param RawSql|string $cond * - * @return BaseBuilder + * @return $this */ public function join(string $table, $cond, string $type = '', ?bool $escape = null) { diff --git a/system/Database/Postgre/Connection.php b/system/Database/Postgre/Connection.php index 295616ab035d..37c1d678fcc0 100644 --- a/system/Database/Postgre/Connection.php +++ b/system/Database/Postgre/Connection.php @@ -469,7 +469,7 @@ protected function _enableForeignKeyChecks() * Must return this format: ['code' => string|int, 'message' => string] * intval(code) === 0 means "no error". * - * @return array + * @return array{code: int|string|null, message: string|null} */ public function error(): array { diff --git a/system/Database/SQLSRV/Builder.php b/system/Database/SQLSRV/Builder.php index 44af621658a6..67f2f26c33f9 100644 --- a/system/Database/SQLSRV/Builder.php +++ b/system/Database/SQLSRV/Builder.php @@ -14,8 +14,10 @@ namespace CodeIgniter\Database\SQLSRV; use CodeIgniter\Database\BaseBuilder; +use CodeIgniter\Database\BaseResult; use CodeIgniter\Database\Exceptions\DatabaseException; use CodeIgniter\Database\Exceptions\DataException; +use CodeIgniter\Database\Query; use CodeIgniter\Database\RawSql; use CodeIgniter\Database\ResultInterface; use Config\Feature; @@ -358,7 +360,7 @@ protected function _limit(string $sql, bool $offsetIgnore = false): string /** * Compiles a replace into string and runs the query * - * @return mixed + * @return BaseResult|false|Query|string * * @throws DatabaseException */ @@ -462,7 +464,7 @@ protected function _replace(string $table, array $keys, array $values): string * * Handle float return value * - * @return BaseBuilder + * @return $this */ protected function maxMinAvgSum(string $select = '', string $alias = '', string $type = 'MAX') { @@ -538,7 +540,7 @@ protected function _delete(string $table): string * * @param mixed $where * - * @return mixed + * @return bool|string * * @throws DatabaseException */ diff --git a/system/Database/SQLSRV/Connection.php b/system/Database/SQLSRV/Connection.php index 76dd80bdb09f..970c582f60ed 100644 --- a/system/Database/SQLSRV/Connection.php +++ b/system/Database/SQLSRV/Connection.php @@ -441,7 +441,7 @@ protected function _transRollback(): bool * Must return this format: ['code' => string|int, 'message' => string] * intval(code) === 0 means "no error". * - * @return array + * @return array{code: int|string|null, message: string|null} */ public function error(): array { diff --git a/system/Database/SQLite3/Connection.php b/system/Database/SQLite3/Connection.php index 4495e68c4418..268ceaa7bea2 100644 --- a/system/Database/SQLite3/Connection.php +++ b/system/Database/SQLite3/Connection.php @@ -428,7 +428,7 @@ protected function _enableForeignKeyChecks() * Must return this format: ['code' => string|int, 'message' => string] * intval(code) === 0 means "no error". * - * @return array + * @return array{code: int|string|null, message: string|null} */ public function error(): array { diff --git a/system/HTTP/DownloadResponse.php b/system/HTTP/DownloadResponse.php index 5e1816e3afe1..b7ce79b8309a 100644 --- a/system/HTTP/DownloadResponse.php +++ b/system/HTTP/DownloadResponse.php @@ -216,7 +216,7 @@ public function setStatusCode(int $code, string $reason = '') * Sets the Content Type header for this response with the mime type * and, optionally, the charset. * - * @return ResponseInterface + * @return $this */ public function setContentType(string $mime, string $charset = 'UTF-8') { @@ -286,7 +286,7 @@ public function buildHeaders() /** * output download file text. * - * @return DownloadResponse + * @return $this * * @throws DownloadException */ @@ -306,7 +306,7 @@ public function sendBody() /** * output download text by file. * - * @return DownloadResponse + * @return $this */ private function sendBodyByFilePath() { @@ -324,7 +324,7 @@ private function sendBodyByFilePath() /** * output download text by binary * - * @return DownloadResponse + * @return $this */ private function sendBodyByBinary() { diff --git a/system/HTTP/Exceptions/HTTPException.php b/system/HTTP/Exceptions/HTTPException.php index 146a565b8c77..332fd8ab9524 100644 --- a/system/HTTP/Exceptions/HTTPException.php +++ b/system/HTTP/Exceptions/HTTPException.php @@ -23,7 +23,7 @@ class HTTPException extends FrameworkException implements ExceptionInterface /** * For CurlRequest * - * @return HTTPException + * @return static * * @codeCoverageIgnore */ @@ -35,7 +35,7 @@ public static function forMissingCurl() /** * For CurlRequest * - * @return HTTPException + * @return static */ public static function forSSLCertNotFound(string $cert) { @@ -45,7 +45,7 @@ public static function forSSLCertNotFound(string $cert) /** * For CurlRequest * - * @return HTTPException + * @return static */ public static function forInvalidSSLKey(string $key) { @@ -190,7 +190,7 @@ public static function forMalformedQueryString() /** * For Uploaded file move * - * @return HTTPException + * @return static */ public static function forAlreadyMoved() { @@ -200,7 +200,7 @@ public static function forAlreadyMoved() /** * For Uploaded file move * - * @return HTTPException + * @return static */ public static function forInvalidFile(?string $path = null) { diff --git a/system/Images/Handlers/BaseHandler.php b/system/Images/Handlers/BaseHandler.php index e38c5836ccca..9301b1573c23 100644 --- a/system/Images/Handlers/BaseHandler.php +++ b/system/Images/Handlers/BaseHandler.php @@ -242,7 +242,7 @@ public function withResource() * * @param bool $maintainRatio If true, will get the closest match possible while keeping aspect ratio true. * - * @return BaseHandler + * @return $this */ public function resize(int $width, int $height, bool $maintainRatio = false, string $masterDim = 'auto') { @@ -536,7 +536,7 @@ public function getEXIF(?string $key = null, bool $silent = false) * - bottom * - bottom-right * - * @return BaseHandler + * @return $this */ public function fit(int $width, ?int $height = null, string $position = 'center') { diff --git a/system/Images/Handlers/ImageMagickHandler.php b/system/Images/Handlers/ImageMagickHandler.php index 0655a4c13ced..1472936d071b 100644 --- a/system/Images/Handlers/ImageMagickHandler.php +++ b/system/Images/Handlers/ImageMagickHandler.php @@ -139,7 +139,7 @@ protected function process(string $action, int $quality = 100) /** * Handles the actual resizing of the image. * - * @return ImageMagickHandler + * @return $this * * @throws ImagickException */ diff --git a/utils/phpstan-baseline/loader.neon b/utils/phpstan-baseline/loader.neon index 57d40a379ca7..a68dbb16241d 100644 --- a/utils/phpstan-baseline/loader.neon +++ b/utils/phpstan-baseline/loader.neon @@ -1,4 +1,4 @@ -# total 2055 errors +# total 2029 errors includes: - argument.type.neon diff --git a/utils/phpstan-baseline/method.childReturnType.neon b/utils/phpstan-baseline/method.childReturnType.neon index cb796e2ba89f..6e6a320a6177 100644 --- a/utils/phpstan-baseline/method.childReturnType.neon +++ b/utils/phpstan-baseline/method.childReturnType.neon @@ -1,122 +1,7 @@ -# total 28 errors +# total 2 errors parameters: ignoreErrors: - - - message: '#^Return type \(array\{code\: int\|string\|null, message\: string\|null\}\) of method CodeIgniter\\Database\\BaseConnection\:\:error\(\) should be covariant with return type \(array\\) of method CodeIgniter\\Database\\ConnectionInterface\\:\:error\(\)$#' - count: 1 - path: ../../system/Database/BaseConnection.php - - - - message: '#^Return type \(array\\) of method CodeIgniter\\Database\\MySQLi\\Connection\:\:error\(\) should be covariant with return type \(array\{code\: int\|string\|null, message\: string\|null\}\) of method CodeIgniter\\Database\\BaseConnection\\:\:error\(\)$#' - count: 1 - path: ../../system/Database/MySQLi/Connection.php - - - - message: '#^Return type \(mysqli_result\|false\) of method CodeIgniter\\Database\\MySQLi\\PreparedQuery\:\:_getResult\(\) should be covariant with return type \(object\|resource\|null\) of method CodeIgniter\\Database\\BasePreparedQuery\\:\:_getResult\(\)$#' - count: 1 - path: ../../system/Database/MySQLi/PreparedQuery.php - - - - message: '#^Return type \(mixed\) of method CodeIgniter\\Database\\OCI8\\Builder\:\:delete\(\) should be covariant with return type \(bool\|string\) of method CodeIgniter\\Database\\BaseBuilder\:\:delete\(\)$#' - count: 1 - path: ../../system/Database/OCI8/Builder.php - - - - message: '#^Return type \(array\{code\: int\|string\|null, message\: string\|null\}\) of method CodeIgniter\\Database\\OCI8\\Connection\:\:error\(\) should be covariant with return type \(array\\) of method CodeIgniter\\Database\\ConnectionInterface\\:\:error\(\)$#' - count: 1 - path: ../../system/Database/OCI8/Connection.php - - - - message: '#^Return type \(CodeIgniter\\Database\\BaseBuilder\) of method CodeIgniter\\Database\\Postgre\\Builder\:\:join\(\) should be covariant with return type \(\$this\(CodeIgniter\\Database\\BaseBuilder\)\) of method CodeIgniter\\Database\\BaseBuilder\:\:join\(\)$#' - count: 1 - path: ../../system/Database/Postgre/Builder.php - - - - message: '#^Return type \(CodeIgniter\\Database\\BaseBuilder\) of method CodeIgniter\\Database\\Postgre\\Builder\:\:orderBy\(\) should be covariant with return type \(\$this\(CodeIgniter\\Database\\BaseBuilder\)\) of method CodeIgniter\\Database\\BaseBuilder\:\:orderBy\(\)$#' - count: 1 - path: ../../system/Database/Postgre/Builder.php - - - - message: '#^Return type \(mixed\) of method CodeIgniter\\Database\\Postgre\\Builder\:\:decrement\(\) should be covariant with return type \(bool\) of method CodeIgniter\\Database\\BaseBuilder\:\:decrement\(\)$#' - count: 1 - path: ../../system/Database/Postgre/Builder.php - - - - message: '#^Return type \(mixed\) of method CodeIgniter\\Database\\Postgre\\Builder\:\:delete\(\) should be covariant with return type \(bool\|string\) of method CodeIgniter\\Database\\BaseBuilder\:\:delete\(\)$#' - count: 1 - path: ../../system/Database/Postgre/Builder.php - - - - message: '#^Return type \(mixed\) of method CodeIgniter\\Database\\Postgre\\Builder\:\:increment\(\) should be covariant with return type \(bool\) of method CodeIgniter\\Database\\BaseBuilder\:\:increment\(\)$#' - count: 1 - path: ../../system/Database/Postgre/Builder.php - - - - message: '#^Return type \(mixed\) of method CodeIgniter\\Database\\Postgre\\Builder\:\:replace\(\) should be covariant with return type \(CodeIgniter\\Database\\BaseResult\|CodeIgniter\\Database\\Query\|string\|false\) of method CodeIgniter\\Database\\BaseBuilder\:\:replace\(\)$#' - count: 1 - path: ../../system/Database/Postgre/Builder.php - - - - message: '#^Return type \(array\\) of method CodeIgniter\\Database\\Postgre\\Connection\:\:error\(\) should be covariant with return type \(array\{code\: int\|string\|null, message\: string\|null\}\) of method CodeIgniter\\Database\\BaseConnection\\:\:error\(\)$#' - count: 1 - path: ../../system/Database/Postgre/Connection.php - - - - message: '#^Return type \(CodeIgniter\\Database\\BaseBuilder\) of method CodeIgniter\\Database\\SQLSRV\\Builder\:\:maxMinAvgSum\(\) should be covariant with return type \(\$this\(CodeIgniter\\Database\\BaseBuilder\)\) of method CodeIgniter\\Database\\BaseBuilder\:\:maxMinAvgSum\(\)$#' - count: 1 - path: ../../system/Database/SQLSRV/Builder.php - - - - message: '#^Return type \(mixed\) of method CodeIgniter\\Database\\SQLSRV\\Builder\:\:delete\(\) should be covariant with return type \(bool\|string\) of method CodeIgniter\\Database\\BaseBuilder\:\:delete\(\)$#' - count: 1 - path: ../../system/Database/SQLSRV/Builder.php - - - - message: '#^Return type \(mixed\) of method CodeIgniter\\Database\\SQLSRV\\Builder\:\:replace\(\) should be covariant with return type \(CodeIgniter\\Database\\BaseResult\|CodeIgniter\\Database\\Query\|string\|false\) of method CodeIgniter\\Database\\BaseBuilder\:\:replace\(\)$#' - count: 1 - path: ../../system/Database/SQLSRV/Builder.php - - - - message: '#^Return type \(array\\) of method CodeIgniter\\Database\\SQLSRV\\Connection\:\:error\(\) should be covariant with return type \(array\{code\: int\|string\|null, message\: string\|null\}\) of method CodeIgniter\\Database\\BaseConnection\\:\:error\(\)$#' - count: 1 - path: ../../system/Database/SQLSRV/Connection.php - - - - message: '#^Return type \(array\\) of method CodeIgniter\\Database\\SQLite3\\Connection\:\:error\(\) should be covariant with return type \(array\{code\: int\|string\|null, message\: string\|null\}\) of method CodeIgniter\\Database\\BaseConnection\\:\:error\(\)$#' - count: 1 - path: ../../system/Database/SQLite3/Connection.php - - - - message: '#^Return type \(SQLite3Result\|false\) of method CodeIgniter\\Database\\SQLite3\\PreparedQuery\:\:_getResult\(\) should be covariant with return type \(object\|resource\|null\) of method CodeIgniter\\Database\\BasePreparedQuery\\:\:_getResult\(\)$#' - count: 1 - path: ../../system/Database/SQLite3/PreparedQuery.php - - - - message: '#^Return type \(CodeIgniter\\HTTP\\DownloadResponse\) of method CodeIgniter\\HTTP\\DownloadResponse\:\:sendBody\(\) should be covariant with return type \(\$this\(CodeIgniter\\HTTP\\ResponseInterface\)\) of method CodeIgniter\\HTTP\\ResponseInterface\:\:sendBody\(\)$#' - count: 1 - path: ../../system/HTTP/DownloadResponse.php - - - - message: '#^Return type \(CodeIgniter\\HTTP\\DownloadResponse\) of method CodeIgniter\\HTTP\\DownloadResponse\:\:sendBody\(\) should be covariant with return type \(\$this\(CodeIgniter\\HTTP\\Response\)\) of method CodeIgniter\\HTTP\\Response\:\:sendBody\(\)$#' - count: 1 - path: ../../system/HTTP/DownloadResponse.php - - - - message: '#^Return type \(CodeIgniter\\HTTP\\ResponseInterface\) of method CodeIgniter\\HTTP\\DownloadResponse\:\:setContentType\(\) should be covariant with return type \(\$this\(CodeIgniter\\HTTP\\ResponseInterface\)\) of method CodeIgniter\\HTTP\\ResponseInterface\:\:setContentType\(\)$#' - count: 1 - path: ../../system/HTTP/DownloadResponse.php - - - - message: '#^Return type \(CodeIgniter\\HTTP\\ResponseInterface\) of method CodeIgniter\\HTTP\\DownloadResponse\:\:setContentType\(\) should be covariant with return type \(\$this\(CodeIgniter\\HTTP\\Response\)\) of method CodeIgniter\\HTTP\\Response\:\:setContentType\(\)$#' - count: 1 - path: ../../system/HTTP/DownloadResponse.php - - - - message: '#^Return type \(CodeIgniter\\HTTP\\Exceptions\\HTTPException\) of method CodeIgniter\\HTTP\\Exceptions\\HTTPException\:\:forInvalidFile\(\) should be covariant with return type \(static\(CodeIgniter\\Exceptions\\FrameworkException\)\) of method CodeIgniter\\Exceptions\\FrameworkException\:\:forInvalidFile\(\)$#' - count: 1 - path: ../../system/HTTP/Exceptions/HTTPException.php - - message: '#^Return type \(bool\) of method CodeIgniter\\HTTP\\Files\\UploadedFile\:\:move\(\) should be compatible with return type \(CodeIgniter\\Files\\File\) of method CodeIgniter\\Files\\File\:\:move\(\)$#' count: 1 @@ -126,18 +11,3 @@ parameters: message: '#^Return type \(CodeIgniter\\HTTP\\URI\|null\) of method CodeIgniter\\HTTP\\OutgoingRequest\:\:getUri\(\) should be covariant with return type \(CodeIgniter\\HTTP\\URI\) of method CodeIgniter\\HTTP\\OutgoingRequestInterface\:\:getUri\(\)$#' count: 1 path: ../../system/HTTP/OutgoingRequest.php - - - - message: '#^Return type \(CodeIgniter\\Images\\Handlers\\BaseHandler\) of method CodeIgniter\\Images\\Handlers\\BaseHandler\:\:fit\(\) should be covariant with return type \(\$this\(CodeIgniter\\Images\\ImageHandlerInterface\)\) of method CodeIgniter\\Images\\ImageHandlerInterface\:\:fit\(\)$#' - count: 1 - path: ../../system/Images/Handlers/BaseHandler.php - - - - message: '#^Return type \(CodeIgniter\\Images\\Handlers\\BaseHandler\) of method CodeIgniter\\Images\\Handlers\\BaseHandler\:\:resize\(\) should be covariant with return type \(\$this\(CodeIgniter\\Images\\ImageHandlerInterface\)\) of method CodeIgniter\\Images\\ImageHandlerInterface\:\:resize\(\)$#' - count: 1 - path: ../../system/Images/Handlers/BaseHandler.php - - - - message: '#^Return type \(CodeIgniter\\Images\\Handlers\\ImageMagickHandler\) of method CodeIgniter\\Images\\Handlers\\ImageMagickHandler\:\:_resize\(\) should be covariant with return type \(\$this\(CodeIgniter\\Images\\Handlers\\BaseHandler\)\) of method CodeIgniter\\Images\\Handlers\\BaseHandler\:\:_resize\(\)$#' - count: 1 - path: ../../system/Images/Handlers/ImageMagickHandler.php