Skip to content

Commit c6ed532

Browse files
committed
Drop deprecated features
1 parent 1d2ec66 commit c6ed532

File tree

13 files changed

+7
-399
lines changed

13 files changed

+7
-399
lines changed

src/Configuration.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -374,17 +374,6 @@ public function getDefaultCommitOptions(): array
374374
/** @phpstan-param CommitOptions $defaultCommitOptions */
375375
public function setDefaultCommitOptions(array $defaultCommitOptions): void
376376
{
377-
foreach (UnitOfWork::DEPRECATED_WRITE_OPTIONS as $deprecatedOption) {
378-
if (array_key_exists($deprecatedOption, $defaultCommitOptions)) {
379-
trigger_deprecation(
380-
'doctrine/mongodb-odm',
381-
'2.6',
382-
'The "%s" commit option used in the configuration is deprecated.',
383-
$deprecatedOption,
384-
);
385-
}
386-
}
387-
388377
$this->attributes['defaultCommitOptions'] = $defaultCommitOptions;
389378
}
390379

src/Mapping/Annotations/EmbeddedDocument.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,4 @@
1212
#[Attribute(Attribute::TARGET_CLASS)]
1313
final class EmbeddedDocument extends AbstractDocument
1414
{
15-
/** @var Index[] */
16-
public $indexes;
17-
18-
/** @param Index[] $indexes */
19-
public function __construct(array $indexes = [])
20-
{
21-
$this->indexes = $indexes;
22-
}
2315
}

src/Mapping/Annotations/File.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ final class File extends AbstractDocument
2121
/** @var string|null */
2222
public $repositoryClass;
2323

24-
/** @var Index[] */
25-
public $indexes;
26-
2724
/** @var bool bool */
2825
public $readOnly;
2926

@@ -34,14 +31,12 @@ final class File extends AbstractDocument
3431
public $chunkSizeBytes;
3532

3633
/**
37-
* @param Index[] $indexes
3834
* @param string|int|null $writeConcern
3935
*/
4036
public function __construct(
4137
?string $db = null,
4238
?string $bucketName = null,
4339
?string $repositoryClass = null,
44-
array $indexes = [],
4540
bool $readOnly = false,
4641
?string $shardKey = null,
4742
public $writeConcern = null,
@@ -50,7 +45,6 @@ public function __construct(
5045
$this->db = $db;
5146
$this->bucketName = $bucketName;
5247
$this->repositoryClass = $repositoryClass;
53-
$this->indexes = $indexes;
5448
$this->readOnly = $readOnly;
5549
$this->shardKey = $shardKey;
5650
$this->chunkSizeBytes = $chunkSizeBytes;

src/Mapping/ClassMetadata.php

Lines changed: 1 addition & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -609,15 +609,6 @@ final class ClassMetadata implements BaseClassMetadata
609609
*/
610610
public private(set) array $subClasses = [];
611611

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-
621612
/** @var array<string, PropertyAccessors\PropertyAccessor> */
622613
public private(set) array $propertyAccessors = [];
623614

@@ -819,7 +810,6 @@ public function __construct(string $documentName)
819810
$this->rootDocumentName = $documentName;
820811
$this->reflectionService = new RuntimeReflectionService();
821812
$this->reflClass = new ReflectionClass($documentName);
822-
$this->reflFields = new LegacyReflectionFields($this, $this->reflectionService);
823813
$this->setCollection($this->reflClass->getShortName());
824814
$this->instantiator = new Instantiator();
825815
}
@@ -1424,29 +1414,6 @@ public function isChangeTrackingDeferredImplicit(): bool
14241414
return $this->changeTrackingPolicy === self::CHANGETRACKING_DEFERRED_IMPLICIT;
14251415
}
14261416

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-
14501417
/**
14511418
* Gets the ReflectionProperties of the mapped class.
14521419
*
@@ -1457,16 +1424,6 @@ public function getPropertyAccessors(): array
14571424
return $this->propertyAccessors;
14581425
}
14591426

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-
14701427
public function getPropertyAccessor(string $name): PropertyAccessor|null
14711428
{
14721429
return $this->propertyAccessors[$name] ?? null;
@@ -2407,13 +2364,7 @@ public function mapField(array $mapping): array
24072364
}
24082365

24092366
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-
);
2367+
throw MappingException::targetDocumentCanNotBeCombinedWithDiscriminatorMap($this->name, $mapping['fieldName']);
24172368
}
24182369

24192370
if (isset($mapping['reference']) && $mapping['type'] === self::ONE) {
@@ -2535,7 +2486,6 @@ public function mapField(array $mapping): array
25352486
*
25362487
* Parts that are also NOT serialized because they cannot be properly unserialized:
25372488
* - reflClass (ReflectionClass)
2538-
* - reflFields (ReflectionProperty array)
25392489
* - propertyAccessors (ReflectionProperty array)
25402490
*
25412491
* @return array The names of all the fields that should be serialized.
@@ -2646,7 +2596,6 @@ public function __wakeup(): void
26462596
$this->reflClass = new ReflectionClass($this->name);
26472597
$this->instantiator = new Instantiator();
26482598
$this->reflectionService = new RuntimeReflectionService();
2649-
$this->reflFields = new LegacyReflectionFields($this, $this->reflectionService);
26502599

26512600
foreach ($this->fieldMappings as $field => $mapping) {
26522601
$accessor = PropertyAccessorFactory::createPropertyAccessor($mapping['declared'] ?? $this->name, $field);

src/Mapping/ClassMetadataFactory.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -197,16 +197,6 @@ protected function doLoadMetadata(ClassMetadataInterface $class, ?ClassMetadataI
197197
Events::loadClassMetadata,
198198
new LoadClassMetadataEventArgs($class, $this->dm),
199199
);
200-
201-
// phpcs:ignore SlevomatCodingStandard.ControlStructures.EarlyExit.EarlyExitNotUsed
202-
if ($class->isChangeTrackingNotify()) {
203-
trigger_deprecation(
204-
'doctrine/mongodb-odm',
205-
'2.4',
206-
'NOTIFY tracking policy used in class "%s" is deprecated. Please use DEFERRED_EXPLICIT instead.',
207-
$class->name,
208-
);
209-
}
210200
}
211201

212202
/**

src/Mapping/Driver/AttributeDriver.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -189,20 +189,6 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad
189189
$metadata->setWriteConcern($documentAttribute->writeConcern);
190190
}
191191

192-
if (isset($documentAttribute->indexes) && count($documentAttribute->indexes)) {
193-
trigger_deprecation(
194-
'doctrine/mongodb-odm',
195-
'2.2',
196-
'The "indexes" parameter in the "%s" attribute for class "%s" is deprecated. Specify all "@Index" and "@UniqueIndex" attributes on the class.',
197-
$documentAttribute::class,
198-
$className,
199-
);
200-
201-
foreach ($documentAttribute->indexes as $index) {
202-
$this->addIndex($metadata, $index);
203-
}
204-
}
205-
206192
if (! empty($documentAttribute->readOnly)) {
207193
$metadata->markReadOnly();
208194
}

src/Mapping/LegacyReflectionFields.php

Lines changed: 0 additions & 136 deletions
This file was deleted.

src/Mapping/MappingException.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,11 @@ public static function repositoryMethodCanNotBeCombinedWithSkipLimitAndSort(stri
232232
return new self(sprintf("'repositoryMethod' used on '%s' in class '%s' can not be combined with skip, limit or sort.", $fieldName, $className));
233233
}
234234

235+
public static function targetDocumentCanNotBeCombinedWithDiscriminatorMap(string $className, string $fieldName): self
236+
{
237+
return new self(sprintf("'targetDocument' used on '%s' in class '%s' can not be combined with 'discriminatorMap'.", $fieldName, $className));
238+
}
239+
235240
public static function xmlMappingFileInvalid(string $filename, string $errorDetails): self
236241
{
237242
return new self(sprintf("The mapping file %s is invalid: \n%s", $filename, $errorDetails));

src/PersistentCollection/PersistentCollectionTrait.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,6 @@ private function changed(): void
174174
}
175175

176176
$this->isDirty = true;
177-
178-
if (! $this->needsSchedulingForSynchronization() || $this->owner === null) {
179-
return;
180-
}
181-
182-
$this->uow->scheduleForSynchronization($this->owner);
183177
}
184178

185179
public function isDirty(): bool
@@ -739,15 +733,6 @@ private function isOrphanRemovalEnabled(): bool
739733
return isset($this->mapping['reference']) && $this->mapping['isOwningSide'] && $this->mapping['orphanRemoval'];
740734
}
741735

742-
/**
743-
* Checks whether collection owner needs to be scheduled for dirty change in case the collection is modified.
744-
*/
745-
private function needsSchedulingForSynchronization(): bool
746-
{
747-
return $this->owner && isset($this->dm) && ! empty($this->mapping['isOwningSide'])
748-
&& $this->dm->getClassMetadata(get_class($this->owner))->isChangeTrackingNotify();
749-
}
750-
751736
/**
752737
* @phpstan-param Closure(TKey, T):bool $p
753738
*

0 commit comments

Comments
 (0)