From 90469f58047f58575fb12154f17f36e4920bfabf Mon Sep 17 00:00:00 2001 From: Adrien Foulon <6115458+Tofandel@users.noreply.github.com> Date: Thu, 29 Jun 2023 12:28:34 +0200 Subject: [PATCH 1/2] Document alternative to Type::getName (#6077) Co-authored-by: Alexander M. Turek --- UPGRADE.md | 4 +++- src/Types/Type.php | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index 44f14436dfc..07d31971980 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -679,11 +679,13 @@ This method is unused by the DBAL since 2.0. ## Deprecated `Type::getName()` -This will method is not useful for the DBAL anymore, and will be removed in 4.0. +This method is not useful for the DBAL anymore, and will be removed in 4.0. As a consequence, depending on the name of a type being `json` for `jsonb` to be used for the Postgres platform is deprecated in favor of extending `Doctrine\DBAL\Types\JsonType`. +You can use `Type::getTypeRegistry()->lookupName($type)` instead. + ## Deprecated `AbstractPlatform::getColumnComment()`, `AbstractPlatform::getDoctrineTypeComment()`, `AbstractPlatform::hasNative*Type()` and `Type::requiresSQLCommentHint()` diff --git a/src/Types/Type.php b/src/Types/Type.php index 536cf36f2b8..2b49248ec3b 100644 --- a/src/Types/Type.php +++ b/src/Types/Type.php @@ -100,7 +100,8 @@ abstract public function getSQLDeclaration(array $column, AbstractPlatform $plat /** * Gets the name of this type. * - * @deprecated this method will be removed in Doctrine DBAL 4.0. + * @deprecated this method will be removed in Doctrine DBAL 4.0, + * use {@see TypeRegistry::lookupName()} instead. * * @return string */ From 5e141d816c34c438e79b801f978497bac2d9fbd2 Mon Sep 17 00:00:00 2001 From: Sam <40273116+Aweptimum@users.noreply.github.com> Date: Wed, 5 Jul 2023 15:22:35 -0400 Subject: [PATCH 2/2] Use triggerIfCalledFromOutside in listTableDetails Though listTableDetails is deprecated, it is still called internally. To avoid getting deprecation messages when called by other doctrine function, we can replace the use of Deprecation::trigger with Deprecation::triggerIfCalledFromOutside in the SchemaManagers. With the exception of SqliteSchemaManager, which already did this --- src/Schema/AbstractSchemaManager.php | 2 +- src/Schema/DB2SchemaManager.php | 2 +- src/Schema/MySQLSchemaManager.php | 2 +- src/Schema/OracleSchemaManager.php | 2 +- src/Schema/PostgreSQLSchemaManager.php | 2 +- src/Schema/SQLServerSchemaManager.php | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Schema/AbstractSchemaManager.php b/src/Schema/AbstractSchemaManager.php index 445c9ff2fb8..7da2b1178db 100644 --- a/src/Schema/AbstractSchemaManager.php +++ b/src/Schema/AbstractSchemaManager.php @@ -442,7 +442,7 @@ protected function doListTables(): array */ public function listTableDetails($name) { - Deprecation::trigger( + Deprecation::triggerIfCalledFromOutside( 'doctrine/dbal', 'https://github.com/doctrine/dbal/pull/5595', '%s is deprecated. Use introspectTable() instead.', diff --git a/src/Schema/DB2SchemaManager.php b/src/Schema/DB2SchemaManager.php index 95d32174105..1070a14e277 100644 --- a/src/Schema/DB2SchemaManager.php +++ b/src/Schema/DB2SchemaManager.php @@ -50,7 +50,7 @@ public function listTables() */ public function listTableDetails($name) { - Deprecation::trigger( + Deprecation::triggerIfCalledFromOutside( 'doctrine/dbal', 'https://github.com/doctrine/dbal/pull/5595', '%s is deprecated. Use introspectTable() instead.', diff --git a/src/Schema/MySQLSchemaManager.php b/src/Schema/MySQLSchemaManager.php index bd383b01292..2ddc249d812 100644 --- a/src/Schema/MySQLSchemaManager.php +++ b/src/Schema/MySQLSchemaManager.php @@ -73,7 +73,7 @@ public function listTables() */ public function listTableDetails($name) { - Deprecation::trigger( + Deprecation::triggerIfCalledFromOutside( 'doctrine/dbal', 'https://github.com/doctrine/dbal/pull/5595', '%s is deprecated. Use introspectTable() instead.', diff --git a/src/Schema/OracleSchemaManager.php b/src/Schema/OracleSchemaManager.php index 9ab32a998c0..07375221460 100644 --- a/src/Schema/OracleSchemaManager.php +++ b/src/Schema/OracleSchemaManager.php @@ -51,7 +51,7 @@ public function listTables() */ public function listTableDetails($name) { - Deprecation::trigger( + Deprecation::triggerIfCalledFromOutside( 'doctrine/dbal', 'https://github.com/doctrine/dbal/pull/5595', '%s is deprecated. Use introspectTable() instead.', diff --git a/src/Schema/PostgreSQLSchemaManager.php b/src/Schema/PostgreSQLSchemaManager.php index 7ca6f335107..183ef5e6a75 100644 --- a/src/Schema/PostgreSQLSchemaManager.php +++ b/src/Schema/PostgreSQLSchemaManager.php @@ -63,7 +63,7 @@ public function listTables() */ public function listTableDetails($name) { - Deprecation::trigger( + Deprecation::triggerIfCalledFromOutside( 'doctrine/dbal', 'https://github.com/doctrine/dbal/pull/5595', '%s is deprecated. Use introspectTable() instead.', diff --git a/src/Schema/SQLServerSchemaManager.php b/src/Schema/SQLServerSchemaManager.php index f717593af31..64538e6898c 100644 --- a/src/Schema/SQLServerSchemaManager.php +++ b/src/Schema/SQLServerSchemaManager.php @@ -55,7 +55,7 @@ public function listTables() */ public function listTableDetails($name) { - Deprecation::trigger( + Deprecation::triggerIfCalledFromOutside( 'doctrine/dbal', 'https://github.com/doctrine/dbal/pull/5595', '%s is deprecated. Use introspectTable() instead.',