diff --git a/benchmark/BaseBench.php b/benchmark/BaseBench.php index 8f62fdee0f..7b85fd001d 100644 --- a/benchmark/BaseBench.php +++ b/benchmark/BaseBench.php @@ -6,7 +6,7 @@ use Doctrine\ODM\MongoDB\Configuration; use Doctrine\ODM\MongoDB\DocumentManager; -use Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver; +use Doctrine\ODM\MongoDB\Mapping\Driver\AttributeDriver; use MongoDB\Client; use MongoDB\Model\DatabaseInfo; use PhpBench\Benchmark\Metadata\Annotations\BeforeMethods; @@ -80,8 +80,8 @@ public function clearDatabase(): void } } - protected static function createMetadataDriverImpl(): AnnotationDriver + protected static function createMetadataDriverImpl(): AttributeDriver { - return AnnotationDriver::create(__DIR__ . '/../tests/Documents'); + return AttributeDriver::create(__DIR__ . '/../tests/Documents'); } } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index b24788a7ab..f8d7c76aa6 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -790,6 +790,16 @@ parameters: count: 1 path: tests/Doctrine/ODM/MongoDB/Tests/Functional/NestedDocumentsTest.php + - + message: "#^Parameter \\$discriminatorMap of attribute class Doctrine\\\\ODM\\\\MongoDB\\\\Mapping\\\\Annotations\\\\ReferenceOne constructor expects array\\\\|null, array\\ given\\.$#" + count: 1 + path: tests/Doctrine/ODM/MongoDB/Tests/Functional/TargetDocumentTest.php + + - + message: "#^Parameter \\$targetDocument of attribute class Doctrine\\\\ODM\\\\MongoDB\\\\Mapping\\\\Annotations\\\\ReferenceOne constructor expects class\\-string\\|null, string given\\.$#" + count: 1 + path: tests/Doctrine/ODM/MongoDB/Tests/Functional/TargetDocumentTest.php + - message: "#^Property Doctrine\\\\ODM\\\\MongoDB\\\\Tests\\\\Functional\\\\Ticket\\\\GH1058PersistDocument\\:\\:\\$id is never written, only read\\.$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index cb52726d8c..bc854ae734 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -391,6 +391,11 @@ true]]]> + + + 'Doctrine\ODM\MongoDB\Tests\Functional\SomeInvalidClass']]]> + + embeds]]> diff --git a/tests/Doctrine/ODM/MongoDB/Tests/BaseTestCase.php b/tests/Doctrine/ODM/MongoDB/Tests/BaseTestCase.php index 66afcd1f07..7806d9cf40 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/BaseTestCase.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/BaseTestCase.php @@ -6,7 +6,7 @@ use Doctrine\ODM\MongoDB\Configuration; use Doctrine\ODM\MongoDB\DocumentManager; -use Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver; +use Doctrine\ODM\MongoDB\Mapping\Driver\AttributeDriver; use Doctrine\ODM\MongoDB\Tests\Query\Filter\Filter; use Doctrine\ODM\MongoDB\UnitOfWork; use Doctrine\Persistence\Mapping\Driver\MappingDriver; @@ -116,7 +116,7 @@ public static function assertArraySubset(array $subset, array $array, bool $chec protected static function createMetadataDriverImpl(): MappingDriver { - return AnnotationDriver::create(__DIR__ . '/../../../../Documents'); + return AttributeDriver::create(__DIR__ . '/../../../../Documents'); } protected static function createTestDocumentManager(): DocumentManager diff --git a/tests/Doctrine/ODM/MongoDB/Tests/DocumentManagerTest.php b/tests/Doctrine/ODM/MongoDB/Tests/DocumentManagerTest.php index ad616f6ae4..ba84318f18 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/DocumentManagerTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/DocumentManagerTest.php @@ -231,59 +231,38 @@ public function testDifferentStoreAsDbReferences(): void } } -/** @ODM\Document */ +#[ODM\Document] class WrongSimpleRefDocument { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\ReferenceOne(targetDocument=Documents\Tournament\Participant::class, storeAs="id") - * - * @var Participant|null - */ + /** @var Participant|null */ + #[ODM\ReferenceOne(targetDocument: Participant::class, storeAs: 'id')] public $ref; } -/** @ODM\Document */ +#[ODM\Document] class ReferenceStoreAsDocument { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\ReferenceOne(targetDocument=User::class, storeAs="id") - * - * @var User|null - */ + /** @var User|null */ + #[ODM\ReferenceOne(targetDocument: User::class, storeAs: 'id')] public $ref1; - /** - * @ODM\ReferenceOne(targetDocument=User::class, storeAs="dbRef") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceOne(targetDocument: User::class, storeAs: 'dbRef')] public $ref2; - /** - * @ODM\ReferenceOne(targetDocument=User::class, storeAs="dbRefWithDb") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceOne(targetDocument: User::class, storeAs: 'dbRefWithDb')] public $ref3; - /** - * @ODM\ReferenceOne(targetDocument=User::class, storeAs="ref") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceOne(targetDocument: User::class, storeAs: 'ref')] public $ref4; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Events/LifecycleCallbacksTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Events/LifecycleCallbacksTest.php index 16474bf497..3cabb91aad 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Events/LifecycleCallbacksTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Events/LifecycleCallbacksTest.php @@ -246,110 +246,72 @@ public function testEventsNotFiredForInverseSide(): void } } -/** @ODM\Document */ +#[ODM\Document] class User extends BaseDocument { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\EmbedOne(targetDocument=Profile::class) - * - * @var Profile|null - */ + /** @var Profile|null */ + #[ODM\EmbedOne(targetDocument: Profile::class)] public $profile; - /** - * @ODM\EmbedMany(targetDocument=Profile::class) - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\EmbedMany(targetDocument: Profile::class)] public $profiles = []; - /** - * @ODM\ReferenceMany(targetDocument=User::class) - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\ReferenceMany(targetDocument: self::class)] public $friends = []; } -/** @ODM\Document */ +#[ODM\Document] class Cart extends BaseDocument { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\ReferenceOne(targetDocument=Customer::class, inversedBy="cart") - * - * @var Customer|null - */ + /** @var Customer|null */ + #[ODM\ReferenceOne(targetDocument: Customer::class, inversedBy: 'cart')] public $customer; } -/** @ODM\Document */ +#[ODM\Document] class Customer extends BaseDocument { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\ReferenceOne(targetDocument=Cart::class, mappedBy="customer") - * - * @var Cart|null - */ + /** @var Cart|null */ + #[ODM\ReferenceOne(targetDocument: Cart::class, mappedBy: 'customer')] public $cart; } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class Profile extends BaseDocument { - /** - * @ODM\EmbedOne(targetDocument=Profile::class) - * - * @var Profile|null - */ + /** @var Profile|null */ + #[ODM\EmbedOne(targetDocument: self::class)] public $profile; } -/** - * @ODM\MappedSuperclass - * @ODM\HasLifecycleCallbacks - */ +#[ODM\MappedSuperclass] +#[ODM\HasLifecycleCallbacks] abstract class BaseDocument { - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; - /** - * @ODM\Field(type="date") - * - * @var DateTime - */ + /** @var DateTime */ + #[ODM\Field(type: 'date')] public $createdAt; - /** - * @ODM\Field(type="date") - * - * @var DateTime|null - */ + /** @var DateTime|null */ + #[ODM\Field(type: 'date')] public $updatedAt; /** @var bool */ @@ -379,57 +341,57 @@ abstract class BaseDocument /** @var bool */ public $preFlush = false; - /** @ODM\PrePersist */ + #[ODM\PrePersist] public function prePersist(Event\LifecycleEventArgs $e): void { $this->prePersist = true; $this->createdAt = new DateTime(); } - /** @ODM\PostPersist */ + #[ODM\PostPersist] public function postPersist(Event\LifecycleEventArgs $e): void { $this->postPersist = true; } - /** @ODM\PreUpdate */ + #[ODM\PreUpdate] public function preUpdate(Event\PreUpdateEventArgs $e): void { $this->preUpdate = true; $this->updatedAt = new DateTime(); } - /** @ODM\PostUpdate */ + #[ODM\PostUpdate] public function postUpdate(Event\LifecycleEventArgs $e): void { $this->postUpdate = true; } - /** @ODM\PreRemove */ + #[ODM\PreRemove] public function preRemove(Event\LifecycleEventArgs $e): void { $this->preRemove = true; } - /** @ODM\PostRemove */ + #[ODM\PostRemove] public function postRemove(Event\LifecycleEventArgs $e): void { $this->postRemove = true; } - /** @ODM\PreLoad */ + #[ODM\PreLoad] public function preLoad(Event\PreLoadEventArgs $e): void { $this->preLoad = true; } - /** @ODM\PostLoad */ + #[ODM\PostLoad] public function postLoad(Event\LifecycleEventArgs $e): void { $this->postLoad = true; } - /** @ODM\PreFlush */ + #[ODM\PreFlush] public function preFlush(Event\PreFlushEventArgs $e): void { $this->preFlush = true; diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Events/LifecycleListenersTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Events/LifecycleListenersTest.php index 96856cf30d..7a5ea7e836 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Events/LifecycleListenersTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Events/LifecycleListenersTest.php @@ -257,60 +257,39 @@ public function postCollectionLoad(PostCollectionLoadEventArgs $e): void } } -/** @ODM\Document */ +#[ODM\Document] class TestDocument { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; - /** - * @ODM\EmbedMany(targetDocument=TestEmbeddedDocument::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: TestEmbeddedDocument::class)] public $embedded; - /** - * @ODM\EmbedOne(targetDocument=Image::class) - * - * @var Image|null - */ + /** @var Image|null */ + #[ODM\EmbedOne(targetDocument: Image::class)] public $image; - /** - * @ODM\ReferenceMany(targetDocument=TestProfile::class) - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\ReferenceMany(targetDocument: TestProfile::class)] public $profiles; - /** - * @ODM\ReferenceOne(targetDocument=TestProfile::class) - * - * @var TestProfile|null - */ + /** @var TestProfile|null */ + #[ODM\ReferenceOne(targetDocument: TestProfile::class)] public $profile; } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class TestEmbeddedDocument { - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $name; public function __construct(string $name = '') @@ -320,46 +299,31 @@ public function __construct(string $name = '') } -/** @ODM\Document */ +#[ODM\Document] class TestProfile { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; - /** - * @ODM\EmbedOne(targetDocument=Image::class) - * - * @var Image|null - */ + /** @var Image|null */ + #[ODM\EmbedOne(targetDocument: Image::class)] public $image; } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class Image { - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $name; - /** - * @ODM\EmbedMany(targetDocument=Thumbnail::class) - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\EmbedMany(targetDocument: Thumbnail::class)] public $thumbnails = []; public function __construct(string $name) @@ -368,14 +332,11 @@ public function __construct(string $name) } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class Thumbnail { - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $name; public function __construct(string $name) diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Events/TransactionalLifecycleEventsTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Events/TransactionalLifecycleEventsTest.php index f5bddaf2a3..a93e683e61 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Events/TransactionalLifecycleEventsTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Events/TransactionalLifecycleEventsTest.php @@ -9,6 +9,7 @@ use Doctrine\ODM\MongoDB\Event\LifecycleEventArgs; use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; use Doctrine\ODM\MongoDB\Tests\BaseTestCase; +use Doctrine\ODM\MongoDB\Types\Type; use MongoDB\Client; use MongoDB\Driver\Session; use PHPUnit\Framework\Assert; @@ -199,22 +200,16 @@ private function createFailPoint(string $failCommand): void } } -/** - * @ODM\MappedSuperclass - * @ODM\HasLifecycleCallbacks - */ +#[ODM\MappedSuperclass] +#[ODM\HasLifecycleCallbacks] abstract class BaseEventDocument { public function __construct() { } - /** - * @ODM\Field(type="string") - * - * @var string|null - */ - public $name; + #[ODM\Field(type: Type::STRING)] + public ?string $name = null; public int $preUpdate = 0; @@ -225,27 +220,28 @@ public function __construct() public int $postRemove = 0; /** @ODM\PreUpdate */ + #[ODM\PreUpdate] public function preUpdate(Event\PreUpdateEventArgs $e): void { $this->assertTransactionState($e); $this->preUpdate++; } - /** @ODM\PostPersist */ + #[ODM\PostPersist] public function postPersist(Event\LifecycleEventArgs $e): void { $this->assertTransactionState($e); $this->postPersist++; } - /** @ODM\PostUpdate */ + #[ODM\PostUpdate] public function postUpdate(Event\LifecycleEventArgs $e): void { $this->assertTransactionState($e); $this->postUpdate++; } - /** @ODM\PostRemove */ + #[ODM\PostRemove] public function postRemove(Event\LifecycleEventArgs $e): void { $this->assertTransactionState($e); @@ -259,17 +255,17 @@ private function assertTransactionState(LifecycleEventArgs $e): void } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class EmbeddedEventDocument extends BaseEventDocument { } -/** @ODM\Document */ +#[ODM\Document] class RootEventDocument extends BaseEventDocument { - /** @ODM\Id */ + #[ODM\Id] public string $id; - /** @ODM\EmbedOne(targetDocument=EmbeddedEventDocument::class) */ + #[ODM\EmbedOne(targetDocument: EmbeddedEventDocument::class)] public ?EmbeddedEventDocument $embedded; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/AlsoLoadTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/AlsoLoadTest.php index 4aa16ab70f..3f71000efe 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/AlsoLoadTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/AlsoLoadTest.php @@ -211,151 +211,106 @@ public function testMethodAlsoLoadGrandparentInheritance(): void } } -/** @ODM\Document */ +#[ODM\Document] class AlsoLoadDocument { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * @ODM\AlsoLoad({"bar", "zip"}) - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] + #[ODM\AlsoLoad(['bar', 'zip'])] public $foo; - /** - * @ODM\Field(notSaved=true) - * @ODM\AlsoLoad({"zip", "bar"}) - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(notSaved: true)] + #[ODM\AlsoLoad(['zip', 'bar'])] public $baz; - /** - * @ODM\Field(notSaved=true) - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(notSaved: true)] public $bar; - /** - * @ODM\Field(notSaved=true) - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(notSaved: true)] public $zip; - /** - * @ODM\Field(type="string") - * @ODM\AlsoLoad("zip") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] + #[ODM\AlsoLoad('zip')] public $zap = 'zap'; - /** - * @ODM\Field(notSaved=true) - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(notSaved: true)] public $name; - /** - * @ODM\Field(notSaved=true) - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(notSaved: true)] public $fullName; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $firstName; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $lastName; - /** - * @ODM\Field(type="string") - * @ODM\AlsoLoad("testNew") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] + #[ODM\AlsoLoad('testNew')] public $test = 'test'; - /** - * @ODM\Field(notSaved=true) - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(notSaved: true)] public $testNew; - /** - * @ODM\Field(notSaved=true) - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(notSaved: true)] public $testOld; - /** - * @ODM\Field(notSaved=true) - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(notSaved: true)] public $testOlder; - /** @ODM\AlsoLoad({"name", "fullName"}) */ + #[ODM\AlsoLoad(['name', 'fullName'])] public function populateFirstAndLastName(string $name): void { [$this->firstName, $this->lastName] = explode(' ', $name); } - /** @ODM\AlsoLoad ({"testOld", "testOlder"}) */ + #[ODM\AlsoLoad(['testOld', 'testOlder'])] public function populateTest(?string $test): void { $this->test = $test; } } -/** @ODM\Document */ +#[ODM\Document] class AlsoLoadChild extends AlsoLoadDocument { - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $fizz; - /** @ODM\AlsoLoad("buzz") */ + #[ODM\AlsoLoad('buzz')] public function populateFizz(string $fizz): void { $this->fizz = $fizz; } - /** @ODM\AlsoLoad ("testOldest") */ + #[ODM\AlsoLoad('testOldest')] public function populateTest(?string $test): void { $this->test = $test; } } -/** @ODM\Document */ +#[ODM\Document] class AlsoLoadGrandchild extends AlsoLoadChild { - /** @ODM\AlsoLoad ("testReallyOldest") */ + #[ODM\AlsoLoad('testReallyOldest')] public function populateTest(?string $test): void { $this->test = $test; diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/AtomicSetTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/AtomicSetTest.php index dd5cdbc3ae..cd8a6437d2 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/AtomicSetTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/AtomicSetTest.php @@ -547,71 +547,44 @@ public function testUpdatedEmbeddedDocumentAndDirtyCollectionInside(): void } } -/** @ODM\Document */ +#[ODM\Document] class AtomicSetUser { - /** - * @ODM\Id - * - * @var ObjectId|null - */ + /** @var ObjectId|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $name; - /** - * @ODM\Field(type="int") - * @ODM\Version - * - * @var int - */ + /** @var int */ + #[ODM\Field(type: 'int')] + #[ODM\Version] public $version = 1; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $surname; - /** - * @ODM\EmbedMany(strategy="atomicSet", targetDocument=Documents\Phonenumber::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(strategy: 'atomicSet', targetDocument: Phonenumber::class)] public $phonenumbers; - /** - * @ODM\EmbedMany(strategy="atomicSetArray", targetDocument=Documents\Phonenumber::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(strategy: 'atomicSetArray', targetDocument: Phonenumber::class)] public $phonenumbersArray; - /** - * @ODM\EmbedMany(strategy="atomicSet", targetDocument=Documents\Phonebook::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(strategy: 'atomicSet', targetDocument: Phonebook::class)] public $phonebooks; - /** - * @ODM\EmbedMany(strategy="atomicSet", targetDocument=AtomicSetInception::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(strategy: 'atomicSet', targetDocument: AtomicSetInception::class)] public $inception; - /** - * @ODM\ReferenceMany(strategy="atomicSetArray", targetDocument=AtomicSetUser::class) - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\ReferenceMany(strategy: 'atomicSetArray', targetDocument: self::class)] public $friends; public function __construct(string $name) @@ -624,28 +597,19 @@ public function __construct(string $name) } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class AtomicSetInception { - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $value; - /** - * @ODM\EmbedOne(targetDocument=AtomicSetInception::class) - * - * @var AtomicSetInception|null - */ + /** @var AtomicSetInception|null */ + #[ODM\EmbedOne(targetDocument: self::class)] public $one; - /** - * @ODM\EmbedMany(targetDocument=AtomicSetInception::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: self::class)] public $many; public function __construct(string $value) diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/BinDataTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/BinDataTest.php index c4e510740d..d0ecb1462f 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/BinDataTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/BinDataTest.php @@ -39,62 +39,38 @@ public static function provideData(): array } } -/** @ODM\Document */ +#[ODM\Document] class BinDataTestUser { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="bin") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'bin')] public $bin; - /** - * @ODM\Field(type="bin_func") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'bin_func')] public $binFunc; - /** - * @ODM\Field(type="bin_bytearray") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'bin_bytearray')] public $binByteArray; - /** - * @ODM\Field(type="bin_uuid") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'bin_uuid')] public $binUUID; - /** - * @ODM\Field(type="bin_uuid_rfc4122") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'bin_uuid_rfc4122')] public $binUUIDRFC4122; - /** - * @ODM\Field(type="bin_md5") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'bin_md5')] public $binMD5; - /** - * @ODM\Field(type="bin_custom") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'bin_custom')] public $binCustom; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/CollectionPersisterTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/CollectionPersisterTest.php index 35b3c27454..4c18afe30a 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/CollectionPersisterTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/CollectionPersisterTest.php @@ -589,67 +589,43 @@ public function testPersistSeveralNestedEmbedManyDifferentStrategiesDeepNesting( } } -/** @ODM\Document(collection="user_collection_persister_test") */ +#[ODM\Document(collection: 'user_collection_persister_test')] class CollectionPersisterUser { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $username; - /** - * @ODM\EmbedMany(targetDocument=CollectionPersisterCategory::class) - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\EmbedMany(targetDocument: CollectionPersisterCategory::class)] public $categories = []; - /** - * @ODM\EmbedMany(targetDocument=CollectionPersisterGroup::class, storeEmptyArray=true) - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\EmbedMany(targetDocument: CollectionPersisterGroup::class, storeEmptyArray: true)] public $groups = []; - /** - * @ODM\ReferenceMany(targetDocument=CollectionPersisterPhonenumber::class, cascade={"persist"}) - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\ReferenceMany(targetDocument: CollectionPersisterPhonenumber::class, cascade: ['persist'])] public $phonenumbers = []; - /** - * @ODM\ReferenceMany(targetDocument=CollectionPersisterRole::class, cascade={"persist"}, storeEmptyArray=true) - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\ReferenceMany(targetDocument: CollectionPersisterRole::class, cascade: ['persist'], storeEmptyArray: true)] public $roles = []; } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class CollectionPersisterCategory { - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $name; - /** - * @ODM\EmbedMany(targetDocument=CollectionPersisterCategory::class) - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\EmbedMany(targetDocument: self::class)] public $children = []; public function __construct(string $name) @@ -658,21 +634,15 @@ public function __construct(string $name) } } -/** @ODM\Document(collection="phonenumber_collection_persister_test") */ +#[ODM\Document(collection: 'phonenumber_collection_persister_test')] class CollectionPersisterPhonenumber { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $phonenumber; public function __construct(string $phonenumber) @@ -681,21 +651,15 @@ public function __construct(string $phonenumber) } } -/** @ODM\Document(collection="role_collection_persister_test") */ +#[ODM\Document(collection: 'role_collection_persister_test')] class CollectionPersisterRole { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $role; public function __construct(string $role) @@ -704,21 +668,15 @@ public function __construct(string $role) } } -/** @ODM\Document(collection="group_collection_persister_test") */ +#[ODM\Document(collection: 'group_collection_persister_test')] class CollectionPersisterGroup { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $group; public function __construct(string $group) @@ -727,28 +685,19 @@ public function __construct(string $group) } } -/** @ODM\Document(collection="post_collection_persister_test") */ +#[ODM\Document(collection: 'post_collection_persister_test')] class CollectionPersisterPost { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $post; - /** - * @ODM\EmbedMany(targetDocument=CollectionPersisterComment::class, strategy="set") - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\EmbedMany(targetDocument: CollectionPersisterComment::class, strategy: 'set')] public $comments = []; public function __construct(string $post) @@ -758,35 +707,23 @@ public function __construct(string $post) } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class CollectionPersisterComment { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $comment; - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $by; - /** - * @ODM\EmbedMany(targetDocument=CollectionPersisterComment::class, strategy="set") - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\EmbedMany(targetDocument: self::class, strategy: 'set')] public $comments = []; public function __construct(string $comment, string $by) @@ -797,70 +734,43 @@ public function __construct(string $comment, string $by) } } -/** @ODM\Document(collection="structure_collection_persister_test") */ +#[ODM\Document(collection: 'structure_collection_persister_test')] class CollectionPersisterStructure { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\EmbedMany(targetDocument=CollectionPersisterNestedStructure::class, strategy="addToSet") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: CollectionPersisterNestedStructure::class, strategy: 'addToSet')] public $addToSet; - /** - * @ODM\EmbedMany(targetDocument=CollectionPersisterNestedStructure::class, strategy="addToSet") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: CollectionPersisterNestedStructure::class, strategy: 'addToSet')] public $addToSet2; - /** - * @ODM\EmbedMany(targetDocument=CollectionPersisterNestedStructure::class, strategy="set") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: CollectionPersisterNestedStructure::class, strategy: 'set')] public $set; - /** - * @ODM\EmbedMany(targetDocument=CollectionPersisterNestedStructure::class, strategy="set") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: CollectionPersisterNestedStructure::class, strategy: 'set')] public $set2; - /** - * @ODM\EmbedMany(targetDocument=CollectionPersisterNestedStructure::class, strategy="setArray") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: CollectionPersisterNestedStructure::class, strategy: 'setArray')] public $setArray; - /** - * @ODM\EmbedMany(targetDocument=CollectionPersisterNestedStructure::class, strategy="setArray") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: CollectionPersisterNestedStructure::class, strategy: 'setArray')] public $setArray2; - /** - * @ODM\EmbedMany(targetDocument=CollectionPersisterNestedStructure::class, strategy="pushAll") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: CollectionPersisterNestedStructure::class, strategy: 'pushAll')] public $pushAll; - /** - * @ODM\EmbedMany(targetDocument=CollectionPersisterNestedStructure::class, strategy="pushAll") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: CollectionPersisterNestedStructure::class, strategy: 'pushAll')] public $pushAll2; public function __construct() @@ -875,77 +785,47 @@ public function __construct() $this->pushAll2 = new ArrayCollection(); } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class CollectionPersisterNestedStructure { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $field; - /** - * @ODM\EmbedMany(targetDocument=CollectionPersisterNestedStructure::class, strategy="addToSet") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: self::class, strategy: 'addToSet')] public $addToSet; - /** - * @ODM\EmbedMany(targetDocument=CollectionPersisterNestedStructure::class, strategy="addToSet") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: self::class, strategy: 'addToSet')] public $addToSet2; - /** - * @ODM\EmbedMany(targetDocument=CollectionPersisterNestedStructure::class, strategy="set") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: self::class, strategy: 'set')] public $set; - /** - * @ODM\EmbedMany(targetDocument=CollectionPersisterNestedStructure::class, strategy="set") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: self::class, strategy: 'set')] public $set2; - /** - * @ODM\EmbedMany(targetDocument=CollectionPersisterNestedStructure::class, strategy="setArray") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: self::class, strategy: 'setArray')] public $setArray; - /** - * @ODM\EmbedMany(targetDocument=CollectionPersisterNestedStructure::class, strategy="setArray") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: self::class, strategy: 'setArray')] public $setArray2; - /** - * @ODM\EmbedMany(targetDocument=CollectionPersisterNestedStructure::class, strategy="pushAll") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: self::class, strategy: 'pushAll')] public $pushAll; - /** - * @ODM\EmbedMany(targetDocument=CollectionPersisterNestedStructure::class, strategy="pushAll") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: self::class, strategy: 'pushAll')] public $pushAll2; public function __construct(string $field) diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/CollectionsTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/CollectionsTest.php index 9690528b00..7a17e28ac2 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/CollectionsTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/CollectionsTest.php @@ -116,45 +116,26 @@ public function testCreateCollectionsCapped(): void } } -/** - * @ODM\Document(collection={ - * "name"="CollectionTestCapped", - * "capped"=true, - * "size"=1000, - * "max"=1 - * }) - */ +#[ODM\Document(collection: ['name' => 'CollectionTestCapped', 'capped' => true, 'size' => 1000, 'max' => 1])] class CollectionTestCapped { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $username; } -/** @ODM\Document */ +#[ODM\Document] class CollectionTestBasic { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $username; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/CustomCollectionsTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/CustomCollectionsTest.php index 5e2d6b73ea..f0a846b2de 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/CustomCollectionsTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/CustomCollectionsTest.php @@ -185,55 +185,27 @@ public function testMethodWithVoidReturnType(): void } } -/** @ODM\Document */ +#[ODM\Document] class DocumentWithCustomCollection { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\EmbedMany( - * collectionClass=MyEmbedsCollection::class, - * targetDocument=EmbeddedDocumentInCustomCollection::class - * ) - * - * @var MyEmbedsCollection - */ + /** @var MyEmbedsCollection */ + #[ODM\EmbedMany(collectionClass: MyEmbedsCollection::class, targetDocument: EmbeddedDocumentInCustomCollection::class)] public $coll; - /** - * @ODM\EmbedMany( - * targetDocument=EmbeddedDocumentInCustomCollection::class - * ) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: EmbeddedDocumentInCustomCollection::class)] public $boring; - /** - * @ODM\ReferenceMany( - * collectionClass=MyDocumentsCollection::class, - * orphanRemoval=true, - * targetDocument=DocumentWithCustomCollection::class - * ) - * - * @var MyDocumentsCollection - */ + /** @var MyDocumentsCollection */ + #[ODM\ReferenceMany(collectionClass: MyDocumentsCollection::class, orphanRemoval: true, targetDocument: self::class)] public $refMany; - /** - * @ODM\ReferenceMany( - * collectionClass="\Doctrine\ODM\MongoDB\Tests\Functional\MyDocumentsCollection", - * mappedBy="refMany", - * targetDocument=DocumentWithCustomCollection::class - * ) - * - * @var MyDocumentsCollection - */ + /** @var MyDocumentsCollection */ + #[ODM\ReferenceMany(collectionClass: '\Doctrine\ODM\MongoDB\Tests\Functional\MyDocumentsCollection', mappedBy: 'refMany', targetDocument: self::class)] public $inverseRefMany; public function __construct() @@ -245,21 +217,15 @@ public function __construct() } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class EmbeddedDocumentInCustomCollection { - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $name; - /** - * @ODM\Field(type="bool") - * - * @var bool - */ + /** @var bool */ + #[ODM\Field(type: 'bool')] public $enabled; public function __construct(string $name, bool $enabled) diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/CustomFieldNameTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/CustomFieldNameTest.php index d5165550fa..ddc220fba5 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/CustomFieldNameTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/CustomFieldNameTest.php @@ -100,20 +100,14 @@ public function testQueryBuilderAndDqlArePrepared(): void } } -/** @ODM\Document */ +#[ODM\Document] class CustomFieldName { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(name="login", type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(name: 'login', type: 'string')] public $username; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/CustomTypeTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/CustomTypeTest.php index baf4d0cb57..3a123f5051 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/CustomTypeTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/CustomTypeTest.php @@ -103,20 +103,14 @@ class CustomTypeException extends Exception { } -/** @ODM\Document */ +#[ODM\Document] class Country { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="date_collection") - * - * @var DateTime[]|DateTime|null - */ + /** @var DateTime[]|DateTime|null */ + #[ODM\Field(type: 'date_collection')] public $nationalHolidays; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/DatabasesTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/DatabasesTest.php index 3ac8e6ff40..624cb515c9 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/DatabasesTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/DatabasesTest.php @@ -30,24 +30,18 @@ protected static function getConfiguration(): Configuration } } -/** @ODM\Document(db="test_custom") */ +#[ODM\Document(db: 'test_custom')] class CustomDatabaseTest { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] private $id; } -/** @ODM\Document() */ +#[ODM\Document] class DefaultDatabaseTest { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] private $id; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/DiscriminatorsDefaultValueTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/DiscriminatorsDefaultValueTest.php index e83fd4510c..cb19a4ec65 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/DiscriminatorsDefaultValueTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/DiscriminatorsDefaultValueTest.php @@ -80,14 +80,11 @@ public function testLoadDocumentWithDifferentChild(): void } // Unmapped superclasses -/** @ODM\Document(collection="discriminator_parent") */ +#[ODM\Document(collection: 'discriminator_parent')] abstract class ParentDocument { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] protected $id; /** @var ChildDocument */ @@ -139,21 +136,15 @@ public function getEmbeddedChildren() } } -/** @ODM\Document(collection="discriminator_child") */ +#[ODM\Document(collection: 'discriminator_child')] abstract class ChildDocument { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] protected $id; - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] protected $type; public function __construct(string $type) @@ -173,100 +164,71 @@ public function getType(): string } // Documents without discriminators - used to create "legacy" data -/** @ODM\Document(collection="discriminator_parent") */ +#[ODM\Document(collection: 'discriminator_parent')] class ParentDocumentWithoutDiscriminator extends ParentDocument { - /** - * @ODM\ReferenceOne(targetDocument=ChildDocumentWithoutDiscriminator::class) - * - * @var ChildDocumentWithDiscriminator - */ + /** @var ChildDocumentWithDiscriminator */ + #[ODM\ReferenceOne(targetDocument: ChildDocumentWithoutDiscriminator::class)] protected $referencedChild; - /** - * @ODM\ReferenceMany(targetDocument=ChildDocumentWithoutDiscriminator::class) - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\ReferenceMany(targetDocument: ChildDocumentWithoutDiscriminator::class)] protected $referencedChildren; - /** - * @ODM\EmbedOne(targetDocument=ChildDocumentWithoutDiscriminator::class) - * - * @var ChildDocumentWithoutDiscriminator - */ + /** @var ChildDocumentWithoutDiscriminator */ + #[ODM\EmbedOne(targetDocument: ChildDocumentWithoutDiscriminator::class)] protected $embeddedChild; - /** - * @ODM\EmbedMany(targetDocument=ChildDocumentWithoutDiscriminator::class) - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\EmbedMany(targetDocument: ChildDocumentWithoutDiscriminator::class)] protected $embeddedChildren; } -/** @ODM\Document(collection="discriminator_child") */ +#[ODM\Document(collection: 'discriminator_child')] class ChildDocumentWithoutDiscriminator extends ChildDocument { } // Documents with discriminators - these represent a "refactored" document structure -/** @ODM\Document(collection="discriminator_parent") */ +#[ODM\Document(collection: 'discriminator_parent')] class ParentDocumentWithDiscriminator extends ParentDocument { - /** - * @ODM\ReferenceOne(targetDocument=ChildDocumentWithDiscriminator::class) - * - * @var ChildDocumentWithDiscriminator - */ + /** @var ChildDocumentWithDiscriminator */ + #[ODM\ReferenceOne(targetDocument: ChildDocumentWithDiscriminator::class)] protected $referencedChild; - /** - * @ODM\ReferenceMany(targetDocument=ChildDocumentWithDiscriminator::class) - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\ReferenceMany(targetDocument: ChildDocumentWithDiscriminator::class)] protected $referencedChildren; - /** - * @ODM\EmbedOne(targetDocument=ChildDocumentWithDiscriminator::class) - * - * @var ChildDocumentWithDiscriminator - */ + /** @var ChildDocumentWithDiscriminator */ + #[ODM\EmbedOne(targetDocument: ChildDocumentWithDiscriminator::class)] protected $embeddedChild; - /** - * @ODM\EmbedMany(targetDocument=ChildDocumentWithDiscriminator::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: ChildDocumentWithDiscriminator::class)] protected $embeddedChildren; } -/** - * @ODM\Document(collection="discriminator_child") - * @ODM\InheritanceType("SINGLE_COLLECTION") - * @ODM\DiscriminatorField("discriminator") - * @ODM\DiscriminatorMap({"simple"=ChildDocumentWithDiscriminatorSimple::class, "complex"=ChildDocumentWithDiscriminatorComplex::class}) - * @ODM\DefaultDiscriminatorValue("simple") - */ +#[ODM\Document(collection: 'discriminator_child')] +#[ODM\InheritanceType('SINGLE_COLLECTION')] +#[ODM\DiscriminatorField('discriminator')] +#[ODM\DiscriminatorMap(['simple' => ChildDocumentWithDiscriminatorSimple::class, 'complex' => ChildDocumentWithDiscriminatorComplex::class])] +#[ODM\DefaultDiscriminatorValue('simple')] class ChildDocumentWithDiscriminator extends ChildDocument { } -/** @ODM\Document(collection="discriminator_child") */ +#[ODM\Document(collection: 'discriminator_child')] class ChildDocumentWithDiscriminatorSimple extends ChildDocumentWithDiscriminator { } -/** @ODM\Document(collection="discriminator_child") */ +#[ODM\Document(collection: 'discriminator_child')] class ChildDocumentWithDiscriminatorComplex extends ChildDocumentWithDiscriminatorSimple { - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] protected $value; public function __construct(string $type, string $value) diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/DocumentPersisterTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/DocumentPersisterTest.php index aa8313c528..326446298f 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/DocumentPersisterTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/DocumentPersisterTest.php @@ -873,231 +873,143 @@ public function testNoVersionIncrementOnUpdateFailure(): void } } -/** @ODM\Document */ +#[ODM\Document] class DocumentPersisterTestDocument { - /** - * @ODM\Id - * - * @var ObjectId|null - */ + /** @var ObjectId|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(name="dbName", type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(name: 'dbName', type: 'string')] public $name; - /** - * @ODM\EmbedOne( - * targetDocument=Doctrine\ODM\MongoDB\Tests\Functional\AbstractDocumentPersisterTestDocumentAssociation::class, - * discriminatorField="type", - * name="associationName" - * ) - * - * @var AbstractDocumentPersisterTestDocumentAssociation|null - */ + /** @var AbstractDocumentPersisterTestDocumentAssociation|null */ + #[ODM\EmbedOne(targetDocument: AbstractDocumentPersisterTestDocumentAssociation::class, discriminatorField: 'type', name: 'associationName')] public $association; - /** - * @ODM\ReferenceOne(targetDocument=DocumentPersisterTestHashIdDocument::class, storeAs="id") - * - * @var DocumentPersisterTestHashIdDocument|null - */ + /** @var DocumentPersisterTestHashIdDocument|null */ + #[ODM\ReferenceOne(targetDocument: DocumentPersisterTestHashIdDocument::class, storeAs: 'id')] public $simpleRef; - /** - * @ODM\ReferenceOne(targetDocument=DocumentPersisterTestHashIdDocument::class, storeAs="dbRef") - * - * @var DocumentPersisterTestHashIdDocument|null - */ + /** @var DocumentPersisterTestHashIdDocument|null */ + #[ODM\ReferenceOne(targetDocument: DocumentPersisterTestHashIdDocument::class, storeAs: 'dbRef')] public $semiComplexRef; - /** - * @ODM\ReferenceOne(targetDocument=DocumentPersisterTestHashIdDocument::class, storeAs="dbRefWithDb") - * - * @var DocumentPersisterTestHashIdDocument|null - */ + /** @var DocumentPersisterTestHashIdDocument|null */ + #[ODM\ReferenceOne(targetDocument: DocumentPersisterTestHashIdDocument::class, storeAs: 'dbRefWithDb')] public $complexRef; - /** - * @ODM\ReferenceOne(targetDocument=DocumentPersisterTestHashIdDocument::class, storeAs="ref") - * - * @var DocumentPersisterTestHashIdDocument|null - */ + /** @var DocumentPersisterTestHashIdDocument|null */ + #[ODM\ReferenceOne(targetDocument: DocumentPersisterTestHashIdDocument::class, storeAs: 'ref')] public $embeddedRef; } -/** @ODM\Document */ +#[ODM\Document] class DocumentPersisterTestDocumentWithVersion { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(name="dbName", type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(name: 'dbName', type: 'string')] public $name; - /** - * @ODM\Version - * @ODM\Field(type="int") - * - * @var int - */ + /** @var int */ + #[ODM\Version] + #[ODM\Field(type: 'int')] public $revision = 1; } -/** - * @ODM\EmbeddedDocument - * @ODM\InheritanceType("SINGLE_COLLECTION") - * @ODM\DiscriminatorField("type") - * @ODM\DiscriminatorMap({ - * "reference"="Doctrine\ODM\MongoDB\Tests\Functional\DocumentPersisterTestDocumentReference", - * "embed"="Doctrine\ODM\MongoDB\Tests\Functional\DocumentPersisterTestDocumentEmbed" - * }) - */ +#[ODM\EmbeddedDocument] +#[ODM\InheritanceType('SINGLE_COLLECTION')] +#[ODM\DiscriminatorField('type')] +#[ODM\DiscriminatorMap(['reference' => DocumentPersisterTestDocumentReference::class, 'embed' => DocumentPersisterTestDocumentEmbed::class])] abstract class AbstractDocumentPersisterTestDocumentAssociation { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\EmbedOne(name="nestedName") - * - * @var object|null - */ + /** @var object|null */ + #[ODM\EmbedOne(name: 'nestedName')] public $nested; - /** - * @ODM\EmbedOne( - * targetDocument=Doctrine\ODM\MongoDB\Tests\Functional\AbstractDocumentPersisterTestDocumentAssociation::class, - * discriminatorField="type", - * name="associationName" - * ) - * - * @var AbstractDocumentPersisterTestDocumentAssociation|null - */ + /** @var AbstractDocumentPersisterTestDocumentAssociation|null */ + #[ODM\EmbedOne(targetDocument: self::class, discriminatorField: 'type', name: 'associationName')] public $association; } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class DocumentPersisterTestDocumentReference extends AbstractDocumentPersisterTestDocumentAssociation { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\ReferenceOne(name="nestedName") - * - * @var object|null - */ + /** @var object|null */ + #[ODM\ReferenceOne(name: 'nestedName')] public $nested; } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class DocumentPersisterTestDocumentEmbed extends AbstractDocumentPersisterTestDocumentAssociation { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\EmbedOne(name="nestedName") - * - * @var object|null - */ + /** @var object|null */ + #[ODM\EmbedOne(name: 'nestedName')] public $nested; } -/** @ODM\Document */ +#[ODM\Document] class DocumentPersisterTestHashIdDocument { - /** - * @ODM\Id(strategy="none", options={"type"="hash"}) - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id(strategy: 'none', options: ['type' => 'hash'])] public $id; - /** - * @ODM\ReferenceOne(targetDocument=DocumentPersisterTestDocument::class, storeAs="id") - * - * @var DocumentPersisterTestDocument|null - */ + /** @var DocumentPersisterTestDocument|null */ + #[ODM\ReferenceOne(targetDocument: DocumentPersisterTestDocument::class, storeAs: 'id')] public $simpleRef; - /** - * @ODM\ReferenceOne(targetDocument=DocumentPersisterTestDocument::class, storeAs="dbRef") - * - * @var DocumentPersisterTestDocument|null - */ + /** @var DocumentPersisterTestDocument|null */ + #[ODM\ReferenceOne(targetDocument: DocumentPersisterTestDocument::class, storeAs: 'dbRef')] public $semiComplexRef; - /** - * @ODM\ReferenceOne(targetDocument=DocumentPersisterTestDocument::class, storeAs="dbRefWithDb") - * - * @var DocumentPersisterTestDocument|null - */ + /** @var DocumentPersisterTestDocument|null */ + #[ODM\ReferenceOne(targetDocument: DocumentPersisterTestDocument::class, storeAs: 'dbRefWithDb')] public $complexRef; - /** - * @ODM\ReferenceOne(targetDocument=DocumentPersisterTestDocument::class, storeAs="ref") - * - * @var DocumentPersisterTestDocument|null - */ + /** @var DocumentPersisterTestDocument|null */ + #[ODM\ReferenceOne(targetDocument: DocumentPersisterTestDocument::class, storeAs: 'ref')] public $embeddedRef; } -/** @ODM\Document(writeConcern="majority") */ +#[ODM\Document(writeConcern: 'majority')] class DocumentPersisterWriteConcernMajority { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; } -/** @ODM\Document(writeConcern=0) */ +#[ODM\Document(writeConcern: 0)] class DocumentPersisterWriteConcernUnacknowledged { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; } -/** @ODM\Document(writeConcern=1) */ +#[ODM\Document(writeConcern: 1)] class DocumentPersisterWriteConcernAcknowledged { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; } @@ -1171,14 +1083,11 @@ private static function createException($value): InvalidArgumentException } } -/** @ODM\Document() */ +#[ODM\Document] class DocumentPersisterTestDocumentWithCustomId { - /** - * @ODM\Id(strategy="NONE", type="DocumentPersisterCustomId") - * - * @var DocumentPersisterCustomTypedId - */ + /** @var DocumentPersisterCustomTypedId */ + #[ODM\Id(strategy: 'NONE', type: 'DocumentPersisterCustomId')] private $id; public function __construct(DocumentPersisterCustomTypedId $id) @@ -1192,21 +1101,15 @@ public function getId(): DocumentPersisterCustomTypedId } } -/** @ODM\Document() */ +#[ODM\Document] class DocumentPersisterTestDocumentWithReferenceToDocumentWithCustomId { - /** - * @ODM\Id() - * - * @var DocumentPersisterCustomTypedId - */ + /** @var DocumentPersisterCustomTypedId */ + #[ODM\Id] private $id; - /** - * @ODM\ReferenceOne(targetDocument=DocumentPersisterTestDocumentWithCustomId::class, storeAs="id") - * - * @var DocumentPersisterTestDocumentWithCustomId - */ + /** @var DocumentPersisterTestDocumentWithCustomId */ + #[ODM\ReferenceOne(targetDocument: DocumentPersisterTestDocumentWithCustomId::class, storeAs: 'id')] private $documentWithCustomId; public function __construct(DocumentPersisterTestDocumentWithCustomId $documentWithCustomId) diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/EmbeddedIdTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/EmbeddedIdTest.php index c43b99bf6c..3e897f2bd8 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/EmbeddedIdTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/EmbeddedIdTest.php @@ -59,74 +59,50 @@ public function testEmbedManyDocumentWithMissingIdentifier(): void } } -/** @ODM\Document */ +#[ODM\Document] class EmbeddedIdTestUser { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\EmbedOne(targetDocument=DefaultIdEmbeddedDocument::class) - * - * @var DefaultIdEmbeddedDocument|null - */ + /** @var DefaultIdEmbeddedDocument|null */ + #[ODM\EmbedOne(targetDocument: DefaultIdEmbeddedDocument::class)] public $embedOne; - /** - * @ODM\EmbedMany(targetDocument=DefaultIdEmbeddedDocument::class) - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\EmbedMany(targetDocument: DefaultIdEmbeddedDocument::class)] public $embedMany = []; } -/** @ODM\Document */ +#[ODM\Document] class EmbeddedStrategyNoneIdTestUser { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\EmbedOne(targetDocument=DefaultIdStrategyNoneEmbeddedDocument::class) - * - * @var DefaultIdStrategyNoneEmbeddedDocument|null - */ + /** @var DefaultIdStrategyNoneEmbeddedDocument|null */ + #[ODM\EmbedOne(targetDocument: DefaultIdStrategyNoneEmbeddedDocument::class)] public $embedOne; - /** - * @ODM\EmbedMany(targetDocument=DefaultIdStrategyNoneEmbeddedDocument::class) - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\EmbedMany(targetDocument: DefaultIdStrategyNoneEmbeddedDocument::class)] public $embedMany = []; } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class DefaultIdEmbeddedDocument { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class DefaultIdStrategyNoneEmbeddedDocument { - /** - * @ODM\Id(strategy="none") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id(strategy: 'none')] public $id; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/EmbeddedReferenceTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/EmbeddedReferenceTest.php index a839fc196c..44368c9604 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/EmbeddedReferenceTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/EmbeddedReferenceTest.php @@ -58,28 +58,19 @@ public function testReferencedDocumentInsideEmbeddedDocument(): void } } -/** @ODM\Document */ +#[ODM\Document] class Offer { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] protected $id; - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $name; - /** - * @ODM\EmbedMany(targetDocument=Link::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: Link::class)] public $links; public function __construct(string $name) @@ -89,28 +80,19 @@ public function __construct(string $name) } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class Link { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] protected $id; - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $url; - /** - * @ODM\ReferenceMany(targetDocument=ReferencedDocument::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(targetDocument: ReferencedDocument::class)] public $referencedDocuments; public function __construct(string $url) @@ -120,21 +102,15 @@ public function __construct(string $url) } } -/** @ODM\Document */ +#[ODM\Document] class ReferencedDocument { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] protected $id; - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $name; public function __construct(string $name) diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/EmbeddedTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/EmbeddedTest.php index e27c082821..cbd13de081 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/EmbeddedTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/EmbeddedTest.php @@ -637,28 +637,19 @@ public function testEmbeddedDocumentWithDifferentFieldNameAnnotation(): void } } -/** @ODM\Document */ +#[ODM\Document] class ChangeEmbeddedIdTest { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\EmbedOne(targetDocument=EmbeddedDocumentWithId::class) - * - * @var EmbeddedDocumentWithId|null - */ + /** @var EmbeddedDocumentWithId|null */ + #[ODM\EmbedOne(targetDocument: EmbeddedDocumentWithId::class)] public $embed; - /** - * @ODM\EmbedMany(targetDocument=EmbeddedDocumentWithId::class) - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\EmbedMany(targetDocument: EmbeddedDocumentWithId::class)] public $embedMany; public function __construct() @@ -667,49 +658,34 @@ public function __construct() } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class EmbeddedDocumentWithId { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; } -/** @ODM\Document */ +#[ODM\Document] class ChangeEmbeddedWithNameAnnotationTest { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\EmbedOne(targetDocument=EmbeddedDocumentWithAnotherEmbedded::class) - * - * @var EmbeddedDocumentWithAnotherEmbedded|null - */ + /** @var EmbeddedDocumentWithAnotherEmbedded|null */ + #[ODM\EmbedOne(targetDocument: EmbeddedDocumentWithAnotherEmbedded::class)] public $embedOne; - /** - * @ODM\EmbedOne(targetDocument=EmbeddedDocumentWithAnotherEmbedded::class) - * - * @var EmbeddedDocumentWithAnotherEmbedded|null - */ + /** @var EmbeddedDocumentWithAnotherEmbedded|null */ + #[ODM\EmbedOne(targetDocument: EmbeddedDocumentWithAnotherEmbedded::class)] public $embedTwo; } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class EmbeddedDocumentWithAnotherEmbedded { - /** - * @ODM\EmbedOne(targetDocument=EmbeddedDocumentWithId::class, name="m_id") - * - * @var EmbeddedDocumentWithId|null - */ + /** @var EmbeddedDocumentWithId|null */ + #[ODM\EmbedOne(targetDocument: EmbeddedDocumentWithId::class, name: 'm_id')] public $embed; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/FunctionalTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/FunctionalTest.php index 6e2bc763dc..8523a5499f 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/FunctionalTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/FunctionalTest.php @@ -928,27 +928,18 @@ public function testFunctionalParentAssociations(): void } } -/** @ODM\Document */ +#[ODM\Document] class ParentAssociationTestA { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $name; - /** - * @ODM\EmbedOne - * - * @var object|null - */ + /** @var object|null */ + #[ODM\EmbedOne] public $child; public function __construct(string $name) @@ -957,20 +948,14 @@ public function __construct(string $name) } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class ParentAssociationTestB { - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; - /** - * @ODM\EmbedMany - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\EmbedMany] public $children = []; public function __construct(string $name) @@ -979,14 +964,11 @@ public function __construct(string $name) } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class ParentAssociationTestC { - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $name; public function __construct(string $name) diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/HasLifecycleCallbacksTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/HasLifecycleCallbacksTest.php index bcb97fad7a..7990b9fe5c 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/HasLifecycleCallbacksTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/HasLifecycleCallbacksTest.php @@ -107,115 +107,99 @@ public function testHasLifecycleCallbacksSubOverrideAnnotatedExtendsSuperAnnotat } } -/** @ODM\MappedSuperclass */ +#[ODM\MappedSuperclass] abstract class HasLifecycleCallbacksSuper { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; /** @var string[] */ public $invoked = []; - /** @ODM\PrePersist */ + #[ODM\PrePersist] public function prePersist(): void { $this->invoked[] = 'super'; } } -/** - * @ODM\MappedSuperclass - * @ODM\HasLifecycleCallbacks - */ +#[ODM\MappedSuperclass] +#[ODM\HasLifecycleCallbacks] abstract class HasLifecycleCallbacksSuperAnnotated { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; /** @var string[] */ public $invoked = []; - /** @ODM\PrePersist */ + #[ODM\PrePersist] public function prePersist(): void { $this->invoked[] = 'super'; } } -/** @ODM\Document */ +#[ODM\Document] class HasLifecycleCallbacksSubExtendsSuper extends HasLifecycleCallbacksSuper { } -/** @ODM\Document */ +#[ODM\Document] class HasLifecycleCallbacksSubExtendsSuperAnnotated extends HasLifecycleCallbacksSuperAnnotated { } -/** - * @ODM\Document - * @ODM\HasLifecycleCallbacks - */ +#[ODM\Document] +#[ODM\HasLifecycleCallbacks] class HasLifecycleCallbacksSubAnnotatedExtendsSuper extends HasLifecycleCallbacksSuper { } -/** - * @ODM\Document - * @ODM\HasLifecycleCallbacks - */ +#[ODM\Document] +#[ODM\HasLifecycleCallbacks] class HasLifecycleCallbacksSubAnnotatedExtendsSuperAnnotated extends HasLifecycleCallbacksSuperAnnotated { } -/** @ODM\Document */ +#[ODM\Document] class HasLifecycleCallbacksSubOverrideExtendsSuper extends HasLifecycleCallbacksSuper { - /** @ODM\PrePersist */ + #[ODM\PrePersist] public function prePersist(): void { $this->invoked[] = 'sub'; } } -/** @ODM\Document */ +#[ODM\Document] class HasLifecycleCallbacksSubOverrideExtendsSuperAnnotated extends HasLifecycleCallbacksSuperAnnotated { - /** @ODM\PrePersist */ + #[ODM\PrePersist] public function prePersist(): void { $this->invoked[] = 'sub'; } } -/** - * @ODM\Document - * @ODM\HasLifecycleCallbacks - */ +#[ODM\Document] +#[ODM\HasLifecycleCallbacks] class HasLifecycleCallbacksSubOverrideAnnotatedExtendsSuper extends HasLifecycleCallbacksSuper { - /** @ODM\PrePersist */ + #[ODM\PrePersist] public function prePersist(): void { $this->invoked[] = 'sub'; } } -/** - * @ODM\Document - * @ODM\HasLifecycleCallbacks - */ +#[ODM\Document] +#[ODM\HasLifecycleCallbacks] class HasLifecycleCallbacksSubOverrideAnnotatedExtendsSuperAnnotated extends HasLifecycleCallbacksSuperAnnotated { - /** @ODM\PrePersist */ + #[ODM\PrePersist] public function prePersist(): void { $this->invoked[] = 'sub'; diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/IdTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/IdTest.php index 71dfbb25e8..b764a2de84 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/IdTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/IdTest.php @@ -368,13 +368,13 @@ private function createIdTestClass(string $type, string $strategy): string use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; -/** @Doctrine\ODM\MongoDB\Mapping\Annotations\Document */ +#[ODM\Document] class %s { - /** @Doctrine\ODM\MongoDB\Mapping\Annotations\Id(strategy="%s", options={"type"="%s"}) **/ + #[ODM\Id(strategy: "%s", options: ["type" => "%s"])] public $id; - /** @Doctrine\ODM\MongoDB\Mapping\Annotations\Field("type=string") **/ + #[ODM\Field(type: "string")] public $test = "test"; }', $shortClassName, @@ -389,21 +389,15 @@ class %s } } -/** @ODM\Document */ +#[ODM\Document] class UuidUser { - /** - * @ODM\Id(strategy="uuid", options={"salt"="test"}) - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id(strategy: 'uuid', options: ['salt' => 'test'])] public $id; - /** - * @ODM\Field(name="t", type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(name: 't', type: 'string')] public $name; public function __construct(string $name) @@ -412,35 +406,23 @@ public function __construct(string $name) } } -/** @ODM\Document */ +#[ODM\Document] class CollectionIdUser { - /** - * @ODM\Id(strategy="increment") - * - * @var int|null - */ + /** @var int|null */ + #[ODM\Id(strategy: 'increment')] public $id; - /** - * @ODM\Field(name="t", type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(name: 't', type: 'string')] public $name; - /** - * @ODM\ReferenceOne(targetDocument=ReferencedCollectionId::class, cascade={"persist"}) - * - * @var ReferencedCollectionId|null - */ + /** @var ReferencedCollectionId|null */ + #[ODM\ReferenceOne(targetDocument: ReferencedCollectionId::class, cascade: ['persist'])] public $reference; - /** - * @ODM\EmbedMany(targetDocument=EmbeddedCollectionId::class) - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\EmbedMany(targetDocument: EmbeddedCollectionId::class)] public $embedded = []; public function __construct(string $name) @@ -449,35 +431,23 @@ public function __construct(string $name) } } -/** @ODM\Document */ +#[ODM\Document] class CollectionIdUserWithStartingId { - /** - * @ODM\Id(strategy="increment", options={"startingId"=10}) - * - * @var int|null - */ + /** @var int|null */ + #[ODM\Id(strategy: 'increment', options: ['startingId' => 10])] public $id; - /** - * @ODM\Field(name="t", type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(name: 't', type: 'string')] public $name; - /** - * @ODM\ReferenceOne(targetDocument=ReferencedCollectionId::class, cascade={"persist"}) - * - * @var ReferencedCollectionId|null - */ + /** @var ReferencedCollectionId|null */ + #[ODM\ReferenceOne(targetDocument: ReferencedCollectionId::class, cascade: ['persist'])] public $reference; - /** - * @ODM\EmbedMany(targetDocument=EmbeddedCollectionId::class) - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\EmbedMany(targetDocument: EmbeddedCollectionId::class)] public $embedded = []; public function __construct(string $name) @@ -486,21 +456,15 @@ public function __construct(string $name) } } -/** @ODM\Document */ +#[ODM\Document] class ReferencedCollectionId { - /** - * @ODM\Id(strategy="increment") - * - * @var int|null - */ + /** @var int|null */ + #[ODM\Id(strategy: 'increment')] public $id; - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $name; public function __construct(string $name) @@ -514,21 +478,15 @@ public function getName(): string } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class EmbeddedCollectionId { - /** - * @ODM\Id(strategy="increment") - * - * @var int|null - */ + /** @var int|null */ + #[ODM\Id(strategy: 'increment')] public $id; - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $name; public function __construct(string $name) @@ -542,21 +500,15 @@ public function getName(): string } } -/** @ODM\Document */ +#[ODM\Document] class AlnumCharsUser { - /** - * @ODM\Id(strategy="alnum", options={"chars"="zyxwvutsrqponmlkjihgfedcba"}) - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id(strategy: 'alnum', options: ['chars' => 'zyxwvutsrqponmlkjihgfedcba'])] public $id; - /** - * @ODM\Field(name="t", type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(name: 't', type: 'string')] public $name; public function __construct(string $name) @@ -565,21 +517,15 @@ public function __construct(string $name) } } -/** @ODM\Document */ +#[ODM\Document] class CustomIdUser { - /** - * @ODM\Id(strategy="none", nullable=true) - * - * @var int|string|null - */ + /** @var int|string|null */ + #[ODM\Id(strategy: 'none', nullable: true)] public $id; - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $name; public function __construct(string $name) @@ -588,13 +534,10 @@ public function __construct(string $name) } } -/** @ODM\Document */ +#[ODM\Document] class TestIdTypesIdAutoUser { - /** - * @ODM\Id(strategy="auto", options={"type"="id"}) - * - * @var int|null - */ + /** @var int|null */ + #[ODM\Id(strategy: 'auto', options: ['type' => 'id'])] public $id; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/IndexesTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/IndexesTest.php index a0801f25f5..255f861158 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/IndexesTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/IndexesTest.php @@ -251,448 +251,283 @@ public function testGeoIndexCreation(): void } } -/** @ODM\Document */ +#[ODM\Document] class UniqueOnFieldTest { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * @ODM\UniqueIndex() - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] + #[ODM\UniqueIndex] public $username; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $email; } -/** - * @ODM\Document - * @ODM\UniqueIndex(keys={"username"="asc"}) - */ +#[ODM\Document] +#[ODM\UniqueIndex(keys: ['username' => 'asc'])] class UniqueOnDocumentTest { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $username; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $email; } -/** - * @ODM\Document - * @ODM\Indexes(@ODM\UniqueIndex(keys={"username"="asc"})) - */ +#[ODM\Document] +#[ODM\UniqueIndex(keys: ['username' => 'asc'])] class IndexesOnDocumentTest { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $username; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $email; } -/** - * @ODM\Document - * @ODM\Indexes(@ODM\UniqueIndex(keys={"username"="asc"},partialFilterExpression={"counter"={"$gt"=5}})) - */ +#[ODM\Document] +#[ODM\UniqueIndex(keys: ['username' => 'asc'], partialFilterExpression: ['counter' => ['$gt' => 5]])] class PartialIndexOnDocumentTest { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $username; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $email; - /** - * @ODM\Field(type="int") - * - * @var int|null - */ + /** @var int|null */ + #[ODM\Field(type: 'int')] public $counter; } -/** - * @ODM\Document - * @ODM\UniqueIndex(keys={"username"="asc", "email"="asc"}) - */ +#[ODM\Document] +#[ODM\UniqueIndex(keys: ['username' => 'asc', 'email' => 'asc'])] class MultipleFieldsUniqueIndexTest { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $username; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $email; } -/** @ODM\Document */ +#[ODM\Document] class UniqueSparseOnFieldTest { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * @ODM\UniqueIndex(sparse=true) - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] + #[ODM\UniqueIndex(sparse: true)] public $username; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $email; } -/** - * @ODM\Document - * @ODM\UniqueIndex(keys={"username"="asc"}, options={"sparse"=true}) - */ +#[ODM\Document] +#[ODM\UniqueIndex(keys: ['username' => 'asc'], options: ['sparse' => true])] class UniqueSparseOnDocumentTest { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $username; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $email; } -/** - * @ODM\Document - * @ODM\Indexes(@ODM\UniqueIndex(keys={"username"="asc"}, options={"sparse"=true})) - */ +#[ODM\Document] +#[ODM\UniqueIndex(keys: ['username' => 'asc'], options: ['sparse' => true])] class SparseIndexesOnDocumentTest { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $username; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $email; } -/** - * @ODM\Document - * @ODM\UniqueIndex(keys={"username"="asc", "email"="asc"}, options={"sparse"=true}) - */ +#[ODM\Document] +#[ODM\UniqueIndex(keys: ['username' => 'asc', 'email' => 'asc'], options: ['sparse' => true])] class MultipleFieldsUniqueSparseIndexTest { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $username; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $email; } -/** @ODM\Document */ +#[ODM\Document] class MultipleFieldIndexes { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * @ODM\UniqueIndex(name="test") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] + #[ODM\UniqueIndex(name: 'test')] public $username; - /** - * @ODM\Field(type="string") - * @ODM\Index(unique=true) - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] + #[ODM\Index(unique: true)] public $email; } -/** @ODM\Document */ +#[ODM\Document] class DocumentWithEmbeddedIndexes { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; - /** - * @ODM\EmbedOne(targetDocument=EmbeddedDocumentWithIndexes::class) - * - * @var EmbeddedDocumentWithIndexes|null - */ + /** @var EmbeddedDocumentWithIndexes|null */ + #[ODM\EmbedOne(targetDocument: EmbeddedDocumentWithIndexes::class)] public $embedded; - /** - * @ODM\EmbedOne(targetDocument=EmbeddedDocumentWithIndexes::class) - * - * @var EmbeddedDocumentWithIndexes|null - */ + /** @var EmbeddedDocumentWithIndexes|null */ + #[ODM\EmbedOne(targetDocument: EmbeddedDocumentWithIndexes::class)] public $embeddedSecondary; } -/** - * @ODM\Document - * @ODM\DiscriminatorField("type") - * @ODM\Index(keys={"type"="asc"}) - */ +#[ODM\Document] +#[ODM\DiscriminatorField('type')] +#[ODM\Index(keys: ['type' => 'asc'])] class DocumentWithDiscriminatorIndex { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; } -/** - * @ODM\Document - * @ODM\Index(keys={"name"="asc"}) - * @ODM\Index(keys={"name"="desc"}) - * @ODM\UniqueIndex(keys={"name"="asc"}, options={"sparse"=true}) - */ +#[ODM\Document] +#[ODM\Index(keys: ['name' => 'asc'])] +#[ODM\Index(keys: ['name' => 'desc'])] +#[ODM\UniqueIndex(keys: ['name' => 'asc'], options: ['sparse' => true])] class DocumentWithMultipleIndexAnnotations { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class EmbeddedDocumentWithIndexes { - /** - * @ODM\Field(type="string") - * @ODM\Index - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] + #[ODM\Index] public $name; - /** - * @ODM\EmbedMany(targetDocument=EmbeddedManyDocumentWithIndexes::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: EmbeddedManyDocumentWithIndexes::class)] public $embeddedMany; } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class EmbeddedManyDocumentWithIndexes { - /** - * @ODM\Field(type="string") - * @ODM\Index - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] + #[ODM\Index] public $name; } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class YetAnotherEmbeddedDocumentWithIndex { - /** - * @ODM\Field(type="string") - * @ODM\Index - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] + #[ODM\Index] public $value; } -/** @ODM\Document */ +#[ODM\Document] class DocumentWithIndexInDiscriminatedEmbeds { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\EmbedOne( - * discriminatorMap={ - * "d1"=EmbeddedDocumentWithIndexes::class, - * "d2"=YetAnotherEmbeddedDocumentWithIndex::class, - * }) - * - * @var EmbeddedDocumentWithIndexes|YetAnotherEmbeddedDocumentWithIndex|null - */ + /** @var EmbeddedDocumentWithIndexes|YetAnotherEmbeddedDocumentWithIndex|null */ + #[ODM\EmbedOne(discriminatorMap: ['d1' => EmbeddedDocumentWithIndexes::class, 'd2' => YetAnotherEmbeddedDocumentWithIndex::class])] public $embedded; } -/** - * @ODM\Document - * @ODM\Index(keys={"coordinatesWith2DIndex"="2d"}) - * @ODM\Index(keys={"coordinatesWithSphereIndex"="2dsphere"}) - */ +#[ODM\Document] +#[ODM\Index(keys: ['coordinatesWith2DIndex' => '2d'])] +#[ODM\Index(keys: ['coordinatesWithSphereIndex' => '2dsphere'])] class GeoIndexDocument { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="hash") - * - * @var array - */ + /** @var array */ + #[ODM\Field(type: 'hash')] public $coordinatesWith2DIndex; - /** - * @ODM\Field(type="hash") - * - * @var array - */ + /** @var array */ + #[ODM\Field(type: 'hash')] public $coordinatesWithSphereIndex; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/LifecycleTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/LifecycleTest.php index 943818946d..880014c69e 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/LifecycleTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/LifecycleTest.php @@ -52,38 +52,24 @@ public function testEventEmptyFlush(): void } } -/** - * @ODM\Document - * @ODM\HasLifecycleCallbacks - */ +#[ODM\Document] +#[ODM\HasLifecycleCallbacks] class ParentObject { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] private $id; - /** - * @ODM\ReferenceMany(targetDocument=ChildObject::class, cascade="all") - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\ReferenceMany(targetDocument: ChildObject::class, cascade: 'all')] private $children; - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] private $name; - /** - * @ODM\EmbedOne(targetDocument=ChildEmbeddedObject::class) - * - * @var ChildEmbeddedObject - */ + /** @var ChildEmbeddedObject */ + #[ODM\EmbedOne(targetDocument: ChildEmbeddedObject::class)] private $childEmbedded; /** @var ChildObject */ @@ -106,16 +92,14 @@ public function getName(): ?string return $this->name; } - /** - * @ODM\PrePersist - * @ODM\PreUpdate - */ + #[ODM\PrePersist] + #[ODM\PreUpdate] public function prePersistPreUpdate(): void { $this->children = [$this->child]; } - /** @ODM\PreUpdate */ + #[ODM\PreUpdate] public function preUpdate(): void { $this->childEmbedded->setName('changed'); @@ -138,21 +122,15 @@ public function setName(string $name): void } } -/** @ODM\Document */ +#[ODM\Document] class ChildObject { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] private $id; - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] private $name; public function __construct(string $name) @@ -171,14 +149,11 @@ public function getName(): string } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class ChildEmbeddedObject { - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] private $name; public function __construct(string $name) diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/LockTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/LockTest.php index a12014a99a..18455ea46c 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/LockTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/LockTest.php @@ -559,36 +559,24 @@ public function testDeletingCollectionRespectsVersionNumber(): void } } -/** @ODM\MappedSuperclass */ +#[ODM\MappedSuperclass] abstract class AbstractVersionBase { - /** - * @ODM\Id - * - * @var ObjectId|string|null - */ + /** @var ObjectId|string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $title; - /** - * @ODM\Lock - * @ODM\Field(type="int") - * - * @var int|null - */ + /** @var int|null */ + #[ODM\Lock] + #[ODM\Field(type: 'int')] public $locked; - /** - * @ODM\EmbedMany(targetDocument=Issue::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: Issue::class)] public $issues; /** @var int|string|DateTime|DateTimeImmutable|null */ @@ -618,88 +606,64 @@ public function getVersion() } } -/** @ODM\Document */ +#[ODM\Document] class LockInt extends AbstractVersionBase { - /** - * @ODM\Version - * @ODM\Field(type="int") - * - * @var int|null - */ + /** @var int|null */ + #[ODM\Version] + #[ODM\Field(type: 'int')] public $version; } -/** @ODM\Document */ +#[ODM\Document] class LockDate extends AbstractVersionBase { - /** - * @ODM\Version - * @ODM\Field(type="date") - * - * @var DateTime|null - */ + /** @var DateTime|null */ + #[ODM\Version] + #[ODM\Field(type: 'date')] public $version; } -/** @ODM\Document */ +#[ODM\Document] class LockDateImmutable extends AbstractVersionBase { - /** - * @ODM\Version - * @ODM\Field(type="date_immutable") - * - * @var DateTimeImmutable|null - */ + /** @var DateTimeImmutable|null */ + #[ODM\Version] + #[ODM\Field(type: 'date_immutable')] public $version; } -/** @ODM\Document */ +#[ODM\Document] class LockDecimal128 extends AbstractVersionBase { - /** - * @ODM\Version - * @ODM\Field(type="decimal128") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Version] + #[ODM\Field(type: 'decimal128')] public $version; } -/** @ODM\Document */ +#[ODM\Document] class InvalidLockDocument { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Lock - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Lock] + #[ODM\Field(type: 'string')] public $lock; } -/** @ODM\Document */ +#[ODM\Document] class InvalidVersionDocument { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Version - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Version] + #[ODM\Field(type: 'string')] public $version; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/MappedSuperclassTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/MappedSuperclassTest.php index 5fe5780422..924cdc8e03 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/MappedSuperclassTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/MappedSuperclassTest.php @@ -38,28 +38,19 @@ public function testCRUD(): void } } -/** @ODM\MappedSuperclass */ +#[ODM\MappedSuperclass] class MappedSuperclassBase { - /** - * @ODM\Field(type="string") - * - * @var int|string|null - */ + /** @var int|string|null */ + #[ODM\Field(type: 'string')] private $mapped1; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] private $mapped2; - /** - * @ODM\ReferenceOne(targetDocument=MappedSuperclassRelated1::class) - * - * @var MappedSuperclassRelated1|null - */ + /** @var MappedSuperclassRelated1|null */ + #[ODM\ReferenceOne(targetDocument: MappedSuperclassRelated1::class)] private $mappedRelated1; /** @param int|string $val */ @@ -95,21 +86,15 @@ public function getMappedRelated1(): ?MappedSuperclassRelated1 } } -/** @ODM\Document */ +#[ODM\Document] class MappedSuperclassRelated1 { - /** - * @ODM\Id(strategy="none") - * - * @var int|null - */ + /** @var int|null */ + #[ODM\Id(strategy: 'none')] private $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] private $name; public function setName(string $name): void @@ -133,21 +118,15 @@ public function getId(): ?int } } -/** @ODM\Document */ +#[ODM\Document] class DocumentSubClass extends MappedSuperclassBase { - /** - * @ODM\Id(strategy="none") - * - * @var int|null - */ + /** @var int|null */ + #[ODM\Id(strategy: 'none')] private $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] private $name; public function setName(string $name): void diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/NestedCollectionsTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/NestedCollectionsTest.php index 80020bbf3c..7b4b41d55b 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/NestedCollectionsTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/NestedCollectionsTest.php @@ -77,55 +77,34 @@ public static function provideStrategy(): array } } -/** @ODM\Document */ +#[ODM\Document] class DocWithNestedCollections { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\EmbedMany(strategy="atomicSet", targetDocument=Documents\Phonebook::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(strategy: 'atomicSet', targetDocument: Phonebook::class)] public $atomicSet; - /** - * @ODM\EmbedMany(strategy="atomicSetArray", targetDocument=Documents\Phonebook::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(strategy: 'atomicSetArray', targetDocument: Phonebook::class)] public $atomicSetArray; - /** - * @ODM\EmbedMany(strategy="set", targetDocument=Documents\Phonebook::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(strategy: 'set', targetDocument: Phonebook::class)] public $set; - /** - * @ODM\EmbedMany(strategy="setArray", targetDocument=Documents\Phonebook::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(strategy: 'setArray', targetDocument: Phonebook::class)] public $setArray; - /** - * @ODM\EmbedMany(strategy="pushAll", targetDocument=Documents\Phonebook::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(strategy: 'pushAll', targetDocument: Phonebook::class)] public $pushAll; - /** - * @ODM\EmbedMany(strategy="addToSet", targetDocument=Documents\Phonebook::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(strategy: 'addToSet', targetDocument: Phonebook::class)] public $addToSet; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/NestedDocumentsTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/NestedDocumentsTest.php index 8495c4b3c4..d1998444d8 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/NestedDocumentsTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/NestedDocumentsTest.php @@ -140,28 +140,19 @@ public function testNestedReference(): void } } -/** @ODM\Document */ +#[ODM\Document] class Hierarchy { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] private $id; - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] private $name; - /** - * @ODM\ReferenceMany(targetDocument=Hierarchy::class) - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\ReferenceMany(targetDocument: self::class)] private $children = []; public function __construct(string $name) @@ -227,21 +218,15 @@ public function getChildren() } } -/** @ODM\MappedSuperclass */ +#[ODM\MappedSuperclass] class BaseCategory { - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] protected $name; - /** - * @ODM\EmbedMany(targetDocument=ChildCategory::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: ChildCategory::class)] protected $children; public function __construct(string $name) @@ -303,14 +288,11 @@ public function getChildren(): Collection } } -/** @ODM\Document */ +#[ODM\Document] class Category extends BaseCategory { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] protected $id; public function getId(): ?string @@ -319,55 +301,40 @@ public function getId(): ?string } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class ChildCategory extends BaseCategory { } -/** @ODM\Document */ +#[ODM\Document] class Order { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $title; - /** - * @ODM\EmbedOne(targetDocument=ProductBackup::class) - * - * @var ProductBackup|null - */ + /** @var ProductBackup|null */ + #[ODM\EmbedOne(targetDocument: ProductBackup::class)] public $product; } -/** @ODM\Document */ +#[ODM\Document] class Product { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $title; } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class ProductBackup extends Product { } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/OrphanRemovalEmbedTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/OrphanRemovalEmbedTest.php index c5260df54a..c4e034be80 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/OrphanRemovalEmbedTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/OrphanRemovalEmbedTest.php @@ -162,77 +162,50 @@ private function getAddressRepository(): DocumentRepository } } -/** @ODM\Document */ +#[ODM\Document] class OrphanRemovalCascadeUser { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\EmbedOne(targetDocument=OrphanRemovalCascadeProfile::class) - * - * @var OrphanRemovalCascadeProfile|null - */ + /** @var OrphanRemovalCascadeProfile|null */ + #[ODM\EmbedOne(targetDocument: OrphanRemovalCascadeProfile::class)] public $profile; - /** - * @ODM\EmbedMany(targetDocument=OrphanRemovalCascadeProfile::class) - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\EmbedMany(targetDocument: OrphanRemovalCascadeProfile::class)] public $profileMany = []; } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class OrphanRemovalCascadeProfile { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; - /** - * @ODM\ReferenceOne(targetDocument=OrphanRemovalCascadeAddress::class, orphanRemoval=true, cascade={"all"}) - * - * @var OrphanRemovalCascadeAddress|null - */ + /** @var OrphanRemovalCascadeAddress|null */ + #[ODM\ReferenceOne(targetDocument: OrphanRemovalCascadeAddress::class, orphanRemoval: true, cascade: ['all'])] public $address; - /** - * @ODM\ReferenceMany(targetDocument=OrphanRemovalCascadeAddress::class, orphanRemoval=true, cascade={"all"}) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(targetDocument: OrphanRemovalCascadeAddress::class, orphanRemoval: true, cascade: ['all'])] public $addressMany; } -/** @ODM\Document */ +#[ODM\Document] class OrphanRemovalCascadeAddress { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/OrphanRemovalTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/OrphanRemovalTest.php index 3cbbfb1d31..fbee6a5263 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/OrphanRemovalTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/OrphanRemovalTest.php @@ -303,59 +303,38 @@ private function getProfileRepository(): DocumentRepository } } -/** @ODM\Document */ +#[ODM\Document] class OrphanRemovalUser { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\ReferenceOne(targetDocument=OrphanRemovalProfile::class, orphanRemoval=true) - * - * @var OrphanRemovalProfile|null - */ + /** @var OrphanRemovalProfile|null */ + #[ODM\ReferenceOne(targetDocument: OrphanRemovalProfile::class, orphanRemoval: true)] public $profile; - /** - * @ODM\ReferenceOne(targetDocument=OrphanRemovalProfile::class, orphanRemoval=false) - * - * @var OrphanRemovalProfile|null - */ + /** @var OrphanRemovalProfile|null */ + #[ODM\ReferenceOne(targetDocument: OrphanRemovalProfile::class, orphanRemoval: false)] public $profileNoOrphanRemoval; - /** - * @ODM\ReferenceMany(targetDocument=OrphanRemovalProfile::class, orphanRemoval=true) - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\ReferenceMany(targetDocument: OrphanRemovalProfile::class, orphanRemoval: true)] public $profileMany = []; - /** - * @ODM\ReferenceMany(targetDocument=OrphanRemovalProfile::class, orphanRemoval=false) - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\ReferenceMany(targetDocument: OrphanRemovalProfile::class, orphanRemoval: false)] public $profileManyNoOrphanRemoval = []; } -/** @ODM\Document */ +#[ODM\Document] class OrphanRemovalProfile { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/PrePersistTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/PrePersistTest.php index f926cc22d8..b419ac4d9b 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/PrePersistTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/PrePersistTest.php @@ -28,10 +28,8 @@ public function testPrePersist(): void } } -/** - * @ODM\Document - * @ODM\HasLifecycleCallbacks - */ +#[ODM\Document] +#[ODM\HasLifecycleCallbacks] class PrePersistTestDocument { /** @var int */ @@ -40,27 +38,21 @@ class PrePersistTestDocument /** @var int */ public $preUpdate; - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $field; - /** @ODM\PrePersist */ + #[ODM\PrePersist] public function prePersist(): void { $this->prePersist++; } - /** @ODM\PreUpdate */ + #[ODM\PreUpdate] public function preUpdate(): void { $this->preUpdate++; diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/RawTypeTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/RawTypeTest.php index 90bfecd8c5..1b0c894f22 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/RawTypeTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/RawTypeTest.php @@ -41,20 +41,14 @@ public static function getTestRawTypeData(): array } } -/** @ODM\Document */ +#[ODM\Document] class RawType { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="raw") - * - * @var mixed - */ + /** @var mixed */ + #[ODM\Field(type: 'raw')] public $raw; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/ReadOnlyDocumentTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/ReadOnlyDocumentTest.php index 565430c247..5e7aad58d8 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/ReadOnlyDocumentTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/ReadOnlyDocumentTest.php @@ -78,21 +78,15 @@ public function testCantBeUpdated(): void } } -/** @ODM\Document(readOnly=true) */ +#[ODM\Document(readOnly: true)] class ReadOnlyDocument { - /** - * @ODM\Id - * - * @var ObjectId|null - */ + /** @var ObjectId|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $value; public function __construct(string $value) diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/ReadPreferenceTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/ReadPreferenceTest.php index f27f8fbb68..8135cce282 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/ReadPreferenceTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/ReadPreferenceTest.php @@ -110,16 +110,11 @@ private function assertReadPreferenceHint(int $mode, ReadPreference $readPrefere } } -/** - * @ODM\Document() - * @ODM\ReadPreference("nearest", tags={ { "dc"="east" } }) - */ +#[ODM\Document] +#[ODM\ReadPreference('nearest', tags: [['dc' => 'east']])] class DocumentWithReadPreference { - /** - * @ODM\Id() - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/ReferenceDiscriminatorsTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/ReferenceDiscriminatorsTest.php index 0c30315748..c5cd226aca 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/ReferenceDiscriminatorsTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/ReferenceDiscriminatorsTest.php @@ -91,26 +91,18 @@ public function testReferenceDiscriminatorsRaceCondition(): void } } -/** - * @ODM\Document(collection="rdt_action") - * @ODM\InheritanceType("SINGLE_COLLECTION") - * @ODM\DiscriminatorField("discriminator") - * @ODM\DiscriminatorMap({"action"=Action::class, "commentable_action"=CommentableAction::class}) - */ +#[ODM\Document(collection: 'rdt_action')] +#[ODM\InheritanceType('SINGLE_COLLECTION')] +#[ODM\DiscriminatorField('discriminator')] +#[ODM\DiscriminatorMap(['action' => Action::class, 'commentable_action' => CommentableAction::class])] class Action { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] protected $id; - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] protected $type; public function __construct(string $type) @@ -129,14 +121,11 @@ public function getType(): string } } -/** @ODM\Document */ +#[ODM\Document] class CommentableAction extends Action { - /** - * @ODM\Field(type="collection") * - * - * @var string[] - */ + /** @var string[] */ + #[ODM\Field(type: 'collection')] protected $comments = []; /** @param string[] $comments */ @@ -154,21 +143,15 @@ public function getComments(): array } } -/** @ODM\MappedSuperclass */ +#[ODM\MappedSuperclass] abstract class ActivityStreamItem { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] protected $id; - /** - * @ODM\ReferenceOne(targetDocument=Action::class) - * - * @var Action - */ + /** @var Action */ + #[ODM\ReferenceOne(targetDocument: Action::class)] protected $action; public function __construct(Action $action) @@ -187,17 +170,12 @@ public function getAction(): Action } } -/** - * @ODM\MappedSuperclass - * @ODM\UniqueIndex(keys={"groupId"="asc", "action.$id"="asc"}, options={"unique"=true}) - */ +#[ODM\MappedSuperclass] +#[ODM\UniqueIndex(keys: ['groupId' => 'asc', 'action.$id' => 'asc'], options: ['unique' => true])] abstract class GroupActivityStreamItem extends ActivityStreamItem { - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] protected $groupId; public function __construct(Action $action, string $groupId) @@ -213,27 +191,22 @@ public function getGroupId(): string } } -/** @ODM\Document(collection="rdt_group_main_activity_stream_item") */ +#[ODM\Document(collection: 'rdt_group_main_activity_stream_item')] class GroupMainActivityStreamItem extends GroupActivityStreamItem { } -/** @ODM\Document(collection="rdt_group_members_activity_stream_item") */ +#[ODM\Document(collection: 'rdt_group_members_activity_stream_item')] class GroupMembersActivityStreamItem extends GroupActivityStreamItem { } -/** - * @ODM\MappedSuperclass - * @ODM\UniqueIndex(keys={"userId"="asc", "action.$id"="asc"}, options={"unique"=true}) - */ +#[ODM\MappedSuperclass] +#[ODM\UniqueIndex(keys: ['userId' => 'asc', 'action.$id' => 'asc'], options: ['unique' => true])] abstract class UserActivityStreamItem extends ActivityStreamItem { - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] protected $userId; public function __construct(Action $action, string $userId) @@ -249,12 +222,12 @@ public function getUserId(): string } } -/** @ODM\Document(collection="rdt_user_dashboard_activity_stream_item") */ +#[ODM\Document(collection: 'rdt_user_dashboard_activity_stream_item')] class UserDashboardActivityStreamItem extends UserActivityStreamItem { } -/** @ODM\Document(collection="rdt_user_profile_activity_stream_item") */ +#[ODM\Document(collection: 'rdt_user_profile_activity_stream_item')] class UserProfileActivityStreamItem extends UserActivityStreamItem { } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/ReferencesTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/ReferencesTest.php index 7492518493..10de475900 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/ReferencesTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/ReferencesTest.php @@ -507,62 +507,44 @@ public function testDocumentNotFoundEvent(): void } } -/** @ODM\Document */ +#[ODM\Document] class DocumentWithArrayReference { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\ReferenceOne(targetDocument=DocumentWithArrayId::class) - * - * @var DocumentWithArrayId|null - */ + /** @var DocumentWithArrayId|null */ + #[ODM\ReferenceOne(targetDocument: DocumentWithArrayId::class)] public $referenceOne; } -/** @ODM\Document */ +#[ODM\Document] class DocumentWithArrayId { - /** - * @ODM\Id(strategy="none", options={"type"="hash"}) - * - * @var array - */ + /** @var array */ + #[ODM\Id(strategy: 'none', options: ['type' => 'hash'])] public $id; } -/** @ODM\Document */ +#[ODM\Document] class DocumentWithMongoBinDataReference { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\ReferenceOne(targetDocument=DocumentWithMongoBinDataId::class) - * - * @var DocumentWithMongoBinDataId|null - */ + /** @var DocumentWithMongoBinDataId|null */ + #[ODM\ReferenceOne(targetDocument: DocumentWithMongoBinDataId::class)] public $referenceOne; } -/** @ODM\Document */ +#[ODM\Document] class DocumentWithMongoBinDataId { - /** - * @ODM\Id(strategy="none", options={"type"="bin"}) - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id(strategy: 'none', options: ['type' => 'bin'])] public $id; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/SplObjectHashCollisionsTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/SplObjectHashCollisionsTest.php index 78b2e17305..4d4b34fddb 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/SplObjectHashCollisionsTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/SplObjectHashCollisionsTest.php @@ -82,46 +82,31 @@ private function expectCount(string $prop, int $expected): void } } -/** @ODM\Document */ +#[ODM\Document] class SplColDoc { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; - /** - * @ODM\EmbedOne - * - * @var object|null - */ + /** @var object|null */ + #[ODM\EmbedOne] public $one; - /** - * @ODM\EmbedMany - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\EmbedMany] public $many = []; } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class SplColEmbed { - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $name; public function __construct(string $name) diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/TargetDocumentTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/TargetDocumentTest.php index 3ab4183581..863f5a55cc 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/TargetDocumentTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/TargetDocumentTest.php @@ -52,73 +52,52 @@ public function testDiscriminatorTargetIsResolvable(): void } } -/** @ODM\Document */ +#[ODM\Document] class TargetDocumentTestDocument { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\ReferenceOne(targetDocument=Doctrine\ODM\MongoDB\Tests\Functional\TargetDocumentTestReference::class) - * - * @var TargetDocumentTestReference|null - */ + /** @var TargetDocumentTestReference|null */ + #[ODM\ReferenceOne(targetDocument: TargetDocumentTestReference::class)] public $reference; } -/** @ODM\MappedSuperclass */ +#[ODM\MappedSuperclass] abstract class AbstractTargetDocumentTestReference { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; } -/** @ODM\Document */ +#[ODM\Document] class TargetDocumentTestReference extends AbstractTargetDocumentTestReference { } -/** @ODM\Document */ +#[ODM\Document] class InvalidTargetDocumentTestDocument { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\ReferenceOne(targetDocument="Doctrine\ODM\MongoDB\Tests\Functional\SomeInvalidClass") - * - * @var object|null - */ + /** @var object|null */ + #[ODM\ReferenceOne(targetDocument: 'Doctrine\ODM\MongoDB\Tests\Functional\SomeInvalidClass')] public $reference; } -/** @ODM\Document */ +#[ODM\Document] class InvalidDiscriminatorTargetsTestDocument { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\ReferenceOne(discriminatorField="referencedClass", discriminatorMap={"Foo"="Doctrine\ODM\MongoDB\Tests\Functional\SomeInvalidClass"}) - * - * @var object|null - */ + /** @var object|null */ + #[ODM\ReferenceOne(discriminatorField: 'referencedClass', discriminatorMap: ['Foo' => 'Doctrine\ODM\MongoDB\Tests\Functional\SomeInvalidClass'])] public $reference; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1011Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1011Test.php index dbc72a24e6..701744b7aa 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1011Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1011Test.php @@ -43,21 +43,15 @@ public function testReplaceCollection(): void } } -/** @ODM\Document */ +#[ODM\Document] class GH1011Document { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\EmbedMany(targetDocument=GH1011Embedded::class, strategy="set") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: GH1011Embedded::class, strategy: 'set')] public $embeds; public function __construct() @@ -66,14 +60,11 @@ public function __construct() } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class GH1011Embedded { - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $name; public function __construct(string $name) diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1017Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1017Test.php index 7794ffee52..84b5bb8c92 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1017Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1017Test.php @@ -51,25 +51,19 @@ public function testSPLObjectHashCollisionOnReplacingEmbeddedDoc(): void } } -/** @ODM\Document */ +#[ODM\Document] class GH1017Document { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\EmbedOne(targetDocument=GH1017EmbeddedDocument::class) - * - * @var GH1017EmbeddedDocument|null - */ + /** @var GH1017EmbeddedDocument|null */ + #[ODM\EmbedOne(targetDocument: GH1017EmbeddedDocument::class)] public $embedded; } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class GH1017EmbeddedDocument { } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1058Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1058Test.php index 98be7e8504..deec528fee 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1058Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1058Test.php @@ -57,21 +57,15 @@ public function onFlush(OnFlushEventArgs $args): void } } -/** @ODM\Document */ +#[ODM\Document] class GH1058PersistDocument { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] private $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] private $value; public function getId(): ?string @@ -85,21 +79,15 @@ public function setValue(string $value): void } } -/** @ODM\Document */ +#[ODM\Document] class GH1058UpsertDocument { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] private $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] private $value; public function getId(): ?string diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1107Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1107Test.php index 378b626adb..21afeba89d 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1107Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1107Test.php @@ -19,34 +19,23 @@ public function testOverrideIdStrategy(): void } } -/** - * @ODM\Document - * @ODM\InheritanceType("SINGLE_COLLECTION") - */ +#[ODM\Document] +#[ODM\InheritanceType('SINGLE_COLLECTION')] class GH1107ParentClass { - /** - * @ODM\Id(strategy="NONE") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id(strategy: 'NONE')] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; } -/** @ODM\Document */ +#[ODM\Document] class GH1107ChildClass extends GH1107ParentClass { - /** - * @ODM\Id(strategy="AUTO") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id(strategy: 'AUTO')] public $id; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1117Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1117Test.php index 3d68d12949..7b24e0d154 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1117Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1117Test.php @@ -31,21 +31,15 @@ public function testAddOnUninitializedCollection(): void } } -/** @ODM\Document */ +#[ODM\Document] class GH1117Document { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\EmbedMany(strategy="set", targetDocument=GH1117EmbeddedDocument::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(strategy: 'set', targetDocument: GH1117EmbeddedDocument::class)] public $embeds; public function __construct() @@ -54,14 +48,11 @@ public function __construct() } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class GH1117EmbeddedDocument { - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $value; public function __construct(string $value) diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1138Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1138Test.php index 9e80fcffd7..0f11572ac3 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1138Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1138Test.php @@ -50,21 +50,15 @@ public function testUpdatingDocumentBeforeItsInsertionShouldNotEntailMultipleQue } } -/** @ODM\Document */ +#[ODM\Document] class GH1138Document { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1152Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1152Test.php index a7a6894600..cfee336c63 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1152Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1152Test.php @@ -35,31 +35,22 @@ public function testParentAssociationsInPostLoad(): void } } -/** @ODM\Document */ +#[ODM\Document] class GH1152Parent { public const CLASSNAME = self::class; - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\EmbedOne(targetDocument=GH1152Child::class) - * - * @var GH1152Child|null - */ + /** @var GH1152Child|null */ + #[ODM\EmbedOne(targetDocument: GH1152Child::class)] public $child; } -/** - * @ODM\EmbeddedDocument - * - * @psalm-import-type AssociationFieldMapping from ClassMetadata - */ +/** @psalm-import-type AssociationFieldMapping from ClassMetadata */ +#[ODM\EmbeddedDocument] class GH1152Child { /** @psalm-var array{0: AssociationFieldMapping, 1: object|null, 2: string}|null */ diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1225Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1225Test.php index 007df73fe2..e9a4173159 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1225Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1225Test.php @@ -31,24 +31,16 @@ public function testRemoveAddEmbeddedDocToExistingDocumentWithPreUpdateHook(): v } } -/** - * @ODM\Document - * @ODM\HasLifecycleCallbacks - */ +#[ODM\Document] +#[ODM\HasLifecycleCallbacks] class GH1225Document { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\EmbedMany(strategy="atomicSet", targetDocument=GH1225EmbeddedDocument::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(strategy: 'atomicSet', targetDocument: GH1225EmbeddedDocument::class)] public $embeds; public function __construct() @@ -56,20 +48,17 @@ public function __construct() $this->embeds = new ArrayCollection(); } - /** @ODM\PreUpdate */ + #[ODM\PreUpdate] public function exampleHook(): void { } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class GH1225EmbeddedDocument { - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $value; public function __construct(string $value) diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1229Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1229Test.php index 092778668a..a3bae06157 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1229Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1229Test.php @@ -129,23 +129,17 @@ public function testMethodAWithClone(): void } } -/** @ODM\Document */ +#[ODM\Document] class GH1229Parent { public const CLASSNAME = self::class; - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\EmbedMany(discriminatorField="_class") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(discriminatorField: '_class')] protected $children; public function __construct() @@ -183,23 +177,17 @@ public function reorderChildren(int $starting, int $change): void } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class GH1229Child { public const CLASSNAME = self::class; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; - /** - * @ODM\Field(type="int") - * - * @var int - */ + /** @var int */ + #[ODM\Field(type: 'int')] public $order = 0; public function __construct(string $name) @@ -221,7 +209,7 @@ public function setOrder(int $order): self } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class GH1229ChildTypeB extends GH1229Child { public const CLASSNAME = self::class; diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1232Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1232Test.php index 6153e7ccda..59c9266914 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1232Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1232Test.php @@ -35,34 +35,21 @@ public function testRemoveDoesNotCauseErrors(): void } } -/** @ODM\Document */ +#[ODM\Document] class GH1232Post { public const CLASSNAME = self::class; - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\ReferenceMany(targetDocument=GH1232Comment::class, mappedBy="post", cascade={"remove"}) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(targetDocument: GH1232Comment::class, mappedBy: 'post', cascade: ['remove'])] protected $comments; - /** - * @ODM\ReferenceMany( - * targetDocument=GH1232Comment::class, - * mappedBy="post", - * repositoryMethod="getLongComments", - * ) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(targetDocument: GH1232Comment::class, mappedBy: 'post', repositoryMethod: 'getLongComments')] protected $longComments; public function __construct() @@ -71,21 +58,15 @@ public function __construct() } } -/** @ODM\Document(repositoryClass="GH1232CommentRepository") */ +#[ODM\Document(repositoryClass: 'GH1232CommentRepository')] class GH1232Comment { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\ReferenceOne(targetDocument=GH1232Post::class) - * - * @var GH1232Post|null - */ + /** @var GH1232Post|null */ + #[ODM\ReferenceOne(targetDocument: GH1232Post::class)] public $post; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1275Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1275Test.php index 626b9a05a1..84a5aad4c0 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1275Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1275Test.php @@ -181,21 +181,15 @@ public function testResortEmbedManyCollection(string $strategy): void } } -/** @ODM\Document(collection="item") */ +#[ODM\Document(collection: 'item')] class Item { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $name; /** @var Container */ @@ -208,21 +202,15 @@ public function __construct(Container $c, string $name) } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class Element { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $name; public function __construct(string $name) @@ -231,95 +219,43 @@ public function __construct(string $name) } } -/** @ODM\Document(collection="container") */ +#[ODM\Document(collection: 'container')] class Container { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** @ODM\ReferenceMany( - * targetDocument=Item::class, - * cascade={"refresh","persist"}, - * orphanRemoval="true", - * strategy="atomicSet" - * ) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(targetDocument: Item::class, cascade: ['refresh', 'persist'], orphanRemoval: true, strategy: 'atomicSet')] public $items; - /** - * @ODM\ReferenceOne( - * targetDocument=Item::class, - * cascade={"refresh"} - * ) - * - * @var Item - */ + /** @var Item */ + #[ODM\ReferenceOne(targetDocument: Item::class, cascade: ['refresh'])] public $firstItem; - /** - * @ODM\EmbedMany( - * targetDocument=Element::class, - * strategy="addToSet" - * ) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: Element::class, strategy: 'addToSet')] public $addToSet; - /** - * @ODM\EmbedMany( - * targetDocument=Element::class, - * strategy="set" - * ) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: Element::class, strategy: 'set')] public $set; - /** - * @ODM\EmbedMany( - * targetDocument=Element::class, - * strategy="setArray" - * ) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: Element::class, strategy: 'setArray')] public $setArray; - /** - * @ODM\EmbedMany( - * targetDocument=Element::class, - * strategy="pushAll" - * ) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: Element::class, strategy: 'pushAll')] public $pushAll; - /** - * @ODM\EmbedMany( - * targetDocument=Element::class, - * strategy="atomicSet" - * ) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: Element::class, strategy: 'atomicSet')] public $atomicSet; - /** - * @ODM\EmbedMany( - * targetDocument=Element::class, - * strategy="atomicSetArray" - * ) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: Element::class, strategy: 'atomicSetArray')] public $atomicSetArray; public function __construct() diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1294Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1294Test.php index 82a71cad77..2082c10cbb 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1294Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1294Test.php @@ -37,21 +37,15 @@ public function testRegexSearchOnIdentifierWithUuidStrategy(): void } } -/** @ODM\Document */ +#[ODM\Document] class GH1294User { - /** - * @ODM\Id(strategy="UUID", type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id(strategy: 'UUID', type: 'string')] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name = ''; public function getId(): ?string diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1344Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1344Test.php index e5a966ff29..5db7663df5 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1344Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1344Test.php @@ -46,94 +46,61 @@ public function testGeneratingIndexesWithLongIndexNameDoesNotThrowExceptionAfter } } -/** @ODM\Document */ +#[ODM\Document] class GH1344Main { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\EmbedOne(targetDocument=GH1344Embedded::class) - * - * @var GH1344Embedded|null - */ + /** @var GH1344Embedded|null */ + #[ODM\EmbedOne(targetDocument: GH1344Embedded::class)] public $embedded1; - /** - * @ODM\EmbedOne(targetDocument=GH1344Embedded::class) - * - * @var GH1344Embedded|null - */ + /** @var GH1344Embedded|null */ + #[ODM\EmbedOne(targetDocument: GH1344Embedded::class)] public $embedded2; } -/** - * @ODM\EmbeddedDocument - * @ODM\Index(keys={"property"="asc"}, name="embedded") - */ +#[ODM\EmbeddedDocument] +#[ODM\Index(keys: ['property' => 'asc'], name: 'embedded')] class GH1344Embedded { - /** - * @ODM\Field - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field] public $property; - /** - * @ODM\EmbedOne(targetDocument=GH1344EmbeddedNested::class) - * - * @var GH1344EmbeddedNested|null - */ + /** @var GH1344EmbeddedNested|null */ + #[ODM\EmbedOne(targetDocument: GH1344EmbeddedNested::class)] public $embedded; } -/** - * @ODM\EmbeddedDocument - * @ODM\Index(keys={"property"="asc"}, name="nested") - */ +#[ODM\EmbeddedDocument] +#[ODM\Index(keys: ['property' => 'asc'], name: 'nested')] class GH1344EmbeddedNested { - /** - * @ODM\Field - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field] public $property; } -/** @ODM\Document */ +#[ODM\Document] class GH1344LongIndexName { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\EmbedOne(targetDocument=GH1344LongIndexNameEmbedded::class) - * - * @var GH1344LongIndexNameEmbedded|null - */ + /** @var GH1344LongIndexNameEmbedded|null */ + #[ODM\EmbedOne(targetDocument: GH1344LongIndexNameEmbedded::class)] public $embedded1; } -/** - * @ODM\EmbeddedDocument - * @ODM\Index(keys={"property"="asc"}, name="this_is_a_really_long_name_that_will_cause_problems_for_whoever_tries_to_use_it_whether_in_an_embedded_field_or_not") - */ +#[ODM\EmbeddedDocument] +#[ODM\Index(keys: ['property' => 'asc'], name: 'this_is_a_really_long_name_that_will_cause_problems_for_whoever_tries_to_use_it_whether_in_an_embedded_field_or_not')] class GH1344LongIndexNameEmbedded { - /** - * @ODM\Field - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field] public $property; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1346Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1346Test.php index 32ea5356f2..4f97ab6d06 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1346Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1346Test.php @@ -41,21 +41,15 @@ public function testPublicProperty(): void } -/** @ODM\Document */ +#[ODM\Document] class GH1346Document { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] protected $id; - /** - * @ODM\ReferenceMany(targetDocument=GH1346ReferencedDocument::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(targetDocument: GH1346ReferencedDocument::class)] protected $references; public function __construct() @@ -80,21 +74,15 @@ public function getReferences(): Collection } } -/** @ODM\Document */ +#[ODM\Document] class GH1346ReferencedDocument { - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $test; - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] protected $id; public function setTest(string $test): void diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1418Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1418Test.php index 4414b8d977..d001f9b07f 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1418Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1418Test.php @@ -102,46 +102,31 @@ public function testReadDocumentAndManage(): void } } -/** @ODM\Document */ +#[ODM\Document] class GH1418Document { - /** - * @ODM\Id(strategy="none") - * - * @var int|null - */ + /** @var int|null */ + #[ODM\Id(strategy: 'none')] public $id; - /** - * @ODM\EmbedOne(targetDocument=GH1418Embedded::class) - * - * @var GH1418Embedded|null - */ + /** @var GH1418Embedded|null */ + #[ODM\EmbedOne(targetDocument: GH1418Embedded::class)] public $embedOne; - /** - * @ODM\EmbedMany(targetDocument=GH1418Embedded::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: GH1418Embedded::class)] public $embedMany; } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class GH1418Embedded { - /** - * @ODM\Id(strategy="none", type="int") - * @ODM\AlsoLoad("sourceId") - * - * @var int|null - */ + /** @var int|null */ + #[ODM\Id(strategy: 'none', type: 'int')] + #[ODM\AlsoLoad('sourceId')] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1428Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1428Test.php index 28c2a14df4..232d2d71b6 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1428Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1428Test.php @@ -29,36 +29,27 @@ public function testShortNameLossOnReplacingMiddleEmbeddedDocOfNestedEmbedding() } } -/** @ODM\Document */ +#[ODM\Document] class GH1428Document { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\EmbedOne(targetDocument=GH1428EmbeddedDocument::class) - * - * @var GH1428EmbeddedDocument|null - */ + /** @var GH1428EmbeddedDocument|null */ + #[ODM\EmbedOne(targetDocument: GH1428EmbeddedDocument::class)] public $embedded; } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class GH1428EmbeddedDocument { - /** - * @ODM\EmbedOne(targetDocument=GH1428NestedEmbeddedDocument::class, name="shortNameThatDoesntExist") - * - * @var GH1428NestedEmbeddedDocument|null - */ + /** @var GH1428NestedEmbeddedDocument|null */ + #[ODM\EmbedOne(targetDocument: GH1428NestedEmbeddedDocument::class, name: 'shortNameThatDoesntExist')] public $nestedEmbedded; } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class GH1428NestedEmbeddedDocument { } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1435Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1435Test.php index e995ad47fd..14bf4f5150 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1435Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1435Test.php @@ -67,38 +67,26 @@ public function testUpdateWithIncrement(): void } } -/** @ODM\Document() */ +#[ODM\Document] class GH1435Document { - /** - * @ODM\Id() - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string", nullable=true) - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string', nullable: true)] public $name; } -/** @ODM\Document() */ +#[ODM\Document] class GH1435DocumentIncrement { - /** - * @ODM\Id(strategy="increment") - * - * @var int|null - */ + /** @var int|null */ + #[ODM\Id(strategy: 'increment')] public $id; - /** - * @ODM\Field(type="string", nullable=true) - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string', nullable: true)] public $name; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1525Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1525Test.php index 1b4b53d256..d5770bc3d4 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1525Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1525Test.php @@ -95,35 +95,23 @@ public function testEmbedCloneWithIdStrategyNoneOnParentAndLatePersist(): void } } -/** @ODM\Document(collection="document_test") */ +#[ODM\Document(collection: 'document_test')] class GH1525Document { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $name; - /** - * @ODM\EmbedOne(targetDocument=GH1525Embedded::class) - * - * @var GH1525Embedded|null - */ + /** @var GH1525Embedded|null */ + #[ODM\EmbedOne(targetDocument: GH1525Embedded::class)] public $embedded; - /** - * @ODM\EmbedMany(targetDocument=GH1525Embedded::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: GH1525Embedded::class)] public $embedMany; public function __construct(string $name) @@ -133,28 +121,19 @@ public function __construct(string $name) } } -/** @ODM\Document(collection="document_test_with_auto_ids") */ +#[ODM\Document(collection: 'document_test_with_auto_ids')] class GH1525DocumentIdStrategyNone { - /** - * @ODM\Id(strategy="NONE") - * - * @var string - */ + /** @var string */ + #[ODM\Id(strategy: 'NONE')] public $id; - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $name; - /** - * @ODM\EmbedOne(targetDocument=GH1525Embedded::class) - * - * @var GH1525Embedded|null - */ + /** @var GH1525Embedded|null */ + #[ODM\EmbedOne(targetDocument: GH1525Embedded::class)] public $embedded; public function __construct(string $id, string $name) @@ -164,14 +143,11 @@ public function __construct(string $id, string $name) } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class GH1525Embedded { - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $name; public function __construct(string $name) diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1572Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1572Test.php index 0500546add..c8cc052fff 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1572Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1572Test.php @@ -43,53 +43,35 @@ public function testPersistentCollectionCount(): void } } -/** @ODM\Document */ +#[ODM\Document] class GH1572Blog { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\ReferenceMany(targetDocument=GH1572Post::class, mappedBy="blog") - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\ReferenceMany(targetDocument: GH1572Post::class, mappedBy: 'blog')] public $allPosts = []; - /** - * @ODM\ReferenceMany(targetDocument=GH1572Post::class, mappedBy="blog", sort={"id"="asc"}, limit=2) - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\ReferenceMany(targetDocument: GH1572Post::class, mappedBy: 'blog', sort: ['id' => 'asc'], limit: 2)] public $latestPosts = []; - /** - * @ODM\ReferenceMany(targetDocument=GH1572Post::class, repositoryMethod="getPostsForBlog") - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\ReferenceMany(targetDocument: GH1572Post::class, repositoryMethod: 'getPostsForBlog')] public $latestPostsRepositoryMethod = []; } -/** @ODM\Document(repositoryClass=GH1572PostRepository::class) */ +#[ODM\Document(repositoryClass: GH1572PostRepository::class)] class GH1572Post { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\ReferenceOne(targetDocument=GH1572Blog::class) - * - * @var GH1572Blog - */ + /** @var GH1572Blog */ + #[ODM\ReferenceOne(targetDocument: GH1572Blog::class)] public $blog; public function __construct(GH1572Blog $blog) diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1674Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1674Test.php index 073eff91ed..47c7ac11f4 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1674Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1674Test.php @@ -34,21 +34,15 @@ public function testElemMatchUsesCorrectMapping(): void } } -/** @ODM\Document */ +#[ODM\Document] class GH1674Document { - /** - * @ODM\Id - * - * @var ObjectId|null - */ + /** @var ObjectId|null */ + #[ODM\Id] protected $id; - /** - * @ODM\EmbedMany(targetDocument=GH1674Embedded::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: GH1674Embedded::class)] protected $embedded; public function __construct() @@ -58,13 +52,10 @@ public function __construct() } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class GH1674Embedded { - /** - * @ODM\Field - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field] public $id; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1775Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1775Test.php index 00b6ea9a59..b368948b68 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1775Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1775Test.php @@ -58,32 +58,23 @@ public function testProxyInitializationDoesNotLoseData(): void } } -/** @ODM\MappedSuperclass */ +#[ODM\MappedSuperclass] class GH1775MetaDocument { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="int") - * - * @var int - */ + /** @var int */ + #[ODM\Field(type: 'int')] public $version = 5; } -/** @ODM\Document */ +#[ODM\Document] class GH1775Image { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; public function __construct() @@ -91,39 +82,27 @@ public function __construct() } } -/** @ODM\Document */ +#[ODM\Document] class GH1775Blog { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\ReferenceMany(targetDocument=GH1775Post::class, inversedBy="blogs") - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\ReferenceMany(targetDocument: GH1775Post::class, inversedBy: 'blogs')] public $posts = []; } -/** @ODM\Document */ +#[ODM\Document] class GH1775Post extends GH1775MetaDocument { - /** - * @ODM\ReferenceMany(targetDocument=GH1775Image::class, storeAs=ClassMetadata::REFERENCE_STORE_AS_ID) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(targetDocument: GH1775Image::class, storeAs: ClassMetadata::REFERENCE_STORE_AS_ID)] protected $images; - /** - * @ODM\ReferenceMany(targetDocument=GH1775Blog::class, mappedBy="posts") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(targetDocument: GH1775Blog::class, mappedBy: 'posts')] protected $blogs; /** diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1962Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1962Test.php index 485f1fb673..329abb7afe 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1962Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1962Test.php @@ -65,85 +65,64 @@ public function testFetchingDiscriminatedDocumentsWithoutDiscriminatorMap(): voi } } -/** - * @ODM\MappedSuperclass() - * @ODM\DiscriminatorField("type") - * @ODM\InheritanceType("SINGLE_COLLECTION") - * @ODM\DiscriminatorMap({ - * "foo"=GH1962FooDocument::class, - * "bar"=GH1962BarDocument::class, - * "baz"=GH1962BazDocument::class - * }) - */ +#[ODM\MappedSuperclass] +#[ODM\DiscriminatorField('type')] +#[ODM\InheritanceType('SINGLE_COLLECTION')] +#[ODM\DiscriminatorMap(['foo' => GH1962FooDocument::class, 'bar' => GH1962BarDocument::class, 'baz' => GH1962BazDocument::class])] class GH1962Superclass { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; } -/** @ODM\Document */ +#[ODM\Document] class GH1962FooDocument extends GH1962Superclass { } -/** - * @ODM\MappedSuperclass() - * @ODM\DiscriminatorMap({ - * "bar"=GH1962BarDocument::class, - * "baz"=GH1962BazDocument::class - * }) - */ +#[ODM\MappedSuperclass] +#[ODM\DiscriminatorMap(['bar' => GH1962BarDocument::class, 'baz' => GH1962BazDocument::class])] class GH1962BarSuperclass extends GH1962Superclass { } -/** @ODM\Document */ +#[ODM\Document] class GH1962BarDocument extends GH1962BarSuperclass { } -/** @ODM\Document */ +#[ODM\Document] class GH1962BazDocument extends GH1962BarSuperclass { } -/** - * @ODM\MappedSuperclass() - * @ODM\DiscriminatorField("type") - * @ODM\InheritanceType("SINGLE_COLLECTION") - */ +#[ODM\MappedSuperclass] +#[ODM\DiscriminatorField('type')] +#[ODM\InheritanceType('SINGLE_COLLECTION')] class GH1962SuperclassWithoutDiscriminatorMap { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; } -/** @ODM\Document */ +#[ODM\Document] class GH1962FooDocumentWithoutDiscriminatorMap extends GH1962SuperclassWithoutDiscriminatorMap { } -/** @ODM\MappedSuperclass() */ +#[ODM\MappedSuperclass] class GH1962BarSuperclassWithoutDiscriminatorMap extends GH1962SuperclassWithoutDiscriminatorMap { } -/** @ODM\Document */ +#[ODM\Document] class GH1962BarDocumentWithoutDiscriminatorMap extends GH1962BarSuperclassWithoutDiscriminatorMap { } -/** - * @ODM\Document - * @ODM\DiscriminatorValue(GH1962BazDocumentWithoutDiscriminatorMap::class) - */ +#[ODM\Document] +#[ODM\DiscriminatorValue(GH1962BazDocumentWithoutDiscriminatorMap::class)] class GH1962BazDocumentWithoutDiscriminatorMap extends GH1962BarSuperclassWithoutDiscriminatorMap { } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1964Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1964Test.php index 38437faa6a..0b97560bef 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1964Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1964Test.php @@ -24,13 +24,10 @@ public function testSortMetaShouldReturnCorrectQuery(): void } } -/** @ODM\Document */ +#[ODM\Document] class GH1964Document { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] private $id; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1990Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1990Test.php index dbb6c0eb4e..c1becf358b 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1990Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1990Test.php @@ -30,21 +30,15 @@ public function testInitialisationOfInverseProxy(): void } } -/** @ODM\Document */ +#[ODM\Document] class GH1990Document { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] private $id; - /** - * @ODM\ReferenceOne(targetDocument=GH1990Document::class) - * - * @var GH1990Document|null - */ + /** @var GH1990Document|null */ + #[ODM\ReferenceOne(targetDocument: self::class)] private $parent; public function __construct(?GH1990Document $parent) diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH2002Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH2002Test.php index 4b087eb606..b2211d2f0b 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH2002Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH2002Test.php @@ -85,25 +85,17 @@ public static function getInvalidReferenceData(): array } } -/** - * @ODM\Document - * @ODM\InheritanceType("SINGLE_COLLECTION") - * @ODM\DiscriminatorField("class") - */ +#[ODM\Document] +#[ODM\InheritanceType('SINGLE_COLLECTION')] +#[ODM\DiscriminatorField('class')] class GH2002DocumentA { - /** - * @ODM\Id - * - * @var string - */ + /** @var string */ + #[ODM\Id] public $id; - /** - * @ODM\ReferenceOne(targetDocument=GH2002DocumentA::class, cascade="all") - * - * @var GH2002DocumentA - */ + /** @var GH2002DocumentA */ + #[ODM\ReferenceOne(targetDocument: self::class, cascade: 'all')] public $parentDocument; public function __construct(?GH2002DocumentA $parentDocument = null) @@ -112,26 +104,20 @@ public function __construct(?GH2002DocumentA $parentDocument = null) } } -/** @ODM\Document */ +#[ODM\Document] class GH2002DocumentB extends GH2002DocumentA { } -/** @ODM\Document */ +#[ODM\Document] class GH2002ReferenceWithoutTargetDocument { - /** - * @ODM\Id - * - * @var string - */ + /** @var string */ + #[ODM\Id] public $id; - /** - * @ODM\ReferenceOne(cascade="all") - * - * @var GH2002DocumentA - */ + /** @var GH2002DocumentA */ + #[ODM\ReferenceOne(cascade: 'all')] public $parentDocument; public function __construct(?GH2002DocumentA $parentDocument = null) @@ -140,21 +126,15 @@ public function __construct(?GH2002DocumentA $parentDocument = null) } } -/** @ODM\Document */ +#[ODM\Document] class GH2002ReferenceWithoutTargetDocumentWithDiscriminatorField { - /** - * @ODM\Id - * - * @var string - */ + /** @var string */ + #[ODM\Id] public $id; - /** - * @ODM\ReferenceOne(discriminatorField="referencedClass", cascade="all") - * - * @var GH2002DocumentA - */ + /** @var GH2002DocumentA */ + #[ODM\ReferenceOne(discriminatorField: 'referencedClass', cascade: 'all')] public $parentDocument; public function __construct(?GH2002DocumentA $parentDocument = null) @@ -163,21 +143,15 @@ public function __construct(?GH2002DocumentA $parentDocument = null) } } -/** @ODM\Document */ +#[ODM\Document] class GH2002ReferenceWithDiscriminatorField { - /** - * @ODM\Id - * - * @var string - */ + /** @var string */ + #[ODM\Id] public $id; - /** - * @ODM\ReferenceOne(targetDocument=GH2002DocumentA::class, discriminatorField="referencedClass", cascade="all") - * - * @var GH2002DocumentA - */ + /** @var GH2002DocumentA */ + #[ODM\ReferenceOne(targetDocument: GH2002DocumentA::class, discriminatorField: 'referencedClass', cascade: 'all')] public $parentDocument; public function __construct(?GH2002DocumentA $parentDocument = null) @@ -186,21 +160,15 @@ public function __construct(?GH2002DocumentA $parentDocument = null) } } -/** @ODM\Document */ +#[ODM\Document] class GH2002ReferenceWithPartialDiscriminatorMap { - /** - * @ODM\Id - * - * @var string - */ + /** @var string */ + #[ODM\Id] public $id; - /** - * @ODM\ReferenceOne(discriminatorField="referencedClass", discriminatorMap={"B"=GH2002DocumentB::class}, cascade="all") - * - * @var GH2002DocumentA - */ + /** @var GH2002DocumentA */ + #[ODM\ReferenceOne(discriminatorField: 'referencedClass', discriminatorMap: ['B' => GH2002DocumentB::class], cascade: 'all')] public $parentDocument; public function __construct(?GH2002DocumentA $parentDocument = null) @@ -209,26 +177,18 @@ public function __construct(?GH2002DocumentA $parentDocument = null) } } -/** - * @ODM\Document - * @ODM\InheritanceType("SINGLE_COLLECTION") - * @ODM\DiscriminatorField("type") - * @ODM\DiscriminatorMap({"A"=GH2002DocumentWithDiscriminatorMapA::class}) - */ +#[ODM\Document] +#[ODM\InheritanceType('SINGLE_COLLECTION')] +#[ODM\DiscriminatorField('type')] +#[ODM\DiscriminatorMap(['A' => GH2002DocumentWithDiscriminatorMapA::class])] class GH2002DocumentWithDiscriminatorMapA { - /** - * @ODM\Id - * - * @var string - */ + /** @var string */ + #[ODM\Id] public $id; - /** - * @ODM\ReferenceOne(targetDocument=GH2002DocumentWithDiscriminatorMapA::class, cascade="all") - * - * @var GH2002DocumentWithDiscriminatorMapA - */ + /** @var GH2002DocumentWithDiscriminatorMapA */ + #[ODM\ReferenceOne(targetDocument: self::class, cascade: 'all')] public $parentDocument; public function __construct(?GH2002DocumentWithDiscriminatorMapA $parentDocument = null) @@ -237,7 +197,7 @@ public function __construct(?GH2002DocumentWithDiscriminatorMapA $parentDocument } } -/** @ODM\Document */ +#[ODM\Document] class GH2002DocumentWithDiscriminatorMapB extends GH2002DocumentWithDiscriminatorMapA { } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH2157Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH2157Test.php index b98aaf0838..cbfc95abcb 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH2157Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH2157Test.php @@ -38,28 +38,23 @@ public function testFacetDiscriminatorMapCreation(): void } } -/** - * @ODM\Document(collection="documents") - * @ODM\InheritanceType("SINGLE_COLLECTION") - * @ODM\DiscriminatorField("type") - * @ODM\DiscriminatorMap({"firsttype"=GH2157FirstType::class, "secondtype"=GH2157SecondType::class}) - */ +#[ODM\Document(collection: 'documents')] +#[ODM\InheritanceType('SINGLE_COLLECTION')] +#[ODM\DiscriminatorField('type')] +#[ODM\DiscriminatorMap(['firsttype' => GH2157FirstType::class, 'secondtype' => GH2157SecondType::class])] abstract class GH2157Abstract { - /** - * @ODM\Id - * - * @var string - */ + /** @var string */ + #[ODM\Id] protected $id; } -/** @ODM\Document */ +#[ODM\Document] class GH2157FirstType extends GH2157Abstract { } -/** @ODM\Document */ +#[ODM\Document] class GH2157SecondType extends GH2157Abstract { } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH232Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH232Test.php index 4795f12e1b..14388fa183 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH232Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH232Test.php @@ -38,35 +38,23 @@ public function testReferencedDocumentInsideEmbeddedDocument(): void } } -/** @ODM\Document */ +#[ODM\Document] class Product { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] protected $id; - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $name; - /** - * @ODM\EmbedMany(targetDocument=Price::class) - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\EmbedMany(targetDocument: Price::class)] public $prices = []; - /** - * @ODM\EmbedMany(targetDocument=SubProduct::class) - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\EmbedMany(targetDocument: SubProduct::class)] public $subproducts = []; public function __construct(string $name) @@ -76,14 +64,11 @@ public function __construct(string $name) } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class SubProduct { - /** - * @ODM\EmbedMany(targetDocument=Price::class) - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\EmbedMany(targetDocument: Price::class)] public $prices = []; public function __construct() @@ -92,13 +77,10 @@ public function __construct() } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class Price { - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $price; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH245Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH245Test.php index 84c59b2c67..1572f7f6a9 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH245Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH245Test.php @@ -31,31 +31,22 @@ public function testTest(): void } } -/** @ODM\Document */ +#[ODM\Document] class GH245Order { - /** - * @ODM\Id(strategy="NONE") - * - * @var int|null - */ + /** @var int|null */ + #[ODM\Id(strategy: 'NONE')] public $id; } -/** @ODM\Document */ +#[ODM\Document] class GH245OrderLog { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\ReferenceOne(targetDocument=GH245Order::class) - * - * @var GH245Order|null - */ + /** @var GH245Order|null */ + #[ODM\ReferenceOne(targetDocument: GH245Order::class)] public $order; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH267Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH267Test.php index f4145552af..d8a48dd6f0 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH267Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH267Test.php @@ -61,28 +61,19 @@ public function testNestedReferences(): void } } -/** @ODM\Document(collection="users") */ +#[ODM\Document(collection: 'users')] class GH267User { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] protected $id; - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] protected $name; - /** - * @ODM\ReferenceOne(name="company", targetDocument=GH267Company::class, inversedBy="users") - * - * @var GH267Company|null - */ + /** @var GH267Company|null */ + #[ODM\ReferenceOne(name: 'company', targetDocument: GH267Company::class, inversedBy: 'users')] protected $company; public function __construct(string $name) @@ -121,26 +112,18 @@ public function getCompany(): ?GH267Company } } -/** - * @ODM\Document(collection="companies") - * @ODM\InheritanceType("SINGLE_COLLECTION") - * @ODM\DiscriminatorField("type") - * @ODM\DiscriminatorMap({"seller"=GH267SellerCompany::class, "buyer"=GH267BuyerCompany::class}) - */ +#[ODM\Document(collection: 'companies')] +#[ODM\InheritanceType('SINGLE_COLLECTION')] +#[ODM\DiscriminatorField('type')] +#[ODM\DiscriminatorMap(['seller' => GH267SellerCompany::class, 'buyer' => GH267BuyerCompany::class])] class GH267Company { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] protected $id; - /** - * @ODM\ReferenceMany(targetDocument=GH267User::class, mappedBy="company") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(targetDocument: GH267User::class, mappedBy: 'company')] protected $users; public function setId(string $id): void @@ -166,12 +149,12 @@ public function getUsers(): Collection } } -/** @ODM\Document(collection="companies") */ +#[ODM\Document(collection: 'companies')] class GH267BuyerCompany extends GH267Company { } -/** @ODM\Document(collection="companies") */ +#[ODM\Document(collection: 'companies')] class GH267SellerCompany extends GH267Company { } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH389Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH389Test.php index f911a0cf68..eeb6bb0155 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH389Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH389Test.php @@ -31,21 +31,15 @@ public function testDiscriminatorEmptyEmbeddedDocument(): void } } -/** @ODM\Document */ +#[ODM\Document] class RootDocument { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] protected $id; - /** - * @ODM\EmbedOne(targetDocument=EmptyMappedSuperClass::class) - * - * @var EmptyEmbeddedDocument - */ + /** @var EmptyEmbeddedDocument */ + #[ODM\EmbedOne(targetDocument: EmptyMappedSuperClass::class)] protected $emptyEmbeddedDocument; public function __construct() @@ -64,18 +58,14 @@ public function getEmptyEmbeddedDocument(): EmptyEmbeddedDocument } } -/** - * @ODM\MappedSuperClass - * @ODM\DiscriminatorField("foobar") - * @ODM\DiscriminatorMap({ - * "empty"=EmptyEmbeddedDocument::class - * }) - */ +#[ODM\MappedSuperclass] +#[ODM\DiscriminatorField('foobar')] +#[ODM\DiscriminatorMap(['empty' => EmptyEmbeddedDocument::class])] class EmptyMappedSuperClass { } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class EmptyEmbeddedDocument extends EmptyMappedSuperClass { } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH426Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH426Test.php index ccc03fcf43..1f028a41a5 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH426Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH426Test.php @@ -30,53 +30,35 @@ public function testTest(): void } } -/** @ODM\Document */ +#[ODM\Document] class GH426Form { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\ReferenceMany(targetDocument=GH426Field::class, mappedBy="form", cascade={"all"}) - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\ReferenceMany(targetDocument: GH426Field::class, mappedBy: 'form', cascade: ['all'])] public $fields = []; - /** - * @ODM\ReferenceOne(targetDocument=GH426Field::class, mappedBy="form", sort={"_id":1}) - * - * @var GH426Field|null - */ + /** @var GH426Field|null */ + #[ODM\ReferenceOne(targetDocument: GH426Field::class, mappedBy: 'form', sort: ['_id' => 1])] public $firstField; - /** - * @ODM\ReferenceOne(targetDocument=GH426Field::class, mappedBy="form", sort={"_id":-1}) - * - * @var GH426Field|null - */ + /** @var GH426Field|null */ + #[ODM\ReferenceOne(targetDocument: GH426Field::class, mappedBy: 'form', sort: ['_id' => -1])] public $lastField; } -/** @ODM\Document */ +#[ODM\Document] class GH426Field { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\ReferenceOne(inversedBy="fields", discriminatorMap={"f":GH426Form::class}, discriminatorField="type", cascade={"all"}) - * - * @var GH426Form - */ + /** @var GH426Form */ + #[ODM\ReferenceOne(inversedBy: 'fields', discriminatorMap: ['f' => GH426Form::class], discriminatorField: 'type', cascade: ['all'])] public $form; public function __construct(GH426Form $form) diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH435Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH435Test.php index d4f3fa6324..2c22641c47 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH435Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH435Test.php @@ -24,31 +24,22 @@ public function testOverridingFieldsType(): void } } -/** @ODM\Document */ +#[ODM\Document] class GH435Parent { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] protected $id; - /** - * @ODM\Field(type="int") - * - * @var int|string|null - */ + /** @var int|string|null */ + #[ODM\Field(type: 'int')] protected $test; } -/** @ODM\Document */ +#[ODM\Document] class GH435Child extends GH435Parent { - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] protected $test; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH453Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH453Test.php index bf11f081af..b18a4143eb 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH453Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH453Test.php @@ -300,112 +300,70 @@ private function assertBsonTypeAndValue(int $bsonType, $expectedValue, $document } } -/** @ODM\Document */ +#[ODM\Document] class GH453Document { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="hash") - * - * @var array - */ + /** @var array */ + #[ODM\Field(type: 'hash')] public $hash; - /** - * @ODM\Field(type="collection") - * - * @var string[] - */ + /** @var string[] */ + #[ODM\Field(type: 'collection')] public $colPush; - /** - * @ODM\Field(type="collection") - * - * @var string[] - */ + /** @var string[] */ + #[ODM\Field(type: 'collection')] public $colSet; - /** - * @ODM\EmbedMany(strategy="pushAll")) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(strategy: 'pushAll')] public $embedManyPush; - /** - * @ODM\EmbedMany(strategy="set") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(strategy: 'set')] public $embedManySet; - /** - * @ODM\EmbedMany(strategy="setArray") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(strategy: 'setArray')] public $embedManySetArray; - /** - * @ODM\EmbedMany(strategy="addToSet") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(strategy: 'addToSet')] public $embedManyAddToSet; - /** - * @ODM\ReferenceMany(strategy="pushAll")) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(strategy: 'pushAll')] public $referenceManyPush; - /** - * @ODM\ReferenceMany(strategy="set") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(strategy: 'set')] public $referenceManySet; - /** - * @ODM\ReferenceMany(strategy="setArray") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(strategy: 'setArray')] public $referenceManySetArray; - /** - * @ODM\ReferenceMany(strategy="addToSet") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(strategy: 'addToSet')] public $referenceManyAddToSet; } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class GH453EmbeddedDocument { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; } -/** @ODM\Document */ +#[ODM\Document] class GH453ReferencedDocument { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH467Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH467Test.php index e5eae7cfea..613a906e36 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH467Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH467Test.php @@ -29,56 +29,38 @@ public function testMergeDocumentWithUnsetCollectionFields(): void } } -/** @ODM\Document */ +#[ODM\Document] class GH467Document { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="collection") - * - * @var mixed[] - */ + /** @var mixed[] */ + #[ODM\Field(type: 'collection')] public $col; - /** - * @ODM\EmbedMany(targetDocument=GH467EmbeddedDocument::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: GH467EmbeddedDocument::class)] public $embedMany; - /** - * @ODM\ReferenceMany(targetDocument=GH467EmbeddedDocument::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(targetDocument: GH467EmbeddedDocument::class)] public $refMany; } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class GH467EmbeddedDocument { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; } -/** @ODM\Document */ +#[ODM\Document] class GH467ReferencedDocument { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH499Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH499Test.php index d300b77165..3aca5e256c 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH499Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH499Test.php @@ -36,21 +36,15 @@ public function testSetRefMany(): void } } -/** @ODM\Document */ +#[ODM\Document] class GH499Document { - /** - * @ODM\Id - * - * @var string - */ + /** @var string */ + #[ODM\Id] protected $id; - /** - * @ODM\ReferenceMany(targetDocument=GH499Document::class, storeAs="id", strategy="set") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(targetDocument: self::class, storeAs: 'id', strategy: 'set')] protected $refMany; public function __construct(?ObjectId $id = null) diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH520Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH520Test.php index 35d339db6e..6ff6348414 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH520Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH520Test.php @@ -64,20 +64,14 @@ public function testPrimeWithGetSingleResultWillNotPrimeEntireResultSet(): void } } -/** @ODM\Document */ +#[ODM\Document] class GH520Document { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\ReferenceOne(targetDocument=GH520Document::class, cascade={"persist"}) - * - * @var GH520Document|null - */ + /** @var GH520Document|null */ + #[ODM\ReferenceOne(targetDocument: self::class, cascade: ['persist'])] public $ref; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH529Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH529Test.php index ee2c3cb46e..14bcd970ba 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH529Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH529Test.php @@ -75,35 +75,26 @@ public function testIntIdWithInconsistentValues(): void } } -/** @ODM\Document */ +#[ODM\Document] class GH529AutoIdDocument { - /** - * @ODM\Id - * - * @var ObjectId|null - */ + /** @var ObjectId|null */ + #[ODM\Id] public $id; } -/** @ODM\Document */ +#[ODM\Document] class GH529CustomIdDocument { - /** - * @ODM\Id(strategy="none", type="custom_id") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id(strategy: 'none', type: 'custom_id')] public $id; } -/** @ODM\Document */ +#[ODM\Document] class GH529IntIdDocument { - /** - * @ODM\Id(strategy="none", type="int") - * - * @var float|int|null - */ + /** @var float|int|null */ + #[ODM\Id(strategy: 'none', type: 'int')] public $id; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH560Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH560Test.php index 809638fe9c..2364cd3a5e 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH560Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH560Test.php @@ -114,21 +114,15 @@ public function __call(string $eventName, array $args): void } } -/** @ODM\Document */ +#[ODM\Document] class GH560Document { - /** - * @ODM\Id(strategy="NONE") - * - * @var int|string|null - */ + /** @var int|string|null */ + #[ODM\Id(strategy: 'NONE')] public $id; - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $name; /** @param int|string $id */ diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH561Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH561Test.php index 39dc84771e..0335bd344c 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH561Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH561Test.php @@ -37,21 +37,15 @@ public function testPersistMainDocument(): void } } -/** @ODM\Document */ +#[ODM\Document] class GH561Document { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\EmbedMany(targetDocument=GH561EmbeddedDocument::class, strategy="set") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: GH561EmbeddedDocument::class, strategy: 'set')] public $embeddedDocuments; public function __construct() @@ -60,14 +54,11 @@ public function __construct() } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class GH561EmbeddedDocument { - /** - * @ODM\EmbedMany(targetDocument=GH561AnotherEmbeddedDocument::class, strategy="set") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: GH561AnotherEmbeddedDocument::class, strategy: 'set')] public $embeddedDocuments; public function __construct() @@ -76,14 +67,11 @@ public function __construct() } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class GH561AnotherEmbeddedDocument { - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $name; public function __construct(string $name) diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH566Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH566Test.php index a52f17b6c5..aadc194d69 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH566Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH566Test.php @@ -71,40 +71,23 @@ public function testFoo(): void } } -/** @ODM\Document */ +#[ODM\Document] class GH566Document { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\EmbedOne(targetDocument=GH566EmbeddedDocument::class) - * - * @var GH566EmbeddedDocument|null - */ + /** @var GH566EmbeddedDocument|null */ + #[ODM\EmbedOne(targetDocument: GH566EmbeddedDocument::class)] public $version; - /** - * @ODM\EmbedMany(targetDocument=GH566EmbeddedDocument::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: GH566EmbeddedDocument::class)] public $versions; - /** - * @ODM\ReferenceMany( - * targetDocument=GH566Document::class, - * cascade={"all"}, - * mappedBy="version.parent", - * sort={"version.sequence"="asc"} - * ) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(targetDocument: self::class, cascade: ['all'], mappedBy: 'version.parent', sort: ['version.sequence' => 'asc'])] public $children; public function __construct() @@ -114,20 +97,14 @@ public function __construct() } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class GH566EmbeddedDocument { - /** - * @ODM\Field(type="int") - * - * @var int|null - */ + /** @var int|null */ + #[ODM\Field(type: 'int')] public $sequence = 0; - /** - * @ODM\ReferenceOne(targetDocument=GH566Document::class, cascade={"all"}, inversedBy="children") - * - * @var GH566Document|null - */ + /** @var GH566Document|null */ + #[ODM\ReferenceOne(targetDocument: GH566Document::class, cascade: ['all'], inversedBy: 'children')] public $parent; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH580Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH580Test.php index ca7230b523..18827e0f59 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH580Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH580Test.php @@ -62,21 +62,15 @@ public function testDocumentPersisterShouldClearQueuedInsertsOnMongoException(): } } -/** @ODM\Document */ +#[ODM\Document] class GH580Document { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * @ODM\Index(unique=true) - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] + #[ODM\Index(unique: true)] public $name; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH593Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH593Test.php index fe1880418b..0248d9fd87 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH593Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH593Test.php @@ -100,35 +100,23 @@ public function testReferenceManyInverseSidePreparesFilterCriteria(): void } } -/** @ODM\Document */ +#[ODM\Document] class GH593User { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(name="d", type="bool") - * - * @var bool - */ + /** @var bool */ + #[ODM\Field(name: 'd', type: 'bool')] public $deleted = false; - /** - * @ODM\ReferenceMany(targetDocument=GH593User::class, inversedBy="followedBy", storeAs="id") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(targetDocument: self::class, inversedBy: 'followedBy', storeAs: 'id')] public $following; - /** - * @ODM\ReferenceMany(targetDocument=GH593User::class, mappedBy="following") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(targetDocument: self::class, mappedBy: 'following')] public $followedBy; public function __construct() diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH596Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH596Test.php index 4c47bfe734..0663926425 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH596Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH596Test.php @@ -48,27 +48,18 @@ public function testExpressionPreparationDoesNotInjectFilterCriteria(): void } } -/** @ODM\Document */ +#[ODM\Document] class GH596Document { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; - /** - * @ODM\Field(type="bool") - * - * @var bool|null - */ + /** @var bool|null */ + #[ODM\Field(type: 'bool')] public $deleted = false; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH597Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH597Test.php index c6059e2dc3..8f1bdfd343 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH597Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH597Test.php @@ -120,28 +120,19 @@ private function assertPostDocument(array $expected, GH597Post $post): void } } -/** @ODM\Document() */ +#[ODM\Document] class GH597Post { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\EmbedMany(targetDocument=GH597Comment::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: GH597Comment::class)] public $comments; - /** - * @ODM\ReferenceMany(targetDocument=GH597ReferenceMany::class, storeAs="id") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(targetDocument: GH597ReferenceMany::class, storeAs: 'id')] public $referenceMany; public function __construct() @@ -168,14 +159,11 @@ public function getReferenceMany(): Collection } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class GH597Comment { - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $comment; public function __construct(string $comment) @@ -185,21 +173,15 @@ public function __construct(string $comment) } -/** @ODM\Document */ +#[ODM\Document] class GH597ReferenceMany { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $field; public function __construct(string $field) diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH602Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH602Test.php index acabc171ae..ce38f44edb 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH602Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH602Test.php @@ -103,28 +103,19 @@ private function enableDeletedFilter(string $class): void } } -/** @ODM\Document */ +#[ODM\Document] class GH602User { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(name="user_deleted", type="bool") - * - * @var bool - */ + /** @var bool */ + #[ODM\Field(name: 'user_deleted', type: 'bool')] public $deleted = false; - /** - * @ODM\ReferenceMany(targetDocument=GH602Thing::class, inversedBy="likedBy", storeAs="id") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(targetDocument: GH602Thing::class, inversedBy: 'likedBy', storeAs: 'id')] public $likes; public function __construct() @@ -139,28 +130,19 @@ public function getId(): ?string } } -/** @ODM\Document */ +#[ODM\Document] class GH602Thing { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(name="thing_deleted", type="bool") - * - * @var bool - */ + /** @var bool */ + #[ODM\Field(name: 'thing_deleted', type: 'bool')] public $deleted = false; - /** - * @ODM\ReferenceMany(targetDocument=GH602User::class, mappedBy="likes") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(targetDocument: GH602User::class, mappedBy: 'likes')] public $likedBy; public function __construct() diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH611Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH611Test.php index 652cbbb4c0..9bf0aa7290 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH611Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH611Test.php @@ -119,39 +119,27 @@ public function testPreparationofEmbeddedDocumentValues(): void } } -/** @ODM\Document */ +#[ODM\Document] class GH611Document { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\EmbedOne(targetDocument=GH611EmbeddedDocument::class) - * - * @var GH611EmbeddedDocument|null - */ + /** @var GH611EmbeddedDocument|null */ + #[ODM\EmbedOne(targetDocument: GH611EmbeddedDocument::class)] public $embedded; } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class GH611EmbeddedDocument { - /** - * @ODM\Field(type="int") - * - * @var int - */ + /** @var int */ + #[ODM\Field(type: 'int')] public $id; - /** - * @ODM\Field(name="n", type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(name: 'n', type: 'string')] public $name; public function __construct(int $id, string $name) diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH628Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH628Test.php index 76534a20b2..8d190fa2ab 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH628Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH628Test.php @@ -22,20 +22,14 @@ public function testQueryBuilderShouldOnlyPrepareFirstPartOfRawFields(): void } } -/** @ODM\Document */ +#[ODM\Document] class GH628Document { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(name="f", type="raw") - * - * @var mixed - */ + /** @var mixed */ + #[ODM\Field(name: 'f', type: 'raw')] public $foo; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH665Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH665Test.php index 0df54dac1f..e18d10dd1a 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH665Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH665Test.php @@ -47,28 +47,19 @@ public function testUseAddToSetStrategyOnEmbeddedDocument(): void } } -/** @ODM\Document */ +#[ODM\Document] class GH665Document { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\EmbedMany(targetDocument=GH665Embedded::class, strategy="pushAll") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: GH665Embedded::class, strategy: 'pushAll')] public $embeddedPushAll; - /** - * @ODM\EmbedMany(targetDocument=GH665Embedded::class, strategy="addToSet") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: GH665Embedded::class, strategy: 'addToSet')] public $embeddedAddToSet; public function __construct() @@ -78,14 +69,11 @@ public function __construct() } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class GH665Embedded { - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $name; public function __construct(string $name) diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH788Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH788Test.php index a5bef32ed8..024424fa06 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH788Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH788Test.php @@ -240,120 +240,59 @@ public function testRefOneWithNoTargetAndExternalDiscriminatorMap(): void } } -/** @ODM\Document */ +#[ODM\Document] class GH788Document { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\EmbedMany(targetDocument=GH788ExternEmbedListed::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: GH788ExternEmbedListed::class)] public $externEmbedMany; - /** - * @ODM\EmbedOne(targetDocument=GH788ExternEmbedListed::class) - * - * @var GH788ExternEmbedListed|null - */ + /** @var GH788ExternEmbedListed|null */ + #[ODM\EmbedOne(targetDocument: GH788ExternEmbedListed::class)] public $externEmbedOne; - /** - * @ODM\ReferenceMany(targetDocument=GH788ExternRefListed::class, cascade="all") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(targetDocument: GH788ExternRefListed::class, cascade: 'all')] public $externRefMany; - /** - * @ODM\ReferenceOne(targetDocument=GH788ExternRefListed::class, cascade="all") - * - * @var GH788ExternRefListed - */ + /** @var GH788ExternRefListed */ + #[ODM\ReferenceOne(targetDocument: GH788ExternRefListed::class, cascade: 'all')] public $externRefOne; - /** - * @ODM\EmbedMany( - * discriminatorField="type", - * discriminatorMap={ - * "b"=GH788InlineEmbedListed::class - * } - * ) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(discriminatorField: 'type', discriminatorMap: ['b' => GH788InlineEmbedListed::class])] public $inlineEmbedMany; - /** - * @ODM\EmbedOne( - * discriminatorField="type", - * discriminatorMap={ - * "b"=GH788InlineEmbedListed::class - * } - * ) - * - * @var GH788InlineEmbedListed|null - */ + /** @var GH788InlineEmbedListed|null */ + #[ODM\EmbedOne(discriminatorField: 'type', discriminatorMap: ['b' => GH788InlineEmbedListed::class])] public $inlineEmbedOne; - /** - * @ODM\ReferenceMany( - * discriminatorField="type", - * discriminatorMap={ - * "c"=GH788InlineRefListed::class - * }, - * cascade="all" - * ) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(discriminatorField: 'type', discriminatorMap: ['c' => GH788InlineRefListed::class], cascade: 'all')] public $inlineRefMany; - /** - * @ODM\ReferenceOne( - * discriminatorField="type", - * discriminatorMap={ - * "c"=GH788InlineRefListed::class - * }, - * cascade="all" - * ) - * - * @var GH788InlineRefListed|null - */ + /** @var GH788InlineRefListed|null */ + #[ODM\ReferenceOne(discriminatorField: 'type', discriminatorMap: ['c' => GH788InlineRefListed::class], cascade: 'all')] public $inlineRefOne; - /** - * @ODM\EmbedMany - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany] public $noTargetEmbedMany; - /** - * @ODM\EmbedOne - * - * @var object|null - */ + /** @var object|null */ + #[ODM\EmbedOne] public $noTargetEmbedOne; - /** - * @ODM\ReferenceMany(cascade="all") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(cascade: 'all')] public $noTargetRefMany; - /** - * @ODM\ReferenceOne(cascade="all") - * - * @var object|null - */ + /** @var object|null */ + #[ODM\ReferenceOne(cascade: 'all')] public $noTargetRefOne; public function __construct() @@ -367,124 +306,91 @@ public function __construct() } } -/** - * @ODM\Document - * @ODM\InheritanceType("SINGLE_COLLECTION") - * @ODM\DiscriminatorField("type") - * @ODM\DiscriminatorMap({"a"=GH788DocumentListed::class}) - */ +#[ODM\Document] +#[ODM\InheritanceType('SINGLE_COLLECTION')] +#[ODM\DiscriminatorField('type')] +#[ODM\DiscriminatorMap(['a' => GH788DocumentListed::class])] class GH788DocumentListed extends GH788Document { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; } -/** @ODM\Document */ +#[ODM\Document] class GH788DocumentUnlisted extends GH788DocumentListed { } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class GH788InlineEmbedListed { - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class GH788InlineEmbedUnlisted extends GH788InlineEmbedListed { } -/** @ODM\Document */ +#[ODM\Document] class GH788InlineRefListed { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; } -/** @ODM\Document */ +#[ODM\Document] class GH788InlineRefUnlisted extends GH788InlineRefListed { } -/** - * @ODM\EmbeddedDocument - * @ODM\DiscriminatorField("type") - * @ODM\DiscriminatorMap({"d"=GH788ExternEmbedListed::class}) - */ +#[ODM\EmbeddedDocument] +#[ODM\DiscriminatorField('type')] +#[ODM\DiscriminatorMap(['d' => GH788ExternEmbedListed::class])] class GH788ExternEmbedListed { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; } -/** @ODM\Document */ +#[ODM\Document] class GH788ExternEmbedUnlisted extends GH788ExternEmbedListed { } -/** - * @ODM\Document - * @ODM\InheritanceType("SINGLE_COLLECTION") - * @ODM\DiscriminatorField("type") - * @ODM\DiscriminatorMap({"e"=GH788ExternRefListed::class}) - */ +#[ODM\Document] +#[ODM\InheritanceType('SINGLE_COLLECTION')] +#[ODM\DiscriminatorField('type')] +#[ODM\DiscriminatorMap(['e' => GH788ExternRefListed::class])] class GH788ExternRefListed { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; } -/** @ODM\Document */ +#[ODM\Document] class GH788ExternRefUnlisted extends GH788ExternRefListed { } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH816Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH816Test.php index c3613e54e4..efaf1c2032 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH816Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH816Test.php @@ -33,20 +33,14 @@ public function testPersistAfterDetachWithTitleSet(): void } } -/** @ODM\Document */ +#[ODM\Document] class GH816Document { - /** - * @ODM\Id - * - * @var ObjectId|null - */ + /** @var ObjectId|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $title; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH850Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH850Test.php index ac554639fb..e78ab6481f 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH850Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH850Test.php @@ -22,20 +22,14 @@ public function testPersistWrongReference(): void } } -/** @ODM\Document */ +#[ODM\Document] class GH850Document { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\ReferenceOne - * - * @var object|string - */ + /** @var object|string */ + #[ODM\ReferenceOne] public $refs = ''; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH852Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH852Test.php index 8c3aade7ba..0b4e912e82 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH852Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH852Test.php @@ -110,35 +110,23 @@ public static function provideIdGenerators(): array } } -/** @ODM\Document */ +#[ODM\Document] class GH852Document { - /** - * @ODM\Id(strategy="NONE", type="custom_id") - * - * @var Binary|array - */ + /** @var Binary|array */ + #[ODM\Id(strategy: 'NONE', type: 'custom_id')] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; - /** - * @ODM\ReferenceOne(targetDocument=GH852Document::class, cascade="all") - * - * @var GH852Document - */ + /** @var GH852Document */ + #[ODM\ReferenceOne(targetDocument: self::class, cascade: 'all')] public $refOne; - /** - * @ODM\ReferenceMany(targetDocument=GH852Document::class, cascade="all") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(targetDocument: self::class, cascade: 'all')] public $refMany; public function __construct() diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH878Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH878Test.php index 21c9d1bcad..97ea8595f1 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH878Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH878Test.php @@ -53,42 +53,30 @@ private function getPersistedButDetachedDocument(): GH878Document } } -/** @ODM\Document */ +#[ODM\Document] class GH878Document { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\EmbedOne(targetDocument=GH878SubDocument::class) - * - * @var GH878SubDocument|null - */ + /** @var GH878SubDocument|null */ + #[ODM\EmbedOne(targetDocument: GH878SubDocument::class)] public $embeddedField; } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class GH878SubDocument { - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $some = '2'; } -/** @ODM\Document */ +#[ODM\Document] class GH878OtherDocument { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH880Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH880Test.php index 45a6a7760f..b50a0f1182 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH880Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH880Test.php @@ -40,28 +40,19 @@ public function test880(): void } } -/** @ODM\Document */ +#[ODM\Document] class GH880Document { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $status; - /** - * @ODM\Field(type="int") - * - * @var int - */ + /** @var int */ + #[ODM\Field(type: 'int')] public $category; public function __construct(string $status = '', int $category = 0) diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH897Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH897Test.php index f8ff61347f..5f535db21a 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH897Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH897Test.php @@ -40,55 +40,38 @@ public function testRecomputeSingleDocumentChangesetForManagedDocumentWithoutCha } } -/** @ODM\Document */ +#[ODM\Document] class GH897A { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; } -/** - * @ODM\Document - * @ODM\HasLifecycleCallbacks - */ +#[ODM\Document] +#[ODM\HasLifecycleCallbacks] class GH897B { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; - /** - * @ODM\ReferenceOne(targetDocument=GH897A::class) - * - * @var GH897A|null - */ + /** @var GH897A|null */ + #[ODM\ReferenceOne(targetDocument: GH897A::class)] public $refOne; /** @var DocumentManager|null */ public $dm; - /** @ODM\PreFlush */ + #[ODM\PreFlush] public function preFlush(): void { if (! $this->refOne instanceof GH897A) { diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH921Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH921Test.php index ae3683f9ab..2ce01f8637 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH921Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH921Test.php @@ -66,28 +66,19 @@ public function testPersistentCollectionCountAndIterationShouldBeConsistent(): v } } -/** @ODM\Document */ +#[ODM\Document] class GH921User { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] private $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] private $name; - /** - * @ODM\ReferenceMany(targetDocument=GH921Post::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(targetDocument: GH921Post::class)] private $posts; public function __construct() @@ -122,21 +113,15 @@ public function getPosts(): Collection } } -/** @ODM\Document */ +#[ODM\Document] class GH921Post { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] private $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] private $name; public function getId(): ?string diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH927Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH927Test.php index 7de40dd8a8..357a94d1bd 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH927Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH927Test.php @@ -19,36 +19,27 @@ public function testInheritedClassHasAssociationMapping(): void } } -/** @ODM\Document */ +#[ODM\Document] class GH927Parent { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] protected $id; - /** - * @ODM\ReferenceOne(targetDocument=Doctrine\ODM\MongoDB\Tests\Functional\Ticket\GH927Reference::class) - * - * @var GH927Reference|null - */ + /** @var GH927Reference|null */ + #[ODM\ReferenceOne(targetDocument: GH927Reference::class)] protected $reference; } -/** @ODM\Document */ +#[ODM\Document] class GH927Child extends GH927Parent { } -/** @ODM\Document */ +#[ODM\Document] class GH927Reference { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] protected $id; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH928Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH928Test.php index 28c0c02603..8e23658f5b 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH928Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH928Test.php @@ -33,13 +33,10 @@ public function testNullIdCriteriaShouldNotRemoveEverything(): void } } -/** @ODM\Document */ +#[ODM\Document] class GH928Document { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH936Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH936Test.php index df700f16ef..b2eb71704c 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH936Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH936Test.php @@ -39,21 +39,15 @@ public function testRemoveCascadesThroughProxyDocuments(): void } } -/** @ODM\Document */ +#[ODM\Document] class GH936Document { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\ReferenceOne(targetDocument=GH936Document::class, cascade={"persist","remove"}) - * - * @var GH936Document|null - */ + /** @var GH936Document|null */ + #[ODM\ReferenceOne(targetDocument: self::class, cascade: ['persist', 'remove'])] public $ref; public function __construct(?GH936Document $ref = null) diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH942Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH942Test.php index 96c4e2de1c..44445528d2 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH942Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH942Test.php @@ -52,56 +52,40 @@ public function testDiscriminatorValueUsesClassNameIfNotInMap(): void } } -/** - * @ODM\Document - * @ODM\InheritanceType("SINGLE_COLLECTION") - * @ODM\DiscriminatorField("type") - */ +#[ODM\Document] +#[ODM\InheritanceType('SINGLE_COLLECTION')] +#[ODM\DiscriminatorField('type')] class GH942Document { public const CLASSNAME = self::class; - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; } -/** - * @ODM\Document - * @ODM\InheritanceType("SINGLE_COLLECTION") - * @ODM\DiscriminatorField("type") - * @ODM\DiscriminatorMap({"p"=GH942DocumentParent::class}) - */ +#[ODM\Document] +#[ODM\InheritanceType('SINGLE_COLLECTION')] +#[ODM\DiscriminatorField('type')] +#[ODM\DiscriminatorMap(['p' => GH942DocumentParent::class])] class GH942DocumentParent { public const CLASSNAME = self::class; - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; } -/** @ODM\Document */ +#[ODM\Document] class GH942DocumentChild extends GH942DocumentParent { public const CLASSNAME = self::class; diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH944Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH944Test.php index 5711ea757b..73b77d74c4 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH944Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH944Test.php @@ -38,21 +38,15 @@ public function testIssue(): void } } -/** @ODM\Document */ +#[ODM\Document] class GH944Document { - /** - * @ODM\Id(strategy="auto") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id(strategy: 'auto')] public $id; - /** - * @ODM\EmbedMany - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany] public $data; public function __construct() @@ -72,14 +66,11 @@ public function removeByText(string $text): void } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class GH944Embedded { - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $text; public function __construct(string $text) diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH971Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH971Test.php index d38be1a6f0..d822a7043b 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH971Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH971Test.php @@ -71,47 +71,36 @@ public function testUpsertWillUseProvidedDiscriminator(): void } } -/** - * @ODM\Document - * @ODM\InheritanceType("SINGLE_COLLECTION") - * @ODM\DiscriminatorField("type") - * @ODM\DiscriminatorMap({"car"=Car::class, "bicycle"=Bicycle::class, "tandem"=Tandem::class}) - */ +#[ODM\Document] +#[ODM\InheritanceType('SINGLE_COLLECTION')] +#[ODM\DiscriminatorField('type')] +#[ODM\DiscriminatorMap(['car' => Car::class, 'bicycle' => Bicycle::class, 'tandem' => Tandem::class])] class Vehicle { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; - /** - * @ODM\EmbedMany - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany] public $features; } -/** @ODM\Document */ +#[ODM\Document] class Car extends Vehicle { } -/** @ODM\Document */ +#[ODM\Document] class Bicycle extends Vehicle { } -/** @ODM\Document */ +#[ODM\Document] class Tandem extends Bicycle { } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH977Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH977Test.php index 10527c969a..fe78397dc6 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH977Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH977Test.php @@ -53,27 +53,18 @@ public function testRefreshClearsChangeSet(): void } } -/** @ODM\Document */ +#[ODM\Document] class GH977TestDocument { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $value1; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $value2; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH999Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH999Test.php index 9a0b8ccfcd..db06267d52 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH999Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH999Test.php @@ -41,24 +41,16 @@ public function onFlush(OnFlushEventArgs $args): void } } -/** - * @ODM\Document - * @ODM\HasLifecycleCallbacks - */ +#[ODM\Document] +#[ODM\HasLifecycleCallbacks] class GH999Document { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] private $id; - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] private $name; public function __construct(string $name) @@ -81,7 +73,7 @@ public function setName(string $name): void $this->name = $name; } - /** @ODM\PostUpdate */ + #[ODM\PostUpdate] public function postUpdate(): void { throw new Exception('Did not expect postUpdate to be called when persisting a new document'); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM116Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM116Test.php index 822be82c6e..7f41791207 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM116Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM116Test.php @@ -39,31 +39,20 @@ public function testIssue(): void } } -/** - * @ODM\Document - * @ODM\InheritanceType("COLLECTION_PER_CLASS") * - */ +#[ODM\Document] +#[ODM\InheritanceType('COLLECTION_PER_CLASS')] class MODM116Parent { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] private $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] private $name; - /** - * @ODM\ReferenceOne(targetDocument=MODM116Child::class) * - * - * @var MODM116Child|null - */ + /** @var MODM116Child|null */ + #[ODM\ReferenceOne(targetDocument: MODM116Child::class)] private $child; public function getId(): ?string @@ -92,7 +81,7 @@ public function setChild(MODM116Child $child): void } } -/** @ODM\Document **/ +#[ODM\Document] class MODM116Child extends MODM116Parent { } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM140Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM140Test.php index a97c5083c4..ca5ba83cfe 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM140Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM140Test.php @@ -122,28 +122,19 @@ public function testAddingAnotherEmbeddedDocument(): void } } -/** @ODM\Document */ +#[ODM\Document] class Category { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] protected $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; - /** - * @ODM\EmbedMany(targetDocument=Post::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: Post::class)] public $posts; public function __construct() @@ -152,21 +143,15 @@ public function __construct() } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class Post { - /** - * @ODM\EmbedMany(targetDocument=PostVersion::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: PostVersion::class)] public $versions; - /** - * @ODM\ReferenceMany(targetDocument=Comment::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(targetDocument: Comment::class)] public $comments; public function __construct() @@ -176,14 +161,11 @@ public function __construct() } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class PostVersion { - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $name; public function __construct(string $name) @@ -192,20 +174,14 @@ public function __construct(string $name) } } -/** @ODM\Document */ +#[ODM\Document] class Comment { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] protected $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $content; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM29Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM29Test.php index fc0f5de7a0..5fbadc34a8 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM29Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM29Test.php @@ -55,21 +55,15 @@ public function testTest(): void } } -/** @ODM\Document */ +#[ODM\Document] class MODM29Doc { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] protected $id; - /** - * @ODM\EmbedMany(targetDocument=MODM29Embedded::class, strategy="set") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: MODM29Embedded::class, strategy: 'set')] protected $collection; /** @param Collection $c */ @@ -91,14 +85,11 @@ public function get(): Collection } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class MODM29Embedded { - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] protected $val; public function __construct(string $val) diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM43Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM43Test.php index 55c26e7430..1206279475 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM43Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM43Test.php @@ -26,34 +26,23 @@ public function testTest(): void } } -/** - * @ODM\Document - * @ODM\HasLifecycleCallbacks - */ +#[ODM\Document] +#[ODM\HasLifecycleCallbacks] class Person { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $firstName; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $lastName; - /** @ODM\PreLoad */ + #[ODM\PreLoad] public function preLoad(PreLoadEventArgs $e): void { $data =& $e->getData(); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM45Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM45Test.php index 58a0590016..a292d1a4f6 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM45Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM45Test.php @@ -24,21 +24,15 @@ public function testTest(): void } } -/** @ODM\Document(collection="modm45_test") */ +#[ODM\Document(collection: 'modm45_test')] class MODM45A { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] protected $id; - /** - * @ODM\EmbedOne(targetDocument=MODM45B::class) - * - * @var MODM45B|null - */ + /** @var MODM45B|null */ + #[ODM\EmbedOne(targetDocument: MODM45B::class)] protected $b; public function getId(): ?string @@ -57,14 +51,11 @@ public function setB(MODM45B $b): void } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class MODM45B { - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] protected $val; public function setVal(string $val): void diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM46Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM46Test.php index 26062ca2de..b44eaa782d 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM46Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM46Test.php @@ -25,32 +25,23 @@ public function testTest(): void } } -/** @ODM\Document */ +#[ODM\Document] class MODM46A { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\EmbedOne(targetDocument=MODM46AB::class) - * @ODM\AlsoLoad("c") - * - * @var MODM46AB|null - */ + /** @var MODM46AB|null */ + #[ODM\EmbedOne(targetDocument: MODM46AB::class)] + #[ODM\AlsoLoad('c')] public $b; } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class MODM46AB { - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $value; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM47Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM47Test.php index 1b5f6cf495..563caaaf45 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM47Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM47Test.php @@ -23,24 +23,18 @@ public function testTest(): void } } -/** @ODM\Document */ +#[ODM\Document] class MODM47A { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $b = 'tmp'; - /** @ODM\AlsoLoad("c") */ + #[ODM\AlsoLoad('c')] public function renameC(string $c): void { $this->b = $c; diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM48Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM48Test.php index 7e725cfb66..d29e66d2af 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM48Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM48Test.php @@ -30,21 +30,15 @@ public function testTest(): void } } -/** @ODM\Document */ +#[ODM\Document] class MODM48A { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\EmbedOne(targetDocument=MODM48B::class) - * - * @var MODM48B|null - */ + /** @var MODM48B|null */ + #[ODM\EmbedOne(targetDocument: MODM48B::class)] public $b; public function getId(): ?string @@ -63,14 +57,11 @@ public function setB(MODM48B $b): void } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class MODM48B { - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $val; public function setVal(string $val): void diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM52Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM52Test.php index 5e3443bb15..472798bdaf 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM52Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM52Test.php @@ -39,18 +39,12 @@ public function testTest(): void /** @ODM\MappedSuperClass */ class MODM52Container { - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $value; - /** - * @ODM\EmbedMany(targetDocument=MODM52Embedded::class, strategy="set") - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\EmbedMany(targetDocument: MODM52Embedded::class, strategy: 'set')] public $items = []; /** @param array|null $items */ @@ -80,18 +74,15 @@ public function removeItem(int $i): void } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class MODM52Embedded extends MODM52Container { } -/** @ODM\Document */ +#[ODM\Document] class MODM52Doc extends MODM52Container { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] protected $id; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM56Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM56Test.php index b0f6a470dd..b780aaf617 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM56Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM56Test.php @@ -35,38 +35,24 @@ public function testTest(): void } } -/** - * @ODM\Document - * @ODM\HasLifecycleCallbacks - */ +#[ODM\Document] +#[ODM\HasLifecycleCallbacks] class MODM56Parent { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $name; - /** - * @ODM\Field(type="date") - * - * @var DateTime|null - */ + /** @var DateTime|null */ + #[ODM\Field(type: 'date')] public $updatedAt; - /** - * @ODM\EmbedMany(targetDocument=MODM56Child::class) - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\EmbedMany(targetDocument: MODM56Child::class)] public $children = []; public function __construct(string $name) @@ -74,28 +60,22 @@ public function __construct(string $name) $this->name = $name; } - /** @ODM\PreUpdate */ + #[ODM\PreUpdate] public function preUpdate(): void { $this->updatedAt = new DateTime(); } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class MODM56Child { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $name; public function __construct(string $name) diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM62Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM62Test.php index 6e4376637d..0e2d1e8ae8 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM62Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM62Test.php @@ -25,21 +25,15 @@ public function testTest(): void } } -/** @ODM\Document(collection="modm62_users") */ +#[ODM\Document(collection: 'modm62_users')] class MODM62Document { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="collection") - * - * @var string[] - */ + /** @var string[] */ + #[ODM\Field(type: 'collection')] public $b = ['ok']; /** @param string[] $b */ diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM65Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM65Test.php index b69e0d2753..2ff30d5a93 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM65Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM65Test.php @@ -29,42 +29,24 @@ public function testTest(): void } } -/** @ODM\Document(collection="modm65_users") */ +#[ODM\Document(collection: 'modm65_users')] class MODM65User { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\EmbedOne( - * discriminatorField="php", - * discriminatorMap={ - * "fbu"=Doctrine\ODM\MongoDB\Tests\Functional\Ticket\MODM65SocialNetworkUser::class - * }, - * name="snu" - * ) - * - * @var MODM65SocialNetworkUser|null - */ + /** @var MODM65SocialNetworkUser|null */ + #[ODM\EmbedOne(discriminatorField: 'php', discriminatorMap: ['fbu' => MODM65SocialNetworkUser::class], name: 'snu')] public $socialNetworkUser; } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class MODM65SocialNetworkUser { - /** - * @ODM\Field(name="fN", type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(name: 'fN', type: 'string')] public $firstName; - /** - * @ODM\Field(name="lN", type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(name: 'lN', type: 'string')] public $lastName; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM66Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM66Test.php index bc17fd0034..5e841e9615 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM66Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM66Test.php @@ -62,21 +62,15 @@ public function testRefresh(): void } } -/** @ODM\Document */ +#[ODM\Document] class MODM52A { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] protected $id; - /** - * @ODM\ReferenceMany(targetDocument=MODM52B::class, cascade="all") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(targetDocument: MODM52B::class, cascade: 'all')] protected $b; /** @param array $b */ @@ -92,21 +86,15 @@ public function getB(): Collection } } -/** @ODM\Document */ +#[ODM\Document] class MODM52B { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] protected $id; - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] protected $value; public function __construct(string $v) diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM67Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM67Test.php index 06952e0f49..fc7d7cdb19 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM67Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM67Test.php @@ -107,59 +107,38 @@ public function postUpdate(LifecycleEventArgs $eventArgs): void } } -/** @ODM\Document */ +#[ODM\Document] class MODM67DerivedClass { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\EmbedOne(targetDocument=MODM67EmbeddedObject::class) - * - * @var MODM67EmbeddedObject|null - */ + /** @var MODM67EmbeddedObject|null */ + #[ODM\EmbedOne(targetDocument: MODM67EmbeddedObject::class)] public $embedOne; } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class MODM67EmbeddedObject { - /** - * @ODM\Field(type="int") - * - * @var int|null - */ + /** @var int|null */ + #[ODM\Field(type: 'int')] public $numAccesses = 0; - /** - * @ODM\Field(type="bool") - * - * @var bool|null - */ + /** @var bool|null */ + #[ODM\Field(type: 'bool')] public $prePersist = false; - /** - * @ODM\Field(type="bool") - * - * @var bool|null - */ + /** @var bool|null */ + #[ODM\Field(type: 'bool')] public $postPersist = false; - /** - * @ODM\Field(type="bool") - * - * @var bool|null - */ + /** @var bool|null */ + #[ODM\Field(type: 'bool')] public $preUpdate = false; - /** - * @ODM\Field(type="bool") - * - * @var bool|null - */ + /** @var bool|null */ + #[ODM\Field(type: 'bool')] public $postUpdate = false; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM70Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM70Test.php index 8f68e7d930..eb90a65a00 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM70Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM70Test.php @@ -31,38 +31,23 @@ public function testTest(): void } } -/** @ODM\Document */ +#[ODM\Document] class Avatar { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] protected $id; - /** - * @ODM\Field(name="na", type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(name: 'na', type: 'string')] protected $name; - /** - * @ODM\Field(name="sex", type="int") - * - * @var int - */ + /** @var int */ + #[ODM\Field(name: 'sex', type: 'int')] protected $sex; - /** - * @ODM\EmbedMany( - * targetDocument=AvatarPart::class, - * name="aP" - * ) - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\EmbedMany(targetDocument: AvatarPart::class, name: 'aP')] protected $avatarParts; /** @param AvatarPart[] $avatarParts */ @@ -126,14 +111,11 @@ public function removeAvatarPart(AvatarPart $part): void } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class AvatarPart { - /** - * @ODM\Field(name="col", type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(name: 'col', type: 'string')] protected $color; public function __construct(string $color) diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM72Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM72Test.php index da21d63d7f..0b379d4606 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM72Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM72Test.php @@ -16,20 +16,14 @@ public function testTest(): void } } -/** @ODM\Document */ +#[ODM\Document] class MODM72User { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string", options={"test"="test"}) - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string', options: ['test' => 'test'])] public $name; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM76Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM76Test.php index 549329ba84..c08de061da 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM76Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM76Test.php @@ -29,35 +29,23 @@ public function testTest(): void } } -/** @ODM\Document */ +#[ODM\Document] class MODM76A { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] protected $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] protected $test = 'test'; - /** - * @ODM\EmbedMany(targetDocument=MODM76B::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: MODM76B::class)] protected $b; - /** - * @ODM\ReferenceMany(targetDocument=MODM76C::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(targetDocument: MODM76C::class)] protected $c; /** @@ -88,14 +76,11 @@ public function getId(): ?string } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class MODM76B { - /** - * @ODM\ReferenceOne(targetDocument=MODM76C::class) - * - * @var MODM76C - */ + /** @var MODM76C */ + #[ODM\ReferenceOne(targetDocument: MODM76C::class)] protected $c; public function __construct(MODM76C $c) @@ -109,13 +94,10 @@ public function getC(): MODM76C } } -/** @ODM\Document */ +#[ODM\Document] class MODM76C { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] protected $id; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM81Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM81Test.php index 8d37fb5198..289ca79f52 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM81Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM81Test.php @@ -60,28 +60,19 @@ public function testDocumentIdWithSameProxyId(): void } } -/** @ODM\Document */ +#[ODM\Document] class MODM81TestDocument { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] protected $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] protected $name; - /** - * @ODM\EmbedMany(targetDocument=MODM81TestEmbeddedDocument::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: MODM81TestEmbeddedDocument::class)] protected $embeddedDocuments; public function getId(): ?string @@ -112,28 +103,19 @@ public function setEmbeddedDocuments(array $documents): void } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class MODM81TestEmbeddedDocument { - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $message; - /** - * @ODM\ReferenceOne(targetDocument=MODM81TestDocument::class) - * - * @var MODM81TestDocument - */ + /** @var MODM81TestDocument */ + #[ODM\ReferenceOne(targetDocument: MODM81TestDocument::class)] public $refTodocument1; - /** - * @ODM\ReferenceOne(targetDocument=MODM81TestDocument::class) - * - * @var MODM81TestDocument - */ + /** @var MODM81TestDocument */ + #[ODM\ReferenceOne(targetDocument: MODM81TestDocument::class)] public $refTodocument2; public function __construct(MODM81TestDocument $document1, MODM81TestDocument $document2, string $message) diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM83Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM83Test.php index 19f66e3918..01a32596c7 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM83Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM83Test.php @@ -70,56 +70,38 @@ public function __call(string $method, array $args): void } } -/** @ODM\Document */ +#[ODM\Document] class MODM83TestDocument { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; - /** - * @ODM\EmbedOne(targetDocument=MODM83TestEmbeddedDocument::class) - * - * @var MODM83TestEmbeddedDocument|null - */ + /** @var MODM83TestEmbeddedDocument|null */ + #[ODM\EmbedOne(targetDocument: MODM83TestEmbeddedDocument::class)] public $embedded; } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class MODM83TestEmbeddedDocument { - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; } -/** @ODM\Document */ +#[ODM\Document] class MODM83OtherDocument { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM90Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM90Test.php index 906f896509..fcaa6057d9 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM90Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM90Test.php @@ -87,63 +87,41 @@ public function __call(string $method, array $args): void } } -/** @ODM\Document */ +#[ODM\Document] class MODM90TestDocument { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; - /** - * @ODM\EmbedOne - * ( - * discriminatorField="type", - * discriminatorMap={ - * "test"=MODM90TestEmbeddedDocument::class, - * "test2"=MODM90Test2EmbeddedDocument::class - * } - * ) - * - * @var MODM90TestEmbeddedDocument|MODM90Test2EmbeddedDocument|null - */ + /** @var MODM90TestEmbeddedDocument|MODM90Test2EmbeddedDocument|null */ + #[ODM\EmbedOne(discriminatorField: 'type', discriminatorMap: [ + 'test' => MODM90TestEmbeddedDocument::class, + 'test2' => MODM90Test2EmbeddedDocument::class, + ])] public $embedded; } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class MODM90TestEmbeddedDocument { - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class MODM90Test2EmbeddedDocument { - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; - /** - * @ODM\Field(type="string") The discriminator field is a real property - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $type; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM91Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM91Test.php index e8c740dc50..19d164047b 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM91Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM91Test.php @@ -62,38 +62,26 @@ public function __call(string $method, array $args): void } } -/** @ODM\Document */ +#[ODM\Document] class MODM91TestDocument { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; - /** - * @ODM\EmbedOne(targetDocument=MODM91TestEmbeddedDocument::class) - * - * @var MODM91TestEmbeddedDocument|null - */ + /** @var MODM91TestEmbeddedDocument|null */ + #[ODM\EmbedOne(targetDocument: MODM91TestEmbeddedDocument::class)] public $embedded; } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class MODM91TestEmbeddedDocument { - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM92Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM92Test.php index fab4b11254..98d9a1f0d0 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM92Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM92Test.php @@ -40,22 +40,16 @@ public function testDocumentWithEmbeddedDocuments(): void } } -/** @ODM\Document */ +#[ODM\Document] class MODM92TestDocument { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; // Note: Test case fails with default "pushAll" strategy, but "set" works - /** - * @ODM\EmbedMany(targetDocument=MODM92TestEmbeddedDocument::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: MODM92TestEmbeddedDocument::class)] public $embeddedDocuments; public function __construct() @@ -88,14 +82,11 @@ public function setEmbeddedDocuments($embeddedDocuments): void } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class MODM92TestEmbeddedDocument { - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $name; public function __construct(string $name) diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM95Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM95Test.php index f7cf898654..8289f0aba5 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM95Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM95Test.php @@ -43,22 +43,16 @@ public function testDocumentWithEmbeddedDocuments(): void } } -/** @ODM\Document */ +#[ODM\Document] class MODM95TestDocument { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; // Note: Test case fails with default "pushAll" strategy, but "set" works - /** - * @ODM\EmbedMany(targetDocument=MODM95TestEmbeddedDocument::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: MODM95TestEmbeddedDocument::class)] public $embeddedDocuments; public function __construct() @@ -77,14 +71,11 @@ public function setEmbeddedDocuments(iterable $embeddedDocuments): void } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class MODM95TestEmbeddedDocument { - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $name; public function __construct(string $name) diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/UpsertTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/UpsertTest.php index a2da24e6c9..b33495db14 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/UpsertTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/UpsertTest.php @@ -87,42 +87,27 @@ public function testUpsertsWritesNullableFieldsOnInsert(): void } } -/** @ODM\Document */ +#[ODM\Document] class UpsertTestUser { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(nullable=true) - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(nullable: true)] public $nullableField; - /** - * @ODM\EmbedOne(targetDocument=UpsertTestUserEmbedded::class, nullable=true) - * - * @var UpsertTestUserEmbedded|null - */ + /** @var UpsertTestUserEmbedded|null */ + #[ODM\EmbedOne(targetDocument: UpsertTestUserEmbedded::class, nullable: true)] public $nullableEmbedOne; - /** - * @ODM\ReferenceOne(targetDocument=UpsertTestUser::class, cascade="persist", nullable=true) - * - * @var UpsertTestUser|null - */ + /** @var UpsertTestUser|null */ + #[ODM\ReferenceOne(targetDocument: self::class, cascade: 'persist', nullable: true)] public $nullableReferenceOne; - /** - * @ODM\EmbedMany(targetDocument=UpsertTestUserEmbedded::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: UpsertTestUserEmbedded::class)] public $embedMany; public function __construct() @@ -131,13 +116,10 @@ public function __construct() } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class UpsertTestUserEmbedded { - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $test; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/ValidationTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/ValidationTest.php index de325388b5..042afd4763 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/ValidationTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/ValidationTest.php @@ -89,7 +89,7 @@ public function testCreateUpdateValidatedDocument(): void } } -/** @ODM\Document(collection="SchemaValidated") */ +#[ODM\Document(collection: 'SchemaValidated')] class SchemaValidatedUpdate extends SchemaValidated { } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/VersionTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/VersionTest.php index 12f63f6dd9..4be88525fa 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/VersionTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/VersionTest.php @@ -44,36 +44,24 @@ public function testVersioningWhenManipulatingEmbedMany(): void } } -/** @ODM\Document */ +#[ODM\Document] class VersionedDocument { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="int", name="_version") - * @ODM\Version - * - * @var int - */ + /** @var int */ + #[ODM\Field(type: 'int', name: '_version')] + #[ODM\Version] public $version = 1; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; - /** - * @ODM\EmbedMany(targetDocument=VersionedEmbeddedDocument::class) - * - * @var Collection|array|null - */ + /** @var Collection|array|null */ + #[ODM\EmbedMany(targetDocument: VersionedEmbeddedDocument::class)] public $embedMany = []; public function __construct() @@ -82,21 +70,15 @@ public function __construct() } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class VersionedEmbeddedDocument { - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $value; - /** - * @ODM\EmbedMany(targetDocument=VersionedEmbeddedDocument::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: self::class)] public $embedMany; public function __construct(string $value) diff --git a/tests/Doctrine/ODM/MongoDB/Tests/HydratorTest.php b/tests/Doctrine/ODM/MongoDB/Tests/HydratorTest.php index 87e234b8d2..30191a6da6 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/HydratorTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/HydratorTest.php @@ -179,120 +179,78 @@ public function testReferenceManyWithWrongElementType(): void } } -/** @ODM\Document */ +#[ODM\Document] class HydrationClosureUser { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string", nullable=true) - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string', nullable: true)] public $title = 'Mr.'; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; - /** - * @ODM\Field(type="date") - * - * @var DateTime|null - */ + /** @var DateTime|null */ + #[ODM\Field(type: 'date')] public $birthdate; - /** - * @ODM\ReferenceOne(targetDocument=HydrationClosureReferenceOne::class) - * - * @var HydrationClosureReferenceOne|null - */ + /** @var HydrationClosureReferenceOne|null */ + #[ODM\ReferenceOne(targetDocument: HydrationClosureReferenceOne::class)] public $referenceOne; - /** - * @ODM\ReferenceMany(targetDocument=HydrationClosureReferenceMany::class) - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\ReferenceMany(targetDocument: HydrationClosureReferenceMany::class)] public $referenceMany = []; - /** - * @ODM\EmbedOne(targetDocument=HydrationClosureEmbedOne::class) - * - * @var HydrationClosureEmbedOne|null - */ + /** @var HydrationClosureEmbedOne|null */ + #[ODM\EmbedOne(targetDocument: HydrationClosureEmbedOne::class)] public $embedOne; - /** - * @ODM\EmbedMany(targetDocument=HydrationClosureEmbedMany::class) - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\EmbedMany(targetDocument: HydrationClosureEmbedMany::class)] public $embedMany = []; } -/** @ODM\Document */ +#[ODM\Document] class HydrationClosureReferenceOne { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; } -/** @ODM\Document */ +#[ODM\Document] class HydrationClosureReferenceMany { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class HydrationClosureEmbedMany { - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class HydrationClosureEmbedOne { - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Mapping/BasicInheritanceMappingTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Mapping/BasicInheritanceMappingTest.php index c2d201146e..f4ea08679b 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Mapping/BasicInheritanceMappingTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Mapping/BasicInheritanceMappingTest.php @@ -100,94 +100,63 @@ class TransientBaseClass private $transient2; } -/** @ODM\Document */ +#[ODM\Document] class DocumentSubClass extends TransientBaseClass { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] private $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] private $name; } -/** - * @ODM\MappedSuperclass - * @ODM\ReadPreference("secondary", tags={ { "dc"="east" } }) - */ +#[ODM\MappedSuperclass] +#[ODM\ReadPreference('secondary', tags: [['dc' => 'east']])] class MappedSuperclassBase { - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] private $mapped1; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] private $mapped2; - /** - * @ODM\ReferenceOne(targetDocument=MappedSuperclassRelated1::class) - * - * @var MappedSuperclassRelated1|null - */ + /** @var MappedSuperclassRelated1|null */ + #[ODM\ReferenceOne(targetDocument: MappedSuperclassRelated1::class)] private $mappedRelated1; /** @var mixed */ private $transient; } -/** @ODM\Document */ +#[ODM\Document] class DocumentSubClass2 extends MappedSuperclassBase { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] private $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] private $name; } -/** - * @ODM\File(bucketName="myFile", chunkSizeBytes=112) - * @ODM\DiscriminatorField("type") - */ +#[ODM\File(bucketName: 'myFile', chunkSizeBytes: 112)] +#[ODM\DiscriminatorField('type')] class GridFSParentClass { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] private $id; } -/** @ODM\File */ +#[ODM\File] class GridFSChildClass extends GridFSParentClass { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] private $id; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Mapping/ClassMetadataLoadEventTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Mapping/ClassMetadataLoadEventTest.php index 4f37102c9b..69887c1bbb 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Mapping/ClassMetadataLoadEventTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Mapping/ClassMetadataLoadEventTest.php @@ -35,21 +35,15 @@ public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs): void } } -/** @ODM\Document */ +#[ODM\Document] class LoadEventTestDocument { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] private $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] private $name; /** @var mixed */ diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Mapping/ClassMetadataTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Mapping/ClassMetadataTest.php index af9c04feed..adf80fb6a6 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Mapping/ClassMetadataTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Mapping/ClassMetadataTest.php @@ -982,27 +982,18 @@ class EmbedWithCascadeTest public $address; } -/** @ODM\Document */ +#[ODM\Document] class EmbeddedAssociationsCascadeTest { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\EmbedOne(targetDocument=Documents\Address::class) - * - * @var Address|null - */ + /** @var Address|null */ + #[ODM\EmbedOne(targetDocument: Address::class)] public $address; - /** - * @ODM\EmbedOne(targetDocument=Documents\Address::class) - * - * @var Address|null - */ + /** @var Address|null */ + #[ODM\EmbedOne(targetDocument: Address::class)] public $addresses; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Mapping/ShardKeyInheritanceMappingTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Mapping/ShardKeyInheritanceMappingTest.php index dd6ebe39ab..0836a97be9 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Mapping/ShardKeyInheritanceMappingTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Mapping/ShardKeyInheritanceMappingTest.php @@ -62,83 +62,61 @@ public function testShardKeyCollectionPerClassInheritanceOverriding(): void } -/** - * @ODM\MappedSuperclass - * @ODM\ShardKey(keys={"_id"="asc"}) - */ +#[ODM\MappedSuperclass] +#[ODM\ShardKey(keys: ['_id' => 'asc'])] class ShardedSuperclass { - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] private $name; } -/** @ODM\Document */ +#[ODM\Document] class ShardedSubclass extends ShardedSuperclass { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] private $id; } -/** - * @ODM\Document - * @ODM\InheritanceType("SINGLE_COLLECTION") - * @ODM\ShardKey(keys={"_id"="asc"}) - */ +#[ODM\Document] +#[ODM\InheritanceType('SINGLE_COLLECTION')] +#[ODM\ShardKey(keys: ['_id' => 'asc'])] class ShardedSingleCollInheritance1 { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] private $id; } -/** @ODM\Document */ +#[ODM\Document] class ShardedSingleCollInheritance2 extends ShardedSingleCollInheritance1 { } -/** - * @ODM\Document - * @ODM\ShardKey(keys={"_id"="hashed"}) - */ +#[ODM\Document] +#[ODM\ShardKey(keys: ['_id' => 'hashed'])] class ShardedSingleCollInheritance3 extends ShardedSingleCollInheritance1 { } -/** - * @ODM\Document - * @ODM\InheritanceType("COLLECTION_PER_CLASS") - * @ODM\ShardKey(keys={"_id"="asc"}) - */ +#[ODM\Document] +#[ODM\InheritanceType('COLLECTION_PER_CLASS')] +#[ODM\ShardKey(keys: ['_id' => 'asc'])] class ShardedCollectionPerClass1 { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] private $id; } -/** @ODM\Document */ +#[ODM\Document] class ShardedCollectionPerClass2 extends ShardedCollectionPerClass1 { } -/** - * @ODM\Document - * @ODM\ShardKey(keys={"_id"="hashed"}) - */ +#[ODM\Document] +#[ODM\ShardKey(keys: ['_id' => 'hashed'])] class ShardedCollectionPerClass3 extends ShardedCollectionPerClass1 { } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Persisters/DocumentPersisterGetShardKeyQueryTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Persisters/DocumentPersisterGetShardKeyQueryTest.php index 2c3bd946a6..b9841c08e2 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Persisters/DocumentPersisterGetShardKeyQueryTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Persisters/DocumentPersisterGetShardKeyQueryTest.php @@ -96,114 +96,70 @@ public function testShardByReference(): void } } -/** - * @ODM\Document - * @ODM\ShardKey(keys={"int"="asc","string"="asc","bool"="asc","float"="asc"}) - */ +#[ODM\Document] +#[ODM\ShardKey(keys: ['int' => 'asc', 'string' => 'asc', 'bool' => 'asc', 'float' => 'asc'])] class ShardedByScalars { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="int") - * - * @var int - */ + /** @var int */ + #[ODM\Field(type: 'int')] public $int; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $string; - /** - * @ODM\Field(type="bool") - * - * @var bool|null - */ + /** @var bool|null */ + #[ODM\Field(type: 'bool')] public $bool; - /** - * @ODM\Field(type="float") - * - * @var float|null - */ + /** @var float|null */ + #[ODM\Field(type: 'float')] public $float; } -/** - * @ODM\Document - * @ODM\ShardKey(keys={"oid"="asc","bin"="asc","date"="asc"}) - */ +#[ODM\Document] +#[ODM\ShardKey(keys: ['oid' => 'asc', 'bin' => 'asc', 'date' => 'asc'])] class ShardedByObjects { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="object_id") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'object_id')] public $oid; - /** - * @ODM\Field(type="bin") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'bin')] public $bin; - /** - * @ODM\Field(type="date") - * - * @var DateTime|null - */ + /** @var DateTime|null */ + #[ODM\Field(type: 'date')] public $date; } -/** - * @ODM\Document - * @ODM\ShardKey(keys={"_id"="asc"}) - */ +#[ODM\Document] +#[ODM\ShardKey(keys: ['_id' => 'asc'])] class ShardedById { - /** - * @ODM\Id - * - * @var ObjectId|null - */ + /** @var ObjectId|null */ + #[ODM\Id] public $identifier; } -/** - * @ODM\Document - * @ODM\ShardKey(keys={"reference"="asc"}) - */ +#[ODM\Document] +#[ODM\ShardKey(keys: ['reference' => 'asc'])] class ShardedByReferenceOne { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\ReferenceOne(targetDocument=User::class) - * - * @var User|null - */ + /** @var User|null */ + #[ODM\ReferenceOne(targetDocument: User::class)] public $reference; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Query/BuilderTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Query/BuilderTest.php index fd18a4bc92..9f15207a16 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Query/BuilderTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Query/BuilderTest.php @@ -862,100 +862,65 @@ private static function createGeometry(): Geometry } } -/** - * @ODM\Document - * @ODM\InheritanceType("SINGLE_COLLECTION") - * @ODM\DiscriminatorField("type") - * @ODM\DiscriminatorMap({"ca"=ChildA::class, "cb"=ChildB::class, "cc"=ChildC::class}) - */ +#[ODM\Document] +#[ODM\InheritanceType('SINGLE_COLLECTION')] +#[ODM\DiscriminatorField('type')] +#[ODM\DiscriminatorMap(['ca' => ChildA::class, 'cb' => ChildB::class, 'cc' => ChildC::class])] class ParentClass { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; } -/** @ODM\Document */ +#[ODM\Document] class ChildA extends ParentClass { - /** - * @ODM\ReferenceOne(targetDocument=Documents\Feature::class) - * - * @var Feature|null - */ + /** @var Feature|null */ + #[ODM\ReferenceOne(targetDocument: Feature::class)] public $featureFull; - /** - * @ODM\ReferenceMany(targetDocument=Documents\Feature::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(targetDocument: Feature::class)] public $featureFullMany; - /** - * @ODM\ReferenceOne(targetDocument=Documents\Feature::class) - * - * @var Feature|null - */ + /** @var Feature|null */ + #[ODM\ReferenceOne(targetDocument: Feature::class)] public $conflict; - /** - * @ODM\ReferenceMany(targetDocument=Documents\Feature::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(targetDocument: Feature::class)] public $conflictMany; } -/** @ODM\Document */ +#[ODM\Document] class ChildB extends ParentClass { - /** - * @ODM\ReferenceOne(targetDocument=Documents\Feature::class, storeAs="id") - * - * @var Feature|null - */ + /** @var Feature|null */ + #[ODM\ReferenceOne(targetDocument: Feature::class, storeAs: 'id')] public $featureSimple; - /** - * @ODM\ReferenceMany(targetDocument=Documents\Feature::class, storeAs="id") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(targetDocument: Feature::class, storeAs: 'id')] public $featureSimpleMany; - /** - * @ODM\ReferenceOne(targetDocument=Documents\Feature::class, storeAs="id") - * - * @var Feature|null - */ + /** @var Feature|null */ + #[ODM\ReferenceOne(targetDocument: Feature::class, storeAs: 'id')] public $conflict; - /** - * @ODM\ReferenceMany(targetDocument=Documents\Feature::class, storeAs="id") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(targetDocument: Feature::class, storeAs: 'id')] public $conflictMany; } -/** @ODM\Document */ +#[ODM\Document] class ChildC extends ParentClass { - /** - * @ODM\ReferenceOne(storeAs="dbRef") - * - * @var object|null - */ + /** @var object|null */ + #[ODM\ReferenceOne(storeAs: 'dbRef')] public $featurePartial; - /** - * @ODM\ReferenceMany(storeAs="dbRef") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(storeAs: 'dbRef')] public $featurePartialMany; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/QueryTest.php b/tests/Doctrine/ODM/MongoDB/Tests/QueryTest.php index a9bc4686c2..0d7e2c1e0a 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/QueryTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/QueryTest.php @@ -585,70 +585,43 @@ private function getMockCollection() } } -/** @ODM\Document(collection="people") */ +#[ODM\Document(collection: 'people')] class Person { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $firstName; - /** - * @ODM\ReferenceOne(storeAs="dbRefWithDb") - * - * @var Person|null - */ + /** @var Person|null */ + #[ODM\ReferenceOne(storeAs: 'dbRefWithDb')] public $bestFriend; - /** - * @ODM\ReferenceOne(storeAs="id", targetDocument=Doctrine\ODM\MongoDB\Tests\Person::class) - * - * @var Person|null - */ + /** @var Person|null */ + #[ODM\ReferenceOne(storeAs: 'id', targetDocument: self::class)] public $bestFriendSimple; - /** - * @ODM\ReferenceOne - * - * @var Person|null - */ + /** @var Person|null */ + #[ODM\ReferenceOne] public $bestFriendPartial; - /** - * @ODM\ReferenceMany(storeAs="dbRefWithDb") - * - * @var DoctrineCollection|array - */ + /** @var DoctrineCollection|array */ + #[ODM\ReferenceMany(storeAs: 'dbRefWithDb')] public $friends = []; - /** - * @ODM\ReferenceMany(storeAs="id", targetDocument=Doctrine\ODM\MongoDB\Tests\Person::class) - * - * @var DoctrineCollection|array - */ + /** @var DoctrineCollection|array */ + #[ODM\ReferenceMany(storeAs: 'id', targetDocument: self::class)] public $friendsSimple = []; - /** - * @ODM\ReferenceMany - * - * @var DoctrineCollection|array - */ + /** @var DoctrineCollection|array */ + #[ODM\ReferenceMany] public $friendsPartial = []; - /** - * @ODM\EmbedOne(targetDocument=Pet::class) - * - * @var Pet|null - */ + /** @var Pet|null */ + #[ODM\EmbedOne(targetDocument: Pet::class)] public $pet; public function __construct(string $firstName) @@ -657,21 +630,15 @@ public function __construct(string $firstName) } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class Pet { - /** - * @ODM\ReferenceOne(name="pO", targetDocument=Doctrine\ODM\MongoDB\Tests\Person::class) - * - * @var Person|null - */ + /** @var Person|null */ + #[ODM\ReferenceOne(name: 'pO', targetDocument: Person::class)] public $owner; - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $name; public function __construct(string $name, Person $owner) @@ -681,41 +648,26 @@ public function __construct(string $name, Person $owner) } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class EmbedTest { - /** - * @ODM\EmbedOne(name="eO", targetDocument=Doctrine\ODM\MongoDB\Tests\EmbedTest::class) - * - * @var EmbedTest|null - */ + /** @var EmbedTest|null */ + #[ODM\EmbedOne(name: 'eO', targetDocument: self::class)] public $embeddedOne; - /** - * @ODM\EmbedMany(name="e1", targetDocument=Doctrine\ODM\MongoDB\Tests\EmbedTest::class) - * - * @var DoctrineCollection - */ + /** @var DoctrineCollection */ + #[ODM\EmbedMany(name: 'e1', targetDocument: self::class)] public $embeddedMany; - /** - * @ODM\Field(name="n", type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(name: 'n', type: 'string')] public $name; - /** - * @ODM\ReferenceOne(name="p", targetDocument=Doctrine\ODM\MongoDB\Tests\Person::class) - * - * @var Person|null - */ + /** @var Person|null */ + #[ODM\ReferenceOne(name: 'p', targetDocument: Person::class)] public $person; - /** - * @ODM\EmbedOne(name="eP", targetDocument=Doctrine\ODM\MongoDB\Tests\Pet::class) - * - * @var Pet|null - */ + /** @var Pet|null */ + #[ODM\EmbedOne(name: 'eP', targetDocument: Pet::class)] public $pet; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Tools/ResolveTargetDocumentListenerTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Tools/ResolveTargetDocumentListenerTest.php index 3eb6e2815d..8da3d14626 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Tools/ResolveTargetDocumentListenerTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Tools/ResolveTargetDocumentListenerTest.php @@ -89,42 +89,27 @@ abstract class AbstractResolveTarget implements ResolveTargetInterface { } -/** @ODM\Document */ +#[ODM\Document] class ResolveTargetDocument extends AbstractResolveTarget implements ResolveTargetInterface { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] private $id; - /** - * @ODM\ReferenceOne(targetDocument=Doctrine\ODM\MongoDB\Tests\Tools\ResolveTargetInterface::class) - * - * @var ResolveTargetInterface|null - */ + /** @var ResolveTargetInterface|null */ + #[ODM\ReferenceOne(targetDocument: ResolveTargetInterface::class)] private $refOne; - /** - * @ODM\ReferenceMany(targetDocument=Doctrine\ODM\MongoDB\Tests\Tools\TargetInterface::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(targetDocument: TargetInterface::class)] private $refMany; - /** - * @ODM\EmbedOne(targetDocument=Doctrine\ODM\MongoDB\Tests\Tools\ResolveTargetInterface::class) - * - * @var ResolveTargetInterface|null - */ + /** @var ResolveTargetInterface|null */ + #[ODM\EmbedOne(targetDocument: ResolveTargetInterface::class)] private $embedOne; - /** - * @ODM\EmbedMany(targetDocument=Doctrine\ODM\MongoDB\Tests\Tools\TargetInterface::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: TargetInterface::class)] private $embedMany; public function getId(): ?string @@ -133,14 +118,11 @@ public function getId(): ?string } } -/** @ODM\Document */ +#[ODM\Document] class TargetDocument implements TargetInterface { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] private $id; public function getId(): ?string diff --git a/tests/Doctrine/ODM/MongoDB/Tests/UnitOfWorkTest.php b/tests/Doctrine/ODM/MongoDB/Tests/UnitOfWorkTest.php index c3a22b308c..1ec3e632ca 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/UnitOfWorkTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/UnitOfWorkTest.php @@ -617,34 +617,23 @@ public function __construct(string $name) } } -/** - * @ODM\Document - * @ODM\ChangeTrackingPolicy("NOTIFY") - */ +#[ODM\Document] +#[ODM\ChangeTrackingPolicy('NOTIFY')] class NotifyChangedDocument implements NotifyPropertyChanged { /** @var PropertyChangedListener[] */ private $_listeners = []; - /** - * @ODM\Id(type="int", strategy="none") - * - * @var int|null - */ + /** @var int|null */ + #[ODM\Id(type: 'int', strategy: 'none')] private $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] private $data; - /** - * @ODM\ReferenceMany(targetDocument=NotifyChangedRelatedItem::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(targetDocument: NotifyChangedRelatedItem::class)] private $items; /** @var mixed */ @@ -714,21 +703,15 @@ protected function onPropertyChanged(string $propName, $oldValue, $newValue): vo } } -/** @ODM\Document */ +#[ODM\Document] class NotifyChangedRelatedItem { - /** - * @ODM\Id(type="int", strategy="none") - * - * @var int|null - */ + /** @var int|null */ + #[ODM\Id(type: 'int', strategy: 'none')] private $id; - /** - * @ODM\ReferenceOne(targetDocument=NotifyChangedDocument::class) - * - * @var NotifyChangedDocument|null - */ + /** @var NotifyChangedDocument|null */ + #[ODM\ReferenceOne(targetDocument: NotifyChangedDocument::class)] private $owner; public function getId(): ?int @@ -752,21 +735,15 @@ public function setOwner(NotifyChangedDocument $owner): void } } -/** @ODM\Document */ +#[ODM\Document] class ArrayTest { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] private $id; - /** - * @ODM\Field(type="hash") - * - * @var array|null - */ + /** @var array|null */ + #[ODM\Field(type: 'hash')] public $data; /** @param array|null $data */ @@ -776,89 +753,68 @@ public function __construct(?array $data) } } -/** @ODM\Document */ +#[ODM\Document] class UowCustomIdDocument { - /** - * @ODM\Id(type="custom_id") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id(type: 'custom_id')] public $id; } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class EmbeddedUpsertDocument { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class EmbeddedDocumentWithoutId { } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class EmbeddedDocumentWithId { /** @var bool */ public $preRemove = false; - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** @ODM\PreRemove */ + #[ODM\PreRemove] public function preRemove(): void { $this->preRemove = true; } } -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class EmbeddedDocumentWithIdStrategyNone { - /** - * @ODM\Id(strategy="none") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id(strategy: 'none')] public $id; } -/** @ODM\Document */ +#[ODM\Document] class PersistRemovedEmbeddedDocument { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\EmbedOne(targetDocument=EmbeddedDocumentWithId::class) - * - * @var EmbeddedDocumentWithId - */ + /** @var EmbeddedDocumentWithId */ + #[ODM\EmbedOne(targetDocument: EmbeddedDocumentWithId::class)] public $embedded; } -/** @ODM\MappedSuperclass */ +#[ODM\MappedSuperclass] class MappedSuperclass { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; } diff --git a/tests/Documents/Account.php b/tests/Documents/Account.php index 67a39d1986..2d47b78fb4 100644 --- a/tests/Documents/Account.php +++ b/tests/Documents/Account.php @@ -6,35 +6,23 @@ use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; -/** @ODM\Document */ +#[ODM\Document] class Account { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] private $id; - /** - * @ODM\Field - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field] private $name; - /** - * @ODM\ReferenceOne(storeAs="dbRefWithDb") - * - * @var User|CustomUser|null - */ + /** @var User|CustomUser|null */ + #[ODM\ReferenceOne(storeAs: 'dbRefWithDb')] protected $user; - /** - * @ODM\ReferenceOne(storeAs="dbRef") - * - * @var User|null - */ + /** @var User|null */ + #[ODM\ReferenceOne(storeAs: 'dbRef')] protected $userDbRef; public function getId(): ?string diff --git a/tests/Documents/Address.php b/tests/Documents/Address.php index 820451c394..c3b46c8144 100644 --- a/tests/Documents/Address.php +++ b/tests/Documents/Address.php @@ -6,56 +6,35 @@ use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class Address { - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] private $address; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] private $city; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] private $state; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] private $zipcode; - /** - * @ODM\Field(type="int", strategy="increment") - * - * @var int - */ + /** @var int */ + #[ODM\Field(type: 'int', strategy: 'increment')] public $count = 0; - /** - * @ODM\EmbedOne(targetDocument=Address::class) - * - * @var Address|null - */ + /** @var Address|null */ + #[ODM\EmbedOne(targetDocument: self::class)] private $subAddress; - /** - * @ODM\Field(name="testFieldName", type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(name: 'testFieldName', type: 'string')] private $test; public function setSubAddress(Address $subAddress): void diff --git a/tests/Documents/Agent.php b/tests/Documents/Agent.php index 4dc5312256..7dc8fb452a 100644 --- a/tests/Documents/Agent.php +++ b/tests/Documents/Agent.php @@ -6,23 +6,14 @@ use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; -/** @ODM\Document(collection="agents") */ +#[ODM\Document(collection: 'agents')] class Agent { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\ReferenceOne(discriminatorMap={ - * "server"=Server::class, - * "server_guest"=GuestServer::class - * }) - * - * @var Server|GuestServer|null - */ + /** @var Server|GuestServer|null */ + #[ODM\ReferenceOne(discriminatorMap: ['server' => Server::class, 'server_guest' => GuestServer::class])] public $server; } diff --git a/tests/Documents/Album.php b/tests/Documents/Album.php index d53079f036..76495a6df1 100644 --- a/tests/Documents/Album.php +++ b/tests/Documents/Album.php @@ -8,28 +8,19 @@ use Doctrine\Common\Collections\Collection; use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; -/** @ODM\Document(collection="albums") */ +#[ODM\Document(collection: 'albums')] class Album { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] private $id; - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] private $name; - /** - * @ODM\EmbedMany(targetDocument=Song::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: Song::class)] private $songs; public function __construct(string $name) diff --git a/tests/Documents/Article.php b/tests/Documents/Article.php index 228bca3ee2..4560751234 100644 --- a/tests/Documents/Article.php +++ b/tests/Documents/Article.php @@ -11,42 +11,27 @@ use function array_search; use function in_array; -/** @ODM\Document(collection="articles") */ +#[ODM\Document(collection: 'articles')] class Article { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] private $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] private $title; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] private $body; - /** - * @ODM\Field(type="date") - * - * @var string|UTCDateTime|DateTimeInterface|null - */ + /** @var string|UTCDateTime|DateTimeInterface|null */ + #[ODM\Field(type: 'date')] private $createdAt; - /** - * @ODM\Field(type="collection") - * - * @var int[] - */ + /** @var int[] */ + #[ODM\Field(type: 'collection')] private $tags = []; public function getId(): ?string diff --git a/tests/Documents/Bars/Bar.php b/tests/Documents/Bars/Bar.php index 8dd6f2b094..68240e9e13 100644 --- a/tests/Documents/Bars/Bar.php +++ b/tests/Documents/Bars/Bar.php @@ -8,28 +8,19 @@ use Doctrine\Common\Collections\Collection; use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; -/** @ODM\Document(collection="bars") */ +#[ODM\Document(collection: 'bars')] class Bar { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] private $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] private $name; - /** - * @ODM\EmbedMany(targetDocument=Documents\Bars\Location::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: Location::class)] private $locations; public function __construct(?string $name = null) diff --git a/tests/Documents/Bars/Location.php b/tests/Documents/Bars/Location.php index d9c4cffd5c..aecf83278b 100644 --- a/tests/Documents/Bars/Location.php +++ b/tests/Documents/Bars/Location.php @@ -6,14 +6,11 @@ use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; -/** @ODM\EmbeddedDocument */ +#[ODM\EmbeddedDocument] class Location { - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] private $name; public function __construct(?string $name = null) diff --git a/tests/Documents/BaseCategory.php b/tests/Documents/BaseCategory.php index 15668e88d6..c7706c3179 100644 --- a/tests/Documents/BaseCategory.php +++ b/tests/Documents/BaseCategory.php @@ -7,21 +7,15 @@ use Doctrine\Common\Collections\Collection; use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; -/** @ODM\MappedSuperclass(repositoryClass="Documents\BaseCategoryRepository") */ +#[ODM\MappedSuperclass(repositoryClass: 'Documents\BaseCategoryRepository')] abstract class BaseCategory { - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] protected $name; - /** - * @ODM\EmbedMany(targetDocument=SubCategory::class) - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\EmbedMany(targetDocument: SubCategory::class)] protected $children = []; public function __construct(?string $name = null) diff --git a/tests/Documents/BaseDocument.php b/tests/Documents/BaseDocument.php index 4de4f42248..b107762f35 100644 --- a/tests/Documents/BaseDocument.php +++ b/tests/Documents/BaseDocument.php @@ -6,20 +6,15 @@ use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; -/** - * @ODM\MappedSuperclass - * @ODM\HasLifecycleCallbacks - */ +#[ODM\MappedSuperclass] +#[ODM\HasLifecycleCallbacks] abstract class BaseDocument { /** @var bool */ public $persisted = false; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] protected $inheritedProperty; public function setInheritedProperty(string $value): void @@ -32,7 +27,7 @@ public function getInheritedProperty(): ?string return $this->inheritedProperty; } - /** @ODM\PrePersist */ + #[ODM\PrePersist] public function prePersist(): void { $this->persisted = true; diff --git a/tests/Documents/BaseEmployee.php b/tests/Documents/BaseEmployee.php index 7e60841f05..7fdab418eb 100644 --- a/tests/Documents/BaseEmployee.php +++ b/tests/Documents/BaseEmployee.php @@ -7,63 +7,39 @@ use DateTime; use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; -/** @ODM\MappedSuperclass */ +#[ODM\MappedSuperclass] abstract class BaseEmployee { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] protected $id; - /** - * @ODM\Field(type="int", strategy="increment") - * - * @var int - */ + /** @var int */ + #[ODM\Field(type: 'int', strategy: 'increment')] protected $changes = 0; - /** - * @ODM\Field(type="collection") - * - * @var string[] - */ + /** @var string[] */ + #[ODM\Field(type: 'collection')] protected $notes = []; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] protected $name; - /** - * @ODM\Field(type="float") - * - * @var float|null - */ + /** @var float|null */ + #[ODM\Field(type: 'float')] protected $salary; - /** - * @ODM\Field(type="date") - * - * @var DateTime|null - */ + /** @var DateTime|null */ + #[ODM\Field(type: 'date')] protected $started; - /** - * @ODM\Field(type="date") - * - * @var DateTime|null - */ + /** @var DateTime|null */ + #[ODM\Field(type: 'date')] protected $left; - /** - * @ODM\EmbedOne(targetDocument=Address::class) - * - * @var Address|null - */ + /** @var Address|null */ + #[ODM\EmbedOne(targetDocument: Address::class)] protected $address; public function getId(): ?string diff --git a/tests/Documents/BlogPost.php b/tests/Documents/BlogPost.php index 956e697189..77fa3655c1 100644 --- a/tests/Documents/BlogPost.php +++ b/tests/Documents/BlogPost.php @@ -7,105 +7,63 @@ use Doctrine\Common\Collections\Collection; use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; -/** @ODM\Document */ +#[ODM\Document] class BlogPost { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; - /** - * @ODM\ReferenceMany(targetDocument=Tag::class, inversedBy="blogPosts", cascade={"all"}) - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\ReferenceMany(targetDocument: Tag::class, inversedBy: 'blogPosts', cascade: ['all'])] public $tags = []; - /** - * @ODM\ReferenceMany(targetDocument=Comment::class, mappedBy="parent", cascade={"all"}, prime={"author"}) - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\ReferenceMany(targetDocument: Comment::class, mappedBy: 'parent', cascade: ['all'], prime: ['author'])] public $comments = []; - /** - * @ODM\ReferenceOne(targetDocument=Comment::class, mappedBy="parent", sort={"date"="asc"}) - * - * @var Comment|null - */ + /** @var Comment|null */ + #[ODM\ReferenceOne(targetDocument: Comment::class, mappedBy: 'parent', sort: ['date' => 'asc'])] public $firstComment; - /** - * @ODM\ReferenceOne(targetDocument=Comment::class, mappedBy="parent", sort={"date"="desc"}) - * - * @var Comment|null - */ + /** @var Comment|null */ + #[ODM\ReferenceOne(targetDocument: Comment::class, mappedBy: 'parent', sort: ['date' => 'desc'])] public $latestComment; - /** - * @ODM\ReferenceMany(targetDocument=Comment::class, mappedBy="parent", sort={"date"="desc"}, limit=5) - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\ReferenceMany(targetDocument: Comment::class, mappedBy: 'parent', sort: ['date' => 'desc'], limit: 5)] public $last5Comments = []; - /** - * @ODM\ReferenceMany(targetDocument=Comment::class, mappedBy="parent", criteria={"isByAdmin"=true}, sort={"date"="desc"}) - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\ReferenceMany(targetDocument: Comment::class, mappedBy: 'parent', criteria: ['isByAdmin' => true], sort: ['date' => 'desc'])] public $adminComments = []; - /** - * @ODM\ReferenceOne(targetDocument=Comment::class, mappedBy="parent", repositoryMethod="findOneComment") - * - * @var Comment|null - */ + /** @var Comment|null */ + #[ODM\ReferenceOne(targetDocument: Comment::class, mappedBy: 'parent', repositoryMethod: 'findOneComment')] public $repoComment; - /** - * @ODM\ReferenceMany(targetDocument=Comment::class, mappedBy="parent", repositoryMethod="findManyComments") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(targetDocument: Comment::class, mappedBy: 'parent', repositoryMethod: 'findManyComments')] public $repoComments; - /** - * @ODM\ReferenceMany(targetDocument=Comment::class, mappedBy="parent", repositoryMethod="findManyComments", prime={"author"}) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(targetDocument: Comment::class, mappedBy: 'parent', repositoryMethod: 'findManyComments', prime: ['author'])] public $repoCommentsWithPrimer; - /** - * @ODM\ReferenceMany(targetDocument=Comment::class, mappedBy="parent", strategy="set", repositoryMethod="findManyComments") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(targetDocument: Comment::class, mappedBy: 'parent', strategy: 'set', repositoryMethod: 'findManyComments')] public $repoCommentsSet; - /** - * @ODM\ReferenceMany(targetDocument=Comment::class, repositoryMethod="findManyComments") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(targetDocument: Comment::class, repositoryMethod: 'findManyComments')] public $repoCommentsWithoutMappedBy; - /** - * @ODM\ReferenceOne(targetDocument=User::class, inversedBy="posts", nullable=true) - * - * @var User|null - */ + /** @var User|null */ + #[ODM\ReferenceOne(targetDocument: User::class, inversedBy: 'posts', nullable: true)] public $user; public function __construct(?string $name = null) diff --git a/tests/Documents/BlogTagAggregation.php b/tests/Documents/BlogTagAggregation.php index 62ea49fe5d..250f438c6e 100644 --- a/tests/Documents/BlogTagAggregation.php +++ b/tests/Documents/BlogTagAggregation.php @@ -6,20 +6,14 @@ use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; -/** @ODM\QueryResultDocument */ +#[ODM\QueryResultDocument] class BlogTagAggregation { - /** - * @ODM\ReferenceOne(targetDocument=Tag::class, name="_id") - * - * @var Tag|null - */ + /** @var Tag|null */ + #[ODM\ReferenceOne(targetDocument: Tag::class, name: '_id')] public $tag; - /** - * @ODM\Field(type="int") - * - * @var int|null - */ + /** @var int|null */ + #[ODM\Field(type: 'int')] public $numPosts; } diff --git a/tests/Documents/Book.php b/tests/Documents/Book.php index 06fdedaf3a..5b30d2ddcc 100644 --- a/tests/Documents/Book.php +++ b/tests/Documents/Book.php @@ -8,38 +8,26 @@ use Doctrine\Common\Collections\Collection; use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; -/** @ODM\Document */ +#[ODM\Document] class Book { public const CLASSNAME = self::class; - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="int") - * @ODM\Version - * - * @var int|null - */ + /** @var int|null */ + #[ODM\Field(type: 'int')] + #[ODM\Version] public $version = 1; - /** - * @ODM\EmbedMany(targetDocument=Chapter::class, strategy="atomicSet") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: Chapter::class, strategy: 'atomicSet')] public $chapters; - /** - * @ODM\EmbedMany(targetDocument=IdentifiedChapter::class, strategy="atomicSet") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: IdentifiedChapter::class, strategy: 'atomicSet')] public $identifiedChapters; public function __construct() diff --git a/tests/Documents/BrowseNode.php b/tests/Documents/BrowseNode.php index aba009a45e..c2a4bf0eb9 100644 --- a/tests/Documents/BrowseNode.php +++ b/tests/Documents/BrowseNode.php @@ -8,35 +8,23 @@ use Doctrine\Common\Collections\Collection; use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; -/** @ODM\Document */ +#[ODM\Document] class BrowseNode { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; - /** - * @ODM\ReferenceOne(targetDocument=BrowseNode::class, inversedBy="children", cascade={"all"}) - * - * @var BrowseNode|null - */ + /** @var BrowseNode|null */ + #[ODM\ReferenceOne(targetDocument: self::class, inversedBy: 'children', cascade: ['all'])] public $parent; - /** - * @ODM\ReferenceMany(targetDocument=BrowseNode::class, mappedBy="parent", cascade={"all"}) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(targetDocument: self::class, mappedBy: 'parent', cascade: ['all'])] public $children; public function __construct(?string $name = null) diff --git a/tests/Documents/Cart.php b/tests/Documents/Cart.php index 9d7b59d8e9..3b72a9efb6 100644 --- a/tests/Documents/Cart.php +++ b/tests/Documents/Cart.php @@ -6,27 +6,18 @@ use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; -/** @ODM\Document */ +#[ODM\Document] class Cart { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="int") - * - * @var int - */ + /** @var int */ + #[ODM\Field(type: 'int')] public $numItems = 0; - /** - * @ODM\ReferenceOne(targetDocument=Customer::class, inversedBy="cart") - * - * @var Customer|null - */ + /** @var Customer|null */ + #[ODM\ReferenceOne(targetDocument: Customer::class, inversedBy: 'cart')] public $customer; } diff --git a/tests/Documents/Category.php b/tests/Documents/Category.php index 631e33671a..cac07afaa0 100644 --- a/tests/Documents/Category.php +++ b/tests/Documents/Category.php @@ -6,13 +6,10 @@ use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; -/** @ODM\Document */ +#[ODM\Document] class Category extends BaseCategory { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] private $id; } diff --git a/tests/Documents/Chapter.php b/tests/Documents/Chapter.php index 73fc63fa9a..05b59eefaf 100644 --- a/tests/Documents/Chapter.php +++ b/tests/Documents/Chapter.php @@ -8,31 +8,20 @@ use Doctrine\Common\Collections\Collection; use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; -/** - * @ODM\EmbeddedDocument - * @ODM\HasLifecycleCallbacks - */ +#[ODM\EmbeddedDocument] +#[ODM\HasLifecycleCallbacks] class Chapter { - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; - /** - * @ODM\EmbedMany(targetDocument=Page::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\EmbedMany(targetDocument: Page::class)] public $pages; - /** - * @ODM\Field(type="int") - * - * @var int - */ + /** @var int */ + #[ODM\Field(type: 'int')] public $nbPages = 0; public function __construct(?string $name = null) @@ -41,7 +30,7 @@ public function __construct(?string $name = null) $this->pages = new ArrayCollection(); } - /** @ODM\PostUpdate */ + #[ODM\PostUpdate] public function doThisAfterAnUpdate(): void { /* Do not do this at home, it is here only to see if nothing breaks, diff --git a/tests/Documents/CmsAddress.php b/tests/Documents/CmsAddress.php index 63f7bb6c30..1cfb936ca8 100644 --- a/tests/Documents/CmsAddress.php +++ b/tests/Documents/CmsAddress.php @@ -5,48 +5,30 @@ namespace Documents; use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; +use Doctrine\ODM\MongoDB\Mapping\Annotations\Index; -/** - * @ODM\Document - * @ODM\Indexes({ - * @ODM\Index(keys={"country"="asc", "zip"="asc", "city"="asc"}) - * }) - */ +#[Index(keys: ['country' => 'asc', 'zip' => 'asc', 'city' => 'asc'])] +#[ODM\Document] class CmsAddress { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $country; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $zip; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $city; - /** - * @ODM\ReferenceOne(targetDocument=CmsUser::class) - * - * @var CmsUser|null - */ + /** @var CmsUser|null */ + #[ODM\ReferenceOne(targetDocument: CmsUser::class)] public $user; public function getId(): ?string diff --git a/tests/Documents/CmsArticle.php b/tests/Documents/CmsArticle.php index 8035cc56b3..d78f60bbe9 100644 --- a/tests/Documents/CmsArticle.php +++ b/tests/Documents/CmsArticle.php @@ -6,50 +6,29 @@ use Doctrine\Common\Collections\Collection; use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; +use Doctrine\ODM\MongoDB\Mapping\Annotations\Index; -/** - * @ODM\Document - * @ODM\Indexes({ - * @ODM\Index(keys={"topic"="asc"}) - * }) - */ +#[Index(keys: ['topic' => 'asc'])] +#[ODM\Document] class CmsArticle { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $topic; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $title; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $text; - /** - * @ODM\ReferenceOne(targetDocument=CmsUser::class) - * - * @var CmsUser|null - */ + /** @var CmsUser|null */ + #[ODM\ReferenceOne(targetDocument: CmsUser::class)] public $user; - /** - * @ODM\ReferenceMany(targetDocument=CmsComment::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(targetDocument: CmsComment::class)] public $comments; public function setAuthor(CmsUser $author): void diff --git a/tests/Documents/CmsComment.php b/tests/Documents/CmsComment.php index 59ed4edade..1c96292047 100644 --- a/tests/Documents/CmsComment.php +++ b/tests/Documents/CmsComment.php @@ -5,55 +5,34 @@ namespace Documents; use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; +use Doctrine\ODM\MongoDB\Mapping\Annotations\Index; -/** - * @ODM\Document - * @ODM\Indexes({ - * @ODM\Index(keys={"topic"="asc"}) - * }) - */ +#[Index(keys: ['topic' => 'asc'])] +#[ODM\Document] class CmsComment { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field] public $topic; - /** - * @ODM\Field - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field] public $text; - /** - * @ODM\ReferenceOne(targetDocument=CmsArticle::class) - * - * @var CmsArticle|null - */ + /** @var CmsArticle|null */ + #[ODM\ReferenceOne(targetDocument: CmsArticle::class)] public $article; - /** - * @ODM\Field(name="ip", type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(name: 'ip', type: 'string')] public $authorIp; - /** - * @ODM\Field(type="string", nullable=true) - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string', nullable: true)] public $nullableField; public function setArticle(CmsArticle $article): void diff --git a/tests/Documents/CmsContent.php b/tests/Documents/CmsContent.php index 0a6af5c31a..a6e129a0ff 100644 --- a/tests/Documents/CmsContent.php +++ b/tests/Documents/CmsContent.php @@ -6,13 +6,10 @@ use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; -/** @ODM\MappedSuperclass */ +#[ODM\MappedSuperclass] abstract class CmsContent extends CmsPage { - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $title; } diff --git a/tests/Documents/CmsGroup.php b/tests/Documents/CmsGroup.php index 3f994cb990..a875465460 100644 --- a/tests/Documents/CmsGroup.php +++ b/tests/Documents/CmsGroup.php @@ -7,28 +7,19 @@ use Doctrine\Common\Collections\Collection; use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; -/** @ODM\Document */ +#[ODM\Document] class CmsGroup { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; - /** - * @ODM\ReferenceMany(targetDocument=CmsUser::class) - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(targetDocument: CmsUser::class)] public $users; public function setName(string $name): void diff --git a/tests/Documents/CmsPage.php b/tests/Documents/CmsPage.php index 04e3dd0f8d..ff74dba687 100644 --- a/tests/Documents/CmsPage.php +++ b/tests/Documents/CmsPage.php @@ -5,26 +5,17 @@ namespace Documents; use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; +use Doctrine\ODM\MongoDB\Mapping\Annotations\Index; -/** - * @ODM\MappedSuperclass - * @ODM\Indexes({ - * @ODM\Index(keys={"slug"="asc"}, options={"unique"="true"}) - * }) - */ +#[Index(keys: ['slug' => 'asc'], options: ['unique' => 'true'])] +#[ODM\MappedSuperclass] abstract class CmsPage { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $slug; } diff --git a/tests/Documents/CmsPhonenumber.php b/tests/Documents/CmsPhonenumber.php index 7b13402870..232b864719 100644 --- a/tests/Documents/CmsPhonenumber.php +++ b/tests/Documents/CmsPhonenumber.php @@ -6,21 +6,15 @@ use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; -/** @ODM\Document */ +#[ODM\Document] class CmsPhonenumber { - /** - * @ODM\Id(strategy="NONE", type="custom_id") - * - * @var int|string|null - */ + /** @var int|string|null */ + #[ODM\Id(strategy: 'NONE', type: 'custom_id')] public $phonenumber; - /** - * @ODM\ReferenceOne(targetDocument=CmsUser::class, cascade={"merge"}) - * - * @var CmsUser|null - */ + /** @var CmsUser|null */ + #[ODM\ReferenceOne(targetDocument: CmsUser::class, cascade: ['merge'])] public $user; public function setUser(CmsUser $user): void diff --git a/tests/Documents/CmsProduct.php b/tests/Documents/CmsProduct.php index 034f2f1a49..2989ac2ad2 100644 --- a/tests/Documents/CmsProduct.php +++ b/tests/Documents/CmsProduct.php @@ -6,13 +6,10 @@ use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; -/** @ODM\Document */ +#[ODM\Document] class CmsProduct extends CmsContent { - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; } diff --git a/tests/Documents/CmsUser.php b/tests/Documents/CmsUser.php index daffe42828..17a8a38f4a 100644 --- a/tests/Documents/CmsUser.php +++ b/tests/Documents/CmsUser.php @@ -49,6 +49,7 @@ class CmsUser * * @var Collection */ + #[ODM\ReferenceMany(targetDocument: CmsPhonenumber::class, mappedBy: 'user', cascade: ['persist', 'remove', 'merge'])] public $phonenumbers; /** @@ -56,6 +57,7 @@ class CmsUser * * @var Collection */ + #[ODM\ReferenceMany(targetDocument: CmsArticle::class)] public $articles; /** @@ -63,6 +65,7 @@ class CmsUser * * @var CmsAddress */ + #[ODM\ReferenceOne(targetDocument: CmsAddress::class, cascade: ['persist'])] public $address; /** @@ -70,6 +73,7 @@ class CmsUser * * @var Collection */ + #[ODM\ReferenceMany(targetDocument: CmsGroup::class, cascade: ['persist', 'merge'])] public $groups; public function __construct() diff --git a/tests/Documents/Comment.php b/tests/Documents/Comment.php index 9368b610d0..5d3c07e0a9 100644 --- a/tests/Documents/Comment.php +++ b/tests/Documents/Comment.php @@ -7,50 +7,32 @@ use DateTime; use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; -/** @ODM\Document(repositoryClass=CommentRepository::class) */ +#[ODM\Document(repositoryClass: CommentRepository::class)] class Comment { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] public $text; - /** - * @ODM\ReferenceOne(targetDocument=User::class, cascade={"all"}) - * - * @var User|null - */ + /** @var User|null */ + #[ODM\ReferenceOne(targetDocument: User::class, cascade: ['all'])] public $author; - /** - * @ODM\ReferenceOne(targetDocument=BlogPost::class, inversedBy="comments", cascade={"all"}) - * - * @var BlogPost|null - */ + /** @var BlogPost|null */ + #[ODM\ReferenceOne(targetDocument: BlogPost::class, inversedBy: 'comments', cascade: ['all'])] public $parent; - /** - * @ODM\Field(type="date") - * @ODM\Index(order="1") - * - * @var DateTime - */ + /** @var DateTime */ + #[ODM\Field(type: 'date')] + #[ODM\Index(order: '1')] public $date; - /** - * @ODM\Field(type="bool") - * - * @var bool - */ + /** @var bool */ + #[ODM\Field(type: 'bool')] public $isByAdmin = false; public function __construct(string $text, DateTime $date, bool $isByAdmin = false) diff --git a/tests/Documents/CustomRepository/Document.php b/tests/Documents/CustomRepository/Document.php index 00e9c4d52e..4376668cbb 100644 --- a/tests/Documents/CustomRepository/Document.php +++ b/tests/Documents/CustomRepository/Document.php @@ -6,13 +6,10 @@ use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; -/** @ODM\Document(repositoryClass="Documents\CustomRepository\Repository") */ +#[ODM\Document(repositoryClass: 'Documents\CustomRepository\Repository')] class Document { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] protected $id; } diff --git a/tests/Documents/CustomUser.php b/tests/Documents/CustomUser.php index 0ceaaf4a1e..b1f08c8dae 100644 --- a/tests/Documents/CustomUser.php +++ b/tests/Documents/CustomUser.php @@ -6,35 +6,23 @@ use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; -/** @ODM\Document(collection="custom_users") */ +#[ODM\Document(collection: 'custom_users')] class CustomUser { - /** - * @ODM\Id(strategy="none") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id(strategy: 'none')] protected $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] protected $username; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] protected $password; - /** - * @ODM\ReferenceOne(targetDocument=Account::class, cascade={"all"}) - * - * @var Account|null - */ + /** @var Account|null */ + #[ODM\ReferenceOne(targetDocument: Account::class, cascade: ['all'])] protected $account; public function getId(): ?string diff --git a/tests/Documents/Customer.php b/tests/Documents/Customer.php index 8e26c47299..f7fc8e22cd 100644 --- a/tests/Documents/Customer.php +++ b/tests/Documents/Customer.php @@ -6,34 +6,22 @@ use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; -/** @ODM\Document */ +#[ODM\Document] class Customer { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] public $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] public $name; - /** - * @ODM\Field(name="cartTest", type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(name: 'cartTest', type: 'string')] public $cartTest; - /** - * @ODM\ReferenceOne(targetDocument=Cart::class, mappedBy="customer") - * - * @var Cart|null - */ + /** @var Cart|null */ + #[ODM\ReferenceOne(targetDocument: Cart::class, mappedBy: 'customer')] public $cart; } diff --git a/tests/Documents/Developer.php b/tests/Documents/Developer.php index 4cea4e55ec..4215f50889 100644 --- a/tests/Documents/Developer.php +++ b/tests/Documents/Developer.php @@ -8,28 +8,19 @@ use Doctrine\Common\Collections\Collection; use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; -/** @ODM\Document */ +#[ODM\Document] class Developer { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] private $id; - /** - * @ODM\Field(type="string") - * - * @var string - */ + /** @var string */ + #[ODM\Field(type: 'string')] private $name; - /** - * @ODM\ReferenceMany(targetDocument=Project::class, cascade="all") - * - * @var Collection - */ + /** @var Collection */ + #[ODM\ReferenceMany(targetDocument: Project::class, cascade: 'all')] private $projects; /** @param Collection|null $projects */ diff --git a/tests/Documents/Ecommerce/Basket.php b/tests/Documents/Ecommerce/Basket.php index 8a4b6a7675..b521d77284 100644 --- a/tests/Documents/Ecommerce/Basket.php +++ b/tests/Documents/Ecommerce/Basket.php @@ -7,21 +7,15 @@ use Doctrine\Common\Collections\Collection; use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; -/** @ODM\Document */ +#[ODM\Document] class Basket { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] protected $id; - /** - * @ODM\ReferenceMany(targetDocument=Documents\Ecommerce\ConfigurableProduct::class) - * - * @var Collection|array - */ + /** @var Collection|array */ + #[ODM\ReferenceMany(targetDocument: ConfigurableProduct::class)] protected $products = []; public function getId(): ?string diff --git a/tests/Documents/Ecommerce/ConfigurableProduct.php b/tests/Documents/Ecommerce/ConfigurableProduct.php index 131980220d..68b4e1f010 100644 --- a/tests/Documents/Ecommerce/ConfigurableProduct.php +++ b/tests/Documents/Ecommerce/ConfigurableProduct.php @@ -12,28 +12,19 @@ use function array_search; use function in_array; -/** @ODM\Document */ +#[ODM\Document] class ConfigurableProduct { - /** - * @ODM\Id - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Id] protected $id; - /** - * @ODM\Field(type="string") - * - * @var string|null - */ + /** @var string|null */ + #[ODM\Field(type: 'string')] protected $name; - /** - * @ODM\EmbedMany(targetDocument=Documents\Ecommerce\Option::class) - * - * @var Collection|array