Skip to content

Commit e78d072

Browse files
committed
Deprecate disable_type_comments
It is a no-op with doctrine/dbal 4.
1 parent d36d5f7 commit e78d072

3 files changed

Lines changed: 41 additions & 1 deletion

File tree

UPGRADE-2.17.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ Configuration
99
This option is a no-op when using `doctrine/orm` 3 and has been conditionally
1010
deprecated. You should stop using it as soon as you upgrade to Doctrine ORM 3.
1111

12+
### The `doctrine.dbal.connections.some_connection.disable_type_comments` configuration option is deprecated
13+
14+
This option is a no-op when using `doctrine/dbal` 4 and has been conditionally
15+
deprecated. You should stop using it as soon as you upgrade to Doctrine DBAL 4.
16+
1217
ConnectionFactory::createConnection() signature change
1318
------------------------------------------------------
1419

src/DependencyInjection/Configuration.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Doctrine\Bundle\DoctrineBundle\DependencyInjection;
66

7+
use Doctrine\DBAL\Connection;
78
use Doctrine\DBAL\Schema\LegacySchemaManagerFactory;
89
use Doctrine\Deprecations\Deprecation;
910
use Doctrine\ORM\EntityManager;
@@ -216,7 +217,20 @@ private function getDbalConnectionsNode(): ArrayNodeDefinition
216217
->defaultValue(true)
217218
->info('Enables collecting schema errors when profiling is enabled')
218219
->end()
219-
->booleanNode('disable_type_comments')->end()
220+
->booleanNode('disable_type_comments')
221+
->beforeNormalization()
222+
->ifTrue(static fn ($v): bool => isset($v) && ! method_exists(Connection::class, 'getEventManager'))
223+
->then(static function ($v) {
224+
Deprecation::trigger(
225+
'doctrine/doctrine-bundle',
226+
'https://github.com/doctrine/DoctrineBundle/pull/2048',
227+
'The "disable_type_comments" configuration key is deprecated when using DBAL 4 and will be removed in DoctrineBundle 3.0.',
228+
);
229+
230+
return $v;
231+
})
232+
->end()
233+
->end()
220234
->scalarNode('server_version')->end()
221235
->integerNode('idle_connection_ttl')->defaultValue(600)->end()
222236
->scalarNode('driver_class')->end()

tests/DependencyInjection/AbstractDoctrineExtensionTestCase.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,27 @@ public function testEnablingReportFieldsWhereDeclaredOnOrm2IsFine(): void
999999
$this->loadContainer('orm_report_fields');
10001000
}
10011001

1002+
#[IgnoreDeprecations]
1003+
public function testSettingDisableTypeCommentsWithDbal4IsDeprecated(): void
1004+
{
1005+
if (method_exists(Connection::class, 'getEventManager')) {
1006+
self::markTestSkipped('This test requires DBAL 4.');
1007+
}
1008+
1009+
$this->expectDeprecationWithIdentifier('https://github.com/doctrine/DoctrineBundle/pull/2048');
1010+
$this->loadContainer(fixture: 'dbal_disable_type_comments', withMinimalOrmConfig: false);
1011+
}
1012+
1013+
public function testSettingDisableTypeCommentsWithDbal3IsFine(): void
1014+
{
1015+
if (! method_exists(Connection::class, 'getEventManager')) {
1016+
self::markTestSkipped('This test requires DBAL 3.');
1017+
}
1018+
1019+
$this->expectNoDeprecationWithIdentifier('https://github.com/doctrine/DoctrineBundle/pull/2048');
1020+
$this->loadContainer(fixture: 'dbal_disable_type_comments', withMinimalOrmConfig: false);
1021+
}
1022+
10021023
public function testResolveTargetEntity(): void
10031024
{
10041025
if (! interface_exists(EntityManagerInterface::class)) {

0 commit comments

Comments
 (0)