From 9edc694a2c2934d61cfccdd13499b368d760cb64 Mon Sep 17 00:00:00 2001 From: Ion Bazan Date: Fri, 30 Jul 2021 00:02:15 +0800 Subject: [PATCH] revise annotations and attributes constructors --- .../Mapping/Annotations/AbstractField.php | 8 +++---- .../Mapping/Annotations/AbstractIndex.php | 10 ++++----- .../Annotations/ChangeTrackingPolicy.php | 12 ++++++++-- .../Annotations/DiscriminatorField.php | 4 ++-- .../MongoDB/Mapping/Annotations/Document.php | 4 ++-- .../MongoDB/Mapping/Annotations/EmbedMany.php | 13 ++--------- .../MongoDB/Mapping/Annotations/EmbedOne.php | 8 +------ .../Mapping/Annotations/EmbeddedDocument.php | 9 +++++++- .../ODM/MongoDB/Mapping/Annotations/File.php | 4 ++-- .../Mapping/Annotations/File/ChunkSize.php | 21 +++--------------- .../Mapping/Annotations/File/Filename.php | 21 +++--------------- .../Mapping/Annotations/File/Length.php | 21 +++--------------- .../Mapping/Annotations/File/Metadata.php | 11 +--------- .../Mapping/Annotations/File/UploadDate.php | 21 +++--------------- .../ODM/MongoDB/Mapping/Annotations/Id.php | 13 +---------- .../MongoDB/Mapping/Annotations/Indexes.php | 14 ++++++++++-- .../Mapping/Annotations/InheritanceType.php | 12 ++++++++-- .../Mapping/Annotations/MappedSuperclass.php | 7 +++++- .../Mapping/Annotations/ReadPreference.php | 5 +++-- .../Mapping/Annotations/ReferenceMany.php | 22 ++++++------------- .../Mapping/Annotations/ReferenceOne.php | 16 +++++--------- .../MongoDB/Mapping/Annotations/ShardKey.php | 2 +- .../Mapping/Annotations/UniqueIndex.php | 6 +---- .../ODM/MongoDB/Mapping/Annotations/View.php | 8 +++++-- 24 files changed, 101 insertions(+), 171 deletions(-) diff --git a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/AbstractField.php b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/AbstractField.php index dce0f86b01..06dd282434 100644 --- a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/AbstractField.php +++ b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/AbstractField.php @@ -10,19 +10,19 @@ abstract class AbstractField implements Annotation public $name; /** @var string */ - public $type = 'string'; + public $type; /** @var bool */ - public $nullable = false; + public $nullable; /** @var mixed[] */ - public $options = []; + public $options; /** @var string|null */ public $strategy; /** @var bool */ - public $notSaved = false; + public $notSaved; public function __construct( ?string $name = null, diff --git a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/AbstractIndex.php b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/AbstractIndex.php index 15e6925a7c..ee27544797 100644 --- a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/AbstractIndex.php +++ b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/AbstractIndex.php @@ -7,7 +7,7 @@ abstract class AbstractIndex implements Annotation { /** @var string[] */ - public $keys = []; + public $keys; /** @var string */ public $name; @@ -22,16 +22,16 @@ abstract class AbstractIndex implements Annotation public $order; /** @var bool */ - public $unique = false; + public $unique; /** @var bool */ - public $sparse = false; + public $sparse; /** @var mixed[] */ - public $options = []; + public $options; /** @var array */ - public $partialFilterExpression = []; + public $partialFilterExpression; public function __construct( array $keys = [], diff --git a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/ChangeTrackingPolicy.php b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/ChangeTrackingPolicy.php index be9792f80e..059f24e66b 100644 --- a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/ChangeTrackingPolicy.php +++ b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/ChangeTrackingPolicy.php @@ -5,14 +5,22 @@ namespace Doctrine\ODM\MongoDB\Mapping\Annotations; use Attribute; -use Doctrine\Common\Annotations\Annotation; +use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor; /** * Specifies the change tracking policy for a document * * @Annotation + * @NamedArgumentConstructor */ #[Attribute(Attribute::TARGET_CLASS)] -final class ChangeTrackingPolicy extends Annotation +final class ChangeTrackingPolicy implements Annotation { + /** @var string */ + public $value; + + public function __construct(string $value) + { + $this->value = $value; + } } diff --git a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/DiscriminatorField.php b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/DiscriminatorField.php index a512c91254..ae57be43fe 100644 --- a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/DiscriminatorField.php +++ b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/DiscriminatorField.php @@ -16,10 +16,10 @@ #[Attribute(Attribute::TARGET_CLASS)] final class DiscriminatorField implements Annotation { - /** @var string|null */ + /** @var string */ public $value; - public function __construct(?string $value = null) + public function __construct(string $value) { $this->value = $value; } diff --git a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/Document.php b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/Document.php index 9c84d1c536..7840a31936 100644 --- a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/Document.php +++ b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/Document.php @@ -26,10 +26,10 @@ final class Document extends AbstractDocument public $repositoryClass; /** @var Index[] */ - public $indexes = []; + public $indexes; /** @var bool */ - public $readOnly = false; + public $readOnly; /** @var string|null */ public $shardKey; diff --git a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/EmbedMany.php b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/EmbedMany.php index a71b22af10..ec82cda758 100644 --- a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/EmbedMany.php +++ b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/EmbedMany.php @@ -18,9 +18,6 @@ #[Attribute(Attribute::TARGET_PROPERTY)] final class EmbedMany extends AbstractField { - /** @var string */ - public $type = ClassMetadata::MANY; - /** @var bool */ public $embedded = true; @@ -36,9 +33,6 @@ final class EmbedMany extends AbstractField /** @var string|null */ public $defaultDiscriminatorValue; - /** @var string */ - public $strategy = CollectionHelper::DEFAULT_STRATEGY; - /** @var string|null */ public $collectionClass; @@ -46,19 +40,16 @@ public function __construct( ?string $name = null, bool $nullable = false, array $options = [], - ?string $strategy = null, + string $strategy = CollectionHelper::DEFAULT_STRATEGY, bool $notSaved = false, - string $type = ClassMetadata::MANY, - bool $embedded = true, ?string $targetDocument = null, ?string $discriminatorField = null, ?array $discriminatorMap = null, ?string $defaultDiscriminatorValue = null, ?string $collectionClass = null ) { - parent::__construct($name, $type, $nullable, $options, $strategy, $notSaved); + parent::__construct($name, ClassMetadata::MANY, $nullable, $options, $strategy, $notSaved); - $this->embedded = $embedded; $this->targetDocument = $targetDocument; $this->discriminatorField = $discriminatorField; $this->discriminatorMap = $discriminatorMap; diff --git a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/EmbedOne.php b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/EmbedOne.php index 8e9f96ae91..4ac2d778e3 100644 --- a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/EmbedOne.php +++ b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/EmbedOne.php @@ -17,9 +17,6 @@ #[Attribute(Attribute::TARGET_PROPERTY)] final class EmbedOne extends AbstractField { - /** @var string */ - public $type = ClassMetadata::ONE; - /** @var bool */ public $embedded = true; @@ -41,16 +38,13 @@ public function __construct( array $options = [], ?string $strategy = null, bool $notSaved = false, - string $type = ClassMetadata::ONE, - bool $embedded = true, ?string $targetDocument = null, ?string $discriminatorField = null, ?array $discriminatorMap = null, ?string $defaultDiscriminatorValue = null ) { - parent::__construct($name, $type, $nullable, $options, $strategy, $notSaved); + parent::__construct($name, ClassMetadata::ONE, $nullable, $options, $strategy, $notSaved); - $this->embedded = $embedded; $this->targetDocument = $targetDocument; $this->discriminatorField = $discriminatorField; $this->discriminatorMap = $discriminatorMap; diff --git a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/EmbeddedDocument.php b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/EmbeddedDocument.php index 2030edb81f..30402b9dc2 100644 --- a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/EmbeddedDocument.php +++ b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/EmbeddedDocument.php @@ -5,15 +5,22 @@ namespace Doctrine\ODM\MongoDB\Mapping\Annotations; use Attribute; +use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor; /** * Identifies a class as a document that can be embedded but not stored by itself * * @Annotation + * @NamedArgumentConstructor */ #[Attribute(Attribute::TARGET_CLASS)] final class EmbeddedDocument extends AbstractDocument { /** @var Index[] */ - public $indexes = []; + public $indexes; + + public function __construct(array $indexes = []) + { + $this->indexes = $indexes; + } } diff --git a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/File.php b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/File.php index a6d2eb9e82..2be11a340d 100644 --- a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/File.php +++ b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/File.php @@ -26,10 +26,10 @@ final class File extends AbstractDocument public $repositoryClass; /** @var Index[] */ - public $indexes = []; + public $indexes; /** @var bool bool */ - public $readOnly = false; + public $readOnly; /** @var string|null */ public $shardKey; diff --git a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/File/ChunkSize.php b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/File/ChunkSize.php index 051e380923..ad09a80b4a 100644 --- a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/File/ChunkSize.php +++ b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/File/ChunkSize.php @@ -15,23 +15,8 @@ #[Attribute(Attribute::TARGET_PROPERTY)] final class ChunkSize extends AbstractField { - /** @var string */ - public $name = 'chunkSize'; - - /** @var string */ - public $type = 'int'; - - /** @var bool */ - public $notSaved = true; - - public function __construct( - ?string $name = 'chunkSize', - string $type = 'int', - bool $nullable = false, - array $options = [], - ?string $strategy = null, - bool $notSaved = true - ) { - parent::__construct($name, $type, $nullable, $options, $strategy, $notSaved); + public function __construct(?string $name = 'chunkSize') + { + parent::__construct($name, 'int', false, [], null, true); } } diff --git a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/File/Filename.php b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/File/Filename.php index 2b7edfbe92..a26d52de50 100644 --- a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/File/Filename.php +++ b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/File/Filename.php @@ -15,23 +15,8 @@ #[Attribute(Attribute::TARGET_PROPERTY)] final class Filename extends AbstractField { - /** @var string */ - public $name = 'filename'; - - /** @var string */ - public $type = 'string'; - - /** @var bool */ - public $notSaved = true; - - public function __construct( - ?string $name = 'filename', - string $type = 'string', - bool $nullable = false, - array $options = [], - ?string $strategy = null, - bool $notSaved = true - ) { - parent::__construct($name, $type, $nullable, $options, $strategy, $notSaved); + public function __construct(?string $name = 'filename') + { + parent::__construct($name, 'string', false, [], null, true); } } diff --git a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/File/Length.php b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/File/Length.php index 854207935f..a0d9b6a961 100644 --- a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/File/Length.php +++ b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/File/Length.php @@ -15,23 +15,8 @@ #[Attribute(Attribute::TARGET_PROPERTY)] final class Length extends AbstractField { - /** @var string */ - public $name = 'length'; - - /** @var string */ - public $type = 'int'; - - /** @var bool */ - public $notSaved = true; - - public function __construct( - ?string $name = 'length', - string $type = 'int', - bool $nullable = false, - array $options = [], - ?string $strategy = null, - bool $notSaved = true - ) { - parent::__construct($name, $type, $nullable, $options, $strategy, $notSaved); + public function __construct(?string $name = 'length') + { + parent::__construct($name, 'int', false, [], null, true); } } diff --git a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/File/Metadata.php b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/File/Metadata.php index 4b86157b25..7a77d8399e 100644 --- a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/File/Metadata.php +++ b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/File/Metadata.php @@ -16,12 +16,6 @@ #[Attribute(Attribute::TARGET_PROPERTY)] final class Metadata extends AbstractField { - /** @var string */ - public $name = 'metadata'; - - /** @var string */ - public $type = ClassMetadata::ONE; - /** @var bool */ public $embedded = true; @@ -39,20 +33,17 @@ final class Metadata extends AbstractField public function __construct( ?string $name = 'metadata', - string $type = ClassMetadata::ONE, bool $nullable = false, array $options = [], ?string $strategy = null, bool $notSaved = false, - bool $embedded = true, ?string $targetDocument = null, ?string $discriminatorField = null, ?array $discriminatorMap = null, ?string $defaultDiscriminatorValue = null ) { - parent::__construct($name, $type, $nullable, $options, $strategy, $notSaved); + parent::__construct($name, ClassMetadata::ONE, $nullable, $options, $strategy, $notSaved); - $this->embedded = $embedded; $this->targetDocument = $targetDocument; $this->discriminatorField = $discriminatorField; $this->discriminatorMap = $discriminatorMap; diff --git a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/File/UploadDate.php b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/File/UploadDate.php index 71fc1c5165..bdea254ae4 100644 --- a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/File/UploadDate.php +++ b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/File/UploadDate.php @@ -15,23 +15,8 @@ #[Attribute(Attribute::TARGET_PROPERTY)] final class UploadDate extends AbstractField { - /** @var string */ - public $name = 'uploadDate'; - - /** @var string */ - public $type = 'date'; - - /** @var bool */ - public $notSaved = true; - - public function __construct( - ?string $name = 'uploadDate', - string $type = 'date', - bool $nullable = false, - array $options = [], - ?string $strategy = null, - bool $notSaved = true - ) { - parent::__construct($name, $type, $nullable, $options, $strategy, $notSaved); + public function __construct(?string $name = 'uploadDate', string $type = 'date') + { + parent::__construct($name, $type, false, [], null, true); } } diff --git a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/Id.php b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/Id.php index 90d5e22715..a8b6ec1cfb 100644 --- a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/Id.php +++ b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/Id.php @@ -19,12 +19,6 @@ final class Id extends AbstractField /** @var bool */ public $id = true; - /** @var string|null */ - public $type; - - /** @var string */ - public $strategy = 'auto'; - public function __construct( ?string $name = null, ?string $type = null, @@ -33,11 +27,6 @@ public function __construct( ?string $strategy = 'auto', bool $notSaved = false ) { - $this->name = $name; - $this->type = $type; - $this->nullable = $nullable; - $this->options = $options; - $this->strategy = $strategy; - $this->notSaved = $notSaved; + parent::__construct($name, $type, $nullable, $options, $strategy, $notSaved); } } diff --git a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/Indexes.php b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/Indexes.php index 997082830b..2f3a77ac85 100644 --- a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/Indexes.php +++ b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/Indexes.php @@ -5,7 +5,9 @@ namespace Doctrine\ODM\MongoDB\Mapping\Annotations; use Attribute; -use Doctrine\Common\Annotations\Annotation; +use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor; + +use function is_array; /** * Specifies a list of indexes for a document @@ -13,8 +15,16 @@ * @deprecated class was deprecated in doctrine/mongodb-odm 2.2 and will be removed in 3.0. Specify all Index and UniqueIndex annotations on a class level. * * @Annotation + * @NamedArgumentConstructor */ #[Attribute(Attribute::TARGET_CLASS)] -final class Indexes extends Annotation +final class Indexes implements Annotation { + /** @var AbstractIndex[] */ + public $value; + + public function __construct($value) + { + $this->value = is_array($value) ? $value : [$value]; + } } diff --git a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/InheritanceType.php b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/InheritanceType.php index 581149a484..45c14f1460 100644 --- a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/InheritanceType.php +++ b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/InheritanceType.php @@ -5,14 +5,22 @@ namespace Doctrine\ODM\MongoDB\Mapping\Annotations; use Attribute; -use Doctrine\Common\Annotations\Annotation; +use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor; /** * Specifies which inheritance type to use for a document * * @Annotation + * @NamedArgumentConstructor */ #[Attribute(Attribute::TARGET_CLASS)] -final class InheritanceType extends Annotation +final class InheritanceType implements Annotation { + /** @var string */ + public $value; + + public function __construct(string $value) + { + $this->value = $value; + } } diff --git a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/MappedSuperclass.php b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/MappedSuperclass.php index f69d353ee2..8b1ebe9bff 100644 --- a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/MappedSuperclass.php +++ b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/MappedSuperclass.php @@ -17,6 +17,11 @@ #[Attribute(Attribute::TARGET_CLASS)] final class MappedSuperclass extends AbstractDocument { - /** @var string */ + /** @var string|null */ public $repositoryClass; + + public function __construct(?string $repositoryClass = null) + { + $this->repositoryClass = $repositoryClass; + } } diff --git a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/ReadPreference.php b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/ReadPreference.php index db61822639..e59b8bf419 100644 --- a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/ReadPreference.php +++ b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/ReadPreference.php @@ -14,12 +14,13 @@ #[Attribute(Attribute::TARGET_CLASS)] final class ReadPreference implements Annotation { - /** @var string|null */ + /** @var string */ public $value; + /** @var string[][]|null */ public $tags; - public function __construct(?string $value = null, ?array $tags = null) + public function __construct(string $value, ?array $tags = null) { $this->value = $value; $this->tags = $tags; diff --git a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/ReferenceMany.php b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/ReferenceMany.php index 3369b8bc5f..a0976dae88 100644 --- a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/ReferenceMany.php +++ b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/ReferenceMany.php @@ -18,14 +18,11 @@ #[Attribute(Attribute::TARGET_PROPERTY)] final class ReferenceMany extends AbstractField { - /** @var string */ - public $type = ClassMetadata::MANY; - /** @var bool */ public $reference = true; /** @var string */ - public $storeAs = ClassMetadata::REFERENCE_STORE_AS_DB_REF; + public $storeAs; /** @var string|null */ public $targetDocument; @@ -55,10 +52,10 @@ final class ReferenceMany extends AbstractField public $repositoryMethod; /** @var array */ - public $sort = []; + public $sort; /** @var array */ - public $criteria = []; + public $criteria; /** @var int|null */ public $limit; @@ -67,13 +64,13 @@ final class ReferenceMany extends AbstractField public $skip; /** @var string */ - public $strategy = CollectionHelper::DEFAULT_STRATEGY; + public $strategy; /** @var string|null */ public $collectionClass; /** @var string[] */ - public $prime = []; + public $prime; /** * @param array $options @@ -85,11 +82,10 @@ final class ReferenceMany extends AbstractField */ public function __construct( ?string $name = null, - string $type = ClassMetadata::MANY, bool $nullable = false, array $options = [], + string $strategy = CollectionHelper::DEFAULT_STRATEGY, bool $notSaved = false, - bool $reference = true, string $storeAs = ClassMetadata::REFERENCE_STORE_AS_DB_REF, ?string $targetDocument = null, ?string $discriminatorField = null, @@ -104,14 +100,11 @@ public function __construct( array $criteria = [], ?int $limit = null, ?int $skip = null, - string $strategy = CollectionHelper::DEFAULT_STRATEGY, ?string $collectionClass = null, array $prime = [] ) { - parent::__construct($name, $type, $nullable, $options, $strategy, $notSaved); + parent::__construct($name, ClassMetadata::MANY, $nullable, $options, $strategy, $notSaved); - $this->type = $type; - $this->reference = $reference; $this->storeAs = $storeAs; $this->targetDocument = $targetDocument; $this->discriminatorField = $discriminatorField; @@ -126,7 +119,6 @@ public function __construct( $this->criteria = $criteria; $this->limit = $limit; $this->skip = $skip; - $this->strategy = $strategy; $this->collectionClass = $collectionClass; $this->prime = $prime; } diff --git a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/ReferenceOne.php b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/ReferenceOne.php index 7405d3de09..52f4a69da7 100644 --- a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/ReferenceOne.php +++ b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/ReferenceOne.php @@ -17,14 +17,11 @@ #[Attribute(Attribute::TARGET_PROPERTY)] final class ReferenceOne extends AbstractField { - /** @var string */ - public $type = ClassMetadata::ONE; - /** @var bool */ public $reference = true; /** @var string */ - public $storeAs = ClassMetadata::REFERENCE_STORE_AS_DB_REF; + public $storeAs; /** @var string|null */ public $targetDocument; @@ -54,10 +51,10 @@ final class ReferenceOne extends AbstractField public $repositoryMethod; /** @var array */ - public $sort = []; + public $sort; /** @var array */ - public $criteria = []; + public $criteria; /** @var int|null */ public $limit; @@ -66,7 +63,6 @@ final class ReferenceOne extends AbstractField public $skip; /** - * @param array $options * @param array|null $discriminatorMap * @param string[]|string|null $cascade * @param array $sort @@ -78,8 +74,6 @@ public function __construct( array $options = [], ?string $strategy = null, bool $notSaved = false, - string $type = ClassMetadata::ONE, - bool $reference = true, string $storeAs = ClassMetadata::REFERENCE_STORE_AS_DB_REF, ?string $targetDocument = null, ?string $discriminatorField = null, @@ -95,8 +89,8 @@ public function __construct( ?int $limit = null, ?int $skip = null ) { - parent::__construct($name, $type, $nullable, $options, $strategy, $notSaved); - $this->reference = $reference; + parent::__construct($name, ClassMetadata::ONE, $nullable, $options, $strategy, $notSaved); + $this->storeAs = $storeAs; $this->targetDocument = $targetDocument; $this->discriminatorField = $discriminatorField; diff --git a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/ShardKey.php b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/ShardKey.php index 5c7e65d80f..e8a32ba406 100644 --- a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/ShardKey.php +++ b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/ShardKey.php @@ -15,7 +15,7 @@ final class ShardKey implements Annotation { /** @var string[] */ - public $keys = []; + public $keys; /** @var bool|null */ public $unique; diff --git a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/UniqueIndex.php b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/UniqueIndex.php index 783aac6655..7fb32ea276 100644 --- a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/UniqueIndex.php +++ b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/UniqueIndex.php @@ -16,16 +16,12 @@ #[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_PROPERTY | Attribute::IS_REPEATABLE)] final class UniqueIndex extends AbstractIndex { - /** @var bool */ - public $unique = true; - public function __construct( array $keys = [], ?string $name = null, ?bool $background = null, ?int $expireAfterSeconds = null, $order = null, - bool $unique = true, bool $sparse = false, array $options = [], array $partialFilterExpression = [] @@ -36,7 +32,7 @@ public function __construct( $background, $expireAfterSeconds, $order, - $unique, + true, $sparse, $options, $partialFilterExpression diff --git a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/View.php b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/View.php index e3a9316848..70226cfd70 100644 --- a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/View.php +++ b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/View.php @@ -26,8 +26,12 @@ final class View extends AbstractDocument /** @var string|null */ public $repositoryClass; - public function __construct(?string $db = null, ?string $view = null, ?string $rootClass = null, ?string $repositoryClass = null) - { + public function __construct( + ?string $db = null, + ?string $view = null, + ?string $rootClass = null, + ?string $repositoryClass = null + ) { $this->db = $db; $this->view = $view; $this->rootClass = $rootClass;