2323use Doctrine \ODM \MongoDB \Types \Versionable ;
2424use Doctrine \ODM \MongoDB \Utility \CollectionHelper ;
2525use Doctrine \Persistence \Mapping \ClassMetadata as BaseClassMetadata ;
26- use Doctrine \Persistence \Mapping \ReflectionService ;
27- use Doctrine \Persistence \Mapping \RuntimeReflectionService ;
2826use InvalidArgumentException ;
2927use LogicException ;
3028use MongoDB \BSON \Decimal128 ;
3331use ReflectionClass ;
3432use ReflectionEnum ;
3533use ReflectionNamedType ;
36- use ReflectionProperty ;
3734use Symfony \Component \Uid \UuidV1 ;
3835use Symfony \Component \Uid \UuidV4 ;
3936use Symfony \Component \Uid \UuidV7 ;
5956use function sprintf ;
6057use function strtolower ;
6158use function strtoupper ;
62- use function trigger_deprecation ;
6359
6460/**
6561 * A <tt>ClassMetadata</tt> instance holds all the object-document mapping metadata
@@ -436,15 +432,6 @@ final class ClassMetadata implements BaseClassMetadata
436432 */
437433 public const CHANGETRACKING_DEFERRED_EXPLICIT = 2 ;
438434
439- /**
440- * NOTIFY means that Doctrine relies on the entities sending out notifications
441- * when their properties change. Such entity classes must implement
442- * the <tt>NotifyPropertyChanged</tt> interface.
443- *
444- * @deprecated
445- */
446- public const CHANGETRACKING_NOTIFY = 3 ;
447-
448435 /**
449436 * SET means that fields will be written to the database using a $set operator
450437 */
@@ -609,15 +596,6 @@ final class ClassMetadata implements BaseClassMetadata
609596 */
610597 public private(set) array $ subClasses = [];
611598
612- /**
613- * The ReflectionProperty instances of the mapped class.
614- *
615- * @deprecated Since 2.13, use $propertyAccessors instead.
616- *
617- * @var LegacyReflectionFields|array<ReflectionProperty>
618- */
619- public private(set) LegacyReflectionFields |array $ reflFields = [];
620-
621599 /** @var array<string, PropertyAccessors\PropertyAccessor> */
622600 public private(set) array $ propertyAccessors = [];
623601
@@ -802,8 +780,6 @@ final class ClassMetadata implements BaseClassMetadata
802780
803781 private InstantiatorInterface $ instantiator ;
804782
805- private ReflectionService $ reflectionService ;
806-
807783 /** @var class-string|null */
808784 private ?string $ rootClass ;
809785
@@ -815,11 +791,9 @@ final class ClassMetadata implements BaseClassMetadata
815791 */
816792 public function __construct (string $ documentName )
817793 {
818- $ this ->name = $ documentName ;
819- $ this ->rootDocumentName = $ documentName ;
820- $ this ->reflectionService = new RuntimeReflectionService ();
821- $ this ->reflClass = new ReflectionClass ($ documentName );
822- $ this ->reflFields = new LegacyReflectionFields ($ this , $ this ->reflectionService );
794+ $ this ->name = $ documentName ;
795+ $ this ->rootDocumentName = $ documentName ;
796+ $ this ->reflClass = new ReflectionClass ($ documentName );
823797 $ this ->setCollection ($ this ->reflClass ->getShortName ());
824798 $ this ->instantiator = new Instantiator ();
825799 }
@@ -1056,12 +1030,10 @@ public function setAlsoLoadMethods(array $methods): void
10561030 * are only used to discern the hydration class and are not mapped to class
10571031 * properties.
10581032 *
1059- * @param array{name?: string, fieldName?: string}|string|null $discriminatorField
1060- *
10611033 * @throws MappingException If the discriminator field conflicts with the
10621034 * "name" attribute of a mapped field.
10631035 */
1064- public function setDiscriminatorField (array | string | null $ discriminatorField ): void
1036+ public function setDiscriminatorField (? string $ discriminatorField ): void
10651037 {
10661038 if ($ this ->isFile ) {
10671039 throw MappingException::discriminatorNotAllowedForGridFS ($ this ->name );
@@ -1073,16 +1045,6 @@ public function setDiscriminatorField(array|string|null $discriminatorField): vo
10731045 return ;
10741046 }
10751047
1076- // @todo: deprecate, document and remove this:
1077- // Handle array argument with name/fieldName keys for BC
1078- if (is_array ($ discriminatorField )) {
1079- if (isset ($ discriminatorField ['name ' ])) {
1080- $ discriminatorField = $ discriminatorField ['name ' ];
1081- } elseif (isset ($ discriminatorField ['fieldName ' ])) {
1082- $ discriminatorField = $ discriminatorField ['fieldName ' ];
1083- }
1084- }
1085-
10861048 foreach ($ this ->fieldMappings as $ fieldMapping ) {
10871049 if ($ discriminatorField === $ fieldMapping ['name ' ]) {
10881050 throw MappingException::discriminatorFieldConflict ($ this ->name , $ discriminatorField );
@@ -1424,29 +1386,6 @@ public function isChangeTrackingDeferredImplicit(): bool
14241386 return $ this ->changeTrackingPolicy === self ::CHANGETRACKING_DEFERRED_IMPLICIT ;
14251387 }
14261388
1427- /**
1428- * Whether the change tracking policy of this class is "notify".
1429- *
1430- * @deprecated This method was deprecated in doctrine/mongodb-odm 2.4. Please use DEFERRED_EXPLICIT tracking
1431- * policy and isChangeTrackingDeferredImplicit method to detect it.
1432- */
1433- public function isChangeTrackingNotify (): bool
1434- {
1435- return $ this ->changeTrackingPolicy === self ::CHANGETRACKING_NOTIFY ;
1436- }
1437-
1438- /**
1439- * Gets the ReflectionProperties of the mapped class.
1440- *
1441- * @deprecated Since 2.13, use getPropertyAccessors() instead.
1442- *
1443- * @return array<ReflectionProperty>|LegacyReflectionFields
1444- */
1445- public function getReflectionProperties (): array |LegacyReflectionFields
1446- {
1447- return $ this ->reflFields ;
1448- }
1449-
14501389 /**
14511390 * Gets the ReflectionProperties of the mapped class.
14521391 *
@@ -1457,16 +1396,6 @@ public function getPropertyAccessors(): array
14571396 return $ this ->propertyAccessors ;
14581397 }
14591398
1460- /**
1461- * Gets a ReflectionProperty for a specific field of the mapped class.
1462- *
1463- * @deprecated Since 2.13, use getPropertyAccessor() instead.
1464- */
1465- public function getReflectionProperty (string $ name ): ReflectionProperty
1466- {
1467- return $ this ->reflFields [$ name ];
1468- }
1469-
14701399 public function getPropertyAccessor (string $ name ): PropertyAccessor |null
14711400 {
14721401 return $ this ->propertyAccessors [$ name ] ?? null ;
@@ -2407,13 +2336,7 @@ public function mapField(array $mapping): array
24072336 }
24082337
24092338 if (isset ($ mapping ['targetDocument ' ]) && isset ($ mapping ['discriminatorMap ' ])) {
2410- trigger_deprecation (
2411- 'doctrine/mongodb-odm ' ,
2412- '2.2 ' ,
2413- 'Mapping both "targetDocument" and "discriminatorMap" on field "%s" in class "%s" is deprecated. Only one of them can be used at a time ' ,
2414- $ mapping ['fieldName ' ],
2415- $ this ->name ,
2416- );
2339+ throw MappingException::targetDocumentCanNotBeCombinedWithDiscriminatorMap ($ this ->name , $ mapping ['fieldName ' ]);
24172340 }
24182341
24192342 if (isset ($ mapping ['reference ' ]) && $ mapping ['type ' ] === self ::ONE ) {
@@ -2535,7 +2458,6 @@ public function mapField(array $mapping): array
25352458 *
25362459 * Parts that are also NOT serialized because they cannot be properly unserialized:
25372460 * - reflClass (ReflectionClass)
2538- * - reflFields (ReflectionProperty array)
25392461 * - propertyAccessors (ReflectionProperty array)
25402462 *
25412463 * @return array The names of all the fields that should be serialized.
@@ -2643,10 +2565,8 @@ public function __sleep(): array
26432565 public function __wakeup (): void
26442566 {
26452567 // Restore ReflectionClass and properties
2646- $ this ->reflClass = new ReflectionClass ($ this ->name );
2647- $ this ->instantiator = new Instantiator ();
2648- $ this ->reflectionService = new RuntimeReflectionService ();
2649- $ this ->reflFields = new LegacyReflectionFields ($ this , $ this ->reflectionService );
2568+ $ this ->reflClass = new ReflectionClass ($ this ->name );
2569+ $ this ->instantiator = new Instantiator ();
26502570
26512571 foreach ($ this ->fieldMappings as $ field => $ mapping ) {
26522572 $ accessor = PropertyAccessorFactory::createPropertyAccessor ($ mapping ['declared ' ] ?? $ this ->name , $ field );
0 commit comments