From 4263e6f15a33b0d64e995034fae34e6fe71ec7e2 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Mon, 12 Dec 2022 14:54:30 +0100 Subject: [PATCH] WIP Psalm 5.10.0-dev --- composer.json | 2 +- psalm.xml.dist | 41 ++++++++++++++-- .../Exception/CannotCopyStreamToStream.php | 2 +- .../Exception/CannotCreateTemporaryFile.php | 2 +- src/Driver/IBMDB2/Exception/PrepareFailed.php | 2 +- .../Mysqli/Exception/ConnectionError.php | 2 +- .../Mysqli/Exception/ConnectionFailed.php | 2 +- .../Mysqli/Exception/InvalidCharset.php | 2 +- .../Mysqli/Exception/StatementError.php | 2 +- src/Platforms/AbstractMySQLPlatform.php | 2 +- src/Platforms/AbstractPlatform.php | 8 ++-- src/Schema/SchemaDiff.php | 48 +++++++++---------- src/Schema/TableDiff.php | 14 +++--- tests/ConnectionTest.php | 4 +- .../AbstractDriverMiddlewareTest.php | 7 ++- tests/Functional/BlobTest.php | 5 +- .../Platform/LengthExpressionTest.php | 2 +- .../Functional/Platform/RenameColumnTest.php | 2 +- .../PrimaryReadReplicaConnectionTest.php | 23 +++++++-- .../Schema/PostgreSQLSchemaManagerTest.php | 4 +- .../SchemaManagerFunctionalTestCase.php | 4 +- tests/Logging/MiddlewareTest.php | 4 +- .../Expression/ExpressionBuilderTest.php | 4 +- tests/TestUtil.php | 24 ++++++---- 24 files changed, 135 insertions(+), 77 deletions(-) diff --git a/composer.json b/composer.json index 559ceddd85c..82f6bd59d3b 100644 --- a/composer.json +++ b/composer.json @@ -50,7 +50,7 @@ "squizlabs/php_codesniffer": "3.7.2", "symfony/cache": "^5.4|^6.0", "symfony/console": "^4.4|^5.4|^6.0", - "vimeo/psalm": "4.30.0" + "vimeo/psalm": "^5.10.0@dev" }, "suggest": { "symfony/console": "For helpful console commands such as SQL execution and import of files." diff --git a/psalm.xml.dist b/psalm.xml.dist index 0f94410466a..51bd75ecf62 100644 --- a/psalm.xml.dist +++ b/psalm.xml.dist @@ -5,6 +5,8 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" + findUnusedBaselineEntry="false" + findUnusedCode="false" > @@ -607,6 +609,9 @@ + + + @@ -627,6 +632,12 @@ + + + + + + + + + + @@ -823,6 +841,7 @@ This issue should be fixed in 4.0 --> + @@ -838,10 +857,26 @@ - - - + + + + + + + + + + + + + + + + + + + diff --git a/src/Driver/IBMDB2/Exception/CannotCopyStreamToStream.php b/src/Driver/IBMDB2/Exception/CannotCopyStreamToStream.php index 231c9d47316..2587bf70ebd 100644 --- a/src/Driver/IBMDB2/Exception/CannotCopyStreamToStream.php +++ b/src/Driver/IBMDB2/Exception/CannotCopyStreamToStream.php @@ -13,7 +13,7 @@ */ final class CannotCopyStreamToStream extends AbstractException { - /** @psalm-param array{message: string}|null $error */ + /** @psalm-param array{message: string, ...mixed}|null $error */ public static function new(?array $error): self { $message = 'Could not copy source stream to temporary file'; diff --git a/src/Driver/IBMDB2/Exception/CannotCreateTemporaryFile.php b/src/Driver/IBMDB2/Exception/CannotCreateTemporaryFile.php index 63f7ca1e26f..6b271784a3e 100644 --- a/src/Driver/IBMDB2/Exception/CannotCreateTemporaryFile.php +++ b/src/Driver/IBMDB2/Exception/CannotCreateTemporaryFile.php @@ -13,7 +13,7 @@ */ final class CannotCreateTemporaryFile extends AbstractException { - /** @psalm-param array{message: string}|null $error */ + /** @psalm-param array{message: string, ...mixed}|null $error */ public static function new(?array $error): self { $message = 'Could not create temporary file'; diff --git a/src/Driver/IBMDB2/Exception/PrepareFailed.php b/src/Driver/IBMDB2/Exception/PrepareFailed.php index 42df5e15c85..8b384dcf3fd 100644 --- a/src/Driver/IBMDB2/Exception/PrepareFailed.php +++ b/src/Driver/IBMDB2/Exception/PrepareFailed.php @@ -13,7 +13,7 @@ */ final class PrepareFailed extends AbstractException { - /** @psalm-param array{message: string}|null $error */ + /** @psalm-param array{message: string, ...mixed}|null $error */ public static function new(?array $error): self { if ($error === null) { diff --git a/src/Driver/Mysqli/Exception/ConnectionError.php b/src/Driver/Mysqli/Exception/ConnectionError.php index ef5b980170e..5cebd6d0ce8 100644 --- a/src/Driver/Mysqli/Exception/ConnectionError.php +++ b/src/Driver/Mysqli/Exception/ConnectionError.php @@ -26,6 +26,6 @@ public static function upcast(mysqli_sql_exception $exception): self $p = new ReflectionProperty(mysqli_sql_exception::class, 'sqlstate'); $p->setAccessible(true); - return new self($exception->getMessage(), $p->getValue($exception), (int) $exception->getCode(), $exception); + return new self($exception->getMessage(), $p->getValue($exception), $exception->getCode(), $exception); } } diff --git a/src/Driver/Mysqli/Exception/ConnectionFailed.php b/src/Driver/Mysqli/Exception/ConnectionFailed.php index 44a8cab9995..70d2499215e 100644 --- a/src/Driver/Mysqli/Exception/ConnectionFailed.php +++ b/src/Driver/Mysqli/Exception/ConnectionFailed.php @@ -31,6 +31,6 @@ public static function upcast(mysqli_sql_exception $exception): self $p = new ReflectionProperty(mysqli_sql_exception::class, 'sqlstate'); $p->setAccessible(true); - return new self($exception->getMessage(), $p->getValue($exception), (int) $exception->getCode(), $exception); + return new self($exception->getMessage(), $p->getValue($exception), $exception->getCode(), $exception); } } diff --git a/src/Driver/Mysqli/Exception/InvalidCharset.php b/src/Driver/Mysqli/Exception/InvalidCharset.php index 8c6bbb476e3..cc13c88fcfa 100644 --- a/src/Driver/Mysqli/Exception/InvalidCharset.php +++ b/src/Driver/Mysqli/Exception/InvalidCharset.php @@ -35,7 +35,7 @@ public static function upcast(mysqli_sql_exception $exception, string $charset): return new self( sprintf('Failed to set charset "%s": %s', $charset, $exception->getMessage()), $p->getValue($exception), - (int) $exception->getCode(), + $exception->getCode(), $exception, ); } diff --git a/src/Driver/Mysqli/Exception/StatementError.php b/src/Driver/Mysqli/Exception/StatementError.php index 78dc8556b20..d91509ebe1b 100644 --- a/src/Driver/Mysqli/Exception/StatementError.php +++ b/src/Driver/Mysqli/Exception/StatementError.php @@ -26,6 +26,6 @@ public static function upcast(mysqli_sql_exception $exception): self $p = new ReflectionProperty(mysqli_sql_exception::class, 'sqlstate'); $p->setAccessible(true); - return new self($exception->getMessage(), $p->getValue($exception), (int) $exception->getCode(), $exception); + return new self($exception->getMessage(), $p->getValue($exception), $exception->getCode(), $exception); } } diff --git a/src/Platforms/AbstractMySQLPlatform.php b/src/Platforms/AbstractMySQLPlatform.php index 503881a6c4a..73112d34d7c 100644 --- a/src/Platforms/AbstractMySQLPlatform.php +++ b/src/Platforms/AbstractMySQLPlatform.php @@ -1417,7 +1417,7 @@ public function createSchemaManager(Connection $connection): MySQLSchemaManager } /** - * @param list $assets + * @param array $assets * * @return array * diff --git a/src/Platforms/AbstractPlatform.php b/src/Platforms/AbstractPlatform.php index 1d33038411f..23ace05fea8 100644 --- a/src/Platforms/AbstractPlatform.php +++ b/src/Platforms/AbstractPlatform.php @@ -2172,7 +2172,7 @@ private function buildCreateTableSQL(Table $table, bool $createIndexes, bool $cr } /** - * @param list $tables + * @param array
$tables * * @return list * @@ -2199,7 +2199,7 @@ public function getCreateTablesSQL(array $tables): array } /** - * @param list
$tables + * @param array
$tables * * @return list */ @@ -2840,7 +2840,7 @@ protected function getPreAlterTableIndexForeignKeySQL(TableDiff $diff) return $sql; } - /** @return string[] */ + /** @return list */ protected function getPostAlterTableIndexForeignKeySQL(TableDiff $diff) { $sql = []; @@ -2888,7 +2888,7 @@ protected function getPostAlterTableIndexForeignKeySQL(TableDiff $diff) * @param Index $index The definition of the index to rename to. * @param string $tableName The table to rename the given index on. * - * @return string[] The sequence of SQL statements for renaming the given index. + * @return list The sequence of SQL statements for renaming the given index. */ protected function getRenameIndexSQL($oldIndexName, Index $index, $tableName) { diff --git a/src/Schema/SchemaDiff.php b/src/Schema/SchemaDiff.php index a6a866579cf..c8512e8e571 100644 --- a/src/Schema/SchemaDiff.php +++ b/src/Schema/SchemaDiff.php @@ -29,7 +29,7 @@ class SchemaDiff * * @internal Use {@link getCreatedSchemas()} instead. * - * @var string[] + * @var array */ public $newNamespaces = []; @@ -38,7 +38,7 @@ class SchemaDiff * * @internal Use {@link getDroppedSchemas()} instead. * - * @var string[] + * @var array */ public $removedNamespaces = []; @@ -47,7 +47,7 @@ class SchemaDiff * * @internal Use {@link getCreatedTables()} instead. * - * @var Table[] + * @var array */ public $newTables = []; @@ -56,7 +56,7 @@ class SchemaDiff * * @internal Use {@link getAlteredTables()} instead. * - * @var TableDiff[] + * @var array */ public $changedTables = []; @@ -65,28 +65,28 @@ class SchemaDiff * * @internal Use {@link getDroppedTables()} instead. * - * @var Table[] + * @var array */ public $removedTables = []; /** * @internal Use {@link getCreatedSequences()} instead. * - * @var Sequence[] + * @var list */ public $newSequences = []; /** * @internal Use {@link getAlteredSequences()} instead. * - * @var Sequence[] + * @var list */ public $changedSequences = []; /** * @internal Use {@link getDroppedSequences()} instead. * - * @var Sequence[] + * @var list */ public $removedSequences = []; @@ -102,14 +102,14 @@ class SchemaDiff * * @internal The diff can be only instantiated by a {@see Comparator}. * - * @param Table[] $newTables - * @param TableDiff[] $changedTables - * @param Table[] $removedTables - * @param array $createdSchemas - * @param array $droppedSchemas - * @param array $createdSequences - * @param array $alteredSequences - * @param array $droppedSequences + * @param array $newTables + * @param array $changedTables + * @param array $removedTables + * @param array $createdSchemas + * @param array $droppedSchemas + * @param list $createdSequences + * @param list $alteredSequences + * @param list $droppedSequences */ public function __construct( $newTables = [], @@ -137,49 +137,49 @@ public function __construct( $this->removedSequences = $droppedSequences; } - /** @return array */ + /** @return array */ public function getCreatedSchemas(): array { return $this->newNamespaces; } - /** @return array */ + /** @return array */ public function getDroppedSchemas(): array { return $this->removedNamespaces; } - /** @return array
*/ + /** @return array */ public function getCreatedTables(): array { return $this->newTables; } - /** @return array */ + /** @return array */ public function getAlteredTables(): array { return $this->changedTables; } - /** @return array
*/ + /** @return array */ public function getDroppedTables(): array { return $this->removedTables; } - /** @return array */ + /** @return list */ public function getCreatedSequences(): array { return $this->newSequences; } - /** @return array */ + /** @return list */ public function getAlteredSequences(): array { return $this->changedSequences; } - /** @return array */ + /** @return list */ public function getDroppedSequences(): array { return $this->removedSequences; diff --git a/src/Schema/TableDiff.php b/src/Schema/TableDiff.php index 58128d75b3e..d7fd301ef0c 100644 --- a/src/Schema/TableDiff.php +++ b/src/Schema/TableDiff.php @@ -105,7 +105,7 @@ class TableDiff * * @internal Use {@see getAddedForeignKeys()} instead. * - * @var ForeignKeyConstraint[] + * @var list */ public $addedForeignKeys = []; @@ -114,7 +114,7 @@ class TableDiff * * @internal Use {@see getModifiedForeignKeys()} instead. * - * @var ForeignKeyConstraint[] + * @var list */ public $changedForeignKeys = []; @@ -123,7 +123,7 @@ class TableDiff * * @internal Use {@see getDroppedForeignKeys()} instead. * - * @var (ForeignKeyConstraint|string)[] + * @var list */ public $removedForeignKeys = []; @@ -333,12 +333,10 @@ public function getDroppedForeignKeys(): array */ public function unsetDroppedForeignKey($foreignKey): void { - $this->removedForeignKeys = array_filter( + $this->removedForeignKeys = array_values(array_filter( $this->removedForeignKeys, - static function ($removedForeignKey) use ($foreignKey): bool { - return $removedForeignKey !== $foreignKey; - }, - ); + static fn ($removedForeignKey): bool => $removedForeignKey !== $foreignKey, + )); } /** diff --git a/tests/ConnectionTest.php b/tests/ConnectionTest.php index 69127d1d19e..69fdbee24b9 100644 --- a/tests/ConnectionTest.php +++ b/tests/ConnectionTest.php @@ -37,8 +37,6 @@ class ConnectionTest extends TestCase { use VerifyDeprecations; - private Connection $connection; - private const CONNECTION_PARAMS = [ 'driver' => 'pdo_mysql', 'host' => 'localhost', @@ -47,6 +45,8 @@ class ConnectionTest extends TestCase 'port' => 1234, ]; + private Connection $connection; + protected function setUp(): void { $this->connection = DriverManager::getConnection(self::CONNECTION_PARAMS); diff --git a/tests/Driver/Middleware/AbstractDriverMiddlewareTest.php b/tests/Driver/Middleware/AbstractDriverMiddlewareTest.php index 600cdfd0e83..3151b6e41ae 100644 --- a/tests/Driver/Middleware/AbstractDriverMiddlewareTest.php +++ b/tests/Driver/Middleware/AbstractDriverMiddlewareTest.php @@ -17,10 +17,13 @@ public function testConnect(): void $driver = $this->createMock(Driver::class); $driver->expects(self::once()) ->method('connect') - ->with(['foo' => 'bar']) + ->with(['user' => 'my_user', 'password' => 's3cr3t']) ->willReturn($connection); - self::assertSame($connection, $this->createMiddleware($driver)->connect(['foo' => 'bar'])); + self::assertSame( + $connection, + $this->createMiddleware($driver)->connect(['user' => 'my_user', 'password' => 's3cr3t']), + ); } public function testCreateDatabasePlatformForVersion(): void diff --git a/tests/Functional/BlobTest.php b/tests/Functional/BlobTest.php index ec346406561..722d3156513 100644 --- a/tests/Functional/BlobTest.php +++ b/tests/Functional/BlobTest.php @@ -59,10 +59,7 @@ public function testInsertNull(): void ]); self::assertEquals(1, $ret); - - [$clobValue, $blobValue] = $this->fetchRow(); - self::assertNull($clobValue); - self::assertNull($blobValue); + self::assertSame([null, null], $this->fetchRow()); } public function testInsertProcessesStream(): void diff --git a/tests/Functional/Platform/LengthExpressionTest.php b/tests/Functional/Platform/LengthExpressionTest.php index 1c15f5a1e8b..fc468f0eabe 100644 --- a/tests/Functional/Platform/LengthExpressionTest.php +++ b/tests/Functional/Platform/LengthExpressionTest.php @@ -32,7 +32,7 @@ public function testLengthExpression(string $value, int $expected, bool $isMulti self::assertEquals($expected, $this->connection->fetchOne($query, [$value])); } - /** @return iterable */ + /** @return iterable */ public static function expressionProvider(): iterable { yield '1-byte' => ['Hello, world!', 13, false]; diff --git a/tests/Functional/Platform/RenameColumnTest.php b/tests/Functional/Platform/RenameColumnTest.php index 6afa20d56f5..af226981caa 100644 --- a/tests/Functional/Platform/RenameColumnTest.php +++ b/tests/Functional/Platform/RenameColumnTest.php @@ -34,7 +34,7 @@ public function testColumnPositionRetainedAfterRenaming(string $columnName, stri self::assertSame([strtolower($newColumnName), 'c2'], array_keys($table->getColumns())); } - /** @return iterable */ + /** @return iterable */ public static function columnNameProvider(): iterable { yield ['c1', 'c1_x']; diff --git a/tests/Functional/PrimaryReadReplicaConnectionTest.php b/tests/Functional/PrimaryReadReplicaConnectionTest.php index 27026fc6911..bdc0740c07f 100644 --- a/tests/Functional/PrimaryReadReplicaConnectionTest.php +++ b/tests/Functional/PrimaryReadReplicaConnectionTest.php @@ -51,9 +51,26 @@ private function createPrimaryReadReplicaConnection(bool $keepReplica = false): */ private function createPrimaryReadReplicaConnectionParams(bool $keepReplica = false): array { - $params = $this->connection->getParams(); - $params['primary'] = $params; - $params['replica'] = [$params, $params]; + $params = $this->connection->getParams(); + $overrideParams = $params; + + // Unset all fields that don't belong on a primary/replica definition. + unset( + $overrideParams['defaultTableOptions'], + $overrideParams['keepSlave'], + $overrideParams['keepReplica'], + $overrideParams['master'], + $overrideParams['memory'], + $overrideParams['primary'], + $overrideParams['replica'], + $overrideParams['serverVersion'], + $overrideParams['sharding'], + $overrideParams['slaves'], + $overrideParams['wrapperClass'], + ); + + $params['primary'] = $overrideParams; + $params['replica'] = [$overrideParams, $overrideParams]; $params['keepReplica'] = $keepReplica; $params['wrapperClass'] = PrimaryReadReplicaConnection::class; diff --git a/tests/Functional/Schema/PostgreSQLSchemaManagerTest.php b/tests/Functional/Schema/PostgreSQLSchemaManagerTest.php index a65d938f6df..52fa9259652 100644 --- a/tests/Functional/Schema/PostgreSQLSchemaManagerTest.php +++ b/tests/Functional/Schema/PostgreSQLSchemaManagerTest.php @@ -254,14 +254,14 @@ public function testListForeignKeys(): void $fkOptions = ['SET NULL', 'SET DEFAULT', 'NO ACTION', 'CASCADE', 'RESTRICT']; $foreignKeys = []; $fkTable = $this->getTestTable('test_create_fk1'); - for ($i = 0; $i < count($fkOptions); $i++) { + foreach ($fkOptions as $i => $currentOption) { $fkTable->addColumn('foreign_key_test' . $i, 'integer'); $foreignKeys[] = new ForeignKeyConstraint( ['foreign_key_test' . $i], 'test_create_fk2', ['id'], 'foreign_key_test' . $i . '_fk', - ['onDelete' => $fkOptions[$i]], + ['onDelete' => $currentOption], ); } diff --git a/tests/Functional/Schema/SchemaManagerFunctionalTestCase.php b/tests/Functional/Schema/SchemaManagerFunctionalTestCase.php index a99eb536f1e..ef11ad861d3 100644 --- a/tests/Functional/Schema/SchemaManagerFunctionalTestCase.php +++ b/tests/Functional/Schema/SchemaManagerFunctionalTestCase.php @@ -764,8 +764,8 @@ public function testTableInNamespace(): void } //create schema - $diff = new SchemaDiff(); - $diff->newNamespaces[] = 'testschema'; + $diff = new SchemaDiff(); + $diff->newNamespaces['testschema'] = 'testschema'; foreach ($platform->getAlterSchemaSQL($diff) as $sql) { $this->connection->executeStatement($sql); diff --git a/tests/Logging/MiddlewareTest.php b/tests/Logging/MiddlewareTest.php index 05822b41b4d..851de2a4e18 100644 --- a/tests/Logging/MiddlewareTest.php +++ b/tests/Logging/MiddlewareTest.php @@ -33,7 +33,7 @@ public function setUp(): void public function testConnectAndDisconnect(): void { $this->driver->connect([ - 'username' => 'admin', + 'user' => 'admin', 'password' => 'Passw0rd!', 'url' => 'mysql://user:secret@localhost/mydb', ]); @@ -42,7 +42,7 @@ public function testConnectAndDisconnect(): void 'message' => 'Connecting with parameters {params}', 'context' => [ 'params' => [ - 'username' => 'admin', + 'user' => 'admin', 'password' => '', 'url' => '', ], diff --git a/tests/Query/Expression/ExpressionBuilderTest.php b/tests/Query/Expression/ExpressionBuilderTest.php index 4ecfeb9fa08..c70ff6276e1 100644 --- a/tests/Query/Expression/ExpressionBuilderTest.php +++ b/tests/Query/Expression/ExpressionBuilderTest.php @@ -227,7 +227,7 @@ public function testIsNotNull(): void public function testIn(): void { - self::assertEquals('u.groups IN (1, 3, 4, 7)', $this->expr->in('u.groups', [1, 3, 4, 7])); + self::assertEquals('u.groups IN (1, 3, 4, 7)', $this->expr->in('u.groups', ['1', '3', '4', '7'])); } public function testInWithPlaceholder(): void @@ -237,7 +237,7 @@ public function testInWithPlaceholder(): void public function testNotIn(): void { - self::assertEquals('u.groups NOT IN (1, 3, 4, 7)', $this->expr->notIn('u.groups', [1, 3, 4, 7])); + self::assertEquals('u.groups NOT IN (1, 3, 4, 7)', $this->expr->notIn('u.groups', ['1', '3', '4', '7'])); } public function testNotInWithPlaceholder(): void diff --git a/tests/TestUtil.php b/tests/TestUtil.php index 3da92507daf..a428ec8afc5 100644 --- a/tests/TestUtil.php +++ b/tests/TestUtil.php @@ -13,6 +13,7 @@ use Doctrine\DBAL\Platforms\OraclePlatform; use Doctrine\DBAL\Platforms\SqlitePlatform; use Doctrine\DBAL\Schema\DefaultSchemaManagerFactory; +use LogicException; use PHPUnit\Framework\Assert; use function array_keys; @@ -30,6 +31,8 @@ /** * TestUtil is a class with static utility methods used during tests. + * + * @psalm-import-type Params from DriverManager */ class TestUtil { @@ -66,11 +69,11 @@ public static function getConnection(): Connection return DriverManager::getConnection( $params, - self::createConfiguration($params['driver']), + self::createConfiguration($params['driver'] ?? null), ); } - /** @return mixed[] */ + /** @psalm-return Params */ public static function getConnectionParams(): array { if (self::hasRequiredConnectionParams()) { @@ -110,9 +113,13 @@ private static function initializeDatabase(): void $testConn->close(); } else { if (! $platform instanceof OraclePlatform) { - $dbname = $testConnParams['dbname']; + $dbname = $testConnParams['dbname'] ?? null; } else { - $dbname = $testConnParams['user']; + $dbname = $testConnParams['user'] ?? null; + } + + if (! $dbname) { + throw new LogicException('Cannot inialize test database: Missing database name'); } $sm = $privConn->getSchemaManager(); @@ -128,7 +135,7 @@ private static function initializeDatabase(): void $privConn->close(); } - /** @return mixed[] */ + /** @psalm-return Params */ private static function getFallbackConnectionParams(): array { if (! extension_loaded('pdo_sqlite')) { @@ -141,7 +148,7 @@ private static function getFallbackConnectionParams(): array ]; } - private static function createConfiguration(string $driver): Configuration + private static function createConfiguration(?string $driver): Configuration { $configuration = new Configuration(); @@ -174,7 +181,7 @@ private static function getPrivilegedConnectionParameters(): array return $parameters; } - /** @return mixed[] */ + /** @psalm-return Params */ private static function getTestConnectionParameters(): array { return self::mapConnectionParameters($GLOBALS, 'db_'); @@ -184,6 +191,7 @@ private static function getTestConnectionParameters(): array * @param array $configuration * * @return array + * @psalm-return Params */ private static function mapConnectionParameters(array $configuration, string $prefix): array { @@ -234,7 +242,7 @@ public static function getPrivilegedConnection(): Connection public static function isDriverOneOf(string ...$names): bool { - return in_array(self::getConnectionParams()['driver'], $names, true); + return in_array(self::getConnectionParams()['driver'] ?? null, $names, true); } /**