From 7c5fade8eeaf54f2ae090e51dd6663c84ee1a9bb 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 +- lib/Doctrine/ODM/PHPCR/Document/Generic.php | 4 +- 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 | 34 +-- .../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 | 14 +- .../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 | 12 +- .../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 +- .../PHPCR/Mapping/AnnotationDriverTest.php | 37 --- tests/bootstrap.php | 6 - 63 files changed, 115 insertions(+), 864 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/Mapping/AnnotationDriverTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 9cada4a07..3d80dc131 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/lib/Doctrine/ODM/PHPCR/Document/Generic.php b/lib/Doctrine/ODM/PHPCR/Document/Generic.php index 677e029f3..ad75f2c4c 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 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..4101ce04b 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, + public null|string $nodeType = null, + public null|string $repositoryClass = null, + public null|string $translator = null, + null|string|array $mixins, + public bool|null $inheritMixins = null, + public null|string $versionable = null, + public null|bool $referenceable = null, + public null|bool $uniqueNodeType = null, string|array|null $childClasses = null, - bool|null $isLeaf = 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..7897c60fb 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/ParentDocument.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/ParentDocument.php @@ -2,10 +2,20 @@ 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..681277420 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Referrers.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Referrers.php @@ -2,22 +2,20 @@ 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/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/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']); -}