Skip to content

Commit 2b52637

Browse files
authored
Merge pull request #2089 from greg0ire/deprecs
Deprecate methods related to annotations and yaml
2 parents 05ae10f + ebcf378 commit 2b52637

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed

UPGRADE-2.18.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
UPGRADE FROM 2.17 to 2.18
2+
=========================
3+
4+
DoctrineOrmMappingsPass
5+
-----------------------
6+
7+
### The `DoctrineOrmMappingsPass::createYamlMappingDriver()` method is deprecated
8+
9+
This method is deprecated with no replacement planned and will be removed in
10+
DoctrineBundle 3.0.
11+
12+
### The `DoctrineOrmMappingsPass::createAnnotationMappingDriver()` method is deprecated
13+
14+
This method is deprecated with no replacement planned and will be removed in
15+
DoctrineBundle 3.0.

src/DependencyInjection/Compiler/DoctrineOrmMappingsPass.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler;
66

7+
use Doctrine\Deprecations\Deprecation;
78
use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
89
use Doctrine\ORM\Mapping\Driver\AttributeDriver;
910
use Doctrine\ORM\Mapping\Driver\XmlDriver;
@@ -76,6 +77,8 @@ public static function createXmlMappingDriver(array $namespaces, array $managerP
7677
}
7778

7879
/**
80+
* @deprecated no replacement planned
81+
*
7982
* @param string[] $namespaces Hashmap of directory path to namespace
8083
* @param string[] $managerParameters List of parameters that could which object manager name
8184
* your bundle uses. This compiler pass will automatically
@@ -90,6 +93,12 @@ public static function createXmlMappingDriver(array $namespaces, array $managerP
9093
*/
9194
public static function createYamlMappingDriver(array $namespaces, array $managerParameters = [], $enabledParameter = false, array $aliasMap = [])
9295
{
96+
Deprecation::trigger(
97+
'doctrine/doctrine-bundle',
98+
'https://github.com/doctrine/DoctrineBundle/pull/2088',
99+
'The "%s()" method is deprecated and will be removed in DoctrineBundle 3.0.',
100+
__METHOD__,
101+
);
93102
$locator = new Definition(SymfonyFileLocator::class, [$namespaces, '.orm.yml']);
94103
/* @phpstan-ignore class.notFound */
95104
$driver = new Definition(YamlDriver::class, [$locator]);
@@ -119,6 +128,8 @@ public static function createPhpMappingDriver(array $namespaces, array $managerP
119128
}
120129

121130
/**
131+
* @deprecated no replacement planned
132+
*
122133
* @param string[] $namespaces List of namespaces that are handled with annotation mapping
123134
* @param string[] $directories List of directories to look for annotated classes
124135
* @param string[] $managerParameters List of parameters that could which object manager name
@@ -135,6 +146,13 @@ public static function createPhpMappingDriver(array $namespaces, array $managerP
135146
*/
136147
public static function createAnnotationMappingDriver(array $namespaces, array $directories, array $managerParameters = [], $enabledParameter = false, array $aliasMap = [], bool $reportFieldsWhereDeclared = false)
137148
{
149+
Deprecation::trigger(
150+
'doctrine/doctrine-bundle',
151+
'https://github.com/doctrine/DoctrineBundle/pull/2088',
152+
'The "%s()" method is deprecated and will be removed in DoctrineBundle 3.0.',
153+
__METHOD__,
154+
);
155+
138156
$reader = new Reference('annotation_reader');
139157
/* @phpstan-ignore class.notFound */
140158
$driver = new Definition(AnnotationDriver::class, [$reader, $directories, $reportFieldsWhereDeclared]);
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Doctrine\Bundle\DoctrineBundle\Tests\DependencyInjection\Compiler;
6+
7+
use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass;
8+
use Doctrine\Bundle\DoctrineBundle\Tests\TestCase;
9+
use Doctrine\Deprecations\PHPUnit\VerifyDeprecations;
10+
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
11+
12+
class DoctrineOrmMappingsPassTest extends TestCase
13+
{
14+
use VerifyDeprecations;
15+
16+
#[IgnoreDeprecations]
17+
public function testCreateYamlMappingDriverIsDeprecated(): void
18+
{
19+
$this->expectDeprecationWithIdentifier('https://github.com/doctrine/DoctrineBundle/pull/2088');
20+
21+
DoctrineOrmMappingsPass::createYamlMappingDriver(['/path/to/namespace' => 'App\\Entity']);
22+
}
23+
24+
#[IgnoreDeprecations]
25+
public function testCreateAnnotationMappingDriverIsDeprecated(): void
26+
{
27+
$this->expectDeprecationWithIdentifier('https://github.com/doctrine/DoctrineBundle/pull/2088');
28+
29+
DoctrineOrmMappingsPass::createAnnotationMappingDriver(
30+
['App\\Entity'],
31+
['/path/to/entities'],
32+
);
33+
}
34+
}

0 commit comments

Comments
 (0)