From 4680bb7c9d6d2b218135812f8f20f788fc62b566 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Sun, 3 Dec 2023 10:19:09 +0100 Subject: [PATCH] remove obsolete annotation mapping --- CHANGELOG.md | 2 +- cli-config.doctrine_dbal.php.dist | 5 +- cli-config.jackrabbit.php.dist | 5 +- .../ODM/PHPCR/Document/AbstractFile.php | 2 +- lib/Doctrine/ODM/PHPCR/Document/Generic.php | 8 +- lib/Doctrine/ODM/PHPCR/Document/Resource.php | 8 +- lib/Doctrine/ODM/PHPCR/DocumentManager.php | 2 +- .../ODM/PHPCR/Mapping/Annotations/Child.php | 22 - .../PHPCR/Mapping/Annotations/Children.php | 26 -- .../ODM/PHPCR/Mapping/Annotations/Depth.php | 13 - .../PHPCR/Mapping/Annotations/Document.php | 28 -- .../ODM/PHPCR/Mapping/Annotations/Field.php | 13 - .../ODM/PHPCR/Mapping/Annotations/Id.php | 16 - .../ODM/PHPCR/Mapping/Annotations/Locale.php | 13 - .../Mapping/Annotations/MappedSuperclass.php | 13 - .../Mapping/Annotations/MixedReferrers.php | 14 - .../ODM/PHPCR/Mapping/Annotations/Node.php | 13 - .../PHPCR/Mapping/Annotations/Nodename.php | 15 - .../Mapping/Annotations/ParentDocument.php | 20 - .../PHPCR/Mapping/Annotations/PostLoad.php | 13 - .../PHPCR/Mapping/Annotations/PostPersist.php | 13 - .../PHPCR/Mapping/Annotations/PostRemove.php | 13 - .../PHPCR/Mapping/Annotations/PostUpdate.php | 13 - .../PHPCR/Mapping/Annotations/PrePersist.php | 13 - .../PHPCR/Mapping/Annotations/PreRemove.php | 13 - .../PHPCR/Mapping/Annotations/PreUpdate.php | 13 - .../PHPCR/Mapping/Annotations/Property.php | 19 - .../PHPCR/Mapping/Annotations/Reference.php | 22 - .../Mapping/Annotations/ReferenceMany.php | 13 - .../Mapping/Annotations/ReferenceOne.php | 13 - .../PHPCR/Mapping/Annotations/Referrers.php | 24 -- .../Annotations/TranslatableProperty.php | 11 - .../ODM/PHPCR/Mapping/Annotations/Uuid.php | 15 - .../Mapping/Annotations/VersionCreated.php | 13 - .../PHPCR/Mapping/Annotations/VersionName.php | 13 - .../ODM/PHPCR/Mapping/Attributes/Child.php | 11 +- .../ODM/PHPCR/Mapping/Attributes/Children.php | 20 +- .../ODM/PHPCR/Mapping/Attributes/Depth.php | 3 +- .../ODM/PHPCR/Mapping/Attributes/Document.php | 36 +- .../ODM/PHPCR/Mapping/Attributes/Field.php | 21 +- .../ODM/PHPCR/Mapping/Attributes/Id.php | 12 +- .../ODM/PHPCR/Mapping/Attributes/Locale.php | 3 +- .../Mapping/Attributes/MixedReferrers.php | 9 +- .../ODM/PHPCR/Mapping/Attributes/Node.php | 3 +- .../ODM/PHPCR/Mapping/Attributes/Nodename.php | 3 +- .../Mapping/Attributes/ParentDocument.php | 15 +- .../ODM/PHPCR/Mapping/Attributes/PostLoad.php | 3 +- .../PHPCR/Mapping/Attributes/PostPersist.php | 3 +- .../PHPCR/Mapping/Attributes/PostRemove.php | 3 +- .../PHPCR/Mapping/Attributes/PostUpdate.php | 3 +- .../PHPCR/Mapping/Attributes/PrePersist.php | 3 +- .../PHPCR/Mapping/Attributes/PreRemove.php | 3 +- .../PHPCR/Mapping/Attributes/PreUpdate.php | 3 +- .../PHPCR/Mapping/Attributes/Reference.php | 19 +- .../PHPCR/Mapping/Attributes/Referrers.php | 13 +- .../ODM/PHPCR/Mapping/Attributes/Uuid.php | 3 +- .../Mapping/Attributes/VersionCreated.php | 3 +- .../PHPCR/Mapping/Attributes/VersionName.php | 3 +- .../ODM/PHPCR/Mapping/ClassMetadata.php | 28 +- .../PHPCR/Mapping/Driver/AnnotationDriver.php | 245 ----------- .../ODM/PHPCR/Mapping/Driver/XmlDriver.php | 2 +- .../ODM/PHPCR/Mapping/MappingException.php | 2 +- .../DumpQueryBuilderReferenceCommand.php | 2 +- .../ODM/PHPCR/Tools/Helper/PrefetchHelper.php | 4 +- lib/Doctrine/ODM/PHPCR/UnitOfWork.php | 11 +- .../Doctrine/Tests/Models/CMS/CmsArticle.php | 1 - .../Models/Translation/InvalidMapping.php | 2 +- .../Translation/NoLocalePropertyArticle.php | 3 +- .../InconsistentVersionableArticle.php | 2 +- .../Mapping/AnnotationMappingTest.php | 383 ------------------ .../{Attribute => }/AttributeMappingTest.php | 7 +- .../Tests/ODM/PHPCR/Functional/MixinTest.php | 2 +- .../ODM/PHPCR/Functional/ReferrerTest.php | 2 +- .../Translation/TranslationTest.php | 8 +- ...AnnotationsTest.php => AttributesTest.php} | 20 +- .../Mapping/AbstractMappingDriverTest.php | 2 +- .../PHPCR/Mapping/AnnotationDriverTest.php | 37 -- .../ODM/PHPCR/Mapping/AttributeDriverTest.php | 2 +- .../Mapping/ClassMetadataFactoryTest.php | 13 +- .../ODM/PHPCR/Mapping/ClassMetadataTest.php | 17 +- .../Model/ChildClassesAndLeafObject.php | 6 - .../Mapping/Model/ChildClassesObject.php | 6 - .../Mapping/Model/ChildMappingObject.php | 6 - .../Mapping/Model/ChildrenMappingObject.php | 6 - .../ClassInheritanceChildMappingObject.php | 3 - ...InheritanceChildOverridesMappingObject.php | 14 +- .../ClassInheritanceParentMappingObject.php | 11 - .../Mapping/Model/DefaultMappingObject.php | 4 - .../Mapping/Model/DepthMappingObject.php | 5 - .../Mapping/Model/FieldMappingObject.php | 16 - .../Model/InheritedMixinMappingObject.php | 5 - .../ODM/PHPCR/Mapping/Model/IsLeafObject.php | 4 - .../Model/LifecycleCallbackMappingObject.php | 11 - .../Model/MappedSuperclassMappingObject.php | 4 - .../Mapping/Model/MixinMappingObject.php | 11 +- .../PHPCR/Mapping/Model/NodeMappingObject.php | 5 - .../Mapping/Model/NodeTypeMappingObject.php | 4 - .../Mapping/Model/NodenameMappingObject.php | 5 - .../Model/ParentDocumentMappingObject.php | 5 - .../Model/ReferenceManyMappingObject.php | 6 - .../Model/ReferenceOneMappingObject.php | 6 - .../Model/ReferenceableChildMappingObject.php | 4 - ...leChildReferenceableFalseMappingObject.php | 3 - .../Model/ReferenceableMappingObject.php | 4 - .../Mapping/Model/ReferrersMappingObject.php | 16 - .../Model/ReplaceMixinMappingObject.php | 7 - .../Mapping/Model/RepositoryMappingObject.php | 4 - .../Model/StringExtendedMappingObject.php | 6 - .../Mapping/Model/StringMappingObject.php | 5 - .../Mapping/Model/TranslatorMappingObject.php | 13 - .../TranslatorMappingObjectNoStrategy.php | 14 - .../Model/UniqueNodeTypeMappingObject.php | 4 - .../PHPCR/Mapping/Model/UuidMappingObject.php | 6 - .../UuidMappingObjectNotReferenceable.php | 5 - .../Model/VersionableMappingObject.php | 6 - .../ODM/PHPCR/PHPCRFunctionalTestCase.php | 11 +- tests/bootstrap.php | 6 - 117 files changed, 169 insertions(+), 1553 deletions(-) delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Child.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Children.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Depth.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Document.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Field.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Id.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Locale.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/MappedSuperclass.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/MixedReferrers.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Node.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Nodename.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/ParentDocument.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/PostLoad.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/PostPersist.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/PostRemove.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/PostUpdate.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/PrePersist.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/PreRemove.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/PreUpdate.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Property.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Reference.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/ReferenceMany.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/ReferenceOne.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Referrers.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/TranslatableProperty.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Uuid.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/VersionCreated.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/VersionName.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Driver/AnnotationDriver.php delete mode 100644 tests/Doctrine/Tests/ODM/PHPCR/Functional/Mapping/AnnotationMappingTest.php rename tests/Doctrine/Tests/ODM/PHPCR/Functional/Mapping/{Attribute => }/AttributeMappingTest.php (98%) rename tests/Doctrine/Tests/ODM/PHPCR/Functional/Versioning/{AnnotationsTest.php => AttributesTest.php} (87%) delete mode 100644 tests/Doctrine/Tests/ODM/PHPCR/Mapping/AnnotationDriverTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c5c8ae1d..77d4b1e79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ Changelog * DocumentManager::flush no longer saves the PHPCR session if there are no changes on the ODM layer. -* Removed deprecated annotations for fields. Use `@Field(type="...")` instead. +* Removed annotation mappings. Use attributes (or XML or YAML) instead. ### New Features diff --git a/cli-config.doctrine_dbal.php.dist b/cli-config.doctrine_dbal.php.dist index d6746bbc6..7d66902a8 100644 --- a/cli-config.doctrine_dbal.php.dist +++ b/cli-config.doctrine_dbal.php.dist @@ -37,10 +37,9 @@ if (isset($argv[1]) /* prepare the doctrine configuration */ $config = new \Doctrine\ODM\PHPCR\Configuration(); - $driver = new \Doctrine\ODM\PHPCR\Mapping\Driver\AnnotationDriver( - new \Doctrine\Common\Annotations\AnnotationReader(), + $driver = new \Doctrine\ODM\PHPCR\Mapping\Driver\AttributeDriver([ __DIR__ . '/lib/Doctrine/ODM/PHPCR/Document' - ); + ]); $config->setMetadataDriverImpl($driver); $dm = \Doctrine\ODM\PHPCR\DocumentManager::create($session, $config); diff --git a/cli-config.jackrabbit.php.dist b/cli-config.jackrabbit.php.dist index b3e0b6bfa..85876f9d5 100644 --- a/cli-config.jackrabbit.php.dist +++ b/cli-config.jackrabbit.php.dist @@ -35,10 +35,9 @@ $session = $repository->login($credentials, $workspace); /* prepare the doctrine configuration */ $config = new \Doctrine\ODM\PHPCR\Configuration(); -$driver = new \Doctrine\ODM\PHPCR\Mapping\Driver\AnnotationDriver( - new \Doctrine\Common\Annotations\AnnotationReader(), +$driver = new \Doctrine\ODM\PHPCR\Mapping\Driver\AttributeDriver([ __DIR__ . '/lib/Doctrine/ODM/PHPCR/Document' -); +]); $config->setMetadataDriverImpl($driver); $dm = \Doctrine\ODM\PHPCR\DocumentManager::create($session, $config); diff --git a/lib/Doctrine/ODM/PHPCR/Document/AbstractFile.php b/lib/Doctrine/ODM/PHPCR/Document/AbstractFile.php index 00b6b4031..48ba09422 100644 --- a/lib/Doctrine/ODM/PHPCR/Document/AbstractFile.php +++ b/lib/Doctrine/ODM/PHPCR/Document/AbstractFile.php @@ -3,8 +3,8 @@ namespace Doctrine\ODM\PHPCR\Document; use Doctrine\ODM\PHPCR\HierarchyInterface; -use PHPCR\NodeInterface; use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; +use PHPCR\NodeInterface; /** * This class represents an abstract "file". diff --git a/lib/Doctrine/ODM/PHPCR/Document/Generic.php b/lib/Doctrine/ODM/PHPCR/Document/Generic.php index 677e029f3..b728a143c 100644 --- a/lib/Doctrine/ODM/PHPCR/Document/Generic.php +++ b/lib/Doctrine/ODM/PHPCR/Document/Generic.php @@ -11,8 +11,8 @@ /** * This class represents an arbitrary node. * - * It is used as a default document, for example with the ParentDocument annotation. - * You can not use this to create nodes as it has no type annotation. + * It is used as a default document, for example with the ParentDocument mapping. + * You can not use this to create nodes as it has no type mapping. */ #[PHPCR\Document] class Generic @@ -51,13 +51,14 @@ public function __construct() } /** - * Id (path) of this document + * Id (path) of this document. */ public function getId(): string { if (!isset($this->id)) { throw new BadMethodCallException('Do not call getId on unsaved objects.'); } + return $this->id; } @@ -95,6 +96,7 @@ public function getParentDocument(): object if (!isset($this->parent)) { throw new BadMethodCallException('Do not call getParentDocument on unsaved objects before setting the parent.'); } + return $this->parent; } diff --git a/lib/Doctrine/ODM/PHPCR/Document/Resource.php b/lib/Doctrine/ODM/PHPCR/Document/Resource.php index f9eff7f63..2b6032630 100644 --- a/lib/Doctrine/ODM/PHPCR/Document/Resource.php +++ b/lib/Doctrine/ODM/PHPCR/Document/Resource.php @@ -13,12 +13,10 @@ */ #[PHPCR\Document(nodeType: 'nt:resource')] class Resource -{ #[PHPCR\Id] +{ + #[PHPCR\Id] protected string $id; - /** - * @var NodeInterface - */ #[PHPCR\Node] protected NodeInterface $node; @@ -88,7 +86,7 @@ public function setParentDocument(object $parent): self /** * Set the data from a binary stream. - + * * @param resource $data the contents of this resource */ public function setData($data): self diff --git a/lib/Doctrine/ODM/PHPCR/DocumentManager.php b/lib/Doctrine/ODM/PHPCR/DocumentManager.php index b5706d424..b94af35ee 100644 --- a/lib/Doctrine/ODM/PHPCR/DocumentManager.php +++ b/lib/Doctrine/ODM/PHPCR/DocumentManager.php @@ -107,7 +107,7 @@ public function hasLocaleChooserStrategy(): bool public function getLocaleChooserStrategy(): LocaleChooserInterface { if (!isset($this->localeChooserStrategy)) { - throw new InvalidArgumentException('You must configure a language chooser strategy when having documents with the translatable annotation'); + throw new InvalidArgumentException('You must configure a language chooser strategy when having documents with the translatable mapping'); } return $this->localeChooserStrategy; diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Child.php b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Child.php deleted file mode 100644 index bf3f71bf0..000000000 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Child.php +++ /dev/null @@ -1,22 +0,0 @@ -nodeName = $nodeName; $this->cascade = (array) $cascade; } } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Children.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Children.php index d002352a7..1e42bbf28 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Children.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Children.php @@ -2,21 +2,25 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Doctrine\ODM\PHPCR\Mapping\Annotations\Children as BaseChildren; use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; #[\Attribute(\Attribute::TARGET_PROPERTY)] -final class Children extends BaseChildren implements MappingAttribute +final class Children implements MappingAttribute { + public array $filter; + public array $cascade; + + /** + * @param string[]|string $filter + * @param string[]|string $cascade + */ public function __construct( - array|string $filter = null, - int $fetchDepth = -1, - bool $ignoreUntranslated = true, + array|string $filter = [], + public int $fetchDepth = -1, + public bool $ignoreUntranslated = true, array|string $cascade = [], ) { - $this->filter = $filter ? (array) $filter : null; - $this->fetchDepth = $fetchDepth; - $this->ignoreUntranslated = $ignoreUntranslated; + $this->filter = (array) $filter; $this->cascade = (array) $cascade; } } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Depth.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Depth.php index 513b3fc60..79daa456b 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Depth.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Depth.php @@ -2,10 +2,9 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Doctrine\ODM\PHPCR\Mapping\Annotations\Depth as BaseDepth; use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; #[\Attribute(\Attribute::TARGET_PROPERTY)] -final class Depth extends BaseDepth implements MappingAttribute +final class Depth implements MappingAttribute { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Document.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Document.php index e145ba746..cf4ebb97d 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Document.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Document.php @@ -2,33 +2,27 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Doctrine\ODM\PHPCR\Mapping\Annotations\Document as BaseDocument; use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; #[\Attribute(\Attribute::TARGET_CLASS)] -class Document extends BaseDocument implements MappingAttribute +class Document implements MappingAttribute { + public array $mixins; + public array $childClasses; + public function __construct( - string $nodeType = null, - string $repositoryClass = null, - string $translator = null, - array $mixins = null, - bool|null $inheritMixins = null, - string $versionable = null, - bool|null $referenceable = null, - bool|null $uniqueNodeType = null, - string|array|null $childClasses = null, - bool|null $isLeaf = null, + public null|string $nodeType = null, + public null|string $repositoryClass = null, + public null|string $translator = null, + string|array $mixins = null, + public bool|null $inheritMixins = null, + public null|string $versionable = null, + public null|bool $referenceable = null, + public null|bool $uniqueNodeType = null, + string|array $childClasses = null, + public bool|null $isLeaf = null, ) { - $this->nodeType = $nodeType; - $this->repositoryClass = $repositoryClass; - $this->translator = $translator; - $this->mixins = $mixins; - $this->inheritMixins = $inheritMixins; - $this->versionable = $versionable; - $this->referenceable = $referenceable; - $this->uniqueNodeType = $uniqueNodeType; + $this->mixins = $mixins ? (array) $mixins : null; $this->childClasses = $childClasses ? (array) $childClasses : null; - $this->isLeaf = $isLeaf; } } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Field.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Field.php index 6bd9791e5..c2b31b45c 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Field.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Field.php @@ -2,25 +2,18 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Doctrine\ODM\PHPCR\Mapping\Annotations\Field as BaseField; use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; #[\Attribute(\Attribute::TARGET_PROPERTY)] -class Field extends BaseField implements MappingAttribute +class Field implements MappingAttribute { public function __construct( - string $property = null, - string $type = 'undefined', - bool $multivalue = false, - string $assoc = null, - bool $nullable = false, - bool $translated = false, + public null|string $property = null, + public string $type = 'undefined', + public bool $multivalue = false, + public null|string $assoc = null, + public bool $nullable = false, + public bool $translated = false, ) { - $this->property = $property; - $this->type = $type; - $this->multivalue = $multivalue; - $this->assoc = $assoc; - $this->nullable = $nullable; - $this->translated = $translated; } } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Id.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Id.php index b63ae4842..db48afcbb 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Id.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Id.php @@ -2,19 +2,15 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Doctrine\ODM\PHPCR\Mapping\Annotations\Id as BaseId; use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; #[\Attribute(\Attribute::TARGET_PROPERTY)] -final class Id extends BaseId implements MappingAttribute +final class Id implements MappingAttribute { public function __construct( - bool $id = true, - string $type = 'string', - string $strategy = null, + public bool $id = true, + public string $type = 'string', + public null|string $strategy = null, ) { - $this->id = $id; - $this->type = $type; - $this->strategy = $strategy; } } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Locale.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Locale.php index a859c3bbd..d14ab1dd0 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Locale.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Locale.php @@ -2,10 +2,9 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Doctrine\ODM\PHPCR\Mapping\Annotations\Locale as BaseLocale; use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; #[\Attribute(\Attribute::TARGET_PROPERTY)] -final class Locale extends BaseLocale implements MappingAttribute +final class Locale implements MappingAttribute { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/MixedReferrers.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/MixedReferrers.php index 8a1513668..4ec5371a5 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/MixedReferrers.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/MixedReferrers.php @@ -2,14 +2,13 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Doctrine\ODM\PHPCR\Mapping\Annotations\MixedReferrers as BaseMixedReferrers; use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; #[\Attribute(\Attribute::TARGET_PROPERTY)] -final class MixedReferrers extends BaseMixedReferrers implements MappingAttribute +final class MixedReferrers implements MappingAttribute { - public function __construct(string $referenceType = null) - { - $this->referenceType = $referenceType; + public function __construct( + public null|string $referenceType = null + ) { } } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Node.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Node.php index 4a4d6c6ae..48f609f95 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Node.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Node.php @@ -2,10 +2,9 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Doctrine\ODM\PHPCR\Mapping\Annotations\Node as BaseNode; use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; #[\Attribute(\Attribute::TARGET_PROPERTY)] -final class Node extends BaseNode implements MappingAttribute +final class Node implements MappingAttribute { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Nodename.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Nodename.php index 9941c301c..094a84781 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Nodename.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Nodename.php @@ -2,10 +2,9 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Doctrine\ODM\PHPCR\Mapping\Annotations\Nodename as BaseNodename; use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; #[\Attribute(\Attribute::TARGET_PROPERTY)] -final class Nodename extends BaseNodename implements MappingAttribute +final class Nodename implements MappingAttribute { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/ParentDocument.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/ParentDocument.php index 782b8d8e4..6b231d509 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/ParentDocument.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/ParentDocument.php @@ -2,10 +2,21 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Doctrine\ODM\PHPCR\Mapping\Annotations\ParentDocument as BaseParentDocument; use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; +/** + * The parent of this node as in PHPCR\NodeInterface::getParent. + * + * Parent is a reserved keyword in php, thus we use ParentDocument as name. + */ #[\Attribute(\Attribute::TARGET_PROPERTY)] -final class ParentDocument extends BaseParentDocument implements MappingAttribute +final class ParentDocument implements MappingAttribute { + public array $cascade; + + public function __construct( + string|array $cascade = [] + ) { + $this->cascade = (array) $cascade; + } } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostLoad.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostLoad.php index a85f65a28..1d4eea2f0 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostLoad.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostLoad.php @@ -2,10 +2,9 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Doctrine\ODM\PHPCR\Mapping\Annotations\PostLoad as BasePostLoad; use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; #[\Attribute(\Attribute::TARGET_METHOD)] -final class PostLoad extends BasePostLoad implements MappingAttribute +final class PostLoad implements MappingAttribute { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostPersist.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostPersist.php index 98f7fe949..8d595bc25 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostPersist.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostPersist.php @@ -2,10 +2,9 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Doctrine\ODM\PHPCR\Mapping\Annotations\PostPersist as BasePostPersist; use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; #[\Attribute(\Attribute::TARGET_METHOD)] -final class PostPersist extends BasePostPersist implements MappingAttribute +final class PostPersist implements MappingAttribute { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostRemove.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostRemove.php index 724be8fd4..69783d2ba 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostRemove.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostRemove.php @@ -2,10 +2,9 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Doctrine\ODM\PHPCR\Mapping\Annotations\PostRemove as BasePostRemove; use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; #[\Attribute(\Attribute::TARGET_METHOD)] -final class PostRemove extends BasePostRemove implements MappingAttribute +final class PostRemove implements MappingAttribute { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostUpdate.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostUpdate.php index 23f76cfa6..17635dfe5 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostUpdate.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostUpdate.php @@ -2,10 +2,9 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Doctrine\ODM\PHPCR\Mapping\Annotations\PostUpdate as BasePostUpdate; use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; #[\Attribute(\Attribute::TARGET_METHOD)] -final class PostUpdate extends BasePostUpdate implements MappingAttribute +final class PostUpdate implements MappingAttribute { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PrePersist.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PrePersist.php index 66f334d74..8a757d20b 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PrePersist.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PrePersist.php @@ -2,10 +2,9 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Doctrine\ODM\PHPCR\Mapping\Annotations\PrePersist as BasePrePersist; use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; #[\Attribute(\Attribute::TARGET_METHOD)] -final class PrePersist extends BasePrePersist implements MappingAttribute +final class PrePersist implements MappingAttribute { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PreRemove.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PreRemove.php index fa293a292..b1255c2f1 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PreRemove.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PreRemove.php @@ -2,10 +2,9 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Doctrine\ODM\PHPCR\Mapping\Annotations\PreRemove as BasePreRemove; use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; #[\Attribute(\Attribute::TARGET_METHOD)] -final class PreRemove extends BasePreRemove implements MappingAttribute +final class PreRemove implements MappingAttribute { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PreUpdate.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PreUpdate.php index 005401f7c..1dbd3cf16 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PreUpdate.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PreUpdate.php @@ -2,10 +2,9 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Doctrine\ODM\PHPCR\Mapping\Annotations\PreUpdate as BasePreUpdate; use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; #[\Attribute(\Attribute::TARGET_METHOD)] -final class PreUpdate extends BasePreUpdate implements MappingAttribute +final class PreUpdate implements MappingAttribute { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Reference.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Reference.php index 478a4e89e..bddfcd357 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Reference.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Reference.php @@ -2,23 +2,24 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Doctrine\ODM\PHPCR\Mapping\Annotations\Reference as BaseReference; use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; -abstract class Reference extends BaseReference implements MappingAttribute +abstract class Reference implements MappingAttribute { + public array $cascade; + /** - * @param string[] $cascade + * @param string[]|string $cascade */ public function __construct( - string $property = null, - string $targetDocument = null, - string $strategy = 'weak', + /** + * The PHPCR property name to use. + */ + public null|string $property = null, + public null|string $targetDocument = null, + public string $strategy = 'weak', array|string $cascade = [] ) { - $this->property = $property; - $this->targetDocument = $targetDocument; - $this->strategy = $strategy; $this->cascade = (array) $cascade; } } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Referrers.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Referrers.php index e957ea734..f6f453ca6 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Referrers.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Referrers.php @@ -2,22 +2,21 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Doctrine\ODM\PHPCR\Mapping\Annotations\Referrers as BaseReferrers; use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; #[\Attribute(\Attribute::TARGET_PROPERTY)] -final class Referrers extends BaseReferrers implements MappingAttribute +final class Referrers implements MappingAttribute { + public array $cascade; + /** - * @param string[] $cascade + * @param string[]|string $cascade */ public function __construct( - string $referencedBy, - string $referringDocument, + public string $referencedBy, + public string $referringDocument, array|string $cascade = [] ) { - $this->referencedBy = $referencedBy; - $this->referringDocument = $referringDocument; $this->cascade = (array) $cascade; } } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Uuid.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Uuid.php index db1e77dcc..9a16e8891 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Uuid.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Uuid.php @@ -11,8 +11,7 @@ public function __construct( bool $multivalue = false, string $assoc = null, bool $nullable = false, - bool $translated = false, ) { - parent::__construct($property, $type, $multivalue, $assoc, $nullable, $translated); + parent::__construct($property, $type, $multivalue, $assoc, $nullable, false); } } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/VersionCreated.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/VersionCreated.php index f722885f3..fd059f589 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/VersionCreated.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/VersionCreated.php @@ -2,10 +2,9 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Doctrine\ODM\PHPCR\Mapping\Annotations\VersionCreated as BaseVersionCreated; use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; #[\Attribute(\Attribute::TARGET_PROPERTY)] -final class VersionCreated extends BaseVersionCreated implements MappingAttribute +final class VersionCreated implements MappingAttribute { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/VersionName.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/VersionName.php index 403752f6e..ad02f7642 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/VersionName.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/VersionName.php @@ -2,10 +2,9 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Doctrine\ODM\PHPCR\Mapping\Annotations\VersionName as BaseVersionName; use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; #[\Attribute(\Attribute::TARGET_PROPERTY)] -final class VersionName extends BaseVersionName implements MappingAttribute +final class VersionName implements MappingAttribute { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/ClassMetadata.php b/lib/Doctrine/ODM/PHPCR/Mapping/ClassMetadata.php index 045f8621b..6cbb54040 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/ClassMetadata.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/ClassMetadata.php @@ -73,7 +73,7 @@ class ClassMetadata implements ClassMetadataInterface */ public const GENERATOR_TYPE_AUTO = 4; - protected static $validVersionableAnnotations = ['simple', 'full']; + protected static $validVersionableMappings = ['simple', 'full']; /** * READ-ONLY: The ReflectionProperty instances of the mapped class. @@ -233,7 +233,7 @@ class ClassMetadata implements ClassMetadataInterface /** * READ-ONLY: Whether this document should be versioned. If this is not false, it will - * be one of the values from self::validVersionableAnnotations. + * be one of the values from self::validVersionableMappings. * * @var bool|string */ @@ -287,10 +287,8 @@ class ClassMetadata implements ClassMetadataInterface /** * Initializes a new ClassMetadata instance that will hold the object-document mapping * metadata of the class with the given name. - * - * @param string $className the name of the document class the new instance is used for */ - public function __construct($className) + public function __construct(string $className) { $this->name = $className; } @@ -572,13 +570,13 @@ public function setLifecycleCallbacks(array $callbacks): void } /** - * @param string|bool $versionable a valid versionable annotation or false to disable versioning + * @param string|bool $versionable a valid versionable mapping or false to disable versioning */ public function setVersioned($versionable): void { - if ($versionable && !in_array($versionable, self::$validVersionableAnnotations, true)) { + if ($versionable && !in_array($versionable, self::$validVersionableMappings, true)) { throw new MappingException(sprintf( - 'Invalid value in "%s" for the versionable annotation: "%s"', + 'Invalid value in "%s" for the versionable mapping: "%s"', $this->name, $versionable )); @@ -687,7 +685,7 @@ public function mapId(array $mapping, self $inherited = null): void if (true === ($mapping['id'] ?? false)) { $mapping['type'] = 'string'; $this->setIdentifier($mapping['fieldName']); - if (array_key_exists('strategy', $mapping)) { + if (array_key_exists('strategy', $mapping) && null !== $mapping['strategy']) { $this->setIdGenerator($mapping['strategy']); } } @@ -979,7 +977,7 @@ public function validateClassMapping(): void if (!empty($this->versionNameField) && !$this->versionable) { throw new MappingException(sprintf( - 'You cannot use the @VersionName annotation on the non-versionable document %s (field = %s)', + 'You cannot use the @VersionName mapping on the non-versionable document %s (field = %s)', $this->name, $this->versionNameField )); @@ -987,7 +985,7 @@ public function validateClassMapping(): void if (!empty($this->versionCreatedField) && !$this->versionable) { throw new MappingException(sprintf( - 'You cannot use the @VersionCreated annotation on the non-versionable document %s (field = %s)', + 'You cannot use the @VersionCreated mapping on the non-versionable document %s (field = %s)', $this->name, $this->versionCreatedField )); @@ -1084,10 +1082,8 @@ public function mapManyToMany(array $mapping, self $inherited = null): void /** * Sets the ID generator used to generate IDs for instances of this class. - * - * @param string|int $generator */ - protected function setIdGenerator($generator): void + protected function setIdGenerator(int|string $generator): void { if (is_string($generator)) { $generator = constant('Doctrine\ODM\PHPCR\Mapping\ClassMetadata::GENERATOR_TYPE_'.strtoupper($generator)); @@ -1606,7 +1602,7 @@ public function setFieldValue(object $document, string $field, $value): void * @return mixed|null the value of this field for the document or null if * not found */ - public function getFieldValue(object $document, string $field) + public function getFieldValue(object $document, string $field): mixed { if (array_key_exists($field, $this->reflFields) && $this->reflFields[$field]->isInitialized($document)) { return $this->reflFields[$field]->getValue($document); @@ -1662,7 +1658,7 @@ public function isUuid(string $fieldName): bool public function fullyQualifiedClassName(?string $className): ?string { - if (null !== $className && false === strpos($className, '\\') && '' !== $this->namespace) { + if ('' !== $this->namespace && null !== $className && !str_contains($className, '\\')) { return $this->namespace.'\\'.$className; } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Driver/AnnotationDriver.php b/lib/Doctrine/ODM/PHPCR/Mapping/Driver/AnnotationDriver.php deleted file mode 100644 index a527bbf8b..000000000 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Driver/AnnotationDriver.php +++ /dev/null @@ -1,245 +0,0 @@ - - * @author Pascal Helfenstein - * @author Daniel Barsotti - * @author David Buchmann - */ -class AnnotationDriver implements MappingDriver -{ - use ColocatedMappingDriver; - - /** - * Document annotation classes, ordered by precedence. - * - * @var array - */ - private array $documentAnnotationClasses = [ - Document::class => 0, - MappedSuperclass::class => 1, - ]; - - private Reader $reader; - - /** - * Initializes a new AnnotationDriver that uses the given AnnotationReader for reading - * docblock annotations. - * - * @param Reader $reader the AnnotationReader to use, duck-typed - * @param string|string[]|null $paths one or multiple paths where mapping classes can be found - */ - public function __construct(Reader $reader, $paths = null) - { - $this->reader = $reader; - - $this->addPaths((array) $paths); - } - - public function isTransient($className): bool - { - $classAnnotations = $this->reader->getClassAnnotations(new \ReflectionClass($className)); - - foreach ($classAnnotations as $annot) { - if (array_key_exists(get_class($annot), $this->documentAnnotationClasses)) { - return false; - } - } - - return true; - } - - /** - * @param PhpcrClassMetadata $metadata - */ - public function loadMetadataForClass($className, ClassMetadata $metadata): void - { - $reflClass = $metadata->getReflectionClass(); - - $documentAnnots = []; - foreach ($this->reader->getClassAnnotations($reflClass) as $annot) { - foreach ($this->documentAnnotationClasses as $annotClass => $i) { - if ($annot instanceof $annotClass) { - $documentAnnots[$i] = $annot; - } - } - } - if (!$documentAnnots) { - throw MappingException::classIsNotAValidDocument($className); - } - - // find the winning document annotation - ksort($documentAnnots); - - $documentAnnot = reset($documentAnnots); - - if ($documentAnnot instanceof ODM\MappedSuperclass) { - $metadata->isMappedSuperclass = true; - } - if (null !== $documentAnnot->referenceable) { - $metadata->setReferenceable($documentAnnot->referenceable); - } - - if (null !== $documentAnnot->versionable) { - $metadata->setVersioned($documentAnnot->versionable); - } - - if (null !== $documentAnnot->uniqueNodeType) { - $metadata->setUniqueNodeType($documentAnnot->uniqueNodeType); - } - - if (null !== $documentAnnot->mixins) { - $metadata->setMixins(is_string($documentAnnot->mixins) ? [$documentAnnot->mixins] : $documentAnnot->mixins); - } - - if (null !== $documentAnnot->inheritMixins) { - $metadata->setInheritMixins($documentAnnot->inheritMixins); - } - - if (null !== $documentAnnot->nodeType) { - $metadata->setNodeType($documentAnnot->nodeType); - } - - if (null !== $documentAnnot->repositoryClass) { - $metadata->setCustomRepositoryClassName($documentAnnot->repositoryClass); - } - - if (null !== $documentAnnot->translator) { - $metadata->setTranslator($documentAnnot->translator); - } - - if ([] !== $documentAnnot->childClasses) { - $metadata->setChildClasses($documentAnnot->childClasses); - } - - if (null !== $documentAnnot->isLeaf) { - $metadata->setIsLeaf($documentAnnot->isLeaf); - } - - foreach ($reflClass->getProperties() as $property) { - if ($metadata->isInheritedField($property->name) - && $metadata->name !== $property->getDeclaringClass()->getName() - ) { - continue; - } - - $mapping = []; - $mapping['fieldName'] = $property->getName(); - - foreach ($this->reader->getPropertyAnnotations($property) as $fieldAnnot) { - if ($fieldAnnot instanceof ODM\Property) { - $mapping = array_merge($mapping, (array) $fieldAnnot); - $metadata->mapField($mapping); - } elseif ($fieldAnnot instanceof ODM\Id) { - $mapping = array_merge($mapping, (array) $fieldAnnot); - $metadata->mapId($mapping); - } elseif ($fieldAnnot instanceof ODM\Node) { - $mapping = array_merge($mapping, (array) $fieldAnnot); - $metadata->mapNode($mapping); - } elseif ($fieldAnnot instanceof ODM\Nodename) { - $mapping = array_merge($mapping, (array) $fieldAnnot); - $metadata->mapNodename($mapping); - } elseif ($fieldAnnot instanceof ODM\ParentDocument) { - $mapping = array_merge($mapping, (array) $fieldAnnot); - $mapping['cascade'] = $this->getCascadeMode($fieldAnnot->cascade); - $metadata->mapParentDocument($mapping); - } elseif ($fieldAnnot instanceof ODM\Child) { - $mapping = array_merge($mapping, (array) $fieldAnnot); - $mapping['cascade'] = $this->getCascadeMode($fieldAnnot->cascade); - $metadata->mapChild($mapping); - } elseif ($fieldAnnot instanceof ODM\Children) { - $mapping = array_merge($mapping, (array) $fieldAnnot); - $mapping['cascade'] = $this->getCascadeMode($fieldAnnot->cascade); - $metadata->mapChildren($mapping); - } elseif ($fieldAnnot instanceof ODM\ReferenceOne) { - $mapping = array_merge($mapping, (array) $fieldAnnot); - $mapping['cascade'] = $this->getCascadeMode($fieldAnnot->cascade); - $metadata->mapManyToOne($mapping); - } elseif ($fieldAnnot instanceof ODM\ReferenceMany) { - $mapping = array_merge($mapping, (array) $fieldAnnot); - $mapping['cascade'] = $this->getCascadeMode($fieldAnnot->cascade); - $metadata->mapManyToMany($mapping); - } elseif ($fieldAnnot instanceof ODM\Referrers) { - $mapping = array_merge($mapping, (array) $fieldAnnot); - $mapping['cascade'] = $this->getCascadeMode($fieldAnnot->cascade); - $metadata->mapReferrers($mapping); - } elseif ($fieldAnnot instanceof ODM\MixedReferrers) { - $mapping = array_merge($mapping, (array) $fieldAnnot); - $metadata->mapMixedReferrers($mapping); - } elseif ($fieldAnnot instanceof ODM\Locale) { - $mapping = array_merge($mapping, (array) $fieldAnnot); - $metadata->mapLocale($mapping); - } elseif ($fieldAnnot instanceof ODM\Depth) { - $mapping = array_merge($mapping, (array) $fieldAnnot); - $metadata->mapDepth($mapping); - } elseif ($fieldAnnot instanceof ODM\VersionName) { - $mapping = array_merge($mapping, (array) $fieldAnnot); - $metadata->mapVersionName($mapping); - } elseif ($fieldAnnot instanceof ODM\VersionCreated) { - $mapping = array_merge($mapping, (array) $fieldAnnot); - $metadata->mapVersionCreated($mapping); - } - } - } - - foreach ($reflClass->getMethods() as $method) { - if ($method->isPublic() && $method->getDeclaringClass()->getName() === $metadata->name) { - foreach ($this->reader->getMethodAnnotations($method) as $annot) { - if ($annot instanceof ODM\PrePersist) { - $metadata->addLifecycleCallback($method->getName(), Event::prePersist); - } elseif ($annot instanceof ODM\PostPersist) { - $metadata->addLifecycleCallback($method->getName(), Event::postPersist); - } elseif ($annot instanceof ODM\PreUpdate) { - $metadata->addLifecycleCallback($method->getName(), Event::preUpdate); - } elseif ($annot instanceof ODM\PostUpdate) { - $metadata->addLifecycleCallback($method->getName(), Event::postUpdate); - } elseif ($annot instanceof ODM\PreRemove) { - $metadata->addLifecycleCallback($method->getName(), Event::preRemove); - } elseif ($annot instanceof ODM\PostRemove) { - $metadata->addLifecycleCallback($method->getName(), Event::postRemove); - } elseif ($annot instanceof ODM\PostLoad) { - $metadata->addLifecycleCallback($method->getName(), Event::postLoad); - } - } - } - } - - $metadata->validateClassMapping(); - } - - /** - * Gathers a list of cascade options found in the given cascade element. - * - * @return int a bitmask of cascade options - */ - private function getCascadeMode(array $cascadeList): int - { - $cascade = 0; - foreach ($cascadeList as $cascadeMode) { - $constantName = 'Doctrine\ODM\PHPCR\Mapping\ClassMetadata::CASCADE_'.strtoupper($cascadeMode); - if (!defined($constantName)) { - throw new MappingException("Cascade mode '$cascadeMode' not supported."); - } - $cascade |= constant($constantName); - } - - return $cascade; - } -} - -interface_exists(ClassMetadata::class); diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Driver/XmlDriver.php b/lib/Doctrine/ODM/PHPCR/Mapping/Driver/XmlDriver.php index 7d8a12005..a85d1ddb3 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Driver/XmlDriver.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Driver/XmlDriver.php @@ -307,7 +307,7 @@ private function getCascadeMode(\SimpleXMLElement $cascadeElement): int foreach ($cascadeElement->children() as $action) { // According to the JPA specifications, XML uses "cascade-persist" // instead of "persist". Here, both variations - // are supported because both YAML and Annotation use "persist" + // are supported because both YAML and Attributes use "persist" // and we want to make sure that this driver doesn't need to know // anything about the supported cascading actions $cascadeMode = str_replace('cascade-', '', $action->getName()); diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/MappingException.php b/lib/Doctrine/ODM/PHPCR/Mapping/MappingException.php index 196d2e4f0..8c1ff5b82 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/MappingException.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/MappingException.php @@ -25,7 +25,7 @@ public static function fieldNotFound(string $documentClass, string $fieldName): } /** - * Non-annotation mappings could specify a fieldName that does not exist on the class. + * XML/YAML mappings can specify a fieldName that does not exist on the class. */ public static function classHasNoField(string $documentClass, string $fieldName): self { diff --git a/lib/Doctrine/ODM/PHPCR/Tools/Console/Command/DumpQueryBuilderReferenceCommand.php b/lib/Doctrine/ODM/PHPCR/Tools/Console/Command/DumpQueryBuilderReferenceCommand.php index 3e87be104..3148b2bb4 100644 --- a/lib/Doctrine/ODM/PHPCR/Tools/Console/Command/DumpQueryBuilderReferenceCommand.php +++ b/lib/Doctrine/ODM/PHPCR/Tools/Console/Command/DumpQueryBuilderReferenceCommand.php @@ -393,7 +393,7 @@ private function getFactoryMethodMap(\ReflectionClass $refl): array if (!array_key_exists(1, $matches)) { throw new \Exception(sprintf( - 'Expected annotation for factoryMethod "%s" to declare a child type.', + 'Expected mapping for factoryMethod "%s" to declare a child type.', $rMethod->name )); } diff --git a/lib/Doctrine/ODM/PHPCR/Tools/Helper/PrefetchHelper.php b/lib/Doctrine/ODM/PHPCR/Tools/Helper/PrefetchHelper.php index 57f03d5ef..0acee973f 100644 --- a/lib/Doctrine/ODM/PHPCR/Tools/Helper/PrefetchHelper.php +++ b/lib/Doctrine/ODM/PHPCR/Tools/Helper/PrefetchHelper.php @@ -51,7 +51,7 @@ public function prefetch(DocumentManagerInterface $dm, iterable $nodes, string $ } /** - * Prefetch all mapped ReferenceOne annotations. + * Prefetch all mapped ReferenceOne fields. * * @param NodeInterface $node the node to prefetch parent and children for */ @@ -64,7 +64,7 @@ public function prefetchReferences(ClassMetadata $class, NodeInterface $node): v } /** - * Prefetch all Child mappings and the ParentDocument if annotations exist. + * Prefetch all Child mappings and the ParentDocument if mapping exist. * * @param NodeInterface $node the node to prefetch parent and children for */ diff --git a/lib/Doctrine/ODM/PHPCR/UnitOfWork.php b/lib/Doctrine/ODM/PHPCR/UnitOfWork.php index 84b249750..9644173bc 100644 --- a/lib/Doctrine/ODM/PHPCR/UnitOfWork.php +++ b/lib/Doctrine/ODM/PHPCR/UnitOfWork.php @@ -241,7 +241,7 @@ public function validateClassName(object $document, ?string $className): void * * Supported hints are * - refresh: reload the fields from the database if set - * - locale: use this locale instead of the one from the annotation or the default + * - locale: use this locale instead of the one from the mapping or the default * - fallback: whether to try other languages or throw a not found * exception if the desired locale is not found. defaults to true if * not set and locale is not given either. @@ -264,7 +264,7 @@ public function getOrCreateDocument(?string $className, NodeInterface $node, arr * * Supported hints are * - refresh: reload the fields from the database if set - * - locale: use this locale instead of the one from the annotation or the default + * - locale: use this locale instead of the one from the mapping or the default * - fallback: whether to try other languages or throw a not found * exception if the desired locale is not found. defaults to true if * not set and locale is not given either. @@ -2396,7 +2396,7 @@ private function executeUpdates(array $documents, bool $dispatchEvents = true): $refClass = $this->dm->getClassMetadata(get_class($fv)); $this->setMixins($refClass, $associatedNode, $fv); if (!$associatedNode->isNodeType('mix:referenceable')) { - throw new PHPCRException(sprintf('Referenced document %s is not referenceable. Use referenceable=true in Document annotation: '.self::objToStr($document, $this->dm), ClassUtils::getClass($fv))); + throw new PHPCRException(sprintf('Referenced document %s is not referenceable. Set referenceable to true in Document mapping: '.self::objToStr($document, $this->dm), ClassUtils::getClass($fv))); } $refNodesIds[] = $associatedNode->getIdentifier(); } @@ -2415,7 +2415,7 @@ private function executeUpdates(array $documents, bool $dispatchEvents = true): $refClass = $this->dm->getClassMetadata(get_class($fieldValue)); $this->setMixins($refClass, $associatedNode, $document); if (!$associatedNode->isNodeType('mix:referenceable')) { - throw new PHPCRException(sprintf('Referenced document %s is not referenceable. Use referenceable=true in Document annotation: '.self::objToStr($document, $this->dm), ClassUtils::getClass($fieldValue))); + throw new PHPCRException(sprintf('Referenced document %s is not referenceable. Set referenceable to true in Document mapping: '.self::objToStr($document, $this->dm), ClassUtils::getClass($fieldValue))); } $node->setProperty($mapping['property'], $associatedNode->getIdentifier(), $strategy); } @@ -2492,7 +2492,7 @@ private function executeUpdates(array $documents, bool $dispatchEvents = true): break; default: // in class metadata we only did a santiy check but not look at the actual mapping - throw new MappingException(sprintf('Field "%s" of document "%s" is not a reference field. Error in referrer annotation: '.self::objToStr($document, $this->dm), $mapping['referencedBy'], ClassUtils::getClass($fv))); + throw new MappingException(sprintf('Field "%s" of document "%s" is not a reference field. Error in referrer mapping: '.self::objToStr($document, $this->dm), $mapping['referencedBy'], ClassUtils::getClass($fv))); } } } @@ -2729,7 +2729,6 @@ public function findVersionByName(?string $className, string $id, string $versio $this->documentHistory[$oid] = $history; $this->documentVersion[$oid] = $version; - // Set the annotations $metadata = $this->dm->getClassMetadata(get_class($frozenDocument)); if ($metadata->versionNameField) { $metadata->reflFields[$metadata->versionNameField]->setValue($frozenDocument, $versionName); diff --git a/tests/Doctrine/Tests/Models/CMS/CmsArticle.php b/tests/Doctrine/Tests/Models/CMS/CmsArticle.php index f3b77c4ca..420c6b7f1 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsArticle.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsArticle.php @@ -4,7 +4,6 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -use mysql_xdevapi\CrudOperationBindable; #[PHPCR\Document] class CmsArticle diff --git a/tests/Doctrine/Tests/Models/Translation/InvalidMapping.php b/tests/Doctrine/Tests/Models/Translation/InvalidMapping.php index 8ecb98c29..fb351c58a 100644 --- a/tests/Doctrine/Tests/Models/Translation/InvalidMapping.php +++ b/tests/Doctrine/Tests/Models/Translation/InvalidMapping.php @@ -3,7 +3,7 @@ /** * !!! WARNING !!! * - * This class is invalid as it uses an invalid key for the @PHPCRODM\Document(translator) annotation. + * This class is invalid as it uses an invalid key for the #[PHPCR\Document](translator) attribute. * This class is supposed to throw an exception when it is read by the ODM !!! */ diff --git a/tests/Doctrine/Tests/Models/Translation/NoLocalePropertyArticle.php b/tests/Doctrine/Tests/Models/Translation/NoLocalePropertyArticle.php index 576dfa489..3eb1815d8 100644 --- a/tests/Doctrine/Tests/Models/Translation/NoLocalePropertyArticle.php +++ b/tests/Doctrine/Tests/Models/Translation/NoLocalePropertyArticle.php @@ -9,10 +9,9 @@ * * !!! WARNING !!! * - * This class is invalid as it uses an invalid key for the @PHPCRODM\Document(translator) annotation. + * This class is invalid as it uses an invalid key for the #[PHPCR\Document](translator) attribute. * This class is supposed to throw an exception when it is read by the ODM !!! */ - #[PHPCR\Document(translator: 'attribute')] class NoLocalePropertyArticle { diff --git a/tests/Doctrine/Tests/Models/Versioning/InconsistentVersionableArticle.php b/tests/Doctrine/Tests/Models/Versioning/InconsistentVersionableArticle.php index 767752e96..62c741000 100644 --- a/tests/Doctrine/Tests/Models/Versioning/InconsistentVersionableArticle.php +++ b/tests/Doctrine/Tests/Models/Versioning/InconsistentVersionableArticle.php @@ -5,7 +5,7 @@ use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; /** - * This document has a Version annotated field but it is not marked as versionable + * This document has a Version annotated field but it is not marked as versionable. */ #[PHPCR\Document] class InconsistentVersionableArticle diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/Mapping/AnnotationMappingTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Mapping/AnnotationMappingTest.php deleted file mode 100644 index 90b8d69b1..000000000 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/Mapping/AnnotationMappingTest.php +++ /dev/null @@ -1,383 +0,0 @@ -dm = $this->createDocumentManager([__DIR__], true); - $this->resetFunctionalNode($this->dm); - } - - public function testAnnotationInheritance(): void - { - $extending = new ExtendingClass(); - $extending->id = '/functional/extending'; - $extending->text = 'test text'; - - $this->dm->persist($extending); - $this->dm->flush(); - - $this->assertEquals(1, $extending->callback_run); - $this->assertEquals(1, $extending->extending_run); - } - - public function testSecondLevelInheritance(): void - { - $second = new SecondLevel(); - $second->id = '/functional/second'; - $this->dm->persist($second); - } - - public function testSecondLevelInheritanceWithDuplicate(): void - { - $second = new SecondLevelWithDuplicate(); - $second->id = '/functional/second'; - $second->text = 'text test'; - - $this->expectException(MappingException::class); - $this->dm->persist($second); - } - - public function testSecondLevelOverwrite(): void - { - $localePrefs = [ - 'en' => ['en', 'de'], - 'de' => ['de', 'en'], - ]; - - $this->dm->setLocaleChooserStrategy(new LocaleChooser($localePrefs, 'en')); - - $secondTrans = new SecondLevelWithDuplicateOverwrite(); - $secondTrans->id = '/functional/secondTrans'; - $secondTrans->text = 'deutsch'; - $this->dm->persist($secondTrans); - $this->dm->bindTranslation($secondTrans, 'de'); - $secondTrans->text = 'english'; - $this->dm->bindTranslation($secondTrans, 'en'); - - $this->dm->flush(); - - $tmpDocDe = $this->dm->findTranslation(null, '/functional/secondTrans', 'de'); - - $this->assertEquals($tmpDocDe->text, 'deutsch'); - - $tmpDocEn = $this->dm->findTranslation(null, '/functional/secondTrans', 'en'); - - $this->assertEquals($tmpDocEn->text, 'english'); - } - - /** - * @dataProvider generatorTypeProvider - * - * @param string $class the fqn class name to load - * @param int $type the generator type constant - * @param string $description to be used in case of failure - */ - public function testIdStrategy($class, $type, $description): void - { - $metadata = $this->dm->getClassMetadata($class); - $this->assertEquals($type, $metadata->idGenerator, $description); - } - - public function generatorTypeProvider(): array - { - return [ - [ - ParentIdStrategy::class, - ClassMetadata::GENERATOR_TYPE_PARENT, - 'parentId', - ], - [ - ParentIdStrategyDifferentOrder::class, - ClassMetadata::GENERATOR_TYPE_PARENT, - 'parentId2', - ], - [ - AutoNameIdStrategy::class, - ClassMetadata::GENERATOR_TYPE_AUTO, - 'autoname as only has parent but not nodename', - ], - [ - AssignedIdStrategy::class, - ClassMetadata::GENERATOR_TYPE_ASSIGNED, - 'assigned', - ], - [ - RepositoryIdStrategy::class, - ClassMetadata::GENERATOR_TYPE_REPOSITORY, - 'repository', - ], - [ - StandardCase::class, - ClassMetadata::GENERATOR_TYPE_ASSIGNED, - 'standardcase', - ], - ]; - } - - /** - * @dataProvider invalidIdProvider - * - * @param string $class fqn of a class with invalid mapping - */ - public function testInvalidId(string $class): void - { - $this->expectException(MappingException::class); - $this->dm->getClassMetadata($class); - } - - public function invalidIdProvider(): array - { - return [ - [ - ParentIdNoParentStrategy::class, - AutoNameIdNoParentStrategy::class, - NoId::class, - ], - ]; - } - - public function testPersistParentId(): void - { - $doc = new ParentIdStrategy(); - $doc->name = 'parent-strategy'; - $doc->parent = $this->dm->find(null, '/functional'); - $this->dm->persist($doc); - $this->dm->flush(); - $this->dm->clear(); - $this->assertInstanceOf(ParentIdStrategy::class, $this->dm->find(null, '/functional/parent-strategy')); - } - - public function testPersistAutoNameId(): void - { - $doc = new AutoNameIdStrategy(); - $doc->parent = $this->dm->find(null, '/functional'); - $this->dm->persist($doc); - $this->dm->flush(); - $id = $this->dm->getUnitOfWork()->getDocumentId($doc); - $this->dm->clear(); - $this->assertInstanceOf(AutoNameIdStrategy::class, $this->dm->find(null, $id)); - } - - public function testPersistRepository(): void - { - $doc = new RepositoryIdStrategy(); - $doc->title = 'repository strategy'; - $this->dm->persist($doc); - $this->dm->flush(); - $id = $this->dm->getUnitOfWork()->getDocumentId($doc); - $this->dm->clear(); - $this->assertInstanceOf(RepositoryIdStrategy::class, $this->dm->find(null, $id)); - } - - // TODO comprehensive test for all possible mapped fields in an abstract test, trying to persist and check if properly set - // then dm->clear and check if still properly set. - - // then a test per mapping implementation extending the abstract test and providing documents with the mapping -} - -/** - * @PHPCRODM\Document() - */ -class Testclass -{ - /** @PHPCRODM\Id */ - public $id; - - /** @PHPCRODM\Node */ - public $node; - - /** @PHPCRODM\Field(type="string") */ - public $text; - - /** @PHPCRODM\Depth */ - public $depth; - - public $callback_run = 0; - - /** - * @PHPCRODM\PostPersist - */ - public function callback(): void - { - ++$this->callback_run; - } -} - -/** - * @PHPCRODM\Document() - */ -class ExtendingClass extends Testclass -{ - /** @PHPCRODM\ReferenceOne */ - public $reference; - - public $extending_run = 0; - - /** - * @PHPCRODM\PostPersist - */ - public function extendingCallback(): void - { - ++$this->extending_run; - } -} - -/** - * @PHPCRODM\Document() - */ -class SecondLevel extends ExtendingClass -{ -} - -/** - * @PHPCRODM\Document() - */ -class SecondLevelWithDuplicate extends ExtendingClass -{ - /** @PHPCRODM\Field(type="long") */ - public $text; -} - -/** - * @PHPCRODM\Document(translator="attribute") - */ -class SecondLevelWithDuplicateOverwrite extends ExtendingClass -{ - /** @PHPCRODM\Locale */ - public $locale; - - /** @PHPCRODM\Field(type="string", translated=true) */ - public $text; -} - -/** - * @PHPCRODM\Document - */ -class ParentIdStrategy -{ - /** @PHPCRODM\Nodename */ - public $name; - - /** @PHPCRODM\ParentDocument */ - public $parent; -} - -/** - * @PHPCRODM\Document - */ -class ParentIdStrategyDifferentOrder -{ - /** @PHPCRODM\Nodename */ - public $name; - - /** @PHPCRODM\ParentDocument */ - public $parent; - - /** @PHPCRODM\Id */ - public $id; -} - -/** - * @PHPCRODM\Document - */ -class AutoNameIdStrategy -{ - /** @PHPCRODM\ParentDocument */ - public $parent; -} - -/** - * @PHPCRODM\Document - */ -class AssignedIdStrategy -{ - /** @PHPCRODM\Id(strategy="assigned") */ - public $id; - - /** @PHPCRODM\Nodename */ - public $name; - - /** @PHPCRODM\ParentDocument */ - public $parent; -} - -/** - * @PHPCRODM\Document(repositoryClass="Doctrine\Tests\ODM\PHPCR\Functional\Mapping\Repository") - */ -class RepositoryIdStrategy -{ - public $title; - - /** @PHPCRODM\Id(strategy="repository") */ - public $id; -} -class Repository extends DocumentRepository implements RepositoryIdInterface -{ - public function generateId(object $document, object $parent = null): string - { - return '/functional/'.str_replace(' ', '-', $document->title); - } -} - -/** - * @PHPCRODM\Document - * - * Invalid document missing a parent mapping for the id strategy - */ -class ParentIdNoParentStrategy -{ - /** @PHPCRODM\Id(strategy="parent") */ - public $id; - - /** @PHPCRODM\Nodename */ - public $name; -} - -/** - * @PHPCRODM\Document - * - * Invalid document not having a parent mapping. - */ -class AutoNameIdNoParentStrategy -{ - /** @PHPCRODM\Id(strategy="auto") */ - public $id; -} - -/** - * @PHPCRODM\Document - * - * Invalid document not having an id at all. - */ -class NoId -{ -} - -/** - * @PHPCRODM\Document - */ -class StandardCase -{ - /** @PHPCRODM\Id */ - public $id; -} diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/Mapping/Attribute/AttributeMappingTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Mapping/AttributeMappingTest.php similarity index 98% rename from tests/Doctrine/Tests/ODM/PHPCR/Functional/Mapping/Attribute/AttributeMappingTest.php rename to tests/Doctrine/Tests/ODM/PHPCR/Functional/Mapping/AttributeMappingTest.php index b04d086ef..9734b2cd1 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/Mapping/Attribute/AttributeMappingTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Mapping/AttributeMappingTest.php @@ -1,6 +1,6 @@ resetFunctionalNode($this->dm); } - public function testAnnotationInheritance(): void + public function testAttributeInheritance(): void { $extending = new ExtendingClass(); $extending->id = '/functional/extending'; @@ -316,7 +316,7 @@ public function generateId($document, $parent = null) } /** - * Invalid document missing a parent mapping for the id strategy + * Invalid document missing a parent mapping for the id strategy. */ #[PHPCR\Document] class ParentIdNoParentStrategy @@ -339,7 +339,6 @@ class AutoNameIdNoParentStrategy } /** - * * Invalid document not having an id at all. */ #[PHPCR\Document] diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/MixinTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/MixinTest.php index 15a09f0d7..bd9ab70ba 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/MixinTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/MixinTest.php @@ -117,7 +117,7 @@ public function testChangingProtectedPropertyToNullThrowsException(): void } /** - * A class that contains mapped children via properties + * A class that contains mapped children via properties. */ #[PHPCR\Document(mixins: ['mix:created'])] class TestObject diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/ReferrerTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/ReferrerTest.php index b8a0867af..cf30042f9 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/ReferrerTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/ReferrerTest.php @@ -661,7 +661,7 @@ class WeakReferrerTestObj public $id; /** - * Should implicitly default to strategy="weak" + * Should implicitly default to strategy="weak". */ #[PHPCR\ReferenceOne(targetDocument: WeakReferrerRefTestObj::class, cascade: 'persist')] public $referenceToWeak; diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/Translation/TranslationTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Translation/TranslationTest.php index 458d7a576..80d5e2e79 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/Translation/TranslationTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Translation/TranslationTest.php @@ -39,9 +39,9 @@ public function testVariantNamespaceRegistered(): void } /** - * Test the annotations pertaining to translations are correctly loaded. + * Test the attributes pertaining to translations are correctly loaded. */ - public function testLoadAnnotations(): void + public function testLoadAttributes(): void { $factory = new ClassMetadataFactory($this->dm); $metadata = $factory->getMetadataFor(Article::class); @@ -61,9 +61,9 @@ public function testLoadAnnotations(): void } /** - * Test loading of a translatable document missing the Locale annotation. + * Test loading of a translatable document missing the Locale attribute. */ - public function testLoadMissingLocaleAnnotation(): void + public function testLoadMissingLocaleAttribute(): void { $factory = new ClassMetadataFactory($this->dm); diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/Versioning/AnnotationsTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Versioning/AttributesTest.php similarity index 87% rename from tests/Doctrine/Tests/ODM/PHPCR/Functional/Versioning/AnnotationsTest.php rename to tests/Doctrine/Tests/ODM/PHPCR/Functional/Versioning/AttributesTest.php index 25de35d68..353707802 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/Versioning/AnnotationsTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Versioning/AttributesTest.php @@ -16,7 +16,7 @@ use PHPCR\NodeInterface; use PHPCR\SessionInterface; -class AnnotationsTest extends PHPCRFunctionalTestCase +class AttributesTest extends PHPCRFunctionalTestCase { /** * @var DocumentManager @@ -35,27 +35,27 @@ public function setUp(): void } /** - * Test the annotations pertaining to versioning are correctly loaded. + * Test the attributes pertaining to versioning are correctly loaded. */ - public function testLoadAnnotations(): void + public function testLoadAttributes(): void { $factory = new ClassMetadataFactory($this->dm); - // Check the annotation is correctly read if it is present + // Check the attribute is correctly read if it is present $metadata = $factory->getMetadataFor(VersionableArticle::class); $this->assertInstanceOf(ClassMetadata::class, $metadata); $this->assertEquals('simple', $metadata->versionable); - // Check the annotation is not set if it is not present + // Check the attribute is not set if it is not present $metadata = $factory->getMetadataFor(NonVersionableArticle::class); $this->assertInstanceOf(ClassMetadata::class, $metadata); $this->assertFalse($metadata->versionable); } /** - * Test that using an invalid versionable annotation will not work. + * Test that using an invalid versionable attribute will not work. */ - public function testLoadInvalidAnnotation(): void + public function testLoadInvalidAttributes(): void { $factory = new ClassMetadataFactory($this->dm); @@ -64,9 +64,9 @@ public function testLoadInvalidAnnotation(): void } /** - * Test that using the Version annotation on non-versionable documents will not work. + * Test that using the Version attribute on non-versionable documents will not work. */ - public function testLoadInconsistentAnnotations(): void + public function testLoadInconsistentAttributes(): void { $factory = new ClassMetadataFactory($this->dm); @@ -77,7 +77,7 @@ public function testLoadInconsistentAnnotations(): void /** * Check that persisting a node with the versionable type will add the correct mixin to the node. */ - public function testAnnotationOnPersist(): void + public function testAttributeOnPersist(): void { $repository = $this->dm->getPhpcrSession()->getRepository(); if (!$repository->getDescriptor('option.versioning.supported')) { diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/AbstractMappingDriverTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/AbstractMappingDriverTest.php index dcccbcbc2..9f1962ff2 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/AbstractMappingDriverTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/AbstractMappingDriverTest.php @@ -116,7 +116,7 @@ public function testGetAllClassNamesReturnsOnlyTheAppropriateClasses(): void /** * @covers \Doctrine\ODM\PHPCR\Mapping\Driver\XmlDriver::loadMetadataForClass * @covers \Doctrine\ODM\PHPCR\Mapping\Driver\YamlDriver::loadMetadataForClass - * @covers \Doctrine\ODM\PHPCR\Mapping\Driver\AnnotationDriver::loadMetadataForClass + * @covers \Doctrine\ODM\PHPCR\Mapping\Driver\AttributeDriver::loadMetadataForClass * * @doesNotPerformAssertions */ diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/AnnotationDriverTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/AnnotationDriverTest.php deleted file mode 100644 index eb10bbe87..000000000 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/AnnotationDriverTest.php +++ /dev/null @@ -1,37 +0,0 @@ -loadDriver(); - $annotationDriver->addPaths([__DIR__.'/Model']); - - return $annotationDriver; - } - - /** - * Overwriting private parent properties isn't supported with annotations. - * - * @doesNotPerformAssertions - */ - public function testParentWithPrivatePropertyMapping(): void - { - } -} diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/AttributeDriverTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/AttributeDriverTest.php index b9a4c3d43..b60132d0d 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/AttributeDriverTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/AttributeDriverTest.php @@ -24,7 +24,7 @@ protected function loadDriverForTestMappingDocuments(): MappingDriver } /** - * Overwriting private parent properties isn't supported with annotations. + * Overwriting private parent properties isn't supported with attributes. * * @doesNotPerformAssertions */ diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/ClassMetadataFactoryTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/ClassMetadataFactoryTest.php index 6173a1b88..fb68b19b0 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/ClassMetadataFactoryTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/ClassMetadataFactoryTest.php @@ -2,12 +2,11 @@ namespace Doctrine\Tests\ODM\PHPCR\Mapping; -use Doctrine\Common\Annotations\AnnotationReader; use Doctrine\ODM\PHPCR\DocumentManager; use Doctrine\ODM\PHPCR\Event; use Doctrine\ODM\PHPCR\Mapping\ClassMetadata; use Doctrine\ODM\PHPCR\Mapping\ClassMetadataFactory; -use Doctrine\ODM\PHPCR\Mapping\Driver\AnnotationDriver; +use Doctrine\ODM\PHPCR\Mapping\Driver\AttributeDriver; use Doctrine\ODM\PHPCR\Mapping\MappingException; use Doctrine\Persistence\Event\LoadClassMetadataEventArgs; use Doctrine\Persistence\Mapping\Driver\PHPDriver; @@ -35,14 +34,10 @@ class ClassMetadataFactoryTest extends TestCase protected function getMetadataFor(string $fqn): ClassMetadata { - $reader = new AnnotationReader(); - $annotationDriver = new AnnotationDriver($reader); - $annotationDriver->addPaths([__DIR__.'/Model']); - $this->dm->getConfiguration()->setMetadataDriverImpl($annotationDriver); + $attributeDriver = new AttributeDriver([__DIR__.'/Model']); + $this->dm->getConfiguration()->setMetadataDriverImpl($attributeDriver); - $cmf = new ClassMetadataFactory($this->dm); - - return $cmf->getMetadataFor($fqn); + return (new ClassMetadataFactory($this->dm))->getMetadataFor($fqn); } public function setUp(): void diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/ClassMetadataTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/ClassMetadataTest.php index 4f442e6fd..57e557d08 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/ClassMetadataTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/ClassMetadataTest.php @@ -2,12 +2,11 @@ namespace Doctrine\Tests\ODM\PHPCR\Mapping; -use Doctrine\Common\Annotations\AnnotationReader; use Doctrine\ODM\PHPCR\DocumentRepository as BaseDocumentRepository; use Doctrine\ODM\PHPCR\Exception\OutOfBoundsException; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; use Doctrine\ODM\PHPCR\Mapping\ClassMetadata; -use Doctrine\ODM\PHPCR\Mapping\Driver\AnnotationDriver; +use Doctrine\ODM\PHPCR\Mapping\Driver\AttributeDriver; use Doctrine\ODM\PHPCR\Mapping\MappingException; use Doctrine\Persistence\Mapping\RuntimeReflectionService; use Doctrine\Tests\Models\CMS\CmsAddress; @@ -149,8 +148,7 @@ public function testMapField(ClassMetadata $cm): ClassMetadata public function testMapFieldWithInheritance(ClassMetadata $cmp): void { // Load parent document metadata. - $ar = new AnnotationReader(); - $ad = new AnnotationDriver($ar); + $ad = new AttributeDriver([]); $ad->loadMetadataForClass($cmp->getName(), $cmp); // Initialize subclass metadata. @@ -429,6 +427,7 @@ class Customer extends Person /** * @PHPCRODM\Document(translator="attribute") */ +#[PHPCR\Document(translator: 'attribute')] class Person { public $id; @@ -443,14 +442,10 @@ class Person public $attachments; - /** - * @PHPCRODM\Locale - */ + #[PHPCR\Locale] public $locale; - /** - * @PHPCRODM\Field(type="string", translated=true) - */ + #[PHPCR\Field(type: 'string', translated: true)] public $translatedField; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ChildClassesAndLeafObject.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ChildClassesAndLeafObject.php index 5cc51420e..f83bc283e 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ChildClassesAndLeafObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ChildClassesAndLeafObject.php @@ -2,20 +2,14 @@ namespace Doctrine\Tests\ODM\PHPCR\Mapping\Model; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; /** * A class that contains mapped children via properties. - * - * @PHPCRODM\Document(childClasses={ - * "stdClass", - * }, isLeaf=true) */ #[PHPCR\Document(childClasses: [\stdClass::class], isLeaf: true)] class ChildClassesAndLeafObject { - /** @PHPCRODM\Id */ #[PHPCR\Id] public $id; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ChildClassesObject.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ChildClassesObject.php index 150c66037..53d6db0a1 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ChildClassesObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ChildClassesObject.php @@ -2,20 +2,14 @@ namespace Doctrine\Tests\ODM\PHPCR\Mapping\Model; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; /** * A class that contains mapped children via properties. - * - * @PHPCRODM\Document(childClasses={ - * "stdClass", - * }, isLeaf=false) */ #[PHPCR\Document(childClasses: [\stdClass::class], isLeaf: false)] class ChildClassesObject { - /** @PHPCRODM\Id */ #[PHPCR\Id] public $id; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ChildMappingObject.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ChildMappingObject.php index 9c7ffdd58..91895dff7 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ChildMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ChildMappingObject.php @@ -2,26 +2,20 @@ namespace Doctrine\Tests\ODM\PHPCR\Mapping\Model; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; /** * A class that contains mapped children via properties. - * - * @PHPCRODM\Document */ #[PHPCR\Document] class ChildMappingObject { - /** @PHPCRODM\Id */ #[PHPCR\Id] public $id; - /** @PHPCRODM\Child(nodeName="first") */ #[PHPCR\Child(nodeName: 'first')] public $child1; - /** @PHPCRODM\Child(nodeName="second") */ #[PHPCR\Child(nodeName: 'second')] public $child2; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ChildrenMappingObject.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ChildrenMappingObject.php index 65d9defb1..969c31d2e 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ChildrenMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ChildrenMappingObject.php @@ -2,26 +2,20 @@ namespace Doctrine\Tests\ODM\PHPCR\Mapping\Model; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; /** * A class that contains mapped children via properties. - * - * @PHPCRODM\Document */ #[PHPCR\Document] class ChildrenMappingObject { - /** @PHPCRODM\Id */ #[PHPCR\Id] public $id; - /** @PHPCRODM\Children() */ #[PHPCR\Children] public $all; - /** @PHPCRODM\Children(filter="*some*", fetchDepth=2, cascade={"persist", "remove"}) */ #[PHPCR\Children(filter: '*some*', fetchDepth: 2, cascade: ['persist', 'remove'])] public $some; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ClassInheritanceChildMappingObject.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ClassInheritanceChildMappingObject.php index 6fc615b54..b5c65bf10 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ClassInheritanceChildMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ClassInheritanceChildMappingObject.php @@ -2,14 +2,11 @@ namespace Doctrine\Tests\ODM\PHPCR\Mapping\Model; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; /** * A class that represents a child class for the purposes * of testing class property inheritance. - * - * @PHPCRODM\Document() */ #[PHPCR\Document] class ClassInheritanceChildMappingObject extends ClassInheritanceParentMappingObject diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ClassInheritanceChildOverridesMappingObject.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ClassInheritanceChildOverridesMappingObject.php index 84dbb10de..847a0dd15 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ClassInheritanceChildOverridesMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ClassInheritanceChildOverridesMappingObject.php @@ -2,28 +2,18 @@ namespace Doctrine\Tests\ODM\PHPCR\Mapping\Model; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; /** * A class that represents a parent class for the purposes * of testing class property inheritance. - * - * @PHPCRODM\Document( - * nodeType="nt:test-override", - * mixins="mix:baz", - * inheritMixins=false, - * translator="bar", - * repositoryClass="BarfooRepository", - * versionable="full" - * ) */ #[PHPCR\Document( nodeType: 'nt:test-override', + repositoryClass: BarfooRepository::class, + translator: 'bar', mixins: ['mix:baz'], inheritMixins: false, - translator: 'bar', - repositoryClass: BarfooRepository::class, versionable: 'full', )] class ClassInheritanceChildOverridesMappingObject extends ClassInheritanceParentMappingObject diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ClassInheritanceParentMappingObject.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ClassInheritanceParentMappingObject.php index bc99f3dda..d4984c0bf 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ClassInheritanceParentMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ClassInheritanceParentMappingObject.php @@ -2,21 +2,11 @@ namespace Doctrine\Tests\ODM\PHPCR\Mapping\Model; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; /** * A class that represents a parent class for the purposes * of testing class property inheritance. - * - * @PHPCRODM\Document( - * referenceable=true, - * nodeType="nt:test", - * mixins={"mix:foo","mix:bar"}, - * translator="foo", - * repositoryClass="DocumentRepository", - * versionable="simple" - * ) */ #[PHPCR\Document( nodeType: 'nt:test', @@ -27,7 +17,6 @@ )] class ClassInheritanceParentMappingObject { - /** @PHPCRODM\Id */ #[PHPCR\Id] public $id; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/DefaultMappingObject.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/DefaultMappingObject.php index bb4d5e96e..07ba5a6d4 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/DefaultMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/DefaultMappingObject.php @@ -2,18 +2,14 @@ namespace Doctrine\Tests\ODM\PHPCR\Mapping\Model; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; /** * A class with no explicitly set properties for testing default values. - * - * @PHPCRODM\Document */ #[PHPCR\Document] class DefaultMappingObject { - /** @PHPCRODM\Id */ #[PHPCR\Id] public $id; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/DepthMappingObject.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/DepthMappingObject.php index adffcd60c..7a734ce22 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/DepthMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/DepthMappingObject.php @@ -2,22 +2,17 @@ namespace Doctrine\Tests\ODM\PHPCR\Mapping\Model; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; /** * A class that contains a mapped parent document via properties. - * - * @PHPCRODM\Document */ #[PHPCR\Document] class DepthMappingObject { - /** @PHPCRODM\Id */ #[PHPCR\Id] public $id; - /** @PHPCRODM\Depth */ #[PHPCR\Depth] public $depth; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/FieldMappingObject.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/FieldMappingObject.php index 39b1b9810..ea99b216b 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/FieldMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/FieldMappingObject.php @@ -2,66 +2,50 @@ namespace Doctrine\Tests\ODM\PHPCR\Mapping\Model; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; /** * A class that contains mapped fields via properties. - * - * @PHPCRODM\Document */ #[PHPCR\Document] class FieldMappingObject { - /** @PHPCRODM\Id */ #[PHPCR\Id] public $id; - /** @PHPCRODM\Field(type="string") */ #[PHPCR\Field(type: 'string')] public $string; - /** @PHPCRODM\Field(type="binary") */ #[PHPCR\Field(type: 'binary')] public $binary; - /** @PHPCRODM\Field(type="long") */ #[PHPCR\Field(type: 'long')] public $long; - /** @PHPCRODM\Field(type="long") */ #[PHPCR\Field(type: 'long')] public $int; - /** @PHPCRODM\Field(type="decimal") */ #[PHPCR\Field(type: 'decimal')] public $decimal; - /** @PHPCRODM\Field(type="double") */ #[PHPCR\Field(type: 'double')] public $double; - /** @PHPCRODM\Field(type="double") */ #[PHPCR\Field(type: 'double')] public $float; - /** @PHPCRODM\Field(type="date") */ #[PHPCR\Field(type: 'date')] public $date; - /** @PHPCRODM\Field(type="boolean") */ #[PHPCR\Field(type: 'boolean')] public $boolean; - /** @PHPCRODM\Field(type="name") */ #[PHPCR\Field(type: 'name')] public $name; - /** @PHPCRODM\Field(type="path") */ #[PHPCR\Field(type: 'path')] public $path; - /** @PHPCRODM\Field(type="uri") */ #[PHPCR\Field(type: 'uri')] public $uri; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/InheritedMixinMappingObject.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/InheritedMixinMappingObject.php index b56eaa235..95429af64 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/InheritedMixinMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/InheritedMixinMappingObject.php @@ -2,22 +2,17 @@ namespace Doctrine\Tests\ODM\PHPCR\Mapping\Model; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; /** * A class that contains mapped children via properties. - * - * @PHPCRODM\Document(mixins={"mix:title"}) */ #[PHPCR\Document(mixins: ['mix:title'])] class InheritedMixinMappingObject extends MixinMappingObject { - /** @PHPCRODM\Field(type="string", property="jcr:title") */ #[PHPCR\Field(type: 'string', property: 'jcr:title')] public $title; - /** @PHPCRODM\Field(type="string", property="jcr:description") */ #[PHPCR\Field(type: 'string', property: 'jcr:description')] public $description; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/IsLeafObject.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/IsLeafObject.php index b2ac89fb4..170b91042 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/IsLeafObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/IsLeafObject.php @@ -2,18 +2,14 @@ namespace Doctrine\Tests\ODM\PHPCR\Mapping\Model; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; /** * A class that contains mapped children via properties. - * - * @PHPCRODM\Document(isLeaf=true) */ #[PHPCR\Document(isLeaf: true)] class IsLeafObject { - /** @PHPCRODM\Id */ #[PHPCR\Id] public $id; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/LifecycleCallbackMappingObject.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/LifecycleCallbackMappingObject.php index b66d5a17c..9a7de9baa 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/LifecycleCallbackMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/LifecycleCallbackMappingObject.php @@ -2,58 +2,47 @@ namespace Doctrine\Tests\ODM\PHPCR\Mapping\Model; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; /** * A class that uses Lifecycle Callbacks. - * - * @PHPCRODM\Document */ #[PHPCR\Document] class LifecycleCallbackMappingObject { - /** @PHPCRODM\Id */ #[PHPCR\Id] public $id; - /** @PHPCRODM\PreRemove */ #[PHPCR\PreRemove] public function preRemoveFunc() { } - /** @PHPCRODM\PostRemove */ #[PHPCR\PostRemove] public function postRemoveFunc() { } - /** @PHPCRODM\PrePersist */ #[PHPCR\PrePersist] public function prePersistFunc() { } - /** @PHPCRODM\PostPersist */ #[PHPCR\PostPersist] public function postPersistFunc() { } - /** @PHPCRODM\PreUpdate */ #[PHPCR\PreUpdate] public function preUpdateFunc() { } - /** @PHPCRODM\PostUpdate */ #[PHPCR\PostUpdate] public function postUpdateFunc() { } - /** @PHPCRODM\PostLoad */ #[PHPCR\PostLoad] public function postLoadFunc() { diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/MappedSuperclassMappingObject.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/MappedSuperclassMappingObject.php index 6754e2784..d6dc8efdc 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/MappedSuperclassMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/MappedSuperclassMappingObject.php @@ -2,13 +2,10 @@ namespace Doctrine\Tests\ODM\PHPCR\Mapping\Model; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; /** * A class that uses the repository strategy to generate IDs. - * - * @PHPCRODM\MappedSuperclass(nodeType="phpcr:test", repositoryClass="Doctrine\Tests\ODM\PHPCR\Mapping\Model\DocumentRepository", translator="children", mixins={"mix:one", "mix:two"}, versionable="simple", referenceable=true) */ #[PHPCR\MappedSuperclass( nodeType: 'phpcr:test', @@ -20,7 +17,6 @@ )] class MappedSuperclassMappingObject { - /** @PHPCRODM\Id */ #[PHPCR\Id] public $id; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/MixinMappingObject.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/MixinMappingObject.php index abfcc39b0..560865e1d 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/MixinMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/MixinMappingObject.php @@ -2,30 +2,23 @@ namespace Doctrine\Tests\ODM\PHPCR\Mapping\Model; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; /** * A class that contains mapped children via properties. - * - * @PHPCRODM\Document(mixins={"mix:lastModified"}) */ #[PHPCR\Document(mixins: ['mix:lastModified'])] class MixinMappingObject { - /** @PHPCRODM\Id */ #[PHPCR\Id] public $id; - /** @PHPCRODM\Node */ #[PHPCR\Node] public $node; - /** @PHPCRODM\Field(type="date", property="jcr:lastModified") */ - #[PHPCR\Field(type: 'date', property: 'jcr:lastModified')] + #[PHPCR\Field(property: 'jcr:lastModified', type: 'date')] public $lastModified; - /** @PHPCRODM\Field(type="string", property="jcr:lastModifiedBy") */ - #[PHPCR\Field(type: 'string', property: 'jcr:lastModifiedBy')] + #[PHPCR\Field(property: 'jcr:lastModifiedBy', type: 'string')] public $lastModifiedBy; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/NodeMappingObject.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/NodeMappingObject.php index ef75e1ad8..c7f4b1511 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/NodeMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/NodeMappingObject.php @@ -2,22 +2,17 @@ namespace Doctrine\Tests\ODM\PHPCR\Mapping\Model; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; /** * A class that uses the repository strategy to generate IDs. - * - * @PHPCRODM\Document */ #[PHPCR\Document] class NodeMappingObject { - /** @PHPCRODM\Id */ #[PHPCR\Id] public $id; - /** @PHPCRODM\Node */ #[PHPCR\Node] public $node; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/NodeTypeMappingObject.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/NodeTypeMappingObject.php index 9598e2349..8086c37b7 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/NodeTypeMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/NodeTypeMappingObject.php @@ -2,18 +2,14 @@ namespace Doctrine\Tests\ODM\PHPCR\Mapping\Model; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; /** * A class that uses the repository strategy to generate IDs. - * - * @PHPCRODM\Document(nodeType="nt:test") */ #[PHPCR\Document(nodeType: 'nt:test')] class NodeTypeMappingObject { - /** @PHPCRODM\Id */ #[PHPCR\Id] public $id; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/NodenameMappingObject.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/NodenameMappingObject.php index 32f548ed6..4ab5e25d8 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/NodenameMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/NodenameMappingObject.php @@ -2,22 +2,17 @@ namespace Doctrine\Tests\ODM\PHPCR\Mapping\Model; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; /** * A class that contains mapped fields via properties. - * - * @PHPCRODM\Document */ #[PHPCR\Document] class NodenameMappingObject { - /** @PHPCRODM\Id */ #[PHPCR\Id] public $id; - /** @PHPCRODM\Nodename */ #[PHPCR\Nodename] public $namefield; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ParentDocumentMappingObject.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ParentDocumentMappingObject.php index 223c1d21a..ae01c0efa 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ParentDocumentMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ParentDocumentMappingObject.php @@ -2,22 +2,17 @@ namespace Doctrine\Tests\ODM\PHPCR\Mapping\Model; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; /** * A class that contains a mapped parent document via properties. - * - * @PHPCRODM\Document */ #[PHPCR\Document] class ParentDocumentMappingObject { - /** @PHPCRODM\Id */ #[PHPCR\Id] public $id; - /** @PHPCRODM\ParentDocument */ #[PHPCR\ParentDocument] public $parent; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferenceManyMappingObject.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferenceManyMappingObject.php index 5f4d3297b..48baac1e3 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferenceManyMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferenceManyMappingObject.php @@ -2,26 +2,20 @@ namespace Doctrine\Tests\ODM\PHPCR\Mapping\Model; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; /** * A class that references many other documents. - * - * @PHPCRODM\Document */ #[PHPCR\Document] class ReferenceManyMappingObject { - /** @PHPCRODM\Id */ #[PHPCR\Id] public $id; - /** @PHPCRODM\ReferenceMany(targetDocument="myDocument", strategy="weak") */ #[PHPCR\ReferenceMany(targetDocument: 'myDocument', strategy: 'weak')] public $referenceManyWeak; - /** @PHPCRODM\ReferenceMany(targetDocument="myDocument", strategy="hard") */ #[PHPCR\ReferenceMany(targetDocument: 'myDocument', strategy: 'hard')] public $referenceManyHard; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferenceOneMappingObject.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferenceOneMappingObject.php index 5722ef183..2054b0390 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferenceOneMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferenceOneMappingObject.php @@ -2,26 +2,20 @@ namespace Doctrine\Tests\ODM\PHPCR\Mapping\Model; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; /** * A class that references one other document. - * - * @PHPCRODM\Document */ #[PHPCR\Document] class ReferenceOneMappingObject { - /** @PHPCRODM\Id */ #[PHPCR\Id] public $id; - /** @PHPCRODM\ReferenceOne(targetDocument="myDocument", strategy="weak") */ #[PHPCR\ReferenceOne(targetDocument: 'myDocument', strategy: 'weak')] public $referenceOneWeak; - /** @PHPCRODM\ReferenceOne(targetDocument="myDocument", strategy="hard") */ #[PHPCR\ReferenceOne(targetDocument: 'myDocument', strategy: 'hard')] public $referenceOneHard; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferenceableChildMappingObject.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferenceableChildMappingObject.php index 79691c266..206967cbe 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferenceableChildMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferenceableChildMappingObject.php @@ -2,19 +2,15 @@ namespace Doctrine\Tests\ODM\PHPCR\Mapping\Model; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; /** * Object which extends a referenceable object and so should also * be referenceable. - * - * @PHPCRODM\Document() */ #[PHPCR\Document] class ReferenceableChildMappingObject extends ReferenceableMappingObject { - /** @PHPCRODM\Id */ #[PHPCR\Id] public $id; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferenceableChildReferenceableFalseMappingObject.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferenceableChildReferenceableFalseMappingObject.php index 421a14729..9eada8528 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferenceableChildReferenceableFalseMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferenceableChildReferenceableFalseMappingObject.php @@ -2,14 +2,11 @@ namespace Doctrine\Tests\ODM\PHPCR\Mapping\Model; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; /** * An object that extends a referenceable object but sets * referenceable to FALSE, which is not permitted. - * - * @PHPCRODM\Document(referenceable=false) */ #[PHPCR\Document(referenceable: false)] class ReferenceableChildReferenceableFalseMappingObject extends ReferenceableMappingObject diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferenceableMappingObject.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferenceableMappingObject.php index b0d6b1f52..cf92b73d9 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferenceableMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferenceableMappingObject.php @@ -2,18 +2,14 @@ namespace Doctrine\Tests\ODM\PHPCR\Mapping\Model; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; /** * A class that uses the repository strategy to generate IDs. - * - * @PHPCRODM\Document(referenceable=true) */ #[PHPCR\Document(referenceable: true)] class ReferenceableMappingObject { - /** @PHPCRODM\Id */ #[PHPCR\Id] public $id; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferrersMappingObject.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferrersMappingObject.php index 1a75ab165..815ab731b 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferrersMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferrersMappingObject.php @@ -2,42 +2,26 @@ namespace Doctrine\Tests\ODM\PHPCR\Mapping\Model; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; /** * A class that uses referrers. - * - * @PHPCRODM\Document(referenceable=true) */ #[PHPCR\Document(referenceable: true)] class ReferrersMappingObject { - /** @PHPCRODM\Id */ #[PHPCR\Id] public $id; - /** - * @PHPCRODM\MixedReferrers - */ #[PHPCR\MixedReferrers] public $allReferrers; - /** - * @PHPCRODM\Referrers(referencedBy="referenceManyWeak", referringDocument="ReferenceManyMappingObject") - */ #[PHPCR\Referrers(referencedBy: 'referenceManyWeak', referringDocument: ReferenceManyMappingObject::class)] public $filteredReferrers; - /** - * @PHPCRODM\MixedReferrers(referenceType="hard") - */ #[PHPCR\MixedReferrers(referenceType: 'hard')] public $hardReferrers; - /** - * @PHPCRODM\MixedReferrers(referenceType="weak") - */ #[PHPCR\MixedReferrers(referenceType: 'weak')] public $weakReferrers; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReplaceMixinMappingObject.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReplaceMixinMappingObject.php index c570cfa1f..908d39e45 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReplaceMixinMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReplaceMixinMappingObject.php @@ -2,30 +2,23 @@ namespace Doctrine\Tests\ODM\PHPCR\Mapping\Model; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; /** * A class that contains mapped children via properties. - * - * @PHPCRODM\Document(mixins={"mix:lastModified"}, inheritMixins=false) */ #[PHPCR\Document(mixins: ['mix:lastModified'], inheritMixins: false)] class ReplaceMixinMappingObject { - /** @PHPCRODM\Id */ #[PHPCR\Id] public $id; - /** @PHPCRODM\Node */ #[PHPCR\Node] public $node; - /** @PHPCRODM\Field(type="date", property="jcr:lastModified") */ #[PHPCR\Field(type: 'date', property: 'jcr:lastModified')] public $lastModified; - /** @PHPCRODM\Field(type="string", property="jcr:lastModifiedBy") */ #[PHPCR\Field(type: 'string', property: 'jcr:lastModifiedBy')] public $lastModifiedBy; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/RepositoryMappingObject.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/RepositoryMappingObject.php index b34ebe280..2f236271e 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/RepositoryMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/RepositoryMappingObject.php @@ -2,18 +2,14 @@ namespace Doctrine\Tests\ODM\PHPCR\Mapping\Model; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; /** * A class that uses the repository strategy to generate IDs. - * - * @PHPCRODM\Document(repositoryClass="Doctrine\Tests\ODM\PHPCR\Mapping\Model\DocumentRepository") */ #[PHPCR\Document(repositoryClass: DocumentRepository::class)] class RepositoryMappingObject { - /** @PHPCRODM\Id(strategy="repository") */ #[PHPCR\Id(strategy: 'repository')] public $id; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/StringExtendedMappingObject.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/StringExtendedMappingObject.php index 44e1a042d..b4c2cb809 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/StringExtendedMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/StringExtendedMappingObject.php @@ -2,26 +2,20 @@ namespace Doctrine\Tests\ODM\PHPCR\Mapping\Model; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; /** * A class that extends a class which contains string properties. - * - * @PHPCRODM\Document(translator="attribute") */ #[PHPCR\Document(translator: 'attribute')] class StringExtendedMappingObject extends StringMappingObject { /** * The language this document currently is in. - * - * @PHPCRODM\Locale */ #[PHPCR\Locale] private $doclocale; - /** @PHPCRODM\Field(type="string", translated=true) */ #[PHPCR\Field(type: 'string', translated: true)] public $stringAssoc; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/StringMappingObject.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/StringMappingObject.php index 46eb46d5e..e2d2c5f2b 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/StringMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/StringMappingObject.php @@ -2,22 +2,17 @@ namespace Doctrine\Tests\ODM\PHPCR\Mapping\Model; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; /** * A class that contains string properties. - * - * @PHPCRODM\Document */ #[PHPCR\Document] class StringMappingObject { - /** @PHPCRODM\Id */ #[PHPCR\Id] public $id; - /** @PHPCRODM\Field(type="string", assoc="") */ #[PHPCR\Field(type: 'string', assoc: '')] public $stringAssoc; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/TranslatorMappingObject.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/TranslatorMappingObject.php index 08c609670..573bc2822 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/TranslatorMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/TranslatorMappingObject.php @@ -2,53 +2,40 @@ namespace Doctrine\Tests\ODM\PHPCR\Mapping\Model; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; /** * A class that uses translator and translatable. - * - * @PHPCRODM\Document(translator="attribute") */ #[PHPCR\Document(translator: 'attribute')] class TranslatorMappingObject { /** * The path. - * - * @PHPCRODM\Id */ #[PHPCR\Id] private $id; /** * The language this document currently is in. - * - * @PHPCRODM\Locale */ #[PHPCR\Locale] private $doclocale; /** * Untranslated property. - * - * @PHPCRODM\Field(type="date") */ #[PHPCR\Field(type: 'date')] private $publishDate; /** * Translated property. - * - * @PHPCRODM\Field(type="string", translated=true) */ #[PHPCR\Field(type: 'string', translated: true)] private $topic; /** * Language specific image. - * - * @PHPCRODM\Field(type="binary", translated=true) */ #[PHPCR\Field(type: 'binary', translated: true)] private $image; diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/TranslatorMappingObjectNoStrategy.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/TranslatorMappingObjectNoStrategy.php index cd4f38d7d..b800e0654 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/TranslatorMappingObjectNoStrategy.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/TranslatorMappingObjectNoStrategy.php @@ -2,51 +2,37 @@ namespace Doctrine\Tests\ODM\PHPCR\Mapping\Model; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; /** * An invalid class with translated fields but no translator. - * - * @PHPCRODM\Document() */ #[PHPCR\Document] class TranslatorMappingObjectNoStrategy { - /** - * @PHPCRODM\Id - */ #[PHPCR\Id] private $id; /** * The language this document currently is in. - * - * @PHPCRODM\Locale */ #[PHPCR\Locale] private $doclocale; /** * Untranslated property. - * - * @PHPCRODM\Field(type="date") */ #[PHPCR\Field(type: 'date')] private $publishDate; /** * Translated property. - * - * @PHPCRODM\Field(type="string", translated=true) */ #[PHPCR\Field(type: 'string', translated: true)] private $topic; /** * Language specific image. - * - * @PHPCRODM\Field(type="binary", translated=true) */ #[PHPCR\Field(type: 'binary', translated: true)] private $image; diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/UniqueNodeTypeMappingObject.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/UniqueNodeTypeMappingObject.php index e04c532f0..47d6e417b 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/UniqueNodeTypeMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/UniqueNodeTypeMappingObject.php @@ -2,18 +2,14 @@ namespace Doctrine\Tests\ODM\PHPCR\Mapping\Model; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; /** * A class that has a unique node type among other mapped documents. - * - * @PHPCRODM\Document(uniqueNodeType=true) */ #[PHPCR\Document(uniqueNodeType: true)] class UniqueNodeTypeMappingObject { - /** @PHPCRODM\Id */ #[PHPCR\Id] public $id; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/UuidMappingObject.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/UuidMappingObject.php index 6e371c3ba..3125f7bd1 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/UuidMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/UuidMappingObject.php @@ -2,20 +2,14 @@ namespace Doctrine\Tests\ODM\PHPCR\Mapping\Model; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCRODM\Document(referenceable=true) - */ #[PHPCR\Document(referenceable: true)] class UuidMappingObject { - /** @PHPCRODM\Id */ #[PHPCR\Id] public $id; - /** @PHPCRODM\Uuid */ #[PHPCR\Uuid] public $uuid; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/UuidMappingObjectNotReferenceable.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/UuidMappingObjectNotReferenceable.php index 6419b2e29..2e9965dad 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/UuidMappingObjectNotReferenceable.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/UuidMappingObjectNotReferenceable.php @@ -2,22 +2,17 @@ namespace Doctrine\Tests\ODM\PHPCR\Mapping\Model; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; /** * An invalid document that has the uuid mapped but is not referenceable. - * - * @PHPCRODM\Document(referenceable=false) */ #[PHPCR\Document(referenceable: false)] class UuidMappingObjectNotReferenceable { - /** @PHPCRODM\Id */ #[PHPCR\Id] public $id; - /** @PHPCRODM\Uuid */ #[PHPCR\Uuid] public $uuid; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/VersionableMappingObject.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/VersionableMappingObject.php index 93dae2220..bb37abb24 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/VersionableMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/VersionableMappingObject.php @@ -2,26 +2,20 @@ namespace Doctrine\Tests\ODM\PHPCR\Mapping\Model; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; /** * A class that uses the repository strategy to generate IDs. - * - * @PHPCRODM\Document(versionable="simple") */ #[PHPCR\Document(versionable: 'simple')] class VersionableMappingObject { - /** @PHPCRODM\Id */ #[PHPCR\Id] public $id; - /** @PHPCRODM\VersionName */ #[PHPCR\VersionName] private $versionName; - /** @PHPCRODM\VersionCreated */ #[PHPCR\VersionCreated] private $versionCreated; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/PHPCRFunctionalTestCase.php b/tests/Doctrine/Tests/ODM/PHPCR/PHPCRFunctionalTestCase.php index a3b9f03da..fd511af10 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/PHPCRFunctionalTestCase.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/PHPCRFunctionalTestCase.php @@ -2,11 +2,9 @@ namespace Doctrine\Tests\ODM\PHPCR; -use Doctrine\Common\Annotations\AnnotationReader; use Doctrine\DBAL\DriverManager; use Doctrine\ODM\PHPCR\Configuration; use Doctrine\ODM\PHPCR\DocumentManager; -use Doctrine\ODM\PHPCR\Mapping\Driver\AnnotationDriver; use Doctrine\ODM\PHPCR\Mapping\Driver\AttributeDriver; use Jackalope\RepositoryFactoryDoctrineDBAL; use Jackalope\RepositoryFactoryJackrabbit; @@ -23,18 +21,13 @@ abstract class PHPCRFunctionalTestCase extends TestCase */ private $sessions = []; - public function createDocumentManager(array $paths = null, bool $annotations = false): DocumentManager + public function createDocumentManager(array $paths = null): DocumentManager { - AnnotationReader::addGlobalIgnoredName('group'); - if (empty($paths)) { $paths = [__DIR__.'/../../Models']; } - $metaDriver = $annotations - ? new AnnotationDriver(new AnnotationReader(), $paths) - : new AttributeDriver($paths) - ; + $metaDriver = new AttributeDriver($paths); $factoryclass = $GLOBALS['DOCTRINE_PHPCR_FACTORY'] ?? RepositoryFactoryJackrabbit::class; diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 1efc8ce71..a18f2a2f4 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -13,9 +13,3 @@ if ($files) { require_once current($files); } - -use Doctrine\Common\Annotations\AnnotationRegistry; - -if (method_exists(AnnotationRegistry::class, 'registerLoader')) { - AnnotationRegistry::registerLoader([$autoload, 'loadClass']); -}