From cd3d38553614a8456c65992ce46c57d88d48616a Mon Sep 17 00:00:00 2001 From: ping-yee <611077101@mail.nknu.edu.tw> Date: Fri, 14 Apr 2023 01:09:24 +0800 Subject: [PATCH 1/2] docs: replace type `mixed` at Database connection. --- system/Database/BaseConnection.php | 6 +++--- system/Database/ConnectionInterface.php | 10 ++++++---- system/Database/Postgre/Connection.php | 2 +- system/Database/SQLSRV/Connection.php | 8 ++++---- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/system/Database/BaseConnection.php b/system/Database/BaseConnection.php index badd34d5c077..c9fac2a49bb0 100644 --- a/system/Database/BaseConnection.php +++ b/system/Database/BaseConnection.php @@ -456,7 +456,7 @@ abstract protected function _close(); /** * Create a persistent database connection. * - * @return mixed + * @return false|object|resource */ public function persistentConnect() { @@ -558,7 +558,7 @@ abstract protected function execute(string $sql); * Should automatically handle different connections for read/write * queries if needed. * - * @param mixed ...$binds + * @param array|string|null ...$binds * * @return BaseResult|bool|Query BaseResult when “read” type query, bool when “write” type query, Query when prepared query * @phpstan-return BaseResult|bool|Query @@ -1747,7 +1747,7 @@ protected function _enableForeignKeyChecks() /** * Accessor for properties if they exist. * - * @return mixed + * @return array|bool|float|int|object|resource|string|null */ public function __get(string $key) { diff --git a/system/Database/ConnectionInterface.php b/system/Database/ConnectionInterface.php index 7cbae20d2ec6..3c434e3c2276 100644 --- a/system/Database/ConnectionInterface.php +++ b/system/Database/ConnectionInterface.php @@ -12,6 +12,8 @@ namespace CodeIgniter\Database; /** + * @property Query $lastQuery + * * @template TConnection of object|resource * @template TResult of object|resource */ @@ -62,7 +64,7 @@ public function getConnection(?string $alias = null); /** * Select a specific database table to use. * - * @return mixed + * @return bool */ public function setDatabase(string $databaseName); @@ -98,7 +100,7 @@ public function getVersion(): string; * Should automatically handle different connections for read/write * queries if needed. * - * @param mixed ...$binds + * @param array|string|null ...$binds * * @return BaseResult|bool|Query * @phpstan-return BaseResult|bool|Query @@ -127,7 +129,7 @@ public function table($tableName); /** * Returns the last query's statement object. * - * @return mixed + * @return Query */ public function getLastQuery(); @@ -150,7 +152,7 @@ public function escape($str); * * @param array ...$params * - * @return mixed + * @return array|bool|float|int|object|resource|string|null */ public function callFunction(string $functionName, ...$params); diff --git a/system/Database/Postgre/Connection.php b/system/Database/Postgre/Connection.php index 4e4fd3b8e4e5..d5074d0ce595 100644 --- a/system/Database/Postgre/Connection.php +++ b/system/Database/Postgre/Connection.php @@ -533,7 +533,7 @@ protected function _transRollback(): bool * * Overrides BaseConnection::isWriteType, adding additional read query types. * - * @param mixed $sql + * @param string $sql */ public function isWriteType($sql): bool { diff --git a/system/Database/SQLSRV/Connection.php b/system/Database/SQLSRV/Connection.php index 5d9b208d6010..deaa7626cbe5 100755 --- a/system/Database/SQLSRV/Connection.php +++ b/system/Database/SQLSRV/Connection.php @@ -44,7 +44,7 @@ class Connection extends BaseConnection * FALSE or SQLSRV_CURSOR_FORWARD would increase performance, * but would disable num_rows() (and possibly insert_id()) * - * @var mixed + * @var bool|string */ public $scrollable; @@ -436,7 +436,7 @@ public function affectedRows(): int /** * Select a specific database table to use. * - * @return mixed + * @return bool */ public function setDatabase(?string $databaseName = null) { @@ -485,7 +485,7 @@ protected function execute(string $sql) /** * Returns the last error encountered by this connection. * - * @return mixed + * @return array * * @deprecated Use `error()` instead. */ @@ -546,7 +546,7 @@ public function getVersion(): string * * Overrides BaseConnection::isWriteType, adding additional read query types. * - * @param mixed $sql + * @param string $sql */ public function isWriteType($sql): bool { From 5ef5579af89d14eb7fc128b4f4b157cf168ab974 Mon Sep 17 00:00:00 2001 From: ping-yee <611077101@mail.nknu.edu.tw> Date: Fri, 14 Apr 2023 23:37:08 +0800 Subject: [PATCH 2/2] docs: fix some type. --- system/Database/BaseConnection.php | 3 ++- system/Database/ConnectionInterface.php | 4 +--- system/Database/SQLSRV/Connection.php | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/system/Database/BaseConnection.php b/system/Database/BaseConnection.php index c9fac2a49bb0..5f141b73c21c 100644 --- a/system/Database/BaseConnection.php +++ b/system/Database/BaseConnection.php @@ -457,6 +457,7 @@ abstract protected function _close(); * Create a persistent database connection. * * @return false|object|resource + * @phpstan-return false|TConnection */ public function persistentConnect() { @@ -558,7 +559,7 @@ abstract protected function execute(string $sql); * Should automatically handle different connections for read/write * queries if needed. * - * @param array|string|null ...$binds + * @param array|string|null $binds * * @return BaseResult|bool|Query BaseResult when “read” type query, bool when “write” type query, Query when prepared query * @phpstan-return BaseResult|bool|Query diff --git a/system/Database/ConnectionInterface.php b/system/Database/ConnectionInterface.php index 3c434e3c2276..57fca79df428 100644 --- a/system/Database/ConnectionInterface.php +++ b/system/Database/ConnectionInterface.php @@ -12,8 +12,6 @@ namespace CodeIgniter\Database; /** - * @property Query $lastQuery - * * @template TConnection of object|resource * @template TResult of object|resource */ @@ -100,7 +98,7 @@ public function getVersion(): string; * Should automatically handle different connections for read/write * queries if needed. * - * @param array|string|null ...$binds + * @param array|string|null $binds * * @return BaseResult|bool|Query * @phpstan-return BaseResult|bool|Query diff --git a/system/Database/SQLSRV/Connection.php b/system/Database/SQLSRV/Connection.php index deaa7626cbe5..4e0ca987df9a 100755 --- a/system/Database/SQLSRV/Connection.php +++ b/system/Database/SQLSRV/Connection.php @@ -44,7 +44,7 @@ class Connection extends BaseConnection * FALSE or SQLSRV_CURSOR_FORWARD would increase performance, * but would disable num_rows() (and possibly insert_id()) * - * @var bool|string + * @var false|string */ public $scrollable;