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/composer.json b/composer.json index f924462ff..6435c9393 100644 --- a/composer.json +++ b/composer.json @@ -40,7 +40,7 @@ "symfony/yaml": "^5.4 || ^6.0.19", "symfony/phpunit-bridge": "^5.4.21 || ^6.0.19", "liip/rmt": "^1.3", - "phpunit/phpunit": "^7.5 || ^8.0 || ^9.0" + "phpunit/phpunit": "^9.6.15" }, "suggest": { "symfony/yaml": "^5.4 || ^6.0", 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/File.php b/lib/Doctrine/ODM/PHPCR/Document/File.php index 8fb31c5d1..a8c6b903b 100644 --- a/lib/Doctrine/ODM/PHPCR/Document/File.php +++ b/lib/Doctrine/ODM/PHPCR/Document/File.php @@ -77,6 +77,8 @@ public function getContent(): Resource * Set the content for this file from the given resource or string. * * @param resource|string $content the content for the file + * + * @phpstan-param closed-resource|string $content */ public function setFileContent($content): self { @@ -99,6 +101,8 @@ public function setFileContent($content): self * Get a stream for the content of this file. * * @return resource the content for the file + * + * @phpstan-return closed-resource */ public function getFileContentAsStream() { diff --git a/lib/Doctrine/ODM/PHPCR/Document/Generic.php b/lib/Doctrine/ODM/PHPCR/Document/Generic.php index 677e029f3..6f928632a 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 @@ -30,7 +30,7 @@ class Generic protected string $nodename = ''; #[PHPCR\ParentDocument] - protected object $parent; + protected ?object $parent; /** * @var Collection @@ -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..f369183b7 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; @@ -30,6 +28,8 @@ class Resource /** * @var resource + * + * @phpstan-var closed-resource */ #[PHPCR\Field(property: 'jcr:data', type: 'binary')] protected $data; @@ -88,8 +88,10 @@ public function setParentDocument(object $parent): self /** * Set the data from a binary stream. - + * * @param resource $data the contents of this resource + * + * @phpstan-param closed-resource $data the contents of this resource */ public function setData($data): self { @@ -102,6 +104,8 @@ public function setData($data): self * Get the binary data stream of this resource. * * @return resource + * + * @phpstan-return closed-resource */ public function getData() { 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/DocumentManagerInterface.php b/lib/Doctrine/ODM/PHPCR/DocumentManagerInterface.php index b86a291e2..80e443a9d 100644 --- a/lib/Doctrine/ODM/PHPCR/DocumentManagerInterface.php +++ b/lib/Doctrine/ODM/PHPCR/DocumentManagerInterface.php @@ -153,7 +153,7 @@ public function findTranslation(?string $className, string $id, string $locale, /** * Quote a string for inclusion in an SQL2 query. * - * @see \PHPCR\PropertyType + * @see PropertyType */ public function quote(string $val, int $type = PropertyType::STRING): string; 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; + $this->cascade = null === $cascade ? null : (array) $cascade; } } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Children.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Children.php index d002352a7..7202a55a6 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|null $filter; + public array|null $cascade; + + /** + * @param string[]|string $filter + * @param string[]|string $cascade + */ public function __construct( array|string $filter = null, - int $fetchDepth = -1, - bool $ignoreUntranslated = true, - array|string $cascade = [], + public int $fetchDepth = -1, + public bool $ignoreUntranslated = true, + array|string $cascade = null, ) { - $this->filter = $filter ? (array) $filter : null; - $this->fetchDepth = $fetchDepth; - $this->ignoreUntranslated = $ignoreUntranslated; - $this->cascade = (array) $cascade; + $this->filter = null === $filter ? null : (array) $filter; + $this->cascade = null === $cascade ? null : (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..08d79ae12 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|null $mixins; + public array|null $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->childClasses = $childClasses ? (array) $childClasses : null; - $this->isLeaf = $isLeaf; + $this->mixins = null === $mixins ? null : (array) $mixins; + $this->childClasses = null === $childClasses ? null : (array) $childClasses; } } 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..a2e9d25c5 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|null $cascade; + + public function __construct( + string|array $cascade = null + ) { + $this->cascade = null === $cascade ? null : (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..6b011b877 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|null $cascade; + /** - * @param string[] $cascade + * @param string[]|string $cascade */ public function __construct( - string $property = null, - string $targetDocument = null, - string $strategy = 'weak', - array|string $cascade = [] + /** + * The PHPCR property name to use. + */ + public null|string $property = null, + public null|string $targetDocument = null, + public string $strategy = 'weak', + array|string $cascade = null ) { - $this->property = $property; - $this->targetDocument = $targetDocument; - $this->strategy = $strategy; - $this->cascade = (array) $cascade; + $this->cascade = null === $cascade ? null : (array) $cascade; } } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Referrers.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Referrers.php index e957ea734..04d2d2f33 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|null $cascade; + /** - * @param string[] $cascade + * @param string[]|string $cascade */ public function __construct( - string $referencedBy, - string $referringDocument, - array|string $cascade = [] + public string $referencedBy, + public string $referringDocument, + array|string $cascade = null ) { - $this->referencedBy = $referencedBy; - $this->referringDocument = $referringDocument; - $this->cascade = (array) $cascade; + $this->cascade = null === $cascade ? null : (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/AttributeDriver.php b/lib/Doctrine/ODM/PHPCR/Mapping/Driver/AttributeDriver.php index c86f34d87..1a6832d81 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Driver/AttributeDriver.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Driver/AttributeDriver.php @@ -125,11 +125,13 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad $metadata->setTranslator($documentAttribute->translator); } - if ($documentAttribute->childClasses) { + if (null !== $documentAttribute->childClasses) { $metadata->setChildClasses($documentAttribute->childClasses); } - $metadata->setIsLeaf($documentAttribute->isLeaf); + if (null !== $documentAttribute->isLeaf) { + $metadata->setIsLeaf($documentAttribute->isLeaf); + } foreach ($reflectionClass->getProperties() as $property) { if ($metadata->isInheritedField($property->name) @@ -227,8 +229,12 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad * * @return int a bitmask of cascade options */ - private function getCascadeMode(array $cascadeList) + private function getCascadeMode(?array $cascadeList): int { + if (!$cascadeList) { + return 0; + } + $cascade = 0; foreach ($cascadeList as $cascadeMode) { $constantName = 'Doctrine\ODM\PHPCR\Mapping\ClassMetadata::CASCADE_'.strtoupper($cascadeMode); 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..853ff8e58 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. @@ -418,7 +418,10 @@ public function getOrCreateDocuments(?string $className, iterable $nodes, array try { $referencedNode = $node->getProperty($mapping['property'])->getNode(); $proxy = $this->getOrCreateProxyFromNode($referencedNode, $locale); - if (array_key_exists('targetDocument', $mapping) && !$proxy instanceof $mapping['targetDocument']) { + if (array_key_exists('targetDocument', $mapping) + && null !== $mapping['targetDocument'] + && !$proxy instanceof $mapping['targetDocument'] + ) { throw new PHPCRException("Unexpected class for referenced document at '{$referencedNode->getPath()}'. Expected '{$mapping['targetDocument']}' but got '".ClassUtils::getClass($proxy)."'."); } } catch (RepositoryException $e) { @@ -2396,7 +2399,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 +2418,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 +2495,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 +2732,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/References/RefCascadeManyTestObj.php b/tests/Doctrine/Tests/Models/References/RefCascadeManyTestObj.php index 59b5ef8a9..3d713c0e2 100644 --- a/tests/Doctrine/Tests/Models/References/RefCascadeManyTestObj.php +++ b/tests/Doctrine/Tests/Models/References/RefCascadeManyTestObj.php @@ -11,7 +11,6 @@ class RefCascadeManyTestObj #[PHPCR\Id] public $id; - /** @PHPCRODM\ReferenceMany(targetDocument="RefRefTestObj", cascade="persist") */ #[PHPCR\ReferenceMany(targetDocument: RefRefTestObj::class, cascade: 'persist')] public $references; 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/DocumentClassMapperTest.php b/tests/Doctrine/Tests/ODM/PHPCR/DocumentClassMapperTest.php index b0c09e934..4fb9d62c2 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/DocumentClassMapperTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/DocumentClassMapperTest.php @@ -145,9 +145,9 @@ public function testWriteMetadata(): void { $parentClasses = [self::CLASS_TEST_2, self::CLASS_TEST_3]; - $this->node->expects($this->at(0)) + $this->node ->method('setProperty') - ->with('phpcr:class', self::CLASS_TEST_1, PropertyType::STRING); + ->withConsecutive(['phpcr:class', self::CLASS_TEST_1, PropertyType::STRING], ['phpcr:classparents', $parentClasses, PropertyType::STRING]); $this->dm->expects($this->once()) ->method('getClassMetadata') @@ -158,11 +158,6 @@ public function testWriteMetadata(): void ->method('getParentClasses') ->willReturn($parentClasses); - // Assert that we set the correct parent classes - $this->node->expects($this->at(1)) - ->method('setProperty') - ->with('phpcr:classparents', $parentClasses, PropertyType::STRING); - $this->mapper->writeMetadata($this->dm, $this->node, self::CLASS_TEST_1); } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Event/MoveEventArgsTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Event/MoveEventArgsTest.php index 72212ce2a..196a9bf51 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Event/MoveEventArgsTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Event/MoveEventArgsTest.php @@ -18,7 +18,7 @@ class MoveEventArgsTest extends TestCase public function setUp(): void { $this->dm = $this->createMock(DocumentManager::class); - $this->object = new \stdClass(); + $this->object = new stdClass(); $this->eventArgs = new MoveEventArgs( $this->object, diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/EventManagerTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/EventManagerTest.php index 22b385ecd..d4ab7b569 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/EventManagerTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/EventManagerTest.php @@ -123,6 +123,7 @@ public function testTriggerEvents(): void $pageId = $this->dm->getUnitOfWork()->getDocumentId($page); $itemId = $this->dm->getUnitOfWork()->getDocumentId($item); + $this->assertIsString($itemId); $this->dm->clear(); $page = $this->dm->find(null, $pageId); diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/EventObjectUpdateTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/EventObjectUpdateTest.php index d352a218b..640b11870 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/EventObjectUpdateTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/EventObjectUpdateTest.php @@ -54,8 +54,8 @@ public function testComputingBetweenEvents(): void $this->assertInstanceOf('stdClass', $entity->status); $this->assertObjectHasProperty('value', $entity->status); - $this->assertEquals($entity->status->value, 'active'); - $this->assertObjectNotHasAttribute('foo', $entity->status); + $this->assertSame('active', $entity->status->value); + $this->assertObjectNotHasProperty('foo', $entity->status); $entity->status->value = 'inactive'; $entity->status->foo = 'bar2'; @@ -65,9 +65,9 @@ public function testComputingBetweenEvents(): void $this->assertInstanceOf('stdClass', $entity->status); $this->assertObjectHasProperty('value', $entity->status); - $this->assertEquals($entity->status->value, 'inactive'); - $this->assertObjectNotHasAttribute('foo', $entity->status); - $this->assertEquals($entity->text, 'test2'); + $this->assertSame('inactive', $entity->status->value); + $this->assertObjectNotHasProperty('foo', $entity->status); + $this->assertSame('test2', $entity->text); $this->dm->clear(); @@ -75,9 +75,9 @@ public function testComputingBetweenEvents(): void $this->assertInstanceOf('stdClass', $entity->status); $this->assertObjectHasProperty('value', $entity->status); - $this->assertEquals($entity->status->value, 'inactive'); - $this->assertObjectNotHasAttribute('foo', $entity->status); - $this->assertEquals($entity->text, 'test2'); + $this->assertSame('inactive', $entity->status->value); + $this->assertObjectNotHasProperty('foo', $entity->status); + $this->assertSame('test2', $entity->text); $entity->status->value = 'active'; @@ -85,8 +85,8 @@ public function testComputingBetweenEvents(): void $this->assertInstanceOf('stdClass', $entity->status); $this->assertObjectHasProperty('value', $entity->status); - $this->assertEquals($entity->status->value, 'active'); - $this->assertEquals($entity->text, 'test2'); + $this->assertSame('active', $entity->status->value); + $this->assertSame('test2', $entity->text); } } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/Hierarchy/ChildrenTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Hierarchy/ChildrenTest.php index 5a202957b..263ec2778 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/Hierarchy/ChildrenTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Hierarchy/ChildrenTest.php @@ -89,6 +89,7 @@ public function testChildrenCollection(): void $this->dm->find($this->type, '/functional/parent/Child D'); $parent = $this->dm->find($this->type, '/functional/parent'); + $this->assertInstanceOf(ChildrenTestObj::class, $parent); $col = $this->dm->getChildren($parent); $this->assertEquals('Child A', $col->key()); @@ -96,6 +97,7 @@ public function testChildrenCollection(): void $this->dm->find($this->type, '/functional/parent/Child D'); $parent = $this->dm->find($this->type, '/functional/parent'); + $this->assertInstanceOf(ChildrenTestObj::class, $parent); $this->assertEquals('Child A', $parent->allChildren->key()); } @@ -630,6 +632,7 @@ public function testRenameChildren(): void $parent = $this->dm->find($this->type, '/functional/parent'); $child = $parent->allChildren->first(); + $this->assertInstanceOf(ChildrenParentAndNameTestObj::class, $child); $this->assertEquals('original', $child->name); $child->name = 'different'; 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 97% 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..d6e422012 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'; @@ -309,14 +309,14 @@ class RepositoryIdStrategy } class Repository extends DocumentRepository implements RepositoryIdInterface { - public function generateId($document, $parent = null) + public function generateId(object $document, object $parent = null): string { return '/functional/'.str_replace(' ', '-', $document->title); } } /** - * 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/DocumentManagerTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Translation/DocumentManagerTest.php index 6cd7c5155..0bea7e3b8 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/Translation/DocumentManagerTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Translation/DocumentManagerTest.php @@ -796,7 +796,7 @@ public function testBindTranslationFlushedOverwrite(): void $a->topic = 'Hello'; $a->text = 'This is an article in English'; $this->dm->persist($a); - $this->expectException(\Doctrine\ODM\PHPCR\Exception\RuntimeException::class); + $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Translation "de" already exists'); $this->dm->flush(); 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/Id/AssignedIdGeneratorTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Id/AssignedIdGeneratorTest.php index ba6b7f868..5bb8a8bf3 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Id/AssignedIdGeneratorTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Id/AssignedIdGeneratorTest.php @@ -50,7 +50,7 @@ public function __construct($value) $this->_value = $value; } - public function getFieldValue(object $document, string $field) + public function getFieldValue(object $document, string $field): mixed { return $this->_value; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Id/ParentIdGeneratorTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Id/ParentIdGeneratorTest.php index 479615be0..15efb50e4 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Id/ParentIdGeneratorTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Id/ParentIdGeneratorTest.php @@ -140,7 +140,7 @@ public function __construct(?object $parent, string $nodename, string $identifie $this->reflFields = [$this->identifier => $mockField]; } - public function getFieldValue(object $document, string $field) + public function getFieldValue(object $document, string $field): mixed { switch ($field) { case $this->parentMapping: @@ -149,6 +149,8 @@ public function getFieldValue(object $document, string $field) return $this->_nodename; case $this->identifier: return $this->_identifier; + default: + throw new \InvalidArgumentException("Unknown field $field"); } } } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Id/RepositoryIdGeneratorTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Id/RepositoryIdGeneratorTest.php index 671463754..86502024c 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Id/RepositoryIdGeneratorTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Id/RepositoryIdGeneratorTest.php @@ -70,7 +70,7 @@ public function __construct($value) $this->name = 'Test'; } - public function getFieldValue(object $document, string $field) + public function getFieldValue(object $document, string $field): mixed { return $this->_value; } 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..e0fd1ecb4 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. @@ -231,13 +229,25 @@ public function testSerialize(ClassMetadata $cm): void { if (PHP_MAJOR_VERSION >= 8 && PHP_MINOR_VERSION >= 1) { // PHP 8.1 orders fields alphabetically. Semantically both are the same. - $expected = 'O:40:"Doctrine\ODM\PHPCR\Mapping\ClassMetadata":20:{s:8:"nodeType";s:15:"nt:unstructured";s:10:"identifier";s:2:"id";s:4:"name";s:39:"Doctrine\Tests\ODM\PHPCR\Mapping\Person";s:11:"idGenerator";i:2;s:8:"mappings";a:5:{s:2:"id";a:7:{s:9:"fieldName";s:2:"id";s:2:"id";b:1;s:8:"strategy";s:8:"assigned";s:4:"type";s:6:"string";s:10:"multivalue";b:0;s:8:"nullable";b:0;s:8:"property";s:2:"id";}s:8:"username";a:5:{s:9:"fieldName";s:8:"username";s:8:"property";s:8:"username";s:4:"type";s:6:"string";s:10:"multivalue";b:0;s:8:"nullable";b:0;}s:7:"created";a:5:{s:9:"fieldName";s:7:"created";s:8:"property";s:7:"created";s:4:"type";s:8:"datetime";s:10:"multivalue";b:0;s:8:"nullable";b:0;}s:6:"locale";a:3:{s:9:"fieldName";s:6:"locale";s:4:"type";s:6:"locale";s:8:"property";s:6:"locale";}s:15:"translatedField";a:7:{s:9:"fieldName";s:15:"translatedField";s:4:"type";s:6:"string";s:10:"multivalue";b:0;s:5:"assoc";N;s:8:"nullable";b:0;s:10:"translated";b:1;s:8:"property";s:15:"translatedField";}}s:13:"fieldMappings";a:4:{i:0;s:2:"id";i:1;s:8:"username";i:2;s:7:"created";i:3;s:15:"translatedField";}s:17:"referenceMappings";a:0:{}s:17:"referrersMappings";a:0:{}s:22:"mixedReferrersMappings";a:0:{}s:16:"childrenMappings";a:0:{}s:13:"childMappings";a:0:{}s:25:"customRepositoryClassName";s:51:"Doctrine\Tests\ODM\PHPCR\Mapping\DocumentRepository";s:18:"isMappedSuperclass";b:1;s:11:"versionable";s:6:"simple";s:14:"uniqueNodeType";b:1;s:18:"lifecycleCallbacks";a:1:{s:8:"postLoad";a:1:{i:0;s:8:"callback";}}s:13:"inheritMixins";b:1;s:13:"localeMapping";s:6:"locale";s:10:"translator";s:9:"attribute";s:18:"translatableFields";a:1:{i:0;s:15:"translatedField";}}'; + $expected = 'O:40:"Doctrine\ODM\PHPCR\Mapping\ClassMetadata":20:{s:8:"nodeType";s:15:"nt:unstructured";s:10:"identifier";s:2:"id";s:4:"name";s:39:"Doctrine\Tests\ODM\PHPCR\Mapping\Person";s:11:"idGenerator";i:2;s:8:"mappings";a:5:{s:2:"id";a:7:{s:9:"fieldName";s:2:"id";s:2:"id";b:1;s:8:"strategy";s:8:"assigned";s:4:"type";s:6:"string";s:10:"multivalue";b:0;s:8:"nullable";b:0;s:8:"property";s:2:"id";}s:8:"username";a:5:{s:9:"fieldName";s:8:"username";s:8:"property";s:8:"username";s:4:"type";s:6:"string";s:10:"multivalue";b:0;s:8:"nullable";b:0;}s:7:"created";a:5:{s:9:"fieldName";s:7:"created";s:8:"property";s:7:"created";s:4:"type";s:8:"datetime";s:10:"multivalue";b:0;s:8:"nullable";b:0;}s:6:"locale";a:5:{s:9:"fieldName";s:6:"locale";s:4:"type";s:6:"locale";s:10:"multivalue";b:0;s:8:"nullable";b:0;s:8:"property";s:6:"locale";}s:15:"translatedField";a:7:{s:9:"fieldName";s:15:"translatedField";s:4:"type";s:6:"string";s:10:"translated";b:1;s:10:"multivalue";b:0;s:8:"nullable";b:0;s:5:"assoc";N;s:8:"property";s:15:"translatedField";}}s:13:"fieldMappings";a:4:{i:0;s:2:"id";i:1;s:8:"username";i:2;s:7:"created";i:3;s:15:"translatedField";}s:17:"referenceMappings";a:0:{}s:17:"referrersMappings";a:0:{}s:22:"mixedReferrersMappings";a:0:{}s:16:"childrenMappings";a:0:{}s:13:"childMappings";a:0:{}s:25:"customRepositoryClassName";s:51:"Doctrine\Tests\ODM\PHPCR\Mapping\DocumentRepository";s:18:"isMappedSuperclass";b:1;s:11:"versionable";s:6:"simple";s:14:"uniqueNodeType";b:1;s:18:"lifecycleCallbacks";a:1:{s:8:"postLoad";a:1:{i:0;s:8:"callback";}}s:13:"inheritMixins";b:1;s:13:"localeMapping";s:6:"locale";s:10:"translator";s:9:"attribute";s:18:"translatableFields";a:1:{i:0;s:15:"translatedField";}}'; } else { - $expected = 'O:40:"Doctrine\ODM\PHPCR\Mapping\ClassMetadata":20:{s:8:"nodeType";s:15:"nt:unstructured";s:10:"identifier";s:2:"id";s:4:"name";s:39:"Doctrine\Tests\ODM\PHPCR\Mapping\Person";s:11:"idGenerator";i:2;s:8:"mappings";a:5:{s:2:"id";a:7:{s:9:"fieldName";s:2:"id";s:2:"id";b:1;s:8:"strategy";s:8:"assigned";s:4:"type";s:6:"string";s:10:"multivalue";b:0;s:8:"nullable";b:0;s:8:"property";s:2:"id";}s:8:"username";a:5:{s:9:"fieldName";s:8:"username";s:8:"property";s:8:"username";s:4:"type";s:6:"string";s:10:"multivalue";b:0;s:8:"nullable";b:0;}s:7:"created";a:5:{s:9:"fieldName";s:7:"created";s:8:"property";s:7:"created";s:4:"type";s:8:"datetime";s:10:"multivalue";b:0;s:8:"nullable";b:0;}s:6:"locale";a:3:{s:9:"fieldName";s:6:"locale";s:4:"type";s:6:"locale";s:8:"property";s:6:"locale";}s:15:"translatedField";a:7:{s:9:"fieldName";s:15:"translatedField";s:10:"translated";b:1;s:4:"type";s:6:"string";s:10:"multivalue";b:0;s:5:"assoc";N;s:8:"nullable";b:0;s:8:"property";s:15:"translatedField";}}s:13:"fieldMappings";a:4:{i:0;s:2:"id";i:1;s:8:"username";i:2;s:7:"created";i:3;s:15:"translatedField";}s:17:"referenceMappings";a:0:{}s:17:"referrersMappings";a:0:{}s:22:"mixedReferrersMappings";a:0:{}s:16:"childrenMappings";a:0:{}s:13:"childMappings";a:0:{}s:25:"customRepositoryClassName";s:51:"Doctrine\Tests\ODM\PHPCR\Mapping\DocumentRepository";s:18:"isMappedSuperclass";b:1;s:11:"versionable";s:6:"simple";s:14:"uniqueNodeType";b:1;s:18:"lifecycleCallbacks";a:1:{s:8:"postLoad";a:1:{i:0;s:8:"callback";}}s:13:"inheritMixins";b:1;s:13:"localeMapping";s:6:"locale";s:10:"translator";s:9:"attribute";s:18:"translatableFields";a:1:{i:0;s:15:"translatedField";}}'; + $expected = 'O:40:"Doctrine\ODM\PHPCR\Mapping\ClassMetadata":20:{s:8:"nodeType";s:15:"nt:unstructured";s:10:"identifier";s:2:"id";s:4:"name";s:39:"Doctrine\Tests\ODM\PHPCR\Mapping\Person";s:11:"idGenerator";i:2;s:8:"mappings";a:5:{s:2:"id";a:7:{s:9:"fieldName";s:2:"id";s:2:"id";b:1;s:8:"strategy";s:8:"assigned";s:4:"type";s:6:"string";s:10:"multivalue";b:0;s:8:"nullable";b:0;s:8:"property";s:2:"id";}s:8:"username";a:5:{s:9:"fieldName";s:8:"username";s:8:"property";s:8:"username";s:4:"type";s:6:"string";s:10:"multivalue";b:0;s:8:"nullable";b:0;}s:7:"created";a:5:{s:9:"fieldName";s:7:"created";s:8:"property";s:7:"created";s:4:"type";s:8:"datetime";s:10:"multivalue";b:0;s:8:"nullable";b:0;}s:6:"locale";a:5:{s:9:"fieldName";s:6:"locale";s:4:"type";s:6:"locale";s:10:"multivalue";b:0;s:8:"nullable";b:0;s:8:"property";s:6:"locale";}s:15:"translatedField";a:7:{s:9:"fieldName";s:15:"translatedField";s:4:"type";s:6:"string";s:10:"translated";b:1;s:10:"multivalue";b:0;s:8:"nullable";b:0;s:5:"assoc";N;s:8:"property";s:15:"translatedField";}}s:13:"fieldMappings";a:4:{i:0;s:2:"id";i:1;s:8:"username";i:2;s:7:"created";i:3;s:15:"translatedField";}s:17:"referenceMappings";a:0:{}s:17:"referrersMappings";a:0:{}s:22:"mixedReferrersMappings";a:0:{}s:16:"childrenMappings";a:0:{}s:13:"childMappings";a:0:{}s:25:"customRepositoryClassName";s:51:"Doctrine\Tests\ODM\PHPCR\Mapping\DocumentRepository";s:18:"isMappedSuperclass";b:1;s:11:"versionable";s:6:"simple";s:14:"uniqueNodeType";b:1;s:18:"lifecycleCallbacks";a:1:{s:8:"postLoad";a:1:{i:0;s:8:"callback";}}s:13:"inheritMixins";b:1;s:13:"localeMapping";s:6:"locale";s:10:"translator";s:9:"attribute";s:18:"translatableFields";a:1:{i:0;s:15:"translatedField";}}'; } $cm->setCustomRepositoryClassName('DocumentRepository'); $cm->setVersioned('simple'); + $cm->setTranslator('attribute'); + $cm->mapField([ + 'fieldName' => 'locale', + 'type' => 'locale', + ]); + $cm->mapField([ + 'fieldName' => 'translatedField', + 'type' => 'string', + 'translated' => true, + 'multivalue' => false, + 'nullable' => false, + ]); $cm->setUniqueNodeType(true); $cm->addLifecycleCallback('callback', 'postLoad'); $cm->isMappedSuperclass = true; @@ -426,9 +436,7 @@ class Customer extends Person { } -/** - * @PHPCRODM\Document(translator="attribute") - */ +#[PHPCR\Document(translator: 'attribute')] class Person { public $id; @@ -443,14 +451,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..efb014362 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ClassInheritanceParentMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ClassInheritanceParentMappingObject.php @@ -2,32 +2,22 @@ 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', repositoryClass: DocumentRepository::class, translator: 'foo', mixins: ['mix:foo', 'mix:bar'], + versionable: 'simple', referenceable: true, )] 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/Mapping/Model/php/Doctrine.Tests.ODM.PHPCR.Mapping.Model.VersionableMappingObject.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/php/Doctrine.Tests.ODM.PHPCR.Mapping.Model.VersionableMappingObject.php index 548c5c1f8..95a82f7f7 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/php/Doctrine.Tests.ODM.PHPCR.Mapping.Model.VersionableMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/php/Doctrine.Tests.ODM.PHPCR.Mapping.Model.VersionableMappingObject.php @@ -1,7 +1,7 @@ setVersioned('simple'); $metadata->mapId([ 'fieldName' => 'id', 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/Doctrine/Tests/ODM/PHPCR/Query/QueryTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Query/QueryTest.php index ce3f51380..7863bc64d 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Query/QueryTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Query/QueryTest.php @@ -118,12 +118,10 @@ public function testExecuteHydrateUnknown(): void public function testExecuteParameters(): void { - $this->phpcrQuery->expects($this->at(0)) + $this->phpcrQuery ->method('bindValue') - ->with('foo', 'bar'); - $this->phpcrQuery->expects($this->at(1)) - ->method('bindValue') - ->with('bar', 'foo'); + ->withConsecutive(['foo', 'bar'], ['bar', 'foo']) + ; $this->query->execute(['foo' => 'bar', 'bar' => 'foo']); } 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']); -}