Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 0 additions & 64 deletions src/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,8 @@

use function array_diff_key;
use function array_intersect_key;
use function array_key_exists;
use function interface_exists;
use function is_string;
use function trigger_deprecation;
use function trim;

/**
* Configuration class for the DocumentManager. When setting up your DocumentManager
Expand Down Expand Up @@ -88,7 +85,6 @@ class Configuration
* defaultDocumentRepositoryClassName?: class-string<ObjectRepository<object>>,
* defaultGridFSRepositoryClassName?: class-string<GridFSRepository<object>>,
* defaultDB?: string,
* documentNamespaces?: array<string, string>,
* filters?: array<string, array{
* class: class-string,
* parameters: array<string, mixed>
Expand Down Expand Up @@ -156,55 +152,6 @@ public function getClientEncryptionOptions(): array
]);
}

/**
* Adds a namespace under a certain alias.
*/
public function addDocumentNamespace(string $alias, string $namespace): void
{
$this->attributes['documentNamespaces'][$alias] = $namespace;
}

/**
* Resolves a registered namespace alias to the full namespace.
*
* @throws MongoDBException
*/
public function getDocumentNamespace(string $documentNamespaceAlias): string
{
trigger_deprecation(
'doctrine/mongodb-odm',
'2.3',
'Document short namespace aliases such as "%s" are deprecated, use ::class constant instead.',
$documentNamespaceAlias,
);

if (! isset($this->attributes['documentNamespaces'][$documentNamespaceAlias])) {
throw MongoDBException::unknownDocumentNamespace($documentNamespaceAlias);
}

return trim($this->attributes['documentNamespaces'][$documentNamespaceAlias], '\\');
}

/**
* Retrieves the list of registered document namespace aliases.
*
* @return array<string, string>
*/
public function getDocumentNamespaces(): array
{
return $this->attributes['documentNamespaces'];
}

/**
* Set the document alias map
*
* @param array<string, string> $documentNamespaces
*/
public function setDocumentNamespaces(array $documentNamespaces): void
{
$this->attributes['documentNamespaces'] = $documentNamespaces;
}

/**
* Sets the cache driver implementation that is used for metadata caching.
*
Expand Down Expand Up @@ -374,17 +321,6 @@ public function getDefaultCommitOptions(): array
/** @phpstan-param CommitOptions $defaultCommitOptions */
public function setDefaultCommitOptions(array $defaultCommitOptions): void
{
foreach (UnitOfWork::DEPRECATED_WRITE_OPTIONS as $deprecatedOption) {
if (array_key_exists($deprecatedOption, $defaultCommitOptions)) {
trigger_deprecation(
'doctrine/mongodb-odm',
'2.6',
'The "%s" commit option used in the configuration is deprecated.',
$deprecatedOption,
);
}
}

$this->attributes['defaultCommitOptions'] = $defaultCommitOptions;
}

Expand Down
8 changes: 0 additions & 8 deletions src/Mapping/Annotations/EmbeddedDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,4 @@
#[Attribute(Attribute::TARGET_CLASS)]
final class EmbeddedDocument extends AbstractDocument
{
/** @var Index[] */
public $indexes;

/** @param Index[] $indexes */
public function __construct(array $indexes = [])
{
$this->indexes = $indexes;
}
}
10 changes: 1 addition & 9 deletions src/Mapping/Annotations/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ final class File extends AbstractDocument
/** @var string|null */
public $repositoryClass;

/** @var Index[] */
public $indexes;

/** @var bool bool */
public $readOnly;

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

/**
* @param Index[] $indexes
* @param string|int|null $writeConcern
*/
/** @param string|int|null $writeConcern */
public function __construct(
?string $db = null,
?string $bucketName = null,
?string $repositoryClass = null,
array $indexes = [],
bool $readOnly = false,
?string $shardKey = null,
public $writeConcern = null,
Expand All @@ -50,7 +43,6 @@ public function __construct(
$this->db = $db;
$this->bucketName = $bucketName;
$this->repositoryClass = $repositoryClass;
$this->indexes = $indexes;
$this->readOnly = $readOnly;
$this->shardKey = $shardKey;
$this->chunkSizeBytes = $chunkSizeBytes;
Expand Down
94 changes: 7 additions & 87 deletions src/Mapping/ClassMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
use Doctrine\ODM\MongoDB\Types\Versionable;
use Doctrine\ODM\MongoDB\Utility\CollectionHelper;
use Doctrine\Persistence\Mapping\ClassMetadata as BaseClassMetadata;
use Doctrine\Persistence\Mapping\ReflectionService;
use Doctrine\Persistence\Mapping\RuntimeReflectionService;
use InvalidArgumentException;
use LogicException;
use MongoDB\BSON\Decimal128;
Expand All @@ -33,7 +31,6 @@
use ReflectionClass;
use ReflectionEnum;
use ReflectionNamedType;
use ReflectionProperty;
use Symfony\Component\Uid\UuidV1;
use Symfony\Component\Uid\UuidV4;
use Symfony\Component\Uid\UuidV7;
Expand All @@ -59,7 +56,6 @@
use function sprintf;
use function strtolower;
use function strtoupper;
use function trigger_deprecation;

/**
* A <tt>ClassMetadata</tt> instance holds all the object-document mapping metadata
Expand Down Expand Up @@ -436,15 +432,6 @@ final class ClassMetadata implements BaseClassMetadata
*/
public const CHANGETRACKING_DEFERRED_EXPLICIT = 2;

/**
* NOTIFY means that Doctrine relies on the entities sending out notifications
* when their properties change. Such entity classes must implement
* the <tt>NotifyPropertyChanged</tt> interface.
*
* @deprecated
*/
public const CHANGETRACKING_NOTIFY = 3;

/**
* SET means that fields will be written to the database using a $set operator
*/
Expand Down Expand Up @@ -609,15 +596,6 @@ final class ClassMetadata implements BaseClassMetadata
*/
public private(set) array $subClasses = [];

/**
* The ReflectionProperty instances of the mapped class.
*
* @deprecated Since 2.13, use $propertyAccessors instead.
*
* @var LegacyReflectionFields|array<ReflectionProperty>
*/
public private(set) LegacyReflectionFields|array $reflFields = [];

/** @var array<string, PropertyAccessors\PropertyAccessor> */
public private(set) array $propertyAccessors = [];

Expand Down Expand Up @@ -802,8 +780,6 @@ final class ClassMetadata implements BaseClassMetadata

private InstantiatorInterface $instantiator;

private ReflectionService $reflectionService;

/** @var class-string|null */
private ?string $rootClass;

Expand All @@ -815,11 +791,9 @@ final class ClassMetadata implements BaseClassMetadata
*/
public function __construct(string $documentName)
{
$this->name = $documentName;
$this->rootDocumentName = $documentName;
$this->reflectionService = new RuntimeReflectionService();
$this->reflClass = new ReflectionClass($documentName);
$this->reflFields = new LegacyReflectionFields($this, $this->reflectionService);
$this->name = $documentName;
$this->rootDocumentName = $documentName;
$this->reflClass = new ReflectionClass($documentName);
$this->setCollection($this->reflClass->getShortName());
$this->instantiator = new Instantiator();
}
Expand Down Expand Up @@ -1056,12 +1030,10 @@ public function setAlsoLoadMethods(array $methods): void
* are only used to discern the hydration class and are not mapped to class
* properties.
*
* @param array{name?: string, fieldName?: string}|string|null $discriminatorField
*
* @throws MappingException If the discriminator field conflicts with the
* "name" attribute of a mapped field.
*/
public function setDiscriminatorField(array|string|null $discriminatorField): void
public function setDiscriminatorField(?string $discriminatorField): void
{
if ($this->isFile) {
throw MappingException::discriminatorNotAllowedForGridFS($this->name);
Expand All @@ -1073,16 +1045,6 @@ public function setDiscriminatorField(array|string|null $discriminatorField): vo
return;
}

// @todo: deprecate, document and remove this:
// Handle array argument with name/fieldName keys for BC
if (is_array($discriminatorField)) {
if (isset($discriminatorField['name'])) {
$discriminatorField = $discriminatorField['name'];
} elseif (isset($discriminatorField['fieldName'])) {
$discriminatorField = $discriminatorField['fieldName'];
}
}

foreach ($this->fieldMappings as $fieldMapping) {
if ($discriminatorField === $fieldMapping['name']) {
throw MappingException::discriminatorFieldConflict($this->name, $discriminatorField);
Expand Down Expand Up @@ -1424,29 +1386,6 @@ public function isChangeTrackingDeferredImplicit(): bool
return $this->changeTrackingPolicy === self::CHANGETRACKING_DEFERRED_IMPLICIT;
}

/**
* Whether the change tracking policy of this class is "notify".
*
* @deprecated This method was deprecated in doctrine/mongodb-odm 2.4. Please use DEFERRED_EXPLICIT tracking
* policy and isChangeTrackingDeferredImplicit method to detect it.
*/
public function isChangeTrackingNotify(): bool
{
return $this->changeTrackingPolicy === self::CHANGETRACKING_NOTIFY;
}

/**
* Gets the ReflectionProperties of the mapped class.
*
* @deprecated Since 2.13, use getPropertyAccessors() instead.
*
* @return array<ReflectionProperty>|LegacyReflectionFields
*/
public function getReflectionProperties(): array|LegacyReflectionFields
{
return $this->reflFields;
}

/**
* Gets the ReflectionProperties of the mapped class.
*
Expand All @@ -1457,16 +1396,6 @@ public function getPropertyAccessors(): array
return $this->propertyAccessors;
}

/**
* Gets a ReflectionProperty for a specific field of the mapped class.
*
* @deprecated Since 2.13, use getPropertyAccessor() instead.
*/
public function getReflectionProperty(string $name): ReflectionProperty
{
return $this->reflFields[$name];
}

public function getPropertyAccessor(string $name): PropertyAccessor|null
{
return $this->propertyAccessors[$name] ?? null;
Expand Down Expand Up @@ -2407,13 +2336,7 @@ public function mapField(array $mapping): array
}

if (isset($mapping['targetDocument']) && isset($mapping['discriminatorMap'])) {
trigger_deprecation(
'doctrine/mongodb-odm',
'2.2',
'Mapping both "targetDocument" and "discriminatorMap" on field "%s" in class "%s" is deprecated. Only one of them can be used at a time',
$mapping['fieldName'],
$this->name,
);
throw MappingException::targetDocumentCanNotBeCombinedWithDiscriminatorMap($this->name, $mapping['fieldName']);
}

if (isset($mapping['reference']) && $mapping['type'] === self::ONE) {
Expand Down Expand Up @@ -2535,7 +2458,6 @@ public function mapField(array $mapping): array
*
* Parts that are also NOT serialized because they cannot be properly unserialized:
* - reflClass (ReflectionClass)
* - reflFields (ReflectionProperty array)
* - propertyAccessors (ReflectionProperty array)
*
* @return array The names of all the fields that should be serialized.
Expand Down Expand Up @@ -2643,10 +2565,8 @@ public function __sleep(): array
public function __wakeup(): void
{
// Restore ReflectionClass and properties
$this->reflClass = new ReflectionClass($this->name);
$this->instantiator = new Instantiator();
$this->reflectionService = new RuntimeReflectionService();
$this->reflFields = new LegacyReflectionFields($this, $this->reflectionService);
$this->reflClass = new ReflectionClass($this->name);
$this->instantiator = new Instantiator();

foreach ($this->fieldMappings as $field => $mapping) {
$accessor = PropertyAccessorFactory::createPropertyAccessor($mapping['declared'] ?? $this->name, $field);
Expand Down
11 changes: 0 additions & 11 deletions src/Mapping/ClassMetadataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
use function get_class_methods;
use function in_array;
use function interface_exists;
use function trigger_deprecation;
use function ucfirst;

/**
Expand Down Expand Up @@ -197,16 +196,6 @@ protected function doLoadMetadata(ClassMetadataInterface $class, ?ClassMetadataI
Events::loadClassMetadata,
new LoadClassMetadataEventArgs($class, $this->dm),
);

// phpcs:ignore SlevomatCodingStandard.ControlStructures.EarlyExit.EarlyExitNotUsed
if ($class->isChangeTrackingNotify()) {
trigger_deprecation(
'doctrine/mongodb-odm',
'2.4',
'NOTIFY tracking policy used in class "%s" is deprecated. Please use DEFERRED_EXPLICIT instead.',
$class->name,
);
}
}

/**
Expand Down
16 changes: 0 additions & 16 deletions src/Mapping/Driver/AttributeDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@
use function assert;
use function class_exists;
use function constant;
use function count;
use function is_array;
use function trigger_deprecation;

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

if (isset($documentAttribute->indexes) && count($documentAttribute->indexes)) {
trigger_deprecation(
'doctrine/mongodb-odm',
'2.2',
'The "indexes" parameter in the "%s" attribute for class "%s" is deprecated. Specify all "@Index" and "@UniqueIndex" attributes on the class.',
$documentAttribute::class,
$className,
);

foreach ($documentAttribute->indexes as $index) {
$this->addIndex($metadata, $index);
}
}

if (! empty($documentAttribute->readOnly)) {
$metadata->markReadOnly();
}
Expand Down
Loading