From 3f45d98b4e750f5bb14c99150d0ec96ba0f0b99e Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Wed, 22 Sep 2021 12:41:37 -0700 Subject: [PATCH] Deprecate Schema::getTableNames() --- UPGRADE.md | 10 ++++++++++ src/Schema/Schema.php | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index 672a88f0335..a0a7327e6e8 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -8,6 +8,16 @@ awareness about deprecated code. # Upgrade to 3.2 +## Deprecated `Schema::getTableNames()`. + +The `Schema::getTableNames()` method has been deprecated. In order to obtain schema table names, +use `Schema::getTables()` and call `Table::getName()` on the elements of the returned array. + +## Deprecated features of `Schema::getTables()` + +Using the returned array keys as table names is deprecated. Retrieve the name from the table +via `Table::getName()` instead. In order to retrieve a table by name, use `Schema::getTable()`. + ## Deprecated `AbstractPlatform::canEmulateSchemas()`. The `AbstractPlatform::canEmulateSchemas()` method and the schema emulation implemented in the SQLite platform diff --git a/src/Schema/Schema.php b/src/Schema/Schema.php index 47d9a0865c6..fe7186fd499 100644 --- a/src/Schema/Schema.php +++ b/src/Schema/Schema.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Schema\Visitor\DropSchemaSqlCollector; use Doctrine\DBAL\Schema\Visitor\NamespaceVisitor; use Doctrine\DBAL\Schema\Visitor\Visitor; +use Doctrine\Deprecations\Deprecation; use function array_keys; use function strpos; @@ -246,10 +247,20 @@ public function hasTable($name) /** * Gets all table names, prefixed with a schema name, even the default one if present. * + * @deprecated Use {@link getTables()} and {@link Table::getName()} instead. + * * @return string[] */ public function getTableNames() { + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/pull/4800', + 'Schema::getTableNames() is deprecated.' + . ' Use Schema::getTables() and Table::getName() instead.', + __METHOD__ + ); + return array_keys($this->_tables); }