diff --git a/composer.json b/composer.json index 3ba155d5f69..c0eaf8a3f10 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.8.0" }, "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..78c2e3666d3 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,18 @@ + + + + + + + + + + + + + + + + + + + + + + @@ -823,6 +853,7 @@ This issue should be fixed in 4.0 --> + @@ -838,10 +869,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/AbstractPlatform.php b/src/Platforms/AbstractPlatform.php index d4d719471c5..9ca69f4e70e 100644 --- a/src/Platforms/AbstractPlatform.php +++ b/src/Platforms/AbstractPlatform.php @@ -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/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/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/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/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