Skip to content

Commit

Permalink
[doctrineGH-3956] Convert CLI HelperSet deprecations to Doctrine API.
Browse files Browse the repository at this point in the history
  • Loading branch information
beberlei committed Mar 6, 2021
1 parent a4f5a81 commit 38553dd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
11 changes: 5 additions & 6 deletions lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
{
Expand Down Expand Up @@ -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'
);
}

Expand Down
11 changes: 5 additions & 6 deletions lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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'
);
}

Expand Down
10 changes: 5 additions & 5 deletions lib/Doctrine/DBAL/Tools/Console/ConsoleRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 38553dd

Please sign in to comment.