Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate AbstractAsset::getFullQualifiedName() #4814

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ awareness about deprecated code.

# Upgrade to 3.2

## Deprecated `AbstractAsset::getFullQualifiedName()`.

The `AbstractAsset::getFullQualifiedName()` method has been deprecated. Use `::getNamespaceName()`
and `::getName()` instead.

## Deprecated schema methods related to explicit foreign key indexes.

The following methods have been deprecated:
Expand Down
5 changes: 5 additions & 0 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@
See https://github.com/doctrine/dbal/pull/4822
-->
<referencedMethod name="Doctrine\DBAL\Schema\SchemaConfig::hasExplicitForeignKeyIndexes"/>
<!--
TODO: remove in 4.0.0
See https://github.com/doctrine/dbal/pull/4814
-->
<referencedMethod name="Doctrine\DBAL\Schema\AbstractAsset::getFullQualifiedName"/>
</errorLevel>
</DeprecatedMethod>
<DeprecatedProperty>
Expand Down
12 changes: 11 additions & 1 deletion src/Schema/AbstractAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Doctrine\DBAL\Schema;

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\Deprecations\Deprecation;

use function array_map;
use function crc32;
Expand Down Expand Up @@ -102,20 +103,29 @@ public function getShortestName($defaultNamespaceName)
}

/**
* The normalized name is full-qualified and lowerspaced. Lowerspacing is
* The normalized name is full-qualified and lower-cased. Lower-casing is
greg0ire marked this conversation as resolved.
Show resolved Hide resolved
* actually wrong, but we have to do it to keep our sanity. If you are
* using database objects that only differentiate in the casing (FOO vs
* Foo) then you will NOT be able to use Doctrine Schema abstraction.
*
* Every non-namespaced element is prefixed with the default namespace
* name which is passed as argument to this method.
*
* @deprecated Use {@link getNamespaceName()} and {@link getName()} instead.
*
* @param string $defaultNamespaceName
*
* @return string
*/
public function getFullQualifiedName($defaultNamespaceName)
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/4814',
'AbstractAsset::getFullQualifiedName() is deprecated.'
. ' Use AbstractAsset::getNamespaceName() and ::getName() instead.'
);

$name = $this->getName();
if ($this->_namespace === null) {
$name = $defaultNamespaceName . '.' . $name;
Expand Down
9 changes: 7 additions & 2 deletions src/Schema/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function hasExplicitForeignKeyIndexes()
protected function _addTable(Table $table)
{
$namespaceName = $table->getNamespaceName();
$tableName = $table->getFullQualifiedName($this->getName());
$tableName = $this->normalizeName($table);

if (isset($this->_tables[$tableName])) {
throw SchemaException::tableAlreadyExists($tableName);
Expand All @@ -138,7 +138,7 @@ protected function _addTable(Table $table)
protected function _addSequence(Sequence $sequence)
{
$namespaceName = $sequence->getNamespaceName();
$seqName = $sequence->getFullQualifiedName($this->getName());
$seqName = $this->normalizeName($sequence);

if (isset($this->_sequences[$seqName])) {
throw SchemaException::sequenceAlreadyExists($seqName);
Expand Down Expand Up @@ -208,6 +208,11 @@ private function getFullQualifiedAssetName($name)
return strtolower($name);
}

private function normalizeName(AbstractAsset $asset): string
{
return $asset->getFullQualifiedName($this->getName());
greg0ire marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* Returns the unquoted representation of a given asset name.
*
Expand Down