Skip to content

Commit

Permalink
Merge pull request #4812 from morozov/deprecate-schema-get-table-namees
Browse files Browse the repository at this point in the history
Deprecate Schema::getTableNames()
  • Loading branch information
morozov authored Sep 27, 2021
2 parents 5e3c4c5 + 3f45d98 commit 09929a3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
10 changes: 10 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions src/Schema/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 09929a3

Please sign in to comment.