Skip to content

Commit

Permalink
Deprecate AbstractPlatform methods exposing quote characters
Browse files Browse the repository at this point in the history
  • Loading branch information
morozov committed May 12, 2022
1 parent 7d3351b commit 221bd83
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
6 changes: 6 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ awareness about deprecated code.

# Upgrade to 3.4

## Deprecated `AbstractPlatform` methods exposing quote characters.

The `AbstractPlatform::getStringLiteralQuoteCharacter()` and `::getIdentifierQuoteCharacter()` methods
have been deprecated. Use `::quoteStringLiteral()` and `::quoteIdentifier()` to quote string literals and identifiers
respectively.

## Deprecated `AbstractSchemaManager::getDatabasePlatform()`

The `AbstractSchemaManager::getDatabasePlatform()` method has been deprecated. Use `Connection::getDatabasePlatform()`
Expand Down
6 changes: 6 additions & 0 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,12 @@
TODO: remove in 4.0.0
-->
<referencedMethod name="Doctrine\DBAL\Platforms\AbstractPlatform::getVarcharTypeDeclarationSQL"/>
<!--
TODO: remove in 4.0.0
-->
<referencedMethod name="Doctrine\DBAL\Platforms\AbstractMySQLPlatform::getIdentifierQuoteCharacter"/>
<referencedMethod name="Doctrine\DBAL\Platforms\AbstractPlatform::getIdentifierQuoteCharacter"/>
<referencedMethod name="Doctrine\DBAL\Platforms\AbstractPlatform::getStringLiteralQuoteCharacter"/>
</errorLevel>
</DeprecatedMethod>
<DeprecatedProperty>
Expand Down
8 changes: 8 additions & 0 deletions src/Platforms/AbstractMySQLPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,17 @@ protected function doModifyLimitQuery($query, $limit, $offset)

/**
* {@inheritDoc}
*
* @deprecated Use {@see quoteIdentifier()} to quote identifiers instead.
*/
public function getIdentifierQuoteCharacter()
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5388',
'AbstractMySQLPlatform::getIdentifierQuoteCharacter() is deprecated. Use quoteIdentifier() instead.'
);

return '`';
}

Expand Down
17 changes: 17 additions & 0 deletions src/Platforms/AbstractPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -563,10 +563,18 @@ protected function getColumnComment(Column $column)
/**
* Gets the character used for identifier quoting.
*
* @deprecated Use {@see quoteIdentifier()} to quote identifiers instead.
*
* @return string
*/
public function getIdentifierQuoteCharacter()
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5388',
'AbstractPlatform::getIdentifierQuoteCharacter() is deprecated. Use quoteIdentifier() instead.'
);

return '"';
}

Expand Down Expand Up @@ -4130,10 +4138,19 @@ public function quoteStringLiteral($str)
/**
* Gets the character used for string literal quoting.
*
* @deprecated Use {@see quoteStringLiteral()} to quote string literals instead.
*
* @return string
*/
public function getStringLiteralQuoteCharacter()
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5388',
'AbstractPlatform::getStringLiteralQuoteCharacter() is deprecated.'
. ' Use quoteStringLiteral() instead.'
);

return "'";
}

Expand Down

0 comments on commit 221bd83

Please sign in to comment.