Skip to content

Commit 9ae4c98

Browse files
committed
Drop deprecated features
1 parent 1d2ec66 commit 9ae4c98

14 files changed

+8
-473
lines changed

src/Configuration.php

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,8 @@
2828

2929
use function array_diff_key;
3030
use function array_intersect_key;
31-
use function array_key_exists;
3231
use function interface_exists;
3332
use function is_string;
34-
use function trigger_deprecation;
35-
use function trim;
3633

3734
/**
3835
* Configuration class for the DocumentManager. When setting up your DocumentManager
@@ -88,7 +85,6 @@ class Configuration
8885
* defaultDocumentRepositoryClassName?: class-string<ObjectRepository<object>>,
8986
* defaultGridFSRepositoryClassName?: class-string<GridFSRepository<object>>,
9087
* defaultDB?: string,
91-
* documentNamespaces?: array<string, string>,
9288
* filters?: array<string, array{
9389
* class: class-string,
9490
* parameters: array<string, mixed>
@@ -156,55 +152,6 @@ public function getClientEncryptionOptions(): array
156152
]);
157153
}
158154

159-
/**
160-
* Adds a namespace under a certain alias.
161-
*/
162-
public function addDocumentNamespace(string $alias, string $namespace): void
163-
{
164-
$this->attributes['documentNamespaces'][$alias] = $namespace;
165-
}
166-
167-
/**
168-
* Resolves a registered namespace alias to the full namespace.
169-
*
170-
* @throws MongoDBException
171-
*/
172-
public function getDocumentNamespace(string $documentNamespaceAlias): string
173-
{
174-
trigger_deprecation(
175-
'doctrine/mongodb-odm',
176-
'2.3',
177-
'Document short namespace aliases such as "%s" are deprecated, use ::class constant instead.',
178-
$documentNamespaceAlias,
179-
);
180-
181-
if (! isset($this->attributes['documentNamespaces'][$documentNamespaceAlias])) {
182-
throw MongoDBException::unknownDocumentNamespace($documentNamespaceAlias);
183-
}
184-
185-
return trim($this->attributes['documentNamespaces'][$documentNamespaceAlias], '\\');
186-
}
187-
188-
/**
189-
* Retrieves the list of registered document namespace aliases.
190-
*
191-
* @return array<string, string>
192-
*/
193-
public function getDocumentNamespaces(): array
194-
{
195-
return $this->attributes['documentNamespaces'];
196-
}
197-
198-
/**
199-
* Set the document alias map
200-
*
201-
* @param array<string, string> $documentNamespaces
202-
*/
203-
public function setDocumentNamespaces(array $documentNamespaces): void
204-
{
205-
$this->attributes['documentNamespaces'] = $documentNamespaces;
206-
}
207-
208155
/**
209156
* Sets the cache driver implementation that is used for metadata caching.
210157
*
@@ -374,17 +321,6 @@ public function getDefaultCommitOptions(): array
374321
/** @phpstan-param CommitOptions $defaultCommitOptions */
375322
public function setDefaultCommitOptions(array $defaultCommitOptions): void
376323
{
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-
388324
$this->attributes['defaultCommitOptions'] = $defaultCommitOptions;
389325
}
390326

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: 1 addition & 9 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

@@ -33,15 +30,11 @@ final class File extends AbstractDocument
3330
/** @var int|null */
3431
public $chunkSizeBytes;
3532

36-
/**
37-
* @param Index[] $indexes
38-
* @param string|int|null $writeConcern
39-
*/
33+
/** @param string|int|null $writeConcern */
4034
public function __construct(
4135
?string $db = null,
4236
?string $bucketName = null,
4337
?string $repositoryClass = null,
44-
array $indexes = [],
4538
bool $readOnly = false,
4639
?string $shardKey = null,
4740
public $writeConcern = null,
@@ -50,7 +43,6 @@ public function __construct(
5043
$this->db = $db;
5144
$this->bucketName = $bucketName;
5245
$this->repositoryClass = $repositoryClass;
53-
$this->indexes = $indexes;
5446
$this->readOnly = $readOnly;
5547
$this->shardKey = $shardKey;
5648
$this->chunkSizeBytes = $chunkSizeBytes;

src/Mapping/ClassMetadata.php

Lines changed: 1 addition & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
use Doctrine\ODM\MongoDB\Types\Versionable;
2424
use Doctrine\ODM\MongoDB\Utility\CollectionHelper;
2525
use Doctrine\Persistence\Mapping\ClassMetadata as BaseClassMetadata;
26-
use Doctrine\Persistence\Mapping\ReflectionService;
27-
use Doctrine\Persistence\Mapping\RuntimeReflectionService;
2826
use InvalidArgumentException;
2927
use LogicException;
3028
use MongoDB\BSON\Decimal128;
@@ -33,7 +31,6 @@
3331
use ReflectionClass;
3432
use ReflectionEnum;
3533
use ReflectionNamedType;
36-
use ReflectionProperty;
3734
use Symfony\Component\Uid\UuidV1;
3835
use Symfony\Component\Uid\UuidV4;
3936
use Symfony\Component\Uid\UuidV7;
@@ -609,15 +606,6 @@ final class ClassMetadata implements BaseClassMetadata
609606
*/
610607
public private(set) array $subClasses = [];
611608

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

@@ -802,8 +790,6 @@ final class ClassMetadata implements BaseClassMetadata
802790

803791
private InstantiatorInterface $instantiator;
804792

805-
private ReflectionService $reflectionService;
806-
807793
/** @var class-string|null */
808794
private ?string $rootClass;
809795

@@ -817,9 +803,7 @@ public function __construct(string $documentName)
817803
{
818804
$this->name = $documentName;
819805
$this->rootDocumentName = $documentName;
820-
$this->reflectionService = new RuntimeReflectionService();
821806
$this->reflClass = new ReflectionClass($documentName);
822-
$this->reflFields = new LegacyReflectionFields($this, $this->reflectionService);
823807
$this->setCollection($this->reflClass->getShortName());
824808
$this->instantiator = new Instantiator();
825809
}
@@ -1424,29 +1408,6 @@ public function isChangeTrackingDeferredImplicit(): bool
14241408
return $this->changeTrackingPolicy === self::CHANGETRACKING_DEFERRED_IMPLICIT;
14251409
}
14261410

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-
14501411
/**
14511412
* Gets the ReflectionProperties of the mapped class.
14521413
*
@@ -1457,16 +1418,6 @@ public function getPropertyAccessors(): array
14571418
return $this->propertyAccessors;
14581419
}
14591420

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-
14701421
public function getPropertyAccessor(string $name): PropertyAccessor|null
14711422
{
14721423
return $this->propertyAccessors[$name] ?? null;
@@ -2407,13 +2358,7 @@ public function mapField(array $mapping): array
24072358
}
24082359

24092360
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-
);
2361+
throw MappingException::targetDocumentCanNotBeCombinedWithDiscriminatorMap($this->name, $mapping['fieldName']);
24172362
}
24182363

24192364
if (isset($mapping['reference']) && $mapping['type'] === self::ONE) {
@@ -2535,7 +2480,6 @@ public function mapField(array $mapping): array
25352480
*
25362481
* Parts that are also NOT serialized because they cannot be properly unserialized:
25372482
* - reflClass (ReflectionClass)
2538-
* - reflFields (ReflectionProperty array)
25392483
* - propertyAccessors (ReflectionProperty array)
25402484
*
25412485
* @return array The names of all the fields that should be serialized.
@@ -2645,8 +2589,6 @@ public function __wakeup(): void
26452589
// Restore ReflectionClass and properties
26462590
$this->reflClass = new ReflectionClass($this->name);
26472591
$this->instantiator = new Instantiator();
2648-
$this->reflectionService = new RuntimeReflectionService();
2649-
$this->reflFields = new LegacyReflectionFields($this, $this->reflectionService);
26502592

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

src/Mapping/ClassMetadataFactory.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
use function get_class_methods;
2828
use function in_array;
2929
use function interface_exists;
30-
use function trigger_deprecation;
3130
use function ucfirst;
3231

3332
/**
@@ -197,16 +196,6 @@ protected function doLoadMetadata(ClassMetadataInterface $class, ?ClassMetadataI
197196
Events::loadClassMetadata,
198197
new LoadClassMetadataEventArgs($class, $this->dm),
199198
);
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-
}
210199
}
211200

212201
/**

src/Mapping/Driver/AttributeDriver.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@
2626
use function assert;
2727
use function class_exists;
2828
use function constant;
29-
use function count;
3029
use function is_array;
31-
use function trigger_deprecation;
3230

3331
/**
3432
* The AttributeDriver reads the mapping metadata from attributes.
@@ -189,20 +187,6 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad
189187
$metadata->setWriteConcern($documentAttribute->writeConcern);
190188
}
191189

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-
206190
if (! empty($documentAttribute->readOnly)) {
207191
$metadata->markReadOnly();
208192
}

0 commit comments

Comments
 (0)