Skip to content

Commit

Permalink
Merge pull request #5431 from morozov/deprecate-keyword-validator
Browse files Browse the repository at this point in the history
Deprecate checking keywords in schema object names
  • Loading branch information
morozov authored Jun 4, 2022
2 parents fbc240b + b145aa5 commit 4be7e2f
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
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.4

## Deprecated the functionality of checking schema for the usage of reserved keywords.

The `dbal:reserved-words` console command and the `ReservedWordsCommand` and `ReservedKeywordsValidator` classes
have been deprecated. Use the documentation on the used database platform(s) instead.

## Deprecated `CreateSchemaSqlCollector` and `DropSchemaSqlCollector`.

The `CreateSchemaSqlCollector` and `DropSchemaSqlCollector` classes have been deprecated in favor of
Expand Down
5 changes: 5 additions & 0 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@
-->
<referencedClass name="Doctrine\DBAL\Schema\Visitor\CreateSchemaSqlCollector"/>
<referencedClass name="Doctrine\DBAL\Schema\Visitor\DropSchemaSqlCollector"/>
<!--
TODO: remove in 4.0.0
-->
<referencedClass name="Doctrine\DBAL\Platforms\Keywords\ReservedKeywordsValidator"/>
<referencedClass name="Doctrine\DBAL\Tools\Console\Command\ReservedWordsCommand"/>
</errorLevel>
</DeprecatedClass>
<DeprecatedInterface>
Expand Down
10 changes: 10 additions & 0 deletions src/Platforms/Keywords/ReservedKeywordsValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@
use Doctrine\DBAL\Schema\Sequence;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\Visitor\Visitor;
use Doctrine\Deprecations\Deprecation;

use function count;
use function implode;
use function str_replace;

/**
* @deprecated Use database documentation instead.
*/
class ReservedKeywordsValidator implements Visitor
{
/** @var KeywordList[] */
Expand All @@ -27,6 +31,12 @@ class ReservedKeywordsValidator implements Visitor
*/
public function __construct(array $keywordLists)
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5431',
'ReservedKeywordsValidator is deprecated. Use database documentation instead.'
);

$this->keywordLists = $keywordLists;
}

Expand Down
15 changes: 15 additions & 0 deletions src/Tools/Console/Command/ReservedWordsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
use function is_array;
use function is_string;

/**
* @deprecated Use database documentation instead.
*/
class ReservedWordsCommand extends Command
{
/** @var array<string,KeywordList> */
Expand All @@ -41,6 +44,12 @@ class ReservedWordsCommand extends Command

public function __construct(ConnectionProvider $connectionProvider)
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5431',
'ReservedWordsCommand is deprecated. Use database documentation instead.'
);

parent::__construct();
$this->connectionProvider = $connectionProvider;

Expand Down Expand Up @@ -139,6 +148,12 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln(
'<comment>The <info>dbal:reserved-words</info> command is deprecated.</comment>'
. ' Use the documentation on the used database platform(s) instead.'
);
$output->writeln('');

$conn = $this->getConnection($input);

$keywordLists = $input->getOption('list');
Expand Down

0 comments on commit 4be7e2f

Please sign in to comment.