diff --git a/phpstan-baseline.php b/phpstan-baseline.php index 05825b1d76ed..c29bace19fca 100644 --- a/phpstan-baseline.php +++ b/phpstan-baseline.php @@ -2083,24 +2083,12 @@ 'count' => 1, 'path' => __DIR__ . '/system/Database/BaseConnection.php', ]; -$ignoreErrors[] = [ - // identifier: missingType.iterableValue - 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseConnection\\:\\:_fieldData\\(\\) return type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/BaseConnection.php', -]; $ignoreErrors[] = [ // identifier: missingType.iterableValue 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseConnection\\:\\:callFunction\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', 'count' => 1, 'path' => __DIR__ . '/system/Database/BaseConnection.php', ]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseConnection\\:\\:close\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/BaseConnection.php', -]; $ignoreErrors[] = [ // identifier: missingType.iterableValue 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseConnection\\:\\:escape\\(\\) has parameter \\$str with no value type specified in iterable type array\\.$#', @@ -2131,24 +2119,6 @@ 'count' => 1, 'path' => __DIR__ . '/system/Database/BaseConnection.php', ]; -$ignoreErrors[] = [ - // identifier: missingType.iterableValue - 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseConnection\\:\\:getFieldNames\\(\\) return type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/BaseConnection.php', -]; -$ignoreErrors[] = [ - // identifier: missingType.iterableValue - 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseConnection\\:\\:getForeignKeyData\\(\\) return type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/BaseConnection.php', -]; -$ignoreErrors[] = [ - // identifier: missingType.iterableValue - 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseConnection\\:\\:listTables\\(\\) return type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/BaseConnection.php', -]; $ignoreErrors[] = [ // identifier: missingType.callable 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseConnection\\:\\:prepare\\(\\) has parameter \\$func with no signature specified for Closure\\.$#', @@ -2191,12 +2161,6 @@ 'count' => 1, 'path' => __DIR__ . '/system/Database/BaseConnection.php', ]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseConnection\\:\\:transOff\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/BaseConnection.php', -]; $ignoreErrors[] = [ // identifier: missingType.iterableValue 'message' => '#^Property CodeIgniter\\\\Database\\\\BaseConnection\\:\\:\\$aliasedTables type has no value type specified in iterable type array\\.$#', @@ -3355,12 +3319,6 @@ 'count' => 1, 'path' => __DIR__ . '/system/Database/Postgre/Connection.php', ]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Method CodeIgniter\\\\Database\\\\Postgre\\\\Connection\\:\\:convertDSN\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/Postgre/Connection.php', -]; $ignoreErrors[] = [ // identifier: missingType.iterableValue 'message' => '#^Method CodeIgniter\\\\Database\\\\Postgre\\\\Connection\\:\\:escape\\(\\) has parameter \\$str with no value type specified in iterable type array\\.$#', @@ -3967,12 +3925,6 @@ 'count' => 1, 'path' => __DIR__ . '/system/Database/SQLite3/Connection.php', ]; -$ignoreErrors[] = [ - // identifier: missingType.iterableValue - 'message' => '#^Method CodeIgniter\\\\Database\\\\SQLite3\\\\Connection\\:\\:getFieldNames\\(\\) return type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/SQLite3/Connection.php', -]; $ignoreErrors[] = [ // identifier: booleanNot.exprNotBoolean 'message' => '#^Only booleans are allowed in a negated boolean, string given\\.$#', @@ -9577,24 +9529,6 @@ 'count' => 1, 'path' => __DIR__ . '/system/Test/Mock/MockConnection.php', ]; -$ignoreErrors[] = [ - // identifier: missingType.iterableValue - 'message' => '#^Method CodeIgniter\\\\Test\\\\Mock\\\\MockConnection\\:\\:_fieldData\\(\\) return type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Test/Mock/MockConnection.php', -]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Method CodeIgniter\\\\Test\\\\Mock\\\\MockConnection\\:\\:shouldReturn\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Test/Mock/MockConnection.php', -]; -$ignoreErrors[] = [ - // identifier: missingType.parameter - 'message' => '#^Method CodeIgniter\\\\Test\\\\Mock\\\\MockConnection\\:\\:shouldReturn\\(\\) has parameter \\$return with no type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Test/Mock/MockConnection.php', -]; $ignoreErrors[] = [ // identifier: method.childReturnType 'message' => '#^Return type \\(array\\{code\\: int\\|string\\|null, message\\: string\\|null\\}\\) of method CodeIgniter\\\\Test\\\\Mock\\\\MockConnection\\:\\:error\\(\\) should be covariant with return type \\(array\\\\) of method CodeIgniter\\\\Database\\\\ConnectionInterface\\\\:\\:error\\(\\)$#', @@ -9625,12 +9559,6 @@ 'count' => 2, 'path' => __DIR__ . '/system/Test/Mock/MockConnection.php', ]; -$ignoreErrors[] = [ - // identifier: method.childReturnType - 'message' => '#^Return type \\(mixed\\) of method CodeIgniter\\\\Test\\\\Mock\\\\MockConnection\\:\\:setDatabase\\(\\) should be covariant with return type \\(bool\\) of method CodeIgniter\\\\Database\\\\ConnectionInterface\\\\:\\:setDatabase\\(\\)$#', - 'count' => 2, - 'path' => __DIR__ . '/system/Test/Mock/MockConnection.php', -]; $ignoreErrors[] = [ // identifier: missingType.return 'message' => '#^Method CodeIgniter\\\\Test\\\\Mock\\\\MockEvents\\:\\:getEventsFile\\(\\) has no return type specified\\.$#', diff --git a/system/Database/BaseConnection.php b/system/Database/BaseConnection.php index 57c37d8a0a6c..6581dc7c5ac0 100644 --- a/system/Database/BaseConnection.php +++ b/system/Database/BaseConnection.php @@ -477,6 +477,8 @@ public function initialize() /** * Close the database connection. + * + * @return void */ public function close() { @@ -736,6 +738,8 @@ public function simpleQuery(string $sql) * Disable Transactions * * This permits transactions to be disabled at run-time. + * + * @return void */ public function transOff() { @@ -1454,7 +1458,7 @@ protected function getDriverFunctionPrefix(): string /** * Returns an array of table names * - * @return array|false + * @return false|list * * @throws DatabaseException */ @@ -1481,6 +1485,7 @@ public function listTables(bool $constrainByPrefix = false) $query = $this->query($sql); foreach ($query->getResultArray() as $row) { + /** @var string $table */ $table = $row['table_name'] ?? $row['TABLE_NAME'] ?? $row[array_key_first($row)]; $this->dataCache['table_names'][] = $table; @@ -1531,7 +1536,7 @@ public function tableExists(string $tableName, bool $cached = true): bool /** * Fetch Field Names * - * @return array|false + * @return false|list * * @throws DatabaseException */ @@ -1608,7 +1613,7 @@ public function getIndexData(string $table) /** * Returns an object with foreign key data * - * @return array + * @return array */ public function getForeignKeyData(string $table) { @@ -1769,7 +1774,9 @@ abstract protected function _listColumns(string $table = ''); /** * Platform-specific field data information. * - * @see getFieldData() + * @see getFieldData() + * + * @return list */ abstract protected function _fieldData(string $table): array; diff --git a/system/Database/MySQLi/Connection.php b/system/Database/MySQLi/Connection.php index e8db25c76640..cc7d5e2a1612 100644 --- a/system/Database/MySQLi/Connection.php +++ b/system/Database/MySQLi/Connection.php @@ -237,6 +237,8 @@ public function connect(bool $persistent = false) /** * Keep or establish the connection if no queries have been sent for * a length of time exceeding the server's idle timeout. + * + * @return void */ public function reconnect() { diff --git a/system/Database/Postgre/Connection.php b/system/Database/Postgre/Connection.php index c22dc8605f56..d3af2380156e 100644 --- a/system/Database/Postgre/Connection.php +++ b/system/Database/Postgre/Connection.php @@ -104,6 +104,8 @@ public function connect(bool $persistent = false) /** * Converts the DSN with semicolon syntax. + * + * @return void */ private function convertDSN() { @@ -143,6 +145,8 @@ private function convertDSN() /** * Keep or establish the connection if no queries have been sent for * a length of time exceeding the server's idle timeout. + * + * @return void */ public function reconnect() { diff --git a/system/Database/SQLSRV/Connection.php b/system/Database/SQLSRV/Connection.php index 0626a63c998b..7e008e27c451 100644 --- a/system/Database/SQLSRV/Connection.php +++ b/system/Database/SQLSRV/Connection.php @@ -164,6 +164,8 @@ public function getAllErrorMessages(): string /** * Keep or establish the connection if no queries have been sent for * a length of time exceeding the server's idle timeout. + * + * @return void */ public function reconnect() { diff --git a/system/Database/SQLite3/Connection.php b/system/Database/SQLite3/Connection.php index 945434184f33..9945d41de11b 100644 --- a/system/Database/SQLite3/Connection.php +++ b/system/Database/SQLite3/Connection.php @@ -55,6 +55,9 @@ class Connection extends BaseConnection */ protected $busyTimeout; + /** + * @return void + */ public function initialize() { parent::initialize(); @@ -101,6 +104,8 @@ public function connect(bool $persistent = false) /** * Keep or establish the connection if no queries have been sent for * a length of time exceeding the server's idle timeout. + * + * @return void */ public function reconnect() { @@ -211,7 +216,7 @@ protected function _listColumns(string $table = ''): string } /** - * @return array|false + * @return false|list * * @throws DatabaseException */ diff --git a/system/Test/Mock/MockConnection.php b/system/Test/Mock/MockConnection.php index 020d6e3dd340..ed814240bad3 100644 --- a/system/Test/Mock/MockConnection.php +++ b/system/Test/Mock/MockConnection.php @@ -38,6 +38,11 @@ class MockConnection extends BaseConnection public $database; public $lastQuery; + /** + * @param mixed $return + * + * @return $this + */ public function shouldReturn(string $method, $return) { $this->returnValues[$method] = $return; @@ -127,13 +132,13 @@ public function reconnect(): bool /** * Select a specific database table to use. * - * @return mixed + * @return bool */ public function setDatabase(string $databaseName) { $this->database = $databaseName; - return $this; + return true; } /**