Skip to content

Commit 41137dc

Browse files
committed
Deprecate AttributeDriver::$entityAnnotationClasses
1 parent 7d9c41e commit 41137dc

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

UPGRADE.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Upgrade to 2.14
22

3+
## Deprecated `AttributeDriver::$entityAnnotationClasses`
4+
5+
If you need to change the behavior of `AttributeDriver::isTransient()`,
6+
override that method instead.
7+
38
## Deprecated incomplete schema updates
49

510
Using `orm:schema-tool:update` without passing the `--complete` flag is

lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php

+20-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,16 @@ class AttributeDriver extends CompatibilityAnnotationDriver
3131
{
3232
use ColocatedMappingDriver;
3333

34-
/** @var array<class-string<MappingAttribute>, int> */
34+
private const ENTITY_ATTRIBUTE_CLASSES = [
35+
Mapping\Entity::class => 1,
36+
Mapping\MappedSuperclass::class => 2,
37+
];
38+
39+
/**
40+
* @deprecated override isTransient() instead of overriding it
41+
*
42+
* @var array<class-string<MappingAttribute>, int>
43+
*/
3544
protected $entityAnnotationClasses = [
3645
Mapping\Entity::class => 1,
3746
Mapping\MappedSuperclass::class => 2,
@@ -58,6 +67,15 @@ public function __construct(array $paths)
5867

5968
$this->reader = new AttributeReader();
6069
$this->addPaths($paths);
70+
71+
if ($this->entityAnnotationClasses !== self::ENTITY_ATTRIBUTE_CLASSES) {
72+
Deprecation::trigger(
73+
'doctrine/orm',
74+
'https://github.com/doctrine/orm/pull/10204',
75+
'Changing the value of %s::$entityAnnotationClasses is deprecated and will have no effect in Doctrine ORM 3.0.',
76+
self::class
77+
);
78+
}
6179
}
6280

6381
/**
@@ -88,7 +106,7 @@ public function isTransient($className)
88106

89107
foreach ($classAttributes as $a) {
90108
$attr = $a instanceof RepeatableAttributeCollection ? $a[0] : $a;
91-
if (isset($this->entityAnnotationClasses[get_class($attr)])) {
109+
if (isset($this->entityAttributeClasses[get_class($attr)])) {
92110
return false;
93111
}
94112
}

0 commit comments

Comments
 (0)