Skip to content

Commit 12f0674

Browse files
committed
Deprecate AttributeDriver::$entityAnnotationClasses
1 parent 069206b commit 12f0674

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-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

+17-2
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,18 @@ class AttributeDriver extends CompatibilityAnnotationDriver
3131
{
3232
use ColocatedMappingDriver;
3333

34-
/** @var array<class-string<MappingAttribute>, int> */
35-
protected $entityAnnotationClasses = [
34+
private const ENTITY_ATTRIBUTE_CLASSES = [
3635
Mapping\Entity::class => 1,
3736
Mapping\MappedSuperclass::class => 2,
3837
];
3938

39+
/**
40+
* @deprecated override isTransient() instead of overriding this property
41+
*
42+
* @var array<class-string<MappingAttribute>, int>
43+
*/
44+
protected $entityAnnotationClasses = self::ENTITY_ATTRIBUTE_CLASSES;
45+
4046
/**
4147
* The attribute reader.
4248
*
@@ -58,6 +64,15 @@ public function __construct(array $paths)
5864

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

6378
/**

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)