Skip to content

Commit 80989af

Browse files
committed
Revert deprecation on annotation driver
1 parent c66820b commit 80989af

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

lib/Doctrine/ODM/MongoDB/Mapping/Driver/AnnotationDriver.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@
1313
*/
1414
class AnnotationDriver extends AttributeDriver
1515
{
16+
/**
17+
* The annotation reader.
18+
*
19+
* @internal this property will be private in 3.0
20+
*
21+
* @var Reader
22+
*/
23+
protected $reader;
24+
1625
/**
1726
* Initializes a new AnnotationDriver that uses the given AnnotationReader for reading
1827
* docblock annotations.
@@ -22,7 +31,9 @@ class AnnotationDriver extends AttributeDriver
2231
*/
2332
public function __construct($reader, $paths = null)
2433
{
25-
parent::__construct($paths, $reader);
34+
parent::__construct($paths);
35+
36+
$this->reader = $reader;
2637
}
2738

2839
/**

lib/Doctrine/ODM/MongoDB/Mapping/Driver/AttributeDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class AttributeDriver implements MappingDriver
4949
/** @param string|string[]|ClassLocator|null $paths */
5050
public function __construct($paths = null, ?Reader $reader = null)
5151
{
52-
if ($reader !== null && ! $this instanceof AnnotationDriver) {
52+
if ($reader !== null) {
5353
trigger_deprecation(
5454
'doctrine/mongodb-odm',
5555
'2.7',

tests/Doctrine/ODM/MongoDB/Tests/Mapping/AbstractAnnotationDriverTestCase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function testFieldInheritance(): void
7575
public function testLoadMetadataForNonDocumentThrowsException(): void
7676
{
7777
$cm = new ClassMetadata('stdClass');
78-
$annotationDriver = AnnotationDriver::create();
78+
$annotationDriver = static::loadDriver();
7979

8080
$this->expectException(MappingException::class);
8181
$annotationDriver->loadMetadataForClass('stdClass', $cm);
@@ -85,7 +85,7 @@ public function testLoadMetadataForNonDocumentThrowsException(): void
8585
public function testColumnWithMissingTypeDefaultsToString(): void
8686
{
8787
$cm = new ClassMetadata(ColumnWithoutType::class);
88-
$annotationDriver = AnnotationDriver::create();
88+
$annotationDriver = static::loadDriver();
8989

9090
$annotationDriver->loadMetadataForClass(stdClass::class, $cm);
9191
self::assertEquals('id', $cm->fieldMappings['id']['type']);

tests/Doctrine/ODM/MongoDB/Tests/Tools/Console/Command/Schema/UpdateCommandTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44

55
namespace Doctrine\ODM\MongoDB\Tests\Tools\Console\Command\Schema;
66

7-
use Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver;
7+
use Doctrine\ODM\MongoDB\Mapping\Driver\AttributeDriver;
88
use Doctrine\ODM\MongoDB\Tests\Tools\Console\Command\AbstractCommandTestCase;
99
use Doctrine\ODM\MongoDB\Tools\Console\Command\Schema\UpdateCommand;
1010
use Doctrine\Persistence\Mapping\Driver\ClassNames;
11+
use Doctrine\Persistence\Mapping\Driver\MappingDriver;
1112
use Documents\Ecommerce;
1213
use Documents\SchemaValidated;
1314
use Symfony\Component\Console\Command\Command;
@@ -88,7 +89,7 @@ public function testDisabledValidatorsProcessing(): void
8889
self::assertStringNotContainsString('Updated validation for all classes', $output);
8990
}
9091

91-
private function createDriver(): AnnotationDriver
92+
private function createDriver(): MappingDriver
9293
{
9394
$paths = [__DIR__ . '/../../../../../../../../Documents/Ecommerce'];
9495
// Available in Doctrine Persistence 4.1+
@@ -104,6 +105,6 @@ private function createDriver(): AnnotationDriver
104105
]);
105106
}
106107

107-
return AnnotationDriver::create($paths);
108+
return AttributeDriver::create($paths);
108109
}
109110
}

0 commit comments

Comments
 (0)