From 0e1dfa628804b860edf08f3d156f97ca67e0ebb7 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Sat, 6 Mar 2021 18:48:14 +0100 Subject: [PATCH] [GH-3956] Convert CLI HelperSet deprecations to Doctrine API. --- .../Tools/Console/Command/ReservedWordsCommand.php | 11 +++++------ .../DBAL/Tools/Console/Command/RunSqlCommand.php | 11 +++++------ lib/Doctrine/DBAL/Tools/Console/ConsoleRunner.php | 10 +++++----- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php b/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php index bd819af0e6a..4553a0a701e 100644 --- a/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php +++ b/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php @@ -23,6 +23,7 @@ use Doctrine\DBAL\Platforms\Keywords\SQLServer2012Keywords; use Doctrine\DBAL\Platforms\Keywords\SQLServerKeywords; use Doctrine\DBAL\Tools\Console\ConnectionProvider; +use Doctrine\Deprecations\Deprecation; use Exception; use InvalidArgumentException; use Symfony\Component\Console\Command\Command; @@ -36,9 +37,6 @@ use function implode; use function is_array; use function is_string; -use function trigger_error; - -use const E_USER_DEPRECATED; class ReservedWordsCommand extends Command { @@ -74,9 +72,10 @@ public function __construct(?ConnectionProvider $connectionProvider = null) return; } - @trigger_error( - 'Not passing a connection provider as the first constructor argument is deprecated', - E_USER_DEPRECATED + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/pull/3956', + 'Not passing a connection provider as the first constructor argument is deprecated' ); } diff --git a/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php b/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php index f7253866403..9a63696b6ff 100644 --- a/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php +++ b/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php @@ -5,6 +5,7 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Tools\Console\ConnectionProvider; use Doctrine\DBAL\Tools\Dumper; +use Doctrine\Deprecations\Deprecation; use Exception; use LogicException; use RuntimeException; @@ -18,9 +19,6 @@ use function is_numeric; use function is_string; use function stripos; -use function trigger_error; - -use const E_USER_DEPRECATED; /** * Task for executing arbitrary SQL that can come from a file or directly from @@ -39,9 +37,10 @@ public function __construct(?ConnectionProvider $connectionProvider = null) return; } - @trigger_error( - 'Not passing a connection provider as the first constructor argument is deprecated', - E_USER_DEPRECATED + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/pull/3956', + 'Not passing a connection provider as the first constructor argument is deprecated' ); } diff --git a/lib/Doctrine/DBAL/Tools/Console/ConsoleRunner.php b/lib/Doctrine/DBAL/Tools/Console/ConsoleRunner.php index 3d73388c73b..7fc14c340ae 100644 --- a/lib/Doctrine/DBAL/Tools/Console/ConsoleRunner.php +++ b/lib/Doctrine/DBAL/Tools/Console/ConsoleRunner.php @@ -8,15 +8,13 @@ use Doctrine\DBAL\Tools\Console\Command\RunSqlCommand; use Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper; use Doctrine\DBAL\Version; +use Doctrine\Deprecations\Deprecation; use Symfony\Component\Console\Application; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Helper\HelperSet; use TypeError; use function sprintf; -use function trigger_error; - -use const E_USER_DEPRECATED; /** * Handles running the Console Tools inside Symfony Console context. @@ -53,11 +51,13 @@ public static function run($helperSetOrConnectionProvider, $commands = []) $connectionProvider = null; if ($helperSetOrConnectionProvider instanceof HelperSet) { - @trigger_error(sprintf( + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/pull/3956', 'Passing an instance of "%s" as the first argument is deprecated. Pass an instance of "%s" instead.', HelperSet::class, ConnectionProvider::class - ), E_USER_DEPRECATED); + ); $connectionProvider = null; $cli->setHelperSet($helperSetOrConnectionProvider); } elseif ($helperSetOrConnectionProvider instanceof ConnectionProvider) {