Skip to content

Commit f9004b3

Browse files
committed
Integrate with symfony/deprecation-contracts
We decided against use of doctrine/deprecations here, otherwise we would be forced to use mixed deprecations approach, which would increase complexity in our test suite when handling deprecations there. Rel: #1300
1 parent f751629 commit f9004b3

7 files changed

+40
-28
lines changed

Command/Proxy/ClearMetadataCacheDoctrineCommand.php

+7-5
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77
use Symfony\Component\Console\Input\InputOption;
88
use Symfony\Component\Console\Output\OutputInterface;
99

10-
use function sprintf;
11-
use function trigger_error;
12-
13-
use const E_USER_DEPRECATED;
10+
use function trigger_deprecation;
1411

1512
/**
1613
* Command to clear the metadata cache of the various cache drivers.
@@ -42,7 +39,12 @@ protected function configure()
4239
*/
4340
protected function execute(InputInterface $input, OutputInterface $output)
4441
{
45-
@trigger_error(sprintf('The "%s" (doctrine:cache:clear-metadata) is deprecated, metadata cache now uses PHP Array cache which can not be cleared.', self::class), E_USER_DEPRECATED);
42+
trigger_deprecation(
43+
'doctrine/doctrine-bundle',
44+
'2.3',
45+
'The "%s" (doctrine:cache:clear-metadata) is deprecated, metadata cache now uses PHP Array cache which can not be cleared.',
46+
self::class
47+
);
4648

4749
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
4850

Command/Proxy/ImportDoctrineCommand.php

+7-5
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77
use Symfony\Component\Console\Input\InputOption;
88
use Symfony\Component\Console\Output\OutputInterface;
99

10-
use function sprintf;
11-
use function trigger_error;
12-
13-
use const E_USER_DEPRECATED;
10+
use function trigger_deprecation;
1411

1512
/**
1613
* Loads an SQL file and executes it.
@@ -36,7 +33,12 @@ protected function configure()
3633
*/
3734
protected function execute(InputInterface $input, OutputInterface $output)
3835
{
39-
@trigger_error(sprintf('The "%s" (doctrine:database:import) command is deprecated, use a database client instead.', self::class), E_USER_DEPRECATED);
36+
trigger_deprecation(
37+
'doctrine/doctrine-bundle',
38+
'2.2',
39+
'The "%s" (doctrine:database:import) is deprecated, use a database client instead.',
40+
self::class
41+
);
4042

4143
DoctrineCommandHelper::setApplicationConnection($this->getApplication(), $input->getOption('connection'));
4244

Command/Proxy/RunSqlDoctrineCommand.php

+7-5
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@
88
use Symfony\Component\Console\Input\InputOption;
99
use Symfony\Component\Console\Output\OutputInterface;
1010

11-
use function sprintf;
12-
use function trigger_error;
13-
14-
use const E_USER_DEPRECATED;
11+
use function trigger_deprecation;
1512

1613
/**
1714
* Execute a SQL query and output the results.
@@ -59,7 +56,12 @@ protected function configure()
5956
*/
6057
protected function execute(InputInterface $input, OutputInterface $output)
6158
{
62-
@trigger_error(sprintf('The "%s" (doctrine:query:sql) is deprecated, use dbal:run-sql command instead.', self::class), E_USER_DEPRECATED);
59+
trigger_deprecation(
60+
'doctrine/doctrine-bundle',
61+
'2.2',
62+
'The "%s" (doctrine:query:sql) is deprecated, use dbal:run-sql command instead.',
63+
self::class
64+
);
6365

6466
if (! $this->connectionProvider) {
6567
DoctrineCommandHelper::setApplicationConnection($this->getApplication(), $input->getOption('connection'));

ConnectionFactory.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@
1616
use function array_merge;
1717
use function class_exists;
1818
use function is_subclass_of;
19-
use function trigger_error;
19+
use function trigger_deprecation;
2020

21-
use const E_USER_DEPRECATED;
2221
use const PHP_EOL;
2322

2423
/** @psalm-import-type Params from DriverManager */
@@ -53,7 +52,7 @@ public function createConnection(array $params, ?Configuration $config = null, ?
5352

5453
$overriddenOptions = [];
5554
if (isset($params['connection_override_options'])) {
56-
@trigger_error('The "connection_override_options" connection parameter is deprecated since DoctrineBundle 2.4.', E_USER_DEPRECATED);
55+
trigger_deprecation('doctrine/doctrine-bundle', '2.4', 'The "connection_override_options" connection parameter is deprecated');
5756
$overriddenOptions = $params['connection_override_options'];
5857
unset($params['connection_override_options']);
5958
}

DependencyInjection/Configuration.php

+8-5
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@
3333
use function strpos;
3434
use function strtoupper;
3535
use function substr;
36-
use function trigger_error;
37-
38-
use const E_USER_DEPRECATED;
36+
use function trigger_deprecation;
3937

4038
/**
4139
* This class contains the configuration information for the bundle
@@ -255,8 +253,13 @@ private function configureDbalDriverNode(ArrayNodeDefinition $node): void
255253

256254
if ($urlConflictingValues) {
257255
$tail = count($urlConflictingValues) > 1 ? sprintf('or "%s" options', array_pop($urlConflictingValues)) : 'option';
258-
259-
@trigger_error(sprintf('Setting the "doctrine.dbal.%s" %s while the "url" one is defined is deprecated since DoctrineBundle 2.4.', implode('", "', $urlConflictingValues), $tail), E_USER_DEPRECATED);
256+
trigger_deprecation(
257+
'doctrine/doctrine-bundle',
258+
'2.4',
259+
'Setting the "doctrine.dbal.%s" %s while the "url" one is defined is deprecated',
260+
implode('", "', $urlConflictingValues),
261+
$tail
262+
);
260263
}
261264

262265
return $values;

Twig/DoctrineExtension.php

+7-4
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@
2323
use function sprintf;
2424
use function strtoupper;
2525
use function substr;
26-
use function trigger_error;
27-
28-
use const E_USER_DEPRECATED;
26+
use function trigger_deprecation;
2927

3028
/**
3129
* This class contains the needed functions in order to do the query highlighting
@@ -147,7 +145,12 @@ static function ($matches) use ($parameters, &$i) {
147145
*/
148146
public function formatQuery($sql, $highlightOnly = false)
149147
{
150-
@trigger_error(sprintf('The "%s()" method is deprecated and will be removed in DoctrineBundle 3.0.', __METHOD__), E_USER_DEPRECATED);
148+
trigger_deprecation(
149+
'doctrine/doctrine-bundle',
150+
'2.1',
151+
'The "%s()" method is deprecated and will be removed in doctrine-bundle 3.0.',
152+
__METHOD__
153+
);
151154

152155
$this->setUpSqlFormatter(true, true);
153156

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,14 @@
3434
"symfony/config": "^4.4.3|^5.0|^6.0",
3535
"symfony/console": "^3.4.30|^4.3.3|^5.0|^6.0",
3636
"symfony/dependency-injection": "^4.3.3|^5.0|^6.0",
37+
"symfony/deprecation-contracts": "^2",
3738
"symfony/doctrine-bridge": "^4.4.22|^5.2.7|^6.0",
3839
"symfony/framework-bundle": "^3.4.30|^4.3.3|^5.0|^6.0",
3940
"symfony/service-contracts": "^1.1.1|^2.0"
4041
},
4142
"require-dev": {
4243
"doctrine/coding-standard": "^9.0",
43-
"doctrine/orm": "^2.9-dev",
44+
"doctrine/orm": "^2.9",
4445
"friendsofphp/proxy-manager-lts": "^1.0",
4546
"phpunit/phpunit": "^7.5 || ^8.0 || ^9.3",
4647
"psalm/plugin-phpunit": "^0.15.1",

0 commit comments

Comments
 (0)