From 33530051d55208b0682cd9a4b8886dc6f5ac36f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dalibor=20Karlovi=C4=87?= Date: Wed, 16 Aug 2023 17:34:30 +0200 Subject: [PATCH 1/4] fix: don't trigger deprecation if called internally --- src/Schema/AbstractSchemaManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Schema/AbstractSchemaManager.php b/src/Schema/AbstractSchemaManager.php index a7d92d2608d..e4ac0d85422 100644 --- a/src/Schema/AbstractSchemaManager.php +++ b/src/Schema/AbstractSchemaManager.php @@ -242,7 +242,7 @@ protected function doListTableColumns($table, $database = null): array if ($database === null) { $database = $this->getDatabase(__METHOD__); } else { - Deprecation::trigger( + Deprecation::triggerIfCalledFromOutside( 'doctrine/dbal', 'https://github.com/doctrine/dbal/issues/5284', 'Passing $database to AbstractSchemaManager::listTableColumns() is deprecated.', From 3780d3ae69c22b2253ef28be4e0a4ae23ae1a74a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dalibor=20Karlovi=C4=87?= Date: Wed, 16 Aug 2023 17:53:30 +0200 Subject: [PATCH 2/4] fix: correct the deprecation method name --- src/Schema/AbstractSchemaManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Schema/AbstractSchemaManager.php b/src/Schema/AbstractSchemaManager.php index e4ac0d85422..7e1fd93ff2d 100644 --- a/src/Schema/AbstractSchemaManager.php +++ b/src/Schema/AbstractSchemaManager.php @@ -245,7 +245,7 @@ protected function doListTableColumns($table, $database = null): array Deprecation::triggerIfCalledFromOutside( 'doctrine/dbal', 'https://github.com/doctrine/dbal/issues/5284', - 'Passing $database to AbstractSchemaManager::listTableColumns() is deprecated.', + 'Passing $database to AbstractSchemaManager::doListTableColumns() is deprecated.', ); } From 0f3f92c3a3fe1cea9722b6758369c351ab6953a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Tue, 22 Aug 2023 13:02:00 +0200 Subject: [PATCH 3/4] Add Type::lookupName() shortcut method (#6130) | Q | A |------------- | ----------- | Type | feature | Fixed issues | n/a #### Summary `Type` class has static methods for global `TypeRegistry` instance shorter access like `Type::getType`. This feature adds a static method for `TypeRegistry::lookupName`. Thanks to https://github.com/doctrine/dbal/pull/6082, the reverse lookup is O(1) thus fine to be used massively - for ex. schema introspection returns type as object, and this method is needed to obtain a string name. In DBAL 4.0, the method can be renamed to `Type::getName(Type $type): string` to be more consistent with `Type::getType(string $name): Type`. --- src/Types/Type.php | 10 ++++++++++ tests/Types/TypeTest.php | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/src/Types/Type.php b/src/Types/Type.php index 2b49248ec3b..7613811e971 100644 --- a/src/Types/Type.php +++ b/src/Types/Type.php @@ -138,6 +138,16 @@ public static function getType($name) return self::getTypeRegistry()->get($name); } + /** + * Finds a name for the given type. + * + * @throws Exception + */ + public static function lookupName(self $type): string + { + return self::getTypeRegistry()->lookupName($type); + } + /** * Adds a custom type to the type map. * diff --git a/tests/Types/TypeTest.php b/tests/Types/TypeTest.php index e6999eabfce..05b2199ae39 100644 --- a/tests/Types/TypeTest.php +++ b/tests/Types/TypeTest.php @@ -17,6 +17,13 @@ public function testDefaultTypesAreRegistered(string $name): void self::assertTrue(Type::hasType($name)); } + /** @dataProvider defaultTypesProvider() */ + public function testDefaultTypesReverseLookup(string $name): void + { + $type = Type::getType($name); + self::assertSame($name, Type::lookupName($type)); + } + /** @return iterable */ public static function defaultTypesProvider(): iterable { From e07f9b5c236eacf8e051b102ce5690e263b5779c Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Thu, 24 Aug 2023 10:35:21 +0200 Subject: [PATCH 4/4] Support Symfony 7 by adding return types conditionally (#6136) Same as doctrine/orm#10919. --- phpcs.xml.dist | 5 +++ psalm.xml.dist | 5 +++ .../Console/Command/CommandCompatibility.php | 35 +++++++++++++++++++ .../Console/Command/ReservedWordsCommand.php | 12 +++---- src/Tools/Console/Command/RunSqlCommand.php | 12 +++---- 5 files changed, 53 insertions(+), 16 deletions(-) create mode 100644 src/Tools/Console/Command/CommandCompatibility.php diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 4599df238c9..8617535973d 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -34,6 +34,10 @@ + + */src/Tools/Console/Command/CommandCompatibility.php + + */src/Configuration.php */src/Connection.php @@ -70,6 +74,7 @@ + */src/Tools/Console/Command/CommandCompatibility.php */tests/* diff --git a/psalm.xml.dist b/psalm.xml.dist index 3662f69b06a..567ecc381ae 100644 --- a/psalm.xml.dist +++ b/psalm.xml.dist @@ -589,6 +589,11 @@ + + + + +