Skip to content

Commit 6262991

Browse files
authored
Merge pull request #2060 from greg0ire/doctrine-depr
Switch entirely to doctrine/deprecations
2 parents 6d3b7bd + 7093c34 commit 6262991

File tree

9 files changed

+51
-28
lines changed

9 files changed

+51
-28
lines changed

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@
3131
"require": {
3232
"php": "^8.1",
3333
"doctrine/dbal": "^3.7.0 || ^4.0",
34+
"doctrine/deprecations": "^1.0",
3435
"doctrine/persistence": "^3.1 || ^4",
3536
"doctrine/sql-formatter": "^1.0.1",
3637
"symfony/cache": "^6.4 || ^7.0",
3738
"symfony/config": "^6.4 || ^7.0",
3839
"symfony/console": "^6.4 || ^7.0",
3940
"symfony/dependency-injection": "^6.4 || ^7.0",
40-
"symfony/deprecation-contracts": "^2.1 || ^3",
4141
"symfony/doctrine-bridge": "^6.4.3 || ^7.0.3",
4242
"symfony/framework-bundle": "^6.4 || ^7.0",
4343
"symfony/service-contracts": "^2.5 || ^3"
@@ -46,7 +46,6 @@
4646
"doctrine/annotations": "^1 || ^2",
4747
"doctrine/cache": "^1.11 || ^2.0",
4848
"doctrine/coding-standard": "^13",
49-
"doctrine/deprecations": "^1.0",
5049
"doctrine/orm": "^2.17 || ^3.1",
5150
"friendsofphp/proxy-manager-lts": "^1.0",
5251
"phpstan/phpstan": "2.1.1",

src/Command/Proxy/DoctrineCommandHelper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy;
44

5+
use Doctrine\Deprecations\Deprecation;
56
use Doctrine\ORM\EntityManagerInterface;
67
use Doctrine\ORM\Tools\Console\EntityManagerProvider;
78
use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper;
89
use Symfony\Bundle\FrameworkBundle\Console\Application;
910

1011
use function assert;
11-
use function trigger_deprecation;
1212

1313
/**
1414
* Provides some helper and convenience methods to configure doctrine commands in the context of bundles
@@ -31,9 +31,9 @@ public static function setApplicationEntityManager(Application $application, $em
3131
/* @phpstan-ignore class.notFound, argument.type (ORM < 3 specific) */
3232
$helperSet->set(new EntityManagerHelper($em), 'em');
3333

34-
trigger_deprecation(
34+
Deprecation::trigger(
3535
'doctrine/doctrine-bundle',
36-
'2.7',
36+
'https://github.com/doctrine/DoctrineBundle/pull/1513',
3737
'Providing an EntityManager using "%s" is deprecated. Use an instance of "%s" instead.',
3838
/* @phpstan-ignore class.notFound */
3939
EntityManagerHelper::class,

src/Command/Proxy/OrmProxyCommand.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22

33
namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy;
44

5+
use Doctrine\Deprecations\Deprecation;
56
use Doctrine\ORM\Tools\Console\EntityManagerProvider;
67
use Symfony\Component\Console\Input\InputInterface;
78
use Symfony\Component\Console\Output\OutputInterface;
89

9-
use function trigger_deprecation;
10-
1110
/**
1211
* @internal
1312
* @deprecated
@@ -19,9 +18,9 @@ public function __construct(
1918
) {
2019
parent::__construct($entityManagerProvider);
2120

22-
trigger_deprecation(
21+
Deprecation::trigger(
2322
'doctrine/doctrine-bundle',
24-
'2.8',
23+
'https://github.com/doctrine/DoctrineBundle/pull/1581',
2524
'Class "%s" is deprecated. Use "%s" instead.',
2625
self::class,
2726
parent::class,

src/Command/Proxy/RunSqlDoctrineCommand.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy;
44

55
use Doctrine\DBAL\Tools\Console\Command\RunSqlCommand;
6+
use Doctrine\Deprecations\Deprecation;
67
use Symfony\Component\Console\Input\InputInterface;
78
use Symfony\Component\Console\Output\OutputInterface;
89

9-
use function trigger_deprecation;
10-
1110
/**
1211
* Execute a SQL query and output the results.
1312
*
@@ -31,9 +30,9 @@ protected function configure(): void
3130

3231
protected function execute(InputInterface $input, OutputInterface $output): int
3332
{
34-
trigger_deprecation(
33+
Deprecation::trigger(
3534
'doctrine/doctrine-bundle',
36-
'2.2',
35+
'https://github.com/doctrine/DoctrineBundle/pull/1231',
3736
'The "%s" (doctrine:query:sql) is deprecated, use dbal:run-sql command instead.',
3837
self::class,
3938
);

src/ConnectionFactory.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
use function class_exists;
2525
use function is_subclass_of;
2626
use function method_exists;
27-
use function trigger_deprecation;
2827

2928
use const PHP_EOL;
3029

@@ -79,7 +78,11 @@ public function createConnection(array $params, Configuration|null $config = nul
7978
$overriddenOptions = [];
8079
/** @phpstan-ignore isset.offset (We should adjust when https://github.com/phpstan/phpstan/issues/12414 is fixed) */
8180
if (isset($params['connection_override_options'])) {
82-
trigger_deprecation('doctrine/doctrine-bundle', '2.4', 'The "connection_override_options" connection parameter is deprecated');
81+
Deprecation::trigger(
82+
'doctrine/doctrine-bundle',
83+
'https://github.com/doctrine/DoctrineBundle/pull/1342',
84+
'The "connection_override_options" connection parameter is deprecated',
85+
);
8386
$overriddenOptions = $params['connection_override_options'];
8487
unset($params['connection_override_options']);
8588
}

src/DependencyInjection/Configuration.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Doctrine\Bundle\DoctrineBundle\DependencyInjection;
44

55
use Doctrine\DBAL\Schema\LegacySchemaManagerFactory;
6+
use Doctrine\Deprecations\Deprecation;
67
use Doctrine\ORM\EntityManager;
78
use Doctrine\ORM\EntityRepository;
89
use Doctrine\ORM\Mapping\ClassMetadata;
@@ -40,7 +41,6 @@
4041
use function strpos;
4142
use function strtoupper;
4243
use function substr;
43-
use function trigger_deprecation;
4444

4545
/**
4646
* This class contains the configuration information for the bundle
@@ -292,9 +292,9 @@ private function configureDbalDriverNode(ArrayNodeDefinition $node): void
292292

293293
if ($urlConflictingValues) {
294294
$tail = count($urlConflictingValues) > 1 ? sprintf('or "%s" options', array_pop($urlConflictingValues)) : 'option';
295-
trigger_deprecation(
295+
Deprecation::trigger(
296296
'doctrine/doctrine-bundle',
297-
'2.4',
297+
'https://github.com/doctrine/DoctrineBundle/pull/1342',
298298
'Setting the "doctrine.dbal.%s" %s while the "url" one is defined is deprecated',
299299
implode('", "', $urlConflictingValues),
300300
$tail,

src/DependencyInjection/DoctrineExtension.php

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Doctrine\DBAL\Connections\PrimaryReadReplicaConnection;
1919
use Doctrine\DBAL\Driver\Middleware as MiddlewareInterface;
2020
use Doctrine\DBAL\Schema\LegacySchemaManagerFactory;
21+
use Doctrine\Deprecations\Deprecation;
2122
use Doctrine\ORM\Configuration as ORMConfiguration;
2223
use Doctrine\ORM\EntityManagerInterface;
2324
use Doctrine\ORM\Events;
@@ -81,7 +82,6 @@
8182
use function reset;
8283
use function sprintf;
8384
use function str_replace;
84-
use function trigger_deprecation;
8585

8686
use const PHP_VERSION_ID;
8787

@@ -506,12 +506,20 @@ protected function ormLoad(array $config, ContainerBuilder $container)
506506
}
507507

508508
if ($config['controller_resolver']['auto_mapping'] === null) {
509-
trigger_deprecation('doctrine/doctrine-bundle', '2.12', 'The default value of "doctrine.orm.controller_resolver.auto_mapping" will be changed from `true` to `false`. Explicitly configure `true` to keep existing behaviour.');
509+
Deprecation::trigger(
510+
'doctrine/doctrine-bundle',
511+
'https://github.com/doctrine/DoctrineBundle/pull/1762',
512+
'The default value of "doctrine.orm.controller_resolver.auto_mapping" will be changed from `true` to `false`. Explicitly configure `true` to keep existing behaviour.',
513+
);
510514
$config['controller_resolver']['auto_mapping'] = true;
511515
}
512516

513517
if ($config['controller_resolver']['auto_mapping'] === true) {
514-
trigger_deprecation('doctrine/doctrine-bundle', '2.13', 'Enabling the controller resolver automapping feature has been deprecated. Symfony Mapped Route Parameters should be used as replacement.');
518+
Deprecation::trigger(
519+
'doctrine/doctrine-bundle',
520+
'https://github.com/doctrine/DoctrineBundle/pull/1804',
521+
'Enabling the controller resolver automapping feature has been deprecated. Symfony Mapped Route Parameters should be used as replacement.',
522+
);
515523
}
516524

517525
if (! $config['controller_resolver']['auto_mapping']) {
@@ -577,7 +585,11 @@ protected function ormLoad(array $config, ContainerBuilder $container)
577585
'Lazy ghost objects cannot be disabled for ORM 3.',
578586
);
579587
} else {
580-
trigger_deprecation('doctrine/doctrine-bundle', '2.11', 'Not setting "doctrine.orm.enable_lazy_ghost_objects" to true is deprecated.');
588+
Deprecation::trigger(
589+
'doctrine/doctrine-bundle',
590+
'https://github.com/doctrine/DoctrineBundle/pull/1568',
591+
'Not setting "doctrine.orm.enable_lazy_ghost_objects" to true is deprecated.',
592+
);
581593
}
582594

583595
if ($config['enable_native_lazy_objects'] ?? false) {
@@ -595,7 +607,11 @@ protected function ormLoad(array $config, ContainerBuilder $container)
595607
$container->removeDefinition('doctrine.orm.proxy_cache_warmer');
596608
} elseif (! class_exists(AnnotationDriver::class) && PHP_VERSION_ID >= 80400) {
597609
// Only emit the deprecation notice for ORM 3 and PHP 8.4+ users
598-
trigger_deprecation('doctrine/doctrine-bundle', '2.16', 'Not setting "doctrine.orm.enable_native_lazy_objects" to true is deprecated.');
610+
Deprecation::trigger(
611+
'doctrine/doctrine-bundle',
612+
'https://github.com/doctrine/DoctrineBundle/pull/1905',
613+
'Not setting "doctrine.orm.enable_native_lazy_objects" to true is deprecated.',
614+
);
599615
}
600616

601617
$options = ['auto_generate_proxy_classes', 'enable_lazy_ghost_objects', 'enable_native_lazy_objects', 'proxy_dir', 'proxy_namespace'];

src/Repository/ContainerRepositoryFactory.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Doctrine\Bundle\DoctrineBundle\Repository;
44

55
use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\ServiceRepositoryCompilerPass;
6+
use Doctrine\Deprecations\Deprecation;
67
use Doctrine\ORM\EntityManagerInterface;
78
use Doctrine\ORM\EntityRepository;
89
use Doctrine\ORM\Mapping\ClassMetadata;
@@ -16,7 +17,6 @@
1617
use function is_a;
1718
use function spl_object_hash;
1819
use function sprintf;
19-
use function trigger_deprecation;
2020

2121
/**
2222
* Fetches repositories from the container or falls back to normal creation.
@@ -62,7 +62,14 @@ private function doGetRepository(EntityManagerInterface $entityManager, string $
6262
}
6363

6464
if (! $repository instanceof EntityRepository) {
65-
trigger_deprecation('doctrine/doctrine-bundle', '2.11', 'The service "%s" of type "%s" should extend "%s", not doing so is deprecated.', $repositoryServiceId, get_debug_type($repository), EntityRepository::class);
65+
Deprecation::trigger(
66+
'doctrine/doctrine-bundle',
67+
'https://github.com/doctrine/DoctrineBundle/pull/1722',
68+
'The service "%s" of type "%s" should extend "%s", not doing so is deprecated.',
69+
$repositoryServiceId,
70+
get_debug_type($repository),
71+
EntityRepository::class,
72+
);
6673
}
6774

6875
/** @phpstan-var ObjectRepository<T> */

src/Twig/DoctrineExtension.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Doctrine\Bundle\DoctrineBundle\Twig;
44

5+
use Doctrine\Deprecations\Deprecation;
56
use Doctrine\SqlFormatter\HtmlHighlighter;
67
use Doctrine\SqlFormatter\NullHighlighter;
78
use Doctrine\SqlFormatter\SqlFormatter;
@@ -25,7 +26,6 @@
2526
use function sprintf;
2627
use function strtoupper;
2728
use function substr;
28-
use function trigger_deprecation;
2929

3030
/**
3131
* This class contains the needed functions in order to do the query highlighting
@@ -154,9 +154,9 @@ static function ($matches) use ($parameters, &$i) {
154154
*/
155155
public function formatQuery($sql, $highlightOnly = false)
156156
{
157-
trigger_deprecation(
157+
Deprecation::trigger(
158158
'doctrine/doctrine-bundle',
159-
'2.1',
159+
'https://github.com/doctrine/DoctrineBundle/pull/1056',
160160
'The "%s()" method is deprecated and will be removed in doctrine-bundle 3.0.',
161161
__METHOD__,
162162
);

0 commit comments

Comments
 (0)