From fe43f5c8347130c1f477b81e8e1d191f5dfef65d Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Sun, 22 Dec 2024 16:19:29 -0800 Subject: [PATCH] Deprecated AbstractAsset namespace-related methods --- UPGRADE.md | 17 +++++++++++++++++ psalm.xml.dist | 14 ++++++++++++++ src/Schema/AbstractAsset.php | 21 +++++++++++++++++++++ 3 files changed, 52 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index e16d24d5b4..a144a26949 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -8,6 +8,23 @@ awareness about deprecated code. # Upgrade to 4.3 +## Deprecated `AbstractAsset` namespace-related methods and property + +The following namespace-related methods and property have been deprecated: + +- `AbstractAsset::getNamespaceName()` +- `AbstractAsset::isInDefaultNamespace()` +- `AbstractAsset::$_namespace` + +In order to identify the namespace of an object, use the following methods instead: + +```php +$qualifier = $table->getObjectName()->getQualifier(); +``` + +If the return value is not null, then it will contain the identifier representing the namespace name – its value and +whether it's quoted. + ## `Table::__construct()` marked as internal The `Table::__construct()` method has been marked as internal. Use `Table::editor()` to instantiate an editor and diff --git a/psalm.xml.dist b/psalm.xml.dist index 92f828b693..a9d9c0a170 100644 --- a/psalm.xml.dist +++ b/psalm.xml.dist @@ -134,6 +134,13 @@ TODO: remove in 5.0.0 --> + + + + @@ -149,6 +156,13 @@ TODO: remove in 5.0.0 --> + + + + diff --git a/src/Schema/AbstractAsset.php b/src/Schema/AbstractAsset.php index 1f130c3e7a..811ccb309f 100644 --- a/src/Schema/AbstractAsset.php +++ b/src/Schema/AbstractAsset.php @@ -49,6 +49,8 @@ abstract class AbstractAsset /** * Namespace of the asset. If none isset the default namespace is assumed. + * + * @deprecated Use {@see NamedObject::getObjectName()} and {@see OptionallyQualifiedName::getQualifier()} instead. */ protected ?string $_namespace = null; @@ -231,9 +233,18 @@ protected function _setName(string $name): void /** * Is this asset in the default namespace? + * + * @deprecated */ public function isInDefaultNamespace(string $defaultNamespaceName): bool { + Deprecation::triggerIfCalledFromOutside( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/pull/6664', + '%s is deprecated and will be removed in 5.0.', + __METHOD__, + ); + return $this->_namespace === $defaultNamespaceName || $this->_namespace === null; } @@ -241,9 +252,19 @@ public function isInDefaultNamespace(string $defaultNamespaceName): bool * Gets the namespace name of this asset. * * If NULL is returned this means the default namespace is used. + * + * @deprecated Use {@see NamedObject::getObjectName()} and {@see OptionallyQualifiedName::getQualifier()} instead. */ public function getNamespaceName(): ?string { + Deprecation::triggerIfCalledFromOutside( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/pull/6664', + '%s is deprecated and will be removed in 5.0. Use NamedObject::getObjectName()' + . ' and OptionallyQualifiedName::getQualifier() instead.', + __METHOD__, + ); + return $this->_namespace; }