Skip to content

Commit 56ef43a

Browse files
committed
Deprecate AttributeDriver::$entityAnnotationClasses
1 parent 7d9c41e commit 56ef43a

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
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

+19-1
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
/**

psalm.xml

+1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
<DeprecatedProperty>
9393
<errorLevel type="suppress">
9494
<referencedProperty name="Doctrine\ORM\Cache\Region\DefaultRegion::$cache"/>
95+
<referencedProperty name="Doctrine\ORM\Mapping\Driver\AttributeDriver::$entityAnnotationClasses"/>
9596
</errorLevel>
9697
</DeprecatedProperty>
9798
<DocblockTypeContradiction>

0 commit comments

Comments
 (0)