From eeca0947c4b14b8b94c0088946532b35596e987a Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Thu, 21 Sep 2023 17:06:09 +0200 Subject: [PATCH 01/14] prepare release --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f22a50f49..39f705aa0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ Changelog 1.x === +1.7.2 +----- + +* Maintenance release with doc and phpunit test cleanups. 1.7.1 ----- From 71c91001a2a69b674705fd53672859b7609d0fbc Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Thu, 21 Sep 2023 17:04:53 +0200 Subject: [PATCH 02/14] bump to php 8 because annotations are only available since PHP 8.0 --- .github/workflows/test-application.yaml | 56 ++++++++----------------- CHANGELOG.md | 7 ++++ composer.json | 4 +- 3 files changed, 27 insertions(+), 40 deletions(-) diff --git a/.github/workflows/test-application.yaml b/.github/workflows/test-application.yaml index 0e7187779..4c7fe08dd 100644 --- a/.github/workflows/test-application.yaml +++ b/.github/workflows/test-application.yaml @@ -27,29 +27,19 @@ jobs: matrix: php-version: - - '7.1' - - '7.2' - - '7.3' - - '7.4' - '8.0' - '8.1' - '8.2' + - '8.3' dependencies: [highest] symfony-version: ['*'] include: - - php-version: '7.1' + - php-version: '8.0' dependencies: lowest symfony-version: '*' - - php-version: '7.4' - dependencies: highest - symfony-version: 2.3.* - - php-version: '7.4' + - php-version: '8.0' dependencies: highest symfony-version: 3.4.* - - php-version: '7.4' - dependencies: highest - symfony-version: 4.4.* - php-bench: true - php-version: '8.0' dependencies: highest symfony-version: 5.0.* @@ -113,35 +103,25 @@ jobs: matrix: php-version: - - '7.1' - - '7.2' - - '7.3' - - '7.4' - '8.0' - '8.1' + - '8.2' + - '8.3' dependencies: [highest] symfony-version: ['*'] include: - - php-version: '7.1' - dependencies: lowest - symfony-version: '*' - - php-version: '7.4' - dependencies: highest - symfony-version: 2.3.* - - php-version: '7.4' - dependencies: highest - symfony-version: 3.4.* - php-bench: true - - php-version: '7.4' - dependencies: highest - symfony-version: 4.4.* - php-bench: true - - php-version: '8.0' - dependencies: highest - symfony-version: 5.0.* - - php-version: '8.0' - dependencies: highest - symfony-version: 6.0.* + - php-version: '8.0' + dependencies: lowest + symfony-version: '*' + - php-version: '8.0' + dependencies: highest + symfony-version: 3.4.* + - php-version: '8.0' + dependencies: highest + symfony-version: 5.0.* + - php-version: '8.0' + dependencies: highest + symfony-version: 6.0.* steps: - name: Checkout project @@ -180,7 +160,7 @@ jobs: run: ./tests/script_jackrabbit.sh - name: Execute test cases - run: vendor/bin/phpunit -c tests/phpunit_jackrabbit.xml.dist + run: vendor/bin/phpunit -c tests/phpunit_jackrabbit.xml.dist || [[ ${{ matrix.php-version }} == 8.2 || ${{ matrix.php-version }} == 8.3 ]] - name: Execute PHPBench if: matrix.php-bench == true diff --git a/CHANGELOG.md b/CHANGELOG.md index 39f705aa0..e957cefda 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,13 @@ Changelog 1.x === + +1.8.0 (unreleased) +------------------ + +* Add support for PHP attributes +* Drop support for PHP 7. + 1.7.2 ----- diff --git a/composer.json b/composer.json index 2b01de2e0..f81a1439d 100644 --- a/composer.json +++ b/composer.json @@ -13,10 +13,10 @@ "minimum-stability": "dev", "prefer-stable": true, "require": { - "php": "^7.1 || ^8.0", + "php": "^8.0", "doctrine/collections": "^1.0 || ^2.0", "doctrine/common": "^2.4 || ^3.0", - "doctrine/annotations": "^1.2 || ^2.0", + "doctrine/annotations": "^1.14.3 || ^2.0", "doctrine/data-fixtures": "^1.0", "doctrine/event-manager": "^1.0 || ^2.0", "doctrine/persistence": "^1.3.7 || ^2.0", From 6d439420e2750f6b2e834a02c72b9de64d9ea45c Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Sat, 23 Sep 2023 18:49:23 +0200 Subject: [PATCH 03/14] adf --- .github/workflows/test-application.yaml | 2 +- CHANGELOG.md | 1 - tests/phpunit_jackrabbit.xml.dist | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-application.yaml b/.github/workflows/test-application.yaml index 4c7fe08dd..718602b6d 100644 --- a/.github/workflows/test-application.yaml +++ b/.github/workflows/test-application.yaml @@ -160,7 +160,7 @@ jobs: run: ./tests/script_jackrabbit.sh - name: Execute test cases - run: vendor/bin/phpunit -c tests/phpunit_jackrabbit.xml.dist || [[ ${{ matrix.php-version }} == 8.2 || ${{ matrix.php-version }} == 8.3 ]] + run: vendor/bin/phpunit -c tests/phpunit_jackrabbit.xml.dist - name: Execute PHPBench if: matrix.php-bench == true diff --git a/CHANGELOG.md b/CHANGELOG.md index e957cefda..d2ee3997c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,6 @@ Changelog 1.8.0 (unreleased) ------------------ -* Add support for PHP attributes * Drop support for PHP 7. 1.7.2 diff --git a/tests/phpunit_jackrabbit.xml.dist b/tests/phpunit_jackrabbit.xml.dist index 4a9804ca8..bd70cfc85 100644 --- a/tests/phpunit_jackrabbit.xml.dist +++ b/tests/phpunit_jackrabbit.xml.dist @@ -13,6 +13,7 @@ + From 2a20f12bc573e8973531d36a8629a2be61328538 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Sat, 23 Sep 2023 18:59:19 +0200 Subject: [PATCH 04/14] make annotations also attributes --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d2ee3997c..e957cefda 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Changelog 1.8.0 (unreleased) ------------------ +* Add support for PHP attributes * Drop support for PHP 7. 1.7.2 From 1e1abebaff53573349ab5a960d26553799f0099d Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Sat, 23 Sep 2023 19:13:58 +0200 Subject: [PATCH 05/14] define annotations as attributes too --- CHANGELOG.md | 2 +- lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Child.php | 2 +- .../ODM/PHPCR/Mapping/Annotations/Children.php | 2 +- lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Depth.php | 2 +- lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Field.php | 2 +- lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Id.php | 2 +- lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Locale.php | 2 +- .../PHPCR/Mapping/Annotations/MappedSuperclass.php | 2 +- .../ODM/PHPCR/Mapping/Annotations/MixedReferrers.php | 2 +- lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Node.php | 2 +- .../ODM/PHPCR/Mapping/Annotations/Nodename.php | 2 +- .../ODM/PHPCR/Mapping/Annotations/ParentDocument.php | 2 +- .../ODM/PHPCR/Mapping/Annotations/PostLoad.php | 2 +- .../ODM/PHPCR/Mapping/Annotations/PostPersist.php | 2 +- .../ODM/PHPCR/Mapping/Annotations/PostRemove.php | 2 +- .../ODM/PHPCR/Mapping/Annotations/PostUpdate.php | 2 +- .../ODM/PHPCR/Mapping/Annotations/PrePersist.php | 2 +- .../ODM/PHPCR/Mapping/Annotations/PreRemove.php | 2 +- .../ODM/PHPCR/Mapping/Annotations/PreUpdate.php | 2 +- .../ODM/PHPCR/Mapping/Annotations/ReferenceMany.php | 2 +- .../ODM/PHPCR/Mapping/Annotations/ReferenceOne.php | 2 +- .../ODM/PHPCR/Mapping/Annotations/Referrers.php | 2 +- lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Uuid.php | 2 +- .../ODM/PHPCR/Mapping/Annotations/VersionCreated.php | 2 +- .../ODM/PHPCR/Mapping/Annotations/VersionName.php | 2 +- lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Child.php | 11 +++++++++++ .../ODM/PHPCR/Mapping/Attributes/Children.php | 9 +++++++++ lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Depth.php | 11 +++++++++++ .../ODM/PHPCR/Mapping/Attributes/Document.php | 11 +++++++++++ lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Field.php | 11 +++++++++++ lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Id.php | 11 +++++++++++ lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Locale.php | 11 +++++++++++ .../ODM/PHPCR/Mapping/Attributes/MappedSuperclass.php | 11 +++++++++++ .../ODM/PHPCR/Mapping/Attributes/MixedReferrers.php | 11 +++++++++++ lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Node.php | 11 +++++++++++ .../ODM/PHPCR/Mapping/Attributes/Nodename.php | 11 +++++++++++ .../ODM/PHPCR/Mapping/Attributes/ParentDocument.php | 11 +++++++++++ .../ODM/PHPCR/Mapping/Attributes/PostLoad.php | 11 +++++++++++ .../ODM/PHPCR/Mapping/Attributes/PostPersist.php | 11 +++++++++++ .../ODM/PHPCR/Mapping/Attributes/PostRemove.php | 11 +++++++++++ .../ODM/PHPCR/Mapping/Attributes/PostUpdate.php | 11 +++++++++++ .../ODM/PHPCR/Mapping/Attributes/PrePersist.php | 11 +++++++++++ .../ODM/PHPCR/Mapping/Attributes/PreRemove.php | 11 +++++++++++ .../ODM/PHPCR/Mapping/Attributes/PreUpdate.php | 11 +++++++++++ .../ODM/PHPCR/Mapping/Attributes/ReferenceMany.php | 11 +++++++++++ .../ODM/PHPCR/Mapping/Attributes/ReferenceOne.php | 11 +++++++++++ .../ODM/PHPCR/Mapping/Attributes/Referrers.php | 11 +++++++++++ lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Uuid.php | 11 +++++++++++ .../ODM/PHPCR/Mapping/Attributes/VersionCreated.php | 11 +++++++++++ .../ODM/PHPCR/Mapping/Attributes/VersionName.php | 11 +++++++++++ 50 files changed, 298 insertions(+), 25 deletions(-) create mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Child.php create mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Children.php create mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Depth.php create mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Document.php create mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Field.php create mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Id.php create mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Locale.php create mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Attributes/MappedSuperclass.php create mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Attributes/MixedReferrers.php create mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Node.php create mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Nodename.php create mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Attributes/ParentDocument.php create mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostLoad.php create mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostPersist.php create mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostRemove.php create mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostUpdate.php create mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PrePersist.php create mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PreRemove.php create mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PreUpdate.php create mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Attributes/ReferenceMany.php create mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Attributes/ReferenceOne.php create mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Referrers.php create mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Uuid.php create mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Attributes/VersionCreated.php create mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Attributes/VersionName.php diff --git a/CHANGELOG.md b/CHANGELOG.md index e957cefda..527685974 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ Changelog 1.8.0 (unreleased) ------------------ -* Add support for PHP attributes +* Add support for PHP attributes (only for the annotations that are not deprecated) * Drop support for PHP 7. 1.7.2 diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Child.php b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Child.php index 3684ffc40..fe706a37b 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Child.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Child.php @@ -25,7 +25,7 @@ * @Annotation * @Target("PROPERTY") */ -final class Child +class Child { /** * PHPCR node name of the child to map diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Children.php b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Children.php index 339de2991..050abd0f1 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Children.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Children.php @@ -25,7 +25,7 @@ * @Annotation * @Target("PROPERTY") */ -final class Children +class Children { /** * @var array diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Depth.php b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Depth.php index 1d2907276..ede140671 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Depth.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Depth.php @@ -25,6 +25,6 @@ * @Annotation * @Target("PROPERTY") */ -final class Depth +class Depth { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Field.php b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Field.php index 21074c30b..6564b87cc 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Field.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Field.php @@ -25,6 +25,6 @@ * @Annotation * @Target("PROPERTY") */ -final class Field extends TranslatableProperty +class Field extends TranslatableProperty { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Id.php b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Id.php index 2fe3b8181..899ed7564 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Id.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Id.php @@ -25,7 +25,7 @@ * @Annotation * @Target("PROPERTY") */ -final class Id +class Id { /** * @var bool diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Locale.php b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Locale.php index d8ba78ff5..0c09d0714 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Locale.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Locale.php @@ -25,6 +25,6 @@ * @Annotation * @Target("PROPERTY") */ -final class Locale +class Locale { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/MappedSuperclass.php b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/MappedSuperclass.php index 35ba27760..9db0cc491 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/MappedSuperclass.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/MappedSuperclass.php @@ -25,6 +25,6 @@ * @Annotation * @Target("CLASS") */ -final class MappedSuperclass extends Document +class MappedSuperclass extends Document { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/MixedReferrers.php b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/MixedReferrers.php index a2f1554e7..79346aa94 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/MixedReferrers.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/MixedReferrers.php @@ -25,7 +25,7 @@ * @Annotation * @Target("PROPERTY") */ -final class MixedReferrers +class MixedReferrers { /** * @var string diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Node.php b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Node.php index 38b98635f..febd6b196 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Node.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Node.php @@ -25,6 +25,6 @@ * @Annotation * @Target("PROPERTY") */ -final class Node +class Node { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Nodename.php b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Nodename.php index 846527049..8deb6a0f0 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Nodename.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Nodename.php @@ -27,6 +27,6 @@ * @Annotation * @Target("PROPERTY") */ -final class Nodename +class Nodename { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/ParentDocument.php b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/ParentDocument.php index 74c01d20f..e57020f3d 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/ParentDocument.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/ParentDocument.php @@ -28,7 +28,7 @@ * @Annotation * @Target("PROPERTY") */ -final class ParentDocument +class ParentDocument { /** * @var array diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/PostLoad.php b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/PostLoad.php index cc9c9ae67..f0a15b81f 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/PostLoad.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/PostLoad.php @@ -25,6 +25,6 @@ * @Annotation * @Target("METHOD") */ -final class PostLoad +class PostLoad { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/PostPersist.php b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/PostPersist.php index 22fedd0c1..d3b8840db 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/PostPersist.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/PostPersist.php @@ -25,6 +25,6 @@ * @Annotation * @Target("METHOD") */ -final class PostPersist +class PostPersist { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/PostRemove.php b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/PostRemove.php index 3d76222a6..f6f29c0b7 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/PostRemove.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/PostRemove.php @@ -25,6 +25,6 @@ * @Annotation * @Target("METHOD") */ -final class PostRemove +class PostRemove { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/PostUpdate.php b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/PostUpdate.php index fe32427b1..e37525c8f 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/PostUpdate.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/PostUpdate.php @@ -25,6 +25,6 @@ * @Annotation * @Target("METHOD") */ -final class PostUpdate +class PostUpdate { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/PrePersist.php b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/PrePersist.php index 861028207..caf43d51a 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/PrePersist.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/PrePersist.php @@ -25,6 +25,6 @@ * @Annotation * @Target("METHOD") */ -final class PrePersist +class PrePersist { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/PreRemove.php b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/PreRemove.php index adbbe5e69..cfb918158 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/PreRemove.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/PreRemove.php @@ -25,6 +25,6 @@ * @Annotation * @Target("METHOD") */ -final class PreRemove +class PreRemove { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/PreUpdate.php b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/PreUpdate.php index fc2bc399a..4e85f8ec7 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/PreUpdate.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/PreUpdate.php @@ -25,6 +25,6 @@ * @Annotation * @Target("METHOD") */ -final class PreUpdate +class PreUpdate { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/ReferenceMany.php b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/ReferenceMany.php index d93fe2436..f87d5bd54 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/ReferenceMany.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/ReferenceMany.php @@ -25,6 +25,6 @@ * @Annotation * @Target("PROPERTY") */ -final class ReferenceMany extends Reference +class ReferenceMany extends Reference { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/ReferenceOne.php b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/ReferenceOne.php index 9333d344f..01c2470b2 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/ReferenceOne.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/ReferenceOne.php @@ -25,6 +25,6 @@ * @Annotation * @Target("PROPERTY") */ -final class ReferenceOne extends Reference +class ReferenceOne extends Reference { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Referrers.php b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Referrers.php index 505e15f90..482f1819e 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Referrers.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Referrers.php @@ -25,7 +25,7 @@ * @Annotation * @Target("PROPERTY") */ -final class Referrers +class Referrers { /** * Name of the field in the other document referencing this document diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Uuid.php b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Uuid.php index 15da4f543..09ab48626 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Uuid.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Uuid.php @@ -25,7 +25,7 @@ * @Annotation * @Target("PROPERTY") */ -final class Uuid extends Property +class Uuid extends Property { /** * @var string diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/VersionCreated.php b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/VersionCreated.php index ab5c60945..1349fd9b8 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/VersionCreated.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/VersionCreated.php @@ -25,6 +25,6 @@ * @Annotation * @Target("PROPERTY") */ -final class VersionCreated +class VersionCreated { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/VersionName.php b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/VersionName.php index c57b8a099..26cb4327b 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/VersionName.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/VersionName.php @@ -25,6 +25,6 @@ * @Annotation * @Target("PROPERTY") */ -final class VersionName +class VersionName { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Child.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Child.php new file mode 100644 index 000000000..c6f2e877e --- /dev/null +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Child.php @@ -0,0 +1,11 @@ + Date: Fri, 13 Oct 2023 17:39:17 +0200 Subject: [PATCH 06/14] attribute driver, fix attribute declarations and adjust documentation --- README.md | 2 +- composer.json | 2 +- docs/en/reference/annotations-mapping.rst | 8 +- docs/en/reference/association-mapping.rst | 106 +-- docs/en/reference/attributes-mapping.rst | 633 ++++++++++++++++++ docs/en/reference/basic-mapping.rst | 205 +++--- docs/en/reference/events.rst | 46 +- docs/en/reference/inheritance-mapping.rst | 2 +- .../reference/installation-configuration.rst | 106 +-- docs/en/reference/introduction.rst | 85 +-- docs/en/reference/multilang.rst | 43 +- docs/en/reference/phpcr-access.rst | 10 +- docs/en/reference/query-builder-reference.rst | 10 +- docs/en/reference/query-builder.rst | 30 +- docs/en/reference/query.rst | 3 +- docs/en/reference/tools.rst | 56 -- docs/en/reference/versioning.rst | 18 +- docs/en/reference/working-with-objects.rst | 64 +- docs/en/reference/xml-mapping.rst | 6 +- .../PHPCR/Mapping/Annotations/Children.php | 2 + .../PHPCR/Mapping/Annotations/Reference.php | 8 +- .../ODM/PHPCR/Mapping/Attributes/Child.php | 10 +- .../ODM/PHPCR/Mapping/Attributes/Children.php | 16 +- .../ODM/PHPCR/Mapping/Attributes/Depth.php | 3 +- .../ODM/PHPCR/Mapping/Attributes/Document.php | 26 +- .../ODM/PHPCR/Mapping/Attributes/Field.php | 19 +- .../ODM/PHPCR/Mapping/Attributes/Id.php | 12 +- .../ODM/PHPCR/Mapping/Attributes/Locale.php | 3 +- .../Mapping/Attributes/MappedSuperclass.php | 3 +- .../Mapping/Attributes/MixedReferrers.php | 7 +- .../ODM/PHPCR/Mapping/Attributes/Node.php | 3 +- .../ODM/PHPCR/Mapping/Attributes/Nodename.php | 3 +- .../Mapping/Attributes/ParentDocument.php | 3 +- .../ODM/PHPCR/Mapping/Attributes/PostLoad.php | 3 +- .../PHPCR/Mapping/Attributes/PostPersist.php | 3 +- .../PHPCR/Mapping/Attributes/PostRemove.php | 3 +- .../PHPCR/Mapping/Attributes/PostUpdate.php | 3 +- .../PHPCR/Mapping/Attributes/PrePersist.php | 3 +- .../PHPCR/Mapping/Attributes/PreRemove.php | 3 +- .../PHPCR/Mapping/Attributes/PreUpdate.php | 3 +- .../PHPCR/Mapping/Attributes/Reference.php | 24 + .../Mapping/Attributes/ReferenceMany.php | 3 +- .../PHPCR/Mapping/Attributes/ReferenceOne.php | 3 +- .../PHPCR/Mapping/Attributes/Referrers.php | 15 +- .../ODM/PHPCR/Mapping/Attributes/Uuid.php | 13 +- .../Mapping/Attributes/VersionCreated.php | 3 +- .../PHPCR/Mapping/Attributes/VersionName.php | 3 +- .../ODM/PHPCR/Mapping/ClassMetadata.php | 2 +- .../PHPCR/Mapping/Driver/AnnotationDriver.php | 12 +- .../PHPCR/Mapping/Driver/AttributeDriver.php | 248 +++++++ .../PHPCR/Mapping/Driver/AttributeReader.php | 77 +++ .../ODM/PHPCR/Mapping/MappingAttribute.php | 8 + .../ODM/PHPCR/Mapping/AttributeDriverTest.php | 34 + .../Model/ChildClassesAndLeafObject.php | 3 + .../Mapping/Model/ChildClassesObject.php | 3 + .../Mapping/Model/ChildMappingObject.php | 5 + .../Mapping/Model/ChildrenMappingObject.php | 5 + .../ClassInheritanceChildMappingObject.php | 2 + ...InheritanceChildOverridesMappingObject.php | 9 + .../ClassInheritanceParentMappingObject.php | 9 + .../Mapping/Model/DefaultMappingObject.php | 3 + .../Mapping/Model/DepthMappingObject.php | 4 + .../Mapping/Model/FieldMappingObject.php | 15 + .../Model/InheritedMixinMappingObject.php | 4 + .../ODM/PHPCR/Mapping/Model/IsLeafObject.php | 3 + .../Model/LifecycleCallbackMappingObject.php | 10 + .../Model/MappedSuperclassMappingObject.php | 10 + .../Mapping/Model/MixinMappingObject.php | 6 + .../PHPCR/Mapping/Model/NodeMappingObject.php | 4 + .../Mapping/Model/NodeTypeMappingObject.php | 3 + .../Mapping/Model/NodenameMappingObject.php | 4 + .../Model/ParentDocumentMappingObject.php | 4 + .../Model/ReferenceManyMappingObject.php | 5 + .../Model/ReferenceOneMappingObject.php | 5 + .../Model/ReferenceableChildMappingObject.php | 3 + ...leChildReferenceableFalseMappingObject.php | 2 + .../Model/ReferenceableMappingObject.php | 3 + .../Mapping/Model/ReferrersMappingObject.php | 7 + .../Model/ReplaceMixinMappingObject.php | 6 + .../Mapping/Model/RepositoryMappingObject.php | 3 + .../Model/StringExtendedMappingObject.php | 4 + .../Mapping/Model/StringMappingObject.php | 4 + .../Mapping/Model/TranslatorMappingObject.php | 7 + .../TranslatorMappingObjectNoStrategy.php | 9 +- .../Model/UniqueNodeTypeMappingObject.php | 3 + .../PHPCR/Mapping/Model/UuidMappingObject.php | 6 +- .../UuidMappingObjectNotReferenceable.php | 6 +- .../Model/VersionableMappingObject.php | 5 + 88 files changed, 1632 insertions(+), 571 deletions(-) create mode 100644 docs/en/reference/attributes-mapping.rst create mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Reference.php create mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Driver/AttributeDriver.php create mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Driver/AttributeReader.php create mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/MappingAttribute.php create mode 100644 tests/Doctrine/Tests/ODM/PHPCR/Mapping/AttributeDriverTest.php diff --git a/README.md b/README.md index e2112d04c..4712afcea 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# PHPCR ODM for Doctrine2 +# PHPCR ODM for Doctrine [![Build Status](https://github.com/doctrine/phpcr-odm/actions/workflows/test-application.yaml/badge.svg?branch=1.x)](https://github.com/doctrine/phpcr-odm/actions/workflows/test-application.yaml) [![Latest Stable Version](https://poser.pugx.org/doctrine/phpcr-odm/version.png)](https://packagist.org/packages/doctrine/phpcr-odm) diff --git a/composer.json b/composer.json index f81a1439d..8dffb66ae 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "doctrine/annotations": "^1.14.3 || ^2.0", "doctrine/data-fixtures": "^1.0", "doctrine/event-manager": "^1.0 || ^2.0", - "doctrine/persistence": "^1.3.7 || ^2.0", + "doctrine/persistence": "^2.4", "phpcr/phpcr": "^2.1.1", "phpcr/phpcr-implementation": "^2.1", "phpcr/phpcr-utils": "^1.3.0", diff --git a/docs/en/reference/annotations-mapping.rst b/docs/en/reference/annotations-mapping.rst index ee167ecc3..912392c09 100644 --- a/docs/en/reference/annotations-mapping.rst +++ b/docs/en/reference/annotations-mapping.rst @@ -4,6 +4,10 @@ Annotation Mapping In this chapter a reference of every PHPCR-ODM annotation is given with short explanations on their context and usage. +.. warning:: + + Annotations have been deprecated in favor of :doc:`Attributes` + Note on usage ------------- @@ -230,12 +234,12 @@ Examples:: /** * @PHPCR\Field(type="string", multivalue=true) */ - protected $keywords; // e.g. array('dog', 'cat', 'mouse') + protected $keywords; // e.g. ['dog', 'cat', 'mouse'] /** * @PHPCR\Field(type="double", assoc="") */ - protected $exchangeRates; // e.g. array('GBP' => 0.810709, 'EUR' => 1, 'USD' => 1.307460) + protected $exchangeRates; // e.g. ['GBP' => 0.810709, 'EUR' => 1, 'USD' => 1.307460] Hierarchy --------- diff --git a/docs/en/reference/association-mapping.rst b/docs/en/reference/association-mapping.rst index 9b201abbc..6585ef3c9 100644 --- a/docs/en/reference/association-mapping.rst +++ b/docs/en/reference/association-mapping.rst @@ -14,7 +14,7 @@ Hierarchy mappings ------------------ We have already seen the ``ParentDocument`` in the previous chapter in the section about -identifier generation. The field with this annotation maps the parent document of this document +identifier generation. The field with this mapping contains the parent document of this document (``PHPCR\NodeInterface::getParent()``). If the repository can determine the document class of the parent, it will use it, otherwise ``Doctrine\ODM\PHPCR\Document\Generic`` is used. @@ -51,21 +51,15 @@ Some sample mappings: .. code-block:: php - use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCR; + use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; - /** - * @PHPCR\Parentdocument - */ + #[PHPCR\ParentDocument] private $parent; - /** - * @PHPCR\Child - */ + #[PHPCR\Child] private $mychild; - /** - * @PHPCR\Children(filter="a*", fetchDepth=3) - */ + #[PHPCR\Children(filter: 'a*', fetchDepth: 3)] private $children; .. code-block:: xml @@ -100,9 +94,7 @@ document is not allowed to have children (i.e. that it is a leaf node). .. code-block:: php - Article - Page + Fqn\Article + Fqn\Page @@ -122,7 +114,7 @@ document is not allowed to have children (i.e. that it is a leaf node). ContentFolder: # ... - child_classes: [ "Article", "Page" ] + child_classes: [ "Fqn\Article", "Fqn\Page" ] To specify that a document can have no children: @@ -131,9 +123,7 @@ To specify that a document can have no children: .. code-block:: php ` and + :ref:`right outer join <_qbref_method_querybuilder_addjoinrightouter>`. + To register a custom node type, use the ``phpcr:node-type:register`` console + command (use ``help phpcr:node-type:register`` for the syntax; see :doc:`Tools ` + for more information). To verify that documents claiming to have unique node types + are truly unique, use the ``doctrine:phpcr:mapping:verify-unique-node-types`` command. +- **repositoryClass**: Name of the repository to use for this document. +- **versionable**: *(string)* Set to ``simple`` or ``full`` to enable versioning + (respectively simple or full level), ``false`` to disable versioning + inheritance. Implies *referenceable*. Note that not every PHPCR implementation + support this feature. See :doc:`Versioning `. +- **referenceable**: Set to true to allow this node to be referenced. +- **translator**: Determines how translations are stored, one of ``attribute`` + or ``child``. See :ref:`langauge mapping ` +- **mixins**: Optional list of PHPCR mixins that will be added to the node on + creation. Note that if this field is present, it overwrites the same field + from the anchestor documents so you have to repeat mixins you want to keep + if you add a mixins field. +- **childClasses**: List of valid child classes (if empty any classes are + permitted). +- **isLeaf**: If the document should act as a leaf (i.e. it can have no + children). Mutually exclusive with ``childClasses``. + +Minimal example:: + + use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; + + #[PHPCR\Document] + class User + { + // ... + } + +Full example:: + + use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; + + #[PHPCR\Document( + repositoryClass: UserRepository::class, + versionable: 'full', + referenceable: true, + translator: 'child', + mixins: ['mix:created', 'mix:lastModified'], + childClasses: [Article::class, Page::class] + )] + class Article + { + // ... + } + +.. note:: + + The ``uniqueNodeType`` attribute is not supported with the sqlite database. + +.. _attref_mappedsuperclass: + +#[MappedSuperclass] +~~~~~~~~~~~~~~~~~~~ + +A mapped superclass is an abstract or concrete class that provides +persistent document state and mapping information for its subclasses +but which is not itself a document. + +.. note:: + + Contrary to ORM, the PHPCR-ODM with its NoSQL nature can handle documents + that extend each other just like any other document, so you only need mapped + superclasses in special situations. See also :doc:`Inheritance Mapping `. + + +Optional parameters: + +- **nodeType**: PHPCR type for this node. Default ``nt:unstructured``. +- **repositoryClass**: Fully qualified name of the repository to use for + documents extending this superclass. +- **translator**: Determines how translations are stored, one of ``attribute`` + or ``child``. See :ref:`language mapping `. + +.. code-block:: php + + use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; + + #[PHPCR\MappedSuperclass] + class MappedSuperclassBase + { + // ... fields and methods + } + + #[PHPCR\Document] + class DocumentSubClassFoo extends MappedSuperclassBase + { + // ... fields and methods + } + + +Mapping Fields +-------------- + +You can attribute an instance variable with the ``#[Field]`` attributeto make it +"persistent". + +.. _attref_field: + + +#[Field] +~~~~~~~~ + +parameters: + +- **property**: The PHPCR property name to which this field is stored. + Defaults to the field name. +- **assoc**: Specify that this attribute should be an associative array. The value should + be a string which will be used by the PHPCR node. Set to an empty string to automatically + use the name of the property with that attribute appended by "Keys". +- **multivalue**: ``true`` to specify that this property should be treated as a simple array. + See :ref:`Mapping multivalue properties `. +- **translated**: ``true`` to specify that the property should be translatable, requires the + ``translator`` attribute to be specified in :ref:`#[Document]`. +- **nullable**: ``true`` to specifiy that this property doesn't have a required value, used + when loading a translation, to allow loading a node with a missing translated property. +- **type**: Type of the field, see table below. + +Types: + +- **binary**: Sets the type of the property to binary. +- **boolean**: Sets the type of the property to boolean. +- **date**: Sets the type of the property to DateTime. +- **decimal**: Sets the type of the property to decimal, + the decimal field uses the BCMath library which supports numbers of any size + or precision. +- **double**: Sets the type of the property to double. The PHP type will be **float**. +- **long**: Sets the type of the property to long. The PHP type will be **integer**. +- **name**: The property must be a valid XML CNAME value + and can be used to store a valid node name. +- **path**: The property must be a valid PHPCR node path + and can be used to store an arbitrary reference to another node. +- **string**: Sets the type of the property to string. +- **uri**: The property will be validated as an URI. + +Examples:: + + use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; + + #[PHPCR\Field(type: 'string')] + protected $author; + + #[PHPCR\Field(type: 'string', translated: true)] + protected $title; + + #[PHPCR\Field(type: 'string', translated: true, nullable: true)] + protected $subTitle; + + #[PHPCR\Field(type: 'boolean')] + protected $enabled; + + #[PHPCR\Field(type: 'string', multivalue: true)] + protected $keywords; // e.g. ['dog', 'cat', 'mouse'] + + #[PHPCR\Field(type: 'double', assoc: '')] + protected $exchangeRates; // e.g. ['GBP' => 0.810709, 'EUR' => 1, 'USD' => 1.307460] + +Hierarchy +--------- + +These mappings mark the properties to contain instances of Documents +above or below the current Document in the document hierarchy, or information +about the state of the document within the hierarchy. They need to be +specified inside the instance variables associated PHP DocBlock comment. + +.. _attref_child: + +#[Child] +~~~~~~~~ + +The property will be populated with the named document +directly below the instance variables document class in the document hierarchy. + +Required parameters: + +- **nodeName**: PHPCR Node name of the child document to map, this should be a string. + +Optional parameters: + +- **cascade**: |cascade_definition| See :ref:`assocmap_cascading` + +.. code-block:: php + + use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; + + #[PHPCR\Child(name: 'Preferences')] + protected $preferences; + +.. _attref_children: + +#[Children] +~~~~~~~~~~~ + +The property will be populated with Documents directly below the +instance variables document class in the document hierarchy. + +Optional parameters: + +- **filter**: Child name filter; only return children whose names match the given filter. +- **fetchDepth**: Performance optimisation, number of levels to pre-fetch and cache, + this should be an integer. +- **ignoreUntranslated**: Set to false to *not* throw exceptions on untranslated child + documents. +- **cascade**: |cascade_definition| See :ref:`assocmap_cascading` + +.. code-block:: php + + use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; + + #[PHPCR\Children(filter: 'a*', fetchDepth: 3)] + private $children; + +.. _attref_depth: + +#[Depth] +~~~~~~~~ + +The property will be populated with an integer value +representing the depth of the document within the document hierarchy:: + + use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; + + #[PHPCR\Depth] + private $depth; + +.. _attref_parentdocument: + +#[ParentDocument] +~~~~~~~~~~~~~~~~~ + +Optional parameters: + +- **cascade**: |cascade_definition| See :ref:`assocmap_cascading` + +The property will contain the nodes parent document. Assigning +a different parent will result in a move operation:: + + use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; + + #[PHPCR\ParentDocument] + private $parent; + +Identification +-------------- + +These mappings help to manage the identification of the document class. + +.. _attref_id: + +#[Id] +~~~~~ + +The property will be marked with the documents +identifier. The ID is the **full path** to the document in the document hierarchy. +See :ref:`identifiers `. + +Required parameters: + +- **strategy**: How to generate IDs, one of ``NONE``, ``REPOSITORY``, ``ASSIGNED`` or ``PARENT``, default + is ``PARENT`` See :ref:`generation strategies `. + +.. code-block:: php + + use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; + + #[PHPCR\Id] + protected $id; // e.g. /path/to/mydocument + +.. _attref_nodename: + +#[Nodename] +~~~~~~~~~~~ + +Mark the property as representing the name of the node. The name +of the node is the last part of the :ref:`ID `. Changing the marked variable will update +the nodes ID:: + + use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; + + #[PHPCR\Id] + protected $id; // e.g. /path/to/mydocument + + #[PHPCR\Nodename] + protected $nodeName; // e.g. mydocument + +.. _attref_uuid: + +#[Uuid] +~~~~~~~ + +The property will be populated with a UUID +(Universally Unique Identifier). The UUID is immutable. For +this field to be reliably populated the document should be +*referenceable*:: + + use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; + + #[PHPCR\Uuid] + protected $uuid; // e.g. 508d6621-0c20-4972-bf0e-0278ccabe6e5 + +Lifcycle callbacks +------------------ + +These attributes are used to map information on methods of a document. +The method is called automatically by the ODM on the +:ref:`lifecycle event ` corresponding to the attribute. + +.. note:: + + Unlike the Doctrine ORM it is **not** necessary to specify a ``#[HasLifecycleCallbacks]`` + attribute. + +.. _attref_postload: + +#[PostLoad] +~~~~~~~~~~~ + +Life cycle callback. The marked method will be called automatically on the ``postLoad`` +event. See :ref:`lifecycle callbacks ` for further explanations:: + + use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; + + #[PHPCR\PostLoad] + public function doSomethingOnPostLoad() + { + // ... do something after the Document has been loaded + } + +.. _attref_postpersist: + +#[PostPersist] +~~~~~~~~~~~~~~ + +Life cycle callback. The marked method will be called automatically on the ``postPersist`` +event. See :ref:`lifecycle callbacks ` for further explanations:: + + use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; + + #[PHPCR\PostPersist] + public function doSomethingOnPostPersist() + { + // ... do something after the document has been persisted + } + +.. _attref_postremove: + +#[PostRemove] +~~~~~~~~~~~~~ + +Life cycle callback. The marked method will be called automatically on the ``postRemove`` +event. See :ref:`lifecycle callbacks ` for further explanations:: + + use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; + + #[PHPCR\PostRemove] + public function doSomethingOnPostRemove() + { + // ... do something after the document has been removed + } + +.. _attref_postupdate: + +#[PostUpdate] +~~~~~~~~~~~~~ + +Life cycle callback. The marked method will be called automatically on the ``postUpdate`` +event. See :ref:`lifecycle callbacks ` for further explanations:: + + use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; + + #[PHPCR\PostUpdate] + public function doSomethingOnPostUpdate() + { + // ... do something after the document has been updated + } + +.. _attref_prepersist: + +#[PrePersist] +~~~~~~~~~~~~~ + +Life cycle callback. The marked method will be called automatically on the ``prePersist`` +event. See :ref:`lifecycle callbacks ` for further explanations:: + + use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; + + #[PHPCR\PrePersist] + public function doSomethingOnPrePersist() + { + // ... do something before the document has been persisted + } + +.. _attref_preremove: + +#[PreRemove] +~~~~~~~~~~~~ + +Life cycle callback. The marked method will be called automatically on the ``preRemove`` +event. See :ref:`lifecycle callbacks ` for further explanations:: + + use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; + + #[PHPCR\PreRemove] + public function doSomethingOnPreRemove() + { + // ... do something before the document has been removed + } + +.. _attref_preupdate: + +#[PreUpdate] +~~~~~~~~~~~~ + +Life cycle callback. The marked method will be called automatically on the ``preUpdate`` +event. See :ref:`lifecycle callbacks ` for further explanations:: + + use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; + + #[PHPCR\PreUpdate] + public function doSomethingOnPreUpdate() + { + // ... do something before the document has been updated + } + +PHPCR +----- + +.. _attref_node: + +#[Node] +~~~~~~~ + +The property will be populated with the underlying +PHPCR node. See :ref:`node field mapping `. + +References +---------- + +.. _attref_referencemany: + +#[ReferenceMany] +~~~~~~~~~~~~~~~~ + +Optional parameters: + +- **targetDocument**: Specify type of target document class. Note that this + is an optional parameter and by default you can associate *any* document. +- **strategy**: One of ``weak``, ``hard`` or ``path``. See :ref:`reference other documents `. + +.. code-block:: php + + use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; + + #[PHPCR\ReferenceMany(targetDocument: PhoneNumber::class, strategy: 'hard')] + protected $phoneNumbers; + +.. _attref_referenceone: +.. _attref_reference: + +#[ReferenceOne] +~~~~~~~~~~~~~~~ + +Optional parameters: + +- **targetDocument**: Specify type of target document class. Note that this + is an optional parameter and by default you can associate *any* document. +- **strategy**: One of `weak`, `hard` or `path`. See :ref:`reference other documents `. +- **cascade**: |cascade_definition| See :ref:`assocmap_cascading` + +.. code-block:: php + + use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; + + #[PHPCR\ReferenceOne(targetDocument: Contact::class, strategy: 'hard')] + protected $contact; + +.. _attref_referrers: + +#[Referrers] +~~~~~~~~~~~~ + +Mark the property to contain a collection of the documents +of the given document class which refer to this document. + +Required parameters: + +- **referringDocument**: Full class name of referring document, the instances + of which should be collected in the property. +- **referencedBy**: Name of the property from the referring document class + which refers to this document class. + +Optional parameters: + +- **cascade**: |cascade_definition| See :ref:`assocmap_cascading` + +.. code-block:: php + + use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; + + #[PHPCR\Referrers(referringDocument: Address::class, referencedBy: 'addressbook')] + protected $addresses; + +#[MixedReferrers] +~~~~~~~~~~~~~~~~~ + +Mark the property to hold a collection of *all* documents +which refer to this document, regardless of document class. + +Optional parameters: + +- **referenceType**: One of ``weak`` or ``hard``. + +.. code-block:: php + + use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; + + #[PHPCR\MixedReferrers] + protected $referrers; + +Translation +----------- + +These attributes only apply to documents where the ``translator`` attribute is +specified in :ref:`#[Document]`. + +Example:: + + use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; + + #[PHPCR\Document(translator: 'attribute')] + class MyDocument + { + #[PHPCR\Locale] + protected $locale; + + #[PHPCR\Field(type: 'string', translated: true)] + protected $title; + } + +.. _attref_locale: + +#[Locale] +~~~~~~~~~ + +Identifies the property as the field in which to store +the documents current locale. + +Versioning +---------- + +These attributes only apply to documents where the ``versionable`` attribute is +specified in :ref:`#[Document]`. + +See :ref:`versioning mappings `. + +Example:: + + use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; + + #[PHPCR\Document(versionable: 'simple')] + class MyPersistentClass + { + #[PHPCR\VersionName] + private $versionName; + + #[PHPCR\VersionCreated] + private $versionCreated; + } + +.. _attref_versioncreated: + +#[VersionCreated] +~~~~~~~~~~~~~~~~~ + +The property will be populated with the date +that the current document version was created. Applies only to +documents with the versionable attribute. + +.. _attref_versionname: + +#[VersionName] +~~~~~~~~~~~~~~ + +The property will be populated with the name +of the current version as given by PHPCR. + +.. |cascade_definition| replace:: One of ``persist``, ``remove``, ``merge``, ``detach``, ``refresh``, ``translation`` or ``all``. diff --git a/docs/en/reference/basic-mapping.rst b/docs/en/reference/basic-mapping.rst index d6d298779..f8e7ae06a 100644 --- a/docs/en/reference/basic-mapping.rst +++ b/docs/en/reference/basic-mapping.rst @@ -10,23 +10,23 @@ Mapping Drivers Doctrine provides several different ways for specifying object-document mapping metadata: +- PHP Attributes +- Docblock Annotations (deprecated) +- XML +- YAML -- Docblock Annotations -- XML -- YAML - -This manual usually mentions docblock annotations in all the examples +This manual usually mentions PHP attributes in all the examples that are spread throughout all chapters, however for many examples alternative YAML and XML examples are given as well. There are dedicated reference chapters for XML and YAML mapping, respectively that explain them -in more detail. There is also an Annotation reference chapter. +in more detail. There is also an Attribute and an Annotation reference chapter. .. note:: If you're wondering which mapping driver gives the best performance, the answer is: They all give exactly the same performance. Once the metadata of a class has - been read from the source (annotations, xml or yaml) it is stored + been read from the source (attributes, xml or yaml) it is stored in an instance of the ``Doctrine\ODM\PHPCR\Mapping\ClassMetadata`` class and these instances are stored in the metadata cache. Therefore at the end of the day all drivers perform equally well. If you're not @@ -35,52 +35,29 @@ in more detail. There is also an Annotation reference chapter. support in PHP. -Introduction to Docblock Annotations ------------------------------------- - -You've probably used docblock annotations in some form already, -most likely to provide documentation metadata for a tool like -``PHPDocumentor`` (@author, @link, ...). Docblock annotations are a -tool to embed metadata inside the documentation section which can -then be processed by some tool. Doctrine generalizes the concept -of docblock annotations so that they can be used for any kind of -metadata and so that it is easy to define new docblock annotations. -In order to allow more involved annotation values and to reduce the -chances of clashes with other docblock annotations, the Doctrine -docblock annotations feature an alternative syntax that is heavily -inspired by the Annotation syntax introduced in Java 5. - -The implementation of these enhanced docblock annotations is -located in the ``Doctrine\Common\Annotations`` namespace and -therefore part of the Common package. Doctrine docblock -annotations support namespaces and nested annotations among other -things. The Doctrine PHPCR-ODM defines its own set of docblock -annotations for supplying object-document mapping metadata. - -.. note:: +Introduction to PHP Attributes +------------------------------ - If you're not comfortable with the concept of docblock - annotations, don't worry, as mentioned earlier Doctrine provides - XML and YAML alternatives and you could easily implement your own - favourite mechanism for defining PHPCR-ODM metadata. +PHP attributes are an official language replacement for the informal +docblock annotations. They allow to embed metadata next to the code. +The Doctrine PHPCR-ODM defines its own set of attributes to supply +object-document mapping metadata. Persistent classes ------------------ In order to mark a class for object-document persistence it needs to be designated as an document. This can be done through the -``@Document`` marker annotation. +``#[Document]`` marker attribute. .. configuration-block:: .. code-block:: php - use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCR; + use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; - /** - * @PHPCR\Document - */ + #[PHPCR\Document] class MyPersistentClass { //... @@ -99,7 +76,7 @@ to be designated as an document. This can be done through the MyPersistentClass: # ... -There is a couple of options you can specify for the document mapping. +There is a couple of parameters you can specify for the document mapping. Some of them are explained here, the rest in the chapters on :ref:`References `, :doc:`Multilanguage ` and :doc:`Versioning `. @@ -146,7 +123,7 @@ information. .. note:: - DateTime types are compared by reference, not by value. Doctrine updates this values + DateTime types are compared by reference, not by value. Doctrine updates these values if the reference changes and therefore behaves as if these objects are immutable value objects. .. warning:: @@ -172,12 +149,11 @@ that hold scalar values like strings, numbers, etc, or arrays thereof. Although references are also stored as properties in PHPCR, they have their own mappings - see the chapter "Association Mapping". -To mark a property for relational persistence the ``@Field`` -docblock annotation is used. This annotation requires at least 1 attribute -to be set, the ``type``. The ``type`` attribute -specifies the Doctrine Mapping Type to use for the field. If the -type is not specified, PHPCR-ODM will try to let the PHPCR implementation determine -a suitable type. +To mark a property for relational persistence the ``#[Field]`` attribute +is used. This attribute requires at least the ``type`` parameter to be set. +The ``type`` parameter specifies the Doctrine Mapping Type to use for the +field. If the type is not specified, PHPCR-ODM will try to let the PHPCR +implementation determine a suitable type. Example: @@ -185,21 +161,15 @@ Example: .. code-block:: php - use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCR; + use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; - /** - * @PHPCR\Document - */ + #[PHPCR\Document] class MyPersistentClass { - /** - * @PHPCR\Field(type="long") - */ + #[PHPCR\Field(type: 'long')] private $count; - /** - * @PHPCR\Field(type="string") - */ + #[PHPCR\Field(type: 'string')] private $name; // type defaults to string //... } @@ -231,19 +201,16 @@ as the field names. Mapping to a differently named PHPCR property ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -To specify a different name for the column, you -can use the ``property`` attribute of the Column annotation as -follows: +To specify a different name for the column, you can use the ``property`` +parameter of the Column attribute follows: .. configuration-block:: .. code-block:: php - use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCR; + use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; - /** - * @PHPCR\Field(property="db_name") - */ + #[PHPCR\Field(property: 'db_name'"')] private $myField; .. code-block:: xml @@ -276,11 +243,9 @@ Unless specified as true, properties are considered single value. .. code-block:: php - use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCR; + use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; - /** - * @PHPCR\Field(type="string", multivalue=true) - */ + #[PHPCR\Field(type: 'string', multivalue: true)] private $names; .. code-block:: xml @@ -311,16 +276,12 @@ the list keys. .. code-block:: php - use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCR; + use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; - /** - * @PHPCR\Field(type="string", assoc="") - */ + #[PHPCR\Field(type: 'string', assoc: '')] private $names; - /** - * @PHPCR\Field(type="string", assoc="listArraykeys") - */ + #[PHPCR\Field(type: 'string', assoc: 'listArraykeys')] private $list; .. code-block:: xml @@ -345,7 +306,7 @@ the list keys. Summary ~~~~~~~ -These are all attributes of the Property annotation. The ORM knows quite a few validation attributes +These are all parameters of the property mapping. The ORM knows quite a few validation parameters because they are used to generate the database schema. As PHPCR-ODM does not (yet) generate PHPCR node type definitions, there is no need for validation. @@ -374,18 +335,21 @@ Every document has an identifier. The id in PHPCR-ODM is the PHPCR path. .. note:: - The id being the path, it is not totally immutable. When the document is moved either explicitly - with DocumentManager::move() or by assignment of a different @Field(type="name") or @ParentDocument, the - id will change. This was discussed thoroughly and is considered the best solution. + The id being the path, it is not totally immutable. When the document is + moved either explicitly with ``DocumentManager::move()`` or by assignment + of a different ``#[Field(type: 'name')]`` or ``#[ParentDocument]``, the id + will change. This was discussed thoroughly and is considered the best solution. - If you need to reference a document reliably even when moving, look at the @ReferenceOne and the @Uuid - annotations explained in the :doc:`next chapter `. + If you need to reference a document reliably even when moving, look at the + ``#[ReferenceOne]`` and the ``#[Uuid]`` attributes explained in the + :doc:`next chapter `. -While you can manually assign the id, this is not recommended. When manually assigning, you need -to ensure that the parent document resulting from the assigned path exists. The recommended way -is to use the @Parentdocument and @Nodename annotations to place the document in the tree. -When using that strategy, you need not have a property with the @Id annotation - though you can -if you want to have access to the path for something. +While you can manually assign the id, this is not recommended. When manually +assigning, you need to ensure that the parent document defined in the assigned +path exists. The recommended way is to use the ``#[ParentDocument]`` and +``#[Nodename]`` attributes to place the document in the tree. When using that +strategy, you need not have a property with the ``#[Id]`` attribute - though if +you need access to the path for something, you can also map the id. .. _basicmapping_identifier_generation_strategies: @@ -397,13 +361,13 @@ You can specify one of them explicitly on the id mapping, or let the PHPCR-ODM pick a fitting one. The order is: - Explicitly specified strategy on the ``id`` mapping, for example - ``@Id(strategy="repository");`` -- If the document has a @ParentDocument and a @Nodename field, the + ``#[PHPCR\Id(strategy: 'repository')]`` +- If the document has a ``#[ParentDocument]`` and a ``#[Nodename]`` field, the ``parent`` is used to determine the id from this information. This is the most failsave strategy as it will ensure that there is a PHPCR parent existing for the document; -- If only an @ParentDocument field is present, the ``auto`` takes - the path from the @ParentDocument as the parent id generator does, but +- If only an ``#[ParentDocument]`` field is present, the ``auto`` takes + the path from the ``#[ParentDocument]`` as the parent id generator does, but generates the node name automatically using the PHPCR ``addNodeAutoNamed`` method; - If there is only an id field, the ``assigned`` is used. It expects @@ -418,11 +382,11 @@ implement any logic you might need. Parent and name strategy (recommended) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -This strategy uses the @Nodename (name of this node) and -@ParentDocument (PHPCR-ODM document that is the parent). The id is generated +This strategy uses the ``#[Nodename]`` (name of this node) and +``#[ParentDocument]`` (PHPCR-ODM document that is the parent). The id is generated as the id of the parent concatenated with '/' and the Nodename. -If you supply a ParentDocument annotation, the strategy is automatically set to +If you supply a ParentDocument attribute, the strategy is automatically set to parent. This strategy will check the parent and the name and will fall back to the assigned id if either is missing. @@ -431,16 +395,12 @@ the assigned id if either is missing. .. code-block:: php - use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCR; + use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; - /** - * @PHPCR\Parentdocument - */ + #[PHPCR\ParentDocument] private $parent; - /** - * @PHPCR\Nodename - */ + #[PHPCR\Nodename] private $nodename; .. code-block:: xml @@ -480,11 +440,9 @@ representing any PHPCR-ODM document, though.) .. code-block:: php - use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCR; + use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; - /** - * @PHPCR\Id - */ + #[PHPCR\Id] private $id; .. code-block:: xml @@ -521,11 +479,9 @@ This gives you full control how you want to build the id path. .. code-block:: php - use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCR; + use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; - /** - * @PHPCR\Id(strategy="repository") - */ + #[PHPCR\Id(strategy: 'repository')] private $id; .. code-block:: xml @@ -545,40 +501,33 @@ This gives you full control how you want to build the id path. generator: strategy: repository -The corresponding code could look like this:: +The document code could look like this:: namespace Demo; - use Doctrine\ODM\PHPCR\Id\RepositoryIdInterface; - use Doctrine\ODM\PHPCR\DocumentRepository as BaseDocumentRepository; - use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCR; + use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; - /** - * @PHPCR\Document(repositoryClass="Demo\DocumentRepository") - */ + #[PHPCR\Document(repositoryClass: DocumentRepository::class)] class Document { - /** - * @PHPCR\Id(strategy="repository") - */ + #[PHPCR\Id(strategy: 'repository')] private $id; - /** - * @PHPCR\Field(type="string") - */ + #[PHPCR\Field(type: 'string')] private $title; //... } +And the corresponding repository like this:: + + namespace Demo; + + use Doctrine\ODM\PHPCR\Id\RepositoryIdInterface; + use Doctrine\ODM\PHPCR\DocumentRepository as BaseDocumentRepository; + class DocumentRepository extends BaseDocumentRepository implements RepositoryIdInterface { - /** - * Generate a document id - * - * @param object $document - * @return string - */ - public function generateId($document, $parent = null) + public function generateId(Document $document, object $parent = null): string { return '/functional/'.$document->getTitle(); } diff --git a/docs/en/reference/events.rst b/docs/en/reference/events.rst index a56512ffd..594c423c8 100644 --- a/docs/en/reference/events.rst +++ b/docs/en/reference/events.rst @@ -41,7 +41,7 @@ the life-time of their registered documents. all references to documents have been removed from the unit of work. This event is not a lifecycle callback; - loadClassMetadata - occurs after mapping metadata for a class has been loaded - from a mapping source (annotations/xml/yaml). This event is not a lifecycle + from a mapping source (attributes/annotations/xml/yaml). This event is not a lifecycle callback. - postLoadTranslation - occurs when a translation of a document has been loaded from the repository. @@ -142,81 +142,61 @@ event occurs. .. code-block:: php - use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCR; + use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; - /** - * @PHPCR\PrePersist - */ + #[PHPCR\PrePersist] public function doStuffOnPrePersist() { $this->createdAt = date('Y-m-d H:m:s'); } - /** - * @PHPCR\PrePersist - */ + #[PHPCR\PrePersist] public function doOtherStuffOnPrePersist() { $this->value = 'changed from prePersist callback!'; } - /** - * @PHPCR\PostPersist - */ + #[PHPCR\PostPersist] public function doStuffOnPostPersist() { $this->value = 'changed from postPersist callback!'; } - /** - * @PHPCR\PostLoad - */ + #[PHPCR\PostLoad] public function doStuffOnPostLoad() { $this->value = 'changed from postLoad callback!'; } - /** - * @PHPCR\PreUpdate - */ + #[PHPCR\PreUpdate] public function doStuffOnPreUpdate() { $this->value = 'changed from preUpdate callback!'; } - /** - * @PHPCR\PreBindTranslation - */ + #[PHPCR\PreBindTranslation] public function doStuffOnPreBindTranslation() { $this->value = 'changed from preBindTranslation callback!'; } - /** - * @PHPCR\PostBindTranslation - */ + #[PHPCR\PostBindTranslation] public function doStuffOnPostBindTranslation() { $this->value = 'changed from postBindTranslation callback!'; } - /** - * @PHPCR\postLoadTranslation - */ + #[PHPCR\postLoadTranslation] public function doStuffOnPostLoadTranslation() { $this->value = 'changed from postLoadTranslation callback!'; } - /** - * @PHPCR\PreRemoveTranslation - */ + #[PHPCR\PreRemoveTranslation] public function doStuffOnPreRemoveTranslation() { $this->value = 'changed from preRemoveTranslation callback!'; } - /** - * @PHPCR\PostRemoveTranslation - */ + #[PHPCR\PostRemoveTranslation] public function doStuffOnPostRemoveTranslation() { $this->value = 'changed from postRemoveTranslation callback!'; @@ -251,7 +231,7 @@ listed in the previous Lifecycle Events section. .. note:: - Contrary to the ORM, PHPCR-ODM does **not** use the @HasLifecycleCallbacks marker. + Contrary to the ORM, PHPCR-ODM does **not** use the ``HasLifecycleCallbacks`` marker. Listening to Lifecycle Events diff --git a/docs/en/reference/inheritance-mapping.rst b/docs/en/reference/inheritance-mapping.rst index 2f0e0d3de..0d106d3b6 100644 --- a/docs/en/reference/inheritance-mapping.rst +++ b/docs/en/reference/inheritance-mapping.rst @@ -13,7 +13,7 @@ to semantically broken data structures. Overwriting mixins works as overwriting any other setting. This means that if your mapping has any mixins, you need to explicitly repeat any mixins - from anchestor classes that you want to keep. + from ancestor classes that you want to keep. Typically, the purpose of such inheritance is to model the is-a relationship in your models and to reuse the mappings and functions of the base class. diff --git a/docs/en/reference/installation-configuration.rst b/docs/en/reference/installation-configuration.rst index 77c70b655..0ae7fc8e1 100644 --- a/docs/en/reference/installation-configuration.rst +++ b/docs/en/reference/installation-configuration.rst @@ -52,8 +52,9 @@ Bootstrap will roughly look like this:: $workspace = 'default'; $user = 'admin'; $pass = 'admin'; - $repository = \Jackalope\RepositoryFactoryJackrabbit::getRepository( - array('jackalope.jackrabbit_uri' => 'http://localhost:8080/server')); + $repository = \Jackalope\RepositoryFactoryJackrabbit::getRepository([ + 'jackalope.jackrabbit_uri' => 'http://localhost:8080/server', + ]); $credentials = new \PHPCR\SimpleCredentials($user, $pass); $session = $repository->login($credentials, $workspace); @@ -75,20 +76,20 @@ Bootstrap will roughly look like this when using mysql as storage backend:: $user = 'admin'; $pass = 'admin'; - $params = array( + $params = [ 'driver' => 'pdo_mysql', // or pdo_pgsql 'host' => 'localhost', 'user' => $user, 'password' => $pass, 'dbname' => 'phpcr_odm_tutorial', - ); + ]; // Bootstrap Doctrine DBAL $dbConn = \Doctrine\DBAL\DriverManager::getConnection($params); - $repository = \Jackalope\RepositoryFactoryDoctrineDBAL::getRepository( - array('jackalope.doctrine_dbal_connection' => $dbConn) - ); + $repository = \Jackalope\RepositoryFactoryDoctrineDBAL::getRepository([ + 'jackalope.doctrine_dbal_connection' => $dbConn, + ]); // dummy credentials to comply with the API $credentials = new \PHPCR\SimpleCredentials(null, null); $session = $repository->login($credentials, $workspace); @@ -99,11 +100,11 @@ credentials are ignored. Jackalope Doctrine DBAL also works with sqlite. Use the following parameters:: - $params = array( + $params = [ 'driver' => 'pdo_sqlite', 'dbname' => 'odm', 'path' => '/tmp/jackalope.db', - ); + ]; Install Midgard2 PHPCR provider @@ -123,7 +124,7 @@ Bootstrap will roughly look like this when using mysql as storage backend:: $user = 'admin'; $pass = 'password'; - $params = array( + $params = [ 'midgard2.configuration.db.type' => 'MySQL', 'midgard2.configuration.db.name' => 'phpcr', 'midgard2.configuration.db.host' => 'localhost', @@ -131,7 +132,7 @@ Bootstrap will roughly look like this when using mysql as storage backend:: 'midgard2.configuration.db.password' => 'midgard', 'midgard2.configuration.blobdir' => '/some/path/for/blobs', 'midgard2.configuration.db.init' => true, - ); + ]; $repository = \Midgard\PHPCR\RepositoryFactory::getRepository($params); $credentials = new \PHPCR\SimpleCredentials($user, $pass); @@ -149,13 +150,13 @@ mysql driver of midgard to connect to the database. Midgard can also use sqlite, with the following parameters:: - $params = array( + $params = [ 'midgard2.configuration.db.type' => 'SQLite', 'midgard2.configuration.db.name' => 'odm', 'midgard2.configuration.db.dir' => '/tmp', 'midgard2.configuration.blobdir' => '/tmp/blobs' 'midgard2.configuration.db.init' => true, - ); + ]; Configuration ============= @@ -198,39 +199,20 @@ Prepare the mapping driver In order to make PHPCR-ODM understand your documents, you need to provide mappings. -You can choose between the drivers for annotations, xml and yml configuration files. +You can choose between the drivers for attributes, xml and yml configuration files. Add the respective code right after the autoloading. See later in this chapter for more options with the mapping drivers. -Annotation Mapping Driver +Attributes Mapping Driver ^^^^^^^^^^^^^^^^^^^^^^^^^ -With the annotation driver, you can annotate the fields in your document +With the attributes driver, you can add attributes to your document classes with the mapping metadata:: - use Doctrine\Common\Annotations\AnnotationRegistry; - use Doctrine\Common\Annotations\AnnotationReader; - use Doctrine\ODM\PHPCR\Mapping\Driver\AnnotationDriver; + use Doctrine\ODM\PHPCR\Mapping\Driver\AttributeDriver; - AnnotationRegistry::registerLoader(array($autoload, 'loadClass')); - - $reader = new AnnotationReader(); - $driver = new AnnotationDriver($reader, array('/path/to/your/document/classes')); - -.. note:: - - Since PHPCR-ODM 1.1, the annotations are autoloaded like any other class. - - With version 1.0, you needed to register the annotation file:: - - use Doctrine\Common\Annotations\AnnotationRegistry; - - AnnotationRegistry::registerLoader(function($class) use ($autoload) { - $autoload->loadClass($class); - return class_exists($class, false); - }); - AnnotationRegistry::registerFile(__DIR__.'/vendor/doctrine/phpcr-odm/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/DoctrineAnnotations.php'); + $driver = new AttributeDriver(['/path/to/your/document/classes']); XML Mapping Driver ^^^^^^^^^^^^^^^^^^ @@ -240,7 +222,7 @@ documents and PHPCR:: use Doctrine\ODM\PHPCR\Mapping\Driver\XmlDriver; - $driver = new XmlDriver(array('/path/to/your/xml-mapping/files')); + $driver = new XmlDriver(['/path/to/your/xml-mapping/files']); YML Mapping Driver ^^^^^^^^^^^^^^^^^^ @@ -249,7 +231,7 @@ Your project must require symfony/yaml in composer.json:: use Doctrine\ODM\PHPCR\Mapping\Driver\YamlDriver; - $driver = new YamlDriver(array('/path/to/your/yml-mapping/files')); + $driver = new YamlDriver(['/path/to/your/yml-mapping/files']); Quick Configuration Example @@ -265,15 +247,15 @@ A complete configuration could look like this:: /* --- see above for sample bootstrapping code of other repository implementations --- */ - $params = array( + $params = [ 'driver' => 'pdo_mysql', 'host' => 'localhost', 'user' => $user, 'password' => $pass, 'dbname' => 'phpcr_odm_tutorial', - ); + ]; $dbConn = \Doctrine\DBAL\DriverManager::getConnection($params); - $parameters = array('jackalope.doctrine_dbal_connection' => $dbConn); + $parameters = ['jackalope.doctrine_dbal_connection' => $dbConn]; $repository = \Jackalope\RepositoryFactoryDoctrineDBAL::getRepository($parameters); $credentials = new \PHPCR\SimpleCredentials(null, null); @@ -283,12 +265,10 @@ A complete configuration could look like this:: $session = $repository->login($credentials, $workspace); /* prepare the doctrine configuration */ - use Doctrine\Common\Annotations\AnnotationReader; - use Doctrine\ODM\PHPCR\Mapping\Driver\AnnotationDriver; + use Doctrine\ODM\PHPCR\Mapping\Driver\AttributeDriver; use Doctrine\ODM\PHPCR\DocumentManager; - $reader = new AnnotationReader(); - $driver = new AnnotationDriver($reader, array('/path/to/your/document/classes')); + $driver = new AttributeDriver(['/path/to/your/document/classes']); $config = new \Doctrine\ODM\PHPCR\Configuration(); $config->setMetadataDriverImpl($driver); @@ -349,20 +329,19 @@ classes. There are currently 4 implementations available: -- ``Doctrine\ODM\PHPCR\Mapping\Driver\AnnotationDriver`` +- ``Doctrine\ODM\PHPCR\Mapping\Driver\AttributeDriver`` - ``Doctrine\ODM\PHPCR\Mapping\Driver\XmlDriver`` - ``Doctrine\ODM\PHPCR\Mapping\Driver\YamlDriver`` - ``Doctrine\ODM\PHPCR\Mapping\Driver\DriverChain`` -Throughout the most part of this manual the AnnotationDriver is +Throughout the most part of this manual the AttributeDriver is used in the examples. For information on the usage of the XmlDriver or YamlDriver please refer to the dedicated chapters ``XML Mapping`` and ``YAML Mapping``. -When you manually instantiate the annotation driver, you need to tell it the -path to the entities. All metadata drivers accept either a single directory as -a string or an array of directories. With this feature a single driver can -support multiple directories of Documents. +When you manually instantiate the attribute driver, you need to tell it the +path to the entities. All metadata drivers accept an array of directories. +With this feature a single driver can support multiple directories of Documents. Metadata Cache (***RECOMMENDED***) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -374,7 +353,7 @@ Metadata Cache (***RECOMMENDED***) Gets or sets the cache implementation to use for caching metadata information, that is, all the information you supply via -annotations, xml or yaml, so that they do not need to be parsed and +attributes, xml or yaml, so that they do not need to be parsed and loaded from scratch on every single request which is a waste of resources. The cache implementation must implement the ``Doctrine\Common\Cache\Cache`` interface. @@ -516,27 +495,6 @@ each time you change anything on your class or mapping: This command is only available since PHPCR-ODM 1.1. -Autoloading Proxies -~~~~~~~~~~~~~~~~~~~ - -When you deserialize proxy objects from the session or any other storage -it is necessary to have an autoloading mechanism in place for these classes. -For implementation reasons Proxy class names are not PSR-0 compliant. This -means that you have to register a special autoloader for these classes:: - - use Doctrine\ORM\Proxy\Autoloader; - - $proxyDir = '/path/to/proxies'; - $proxyNamespace = 'MyProxies'; - - Autoloader::register($proxyDir, $proxyNamespace); - -If you want to execute additional logic to intercept the proxy file not found -state you can pass a closure as the third argument. It will be called with -the arguments proxydir, namespace and className when the proxy file could not -be found. - - Multiple Metadata Sources ~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/en/reference/introduction.rst b/docs/en/reference/introduction.rst index 77c453699..4fe8536a4 100644 --- a/docs/en/reference/introduction.rst +++ b/docs/en/reference/introduction.rst @@ -94,13 +94,13 @@ your project root directory:: throw new RuntimeException('Install dependencies with composer.'); } - $params = array( + $params = [ 'driver' => 'pdo_mysql', 'host' => 'localhost', 'user' => 'root', 'password' => '', 'dbname' => 'phpcr_odm_tutorial', - ); + ]; $workspace = 'default'; $user = 'admin'; @@ -109,7 +109,7 @@ your project root directory:: /* --- transport implementation specific code begin --- */ // for more options, see https://github.com/jackalope/jackalope-doctrine-dbal#bootstrapping $dbConn = \Doctrine\DBAL\DriverManager::getConnection($params); - $parameters = array('jackalope.doctrine_dbal_connection' => $dbConn); + $parameters = ['jackalope.doctrine_dbal_connection' => $dbConn]; $repository = \Jackalope\RepositoryFactoryDoctrineDBAL::getRepository($parameters); $credentials = new \PHPCR\SimpleCredentials(null, null); /* --- transport implementation specific code ends --- */ @@ -117,20 +117,15 @@ your project root directory:: $session = $repository->login($credentials, $workspace); /* prepare the doctrine configuration */ - use Doctrine\Common\Annotations\AnnotationRegistry; - use Doctrine\Common\Annotations\AnnotationReader; - use Doctrine\ODM\PHPCR\Mapping\Driver\AnnotationDriver; + use Doctrine\ODM\PHPCR\Mapping\Driver\AttributeDriver; use Doctrine\ODM\PHPCR\Configuration; use Doctrine\ODM\PHPCR\DocumentManager; - AnnotationRegistry::registerLoader(array($autoload, 'loadClass')); - - $reader = new AnnotationReader(); - $driver = new AnnotationDriver($reader, array( + $driver = new AttributeDriver([ // this is a list of all folders containing document classes 'vendor/doctrine/phpcr-odm/lib/Doctrine/ODM/PHPCR/Document', 'src/Demo', - )); + ]); $config = new Configuration(); $config->setMetadataDriverImpl($driver); @@ -156,46 +151,32 @@ Building the model ------------------ Models are plain PHP classes. Note that you have several ways to define the mapping. -For easy readability, we use the annotation mapping with PHPCR namespace in this tutorial:: +For easy readability, we use the attribute mapping with PHPCR namespace in this tutorial:: // src/Demo/Document.php namespace Demo; - use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCR; + use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; - /** - * @PHPCR\Document - */ + #[PHPCR\Document] class MyDocument { - /** - * @PHPCR\Id - */ + #[PHPCR\Id] private $id; - /** - * @PHPCR\ParentDocument - */ + #[PHPCR\ParentDocument] private $parent; - /** - * @PHPCR\Nodename - */ + #[PHPCR\Nodename] private $name; - /** - * @PHPCR\Children - */ + #[PHPCR\Children] private $children; - /** - * @PHPCR\Field(type="string") - */ + #[PHPCR\Field(type: 'string')] private $title; - /** - * @PHPCR\Field(type="string") - */ + #[PHPCR\Field(type: 'string')] private $content; public function getId() @@ -234,7 +215,7 @@ For easy readability, we use the annotation mapping with PHPCR namespace in this } If you are familiar with Doctrine ORM, this code should look pretty familiar to you. The -only important difference are the hierarchy related annotations ParentDocument, Name and Children. +only important difference are the hierarchy related mappings ``ParentDocument``, ``Name`` and ``Children``. In PHPCR, data is stored in trees. Every document has a parent and its own name. The id is built from this structure, resulting in path strings. The recommended way to generate the id is by assigning a name and a parent to the document. See the section on identifier @@ -315,7 +296,7 @@ This script will simply echo the data to the console:: require_once '../bootstrap.php'; - $doc = $documentManager->find(null, "/doc"); + $doc = $documentManager->find(null, '/doc'); echo 'Found '.$doc->getId() ."\n"; echo 'Title: '.$doc->getTitle()."\n"; @@ -329,15 +310,15 @@ Tree traversal PHPCR is a tree based store. Every document must have a parent, and can have children. We already used this when creating the document. -The ``@ParentDocument`` maps the parent of a document and is used -to determine the position in the tree, together with ``@Nodename``. +The ``ParentDocument`` maps the parent of a document and is used +to determine the position in the tree, together with ``Nodename``. -As the children of our sample document are mapped with ``@Children``, +As the children of our sample document are mapped with ``Children``, we can traverse them:: use Demo\MyDocument; - $doc = $documentManager->find(null, "/doc"); + $doc = $documentManager->find(null, '/doc'); foreach($doc->getChildren() as $child) { if ($child instanceof MyDocument) { @@ -371,12 +352,12 @@ Add references PHPCR-ODM supports arbitrary links between documents. The referring document does not need to know what class it links to. Use -``ReferenceOne`` resp. ``@ReferenceMany`` to map the link +``ReferenceOne`` resp. ``ReferenceMany`` to map the link to a document or a collection of links to documents. -You can also map the inverse relation. ``@Referrers`` needs the +You can also map the inverse relation. ``Referrers`` needs the referring class but can be used to add referencing documents. -``@MixedReferrers`` maps all documents referencing this document, +``MixedReferrers`` maps all documents referencing this document, but is readonly. Lets look at an example of document ``A`` referencing ``B``:: @@ -385,29 +366,21 @@ Lets look at an example of document ``A`` referencing ``B``:: namespace Demo; - use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCR; + use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; - /** - * @PHPCR\Document - */ + #[PHPCR\Document] class A { - /** - * @PHPCR\ReferenceOne - */ + #[PHPCR\ReferenceOne] private $ref; ... } - /** - * @PHPCR\Document - */ + #[PHPCR\Document] class B { - /** - * @PHPCR\Referrers(referringDocument="Demo\A", referencedBy="ref") - */ + #[PHPCR\Referrers(referringDocument: A::class, referencedBy: 'ref')] private $referrers; } diff --git a/docs/en/reference/multilang.rst b/docs/en/reference/multilang.rst index 754bdad5c..a2847eae4 100644 --- a/docs/en/reference/multilang.rst +++ b/docs/en/reference/multilang.rst @@ -32,9 +32,14 @@ soon as at least one field in that locale exists. Mapping ------- -To make a document translated, you need to define the ``translator`` attribute on the document -configuration, and you need to map the ``locale`` field. Then you can use the ``translated`` -attribute on all fields that should be different depending on the locale. +To make a document translated, you need to define the ``translator`` parameter +on the document mapping, and you need to map the ``locale`` field. Then you +can use the ``translated`` parameter on all fields that should be different +depending on the locale. + +PHPCR-ODM does not restrict what fields may be translatable - if you need e.g. +a date to be different depending on the language, you can simply specify the +``translated: true`` parameter. .. configuration-block:: @@ -42,33 +47,29 @@ attribute on all fields that should be different depending on the locale. use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCR; - /** - * @PHPCR\Document(translator="attribute") + #[PHPCR\Document(translator: 'attribute')] */ class MyPersistentClass { - /** - * The language this document currently is in - * @Locale - */ + #[PHPCR\Locale] private $locale; /** * Untranslated property - * @PHPCR\Field(type="date") */ + #[PHPCR\Field(type: 'date')] private $publishDate; /** * Translated property - * @PHPCR\Field(type="string", translated=true) */ + #[PHPCR\Field(type: 'string', translated: true)] private $topic; /** * Language specific image - * @PHPCR\Field(type="binary", translated=true) */ + #[PHPCR\Field(type: 'binary', translated: true)] private $image; } @@ -215,11 +216,11 @@ any translatable documents:: use Doctrine\ODM\PHPCR\DocumentManager; - $localePrefs = array( - 'en' => array('de', 'fr'), - 'fr' => array('de', 'en'), - 'it' => array('de', 'en'), - ); + $localePrefs = [ + 'en' => ['de', 'fr'], + 'fr' => ['de', 'en'], + 'it' => ['de', 'en'], + ]; $dm = new DocumentManager($session, $config); $dm->setLocaleChooserStrategy(new LocaleChooser($localePrefs, 'en')); @@ -239,10 +240,10 @@ Full Example // bootstrap the DocumentManager as required (see above) - $localePrefs = array( - 'en' => array('fr'), - 'fr' => array('en'), - ); + $localePrefs = [ + 'en' => ['fr'], + 'fr' => ['en'], + ]; $dm = new DocumentManager($session, $config); $dm->setLocaleChooserStrategy(new LocaleChooser($localePrefs, 'en')); diff --git a/docs/en/reference/phpcr-access.rst b/docs/en/reference/phpcr-access.rst index 9ec850df2..e1c16e7a5 100644 --- a/docs/en/reference/phpcr-access.rst +++ b/docs/en/reference/phpcr-access.rst @@ -31,16 +31,12 @@ This field is populated on find, and as soon as you register the document with t .. code-block:: php - use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCR; + use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; - /** - * @PHPCR\Document - */ + #[PHPCR\Document] class MyPersistentClass { - /** - * @PHPCR\Node - */ + #[PHPCR\Node] private $node; } diff --git a/docs/en/reference/query-builder-reference.rst b/docs/en/reference/query-builder-reference.rst index aeb3faf88..fa5dfa7b5 100644 --- a/docs/en/reference/query-builder-reference.rst +++ b/docs/en/reference/query-builder-reference.rst @@ -818,7 +818,7 @@ This is the node which is returned when a query builder is asked for:: $dm = // get document manager $qb = $dm->createQueryBuilder(); - $qb->fromDocument('Blog\Post', 'p'); + $qb->fromDocument(BlogPost::class, 'p'); $qb->where()->eq()->field('p.title')->literal('My Post'); $docs = $qb->getQuery()->execute(); @@ -948,7 +948,7 @@ source as the left operand:: Note that for outer joins to work correctly, documents being joined to must be mapped with a node type that is unique to the repository workspace, and the ``uniqueNodeType`` property -must be set to ``true`` for the document (see :ref:`<_annref_document>`). Otherwise, the join +must be set to ``true`` for the document (see :ref:`<_attref_document>`). Otherwise, the join will behave as an inner join. **Adds**: :ref:`select ` (Select) @@ -973,7 +973,7 @@ source as the left operand:: Note that for outer joins to work correctly, documents being joined to must be mapped with a node type that is unique to the repository workspace, and the ``uniqueNodeType`` property -must be set to ``true`` for the document (see :ref:`<_annref_document>`). Otherwise, the join +must be set to ``true`` for the document (see :ref:`<_attref_document>`). Otherwise, the join will behave as an inner join. **Adds**: :ref:`select ` (Select) @@ -998,7 +998,7 @@ source as the left operand:: Note that for outer joins to work correctly, documents being joined to must be mapped with a node type that is unique to the repository workspace, and the ``uniqueNodeType`` property -must be set to ``true`` for the document (see :ref:`<_annref_document>`). Otherwise, the join +must be set to ``true`` for the document (see :ref:`<_attref_document>`). Otherwise, the join will behave as an inner join. **Adds**: :ref:`select ` (Select) @@ -1320,5 +1320,3 @@ Factory node for appending additional "wheres" with an OR **Child Cardinality**: * **1..1** :ref:`constraint ` - - diff --git a/docs/en/reference/query-builder.rst b/docs/en/reference/query-builder.rst index 389870927..8834e162c 100644 --- a/docs/en/reference/query-builder.rst +++ b/docs/en/reference/query-builder.rst @@ -10,7 +10,7 @@ An example query:: $qb = $documentManager->createQueryBuilder(); - $qb->from()->document('Blog\User', 'u'); + $qb->from()->document(User::class, 'u'); $qb->where()->eq()->field('u.name')->literal('dtl'); $query = $qb->getQuery(); @@ -35,7 +35,7 @@ Alternatively the above query can be written more fluently by the using $qb = $documentManager->createQueryBuilder(); $qb->from() - ->document('Blog\User') + ->document(User::class) ->end() ->where() ->eq() @@ -163,7 +163,7 @@ Aliases and fields The term "alias" refers to the string that is assigned to a document source, either a ``SourceFrom`` or a ``SourceJoin``:: - $qb->from('Blog\Post', 'post'); + $qb->from(Post::class, 'post'); In the example above, "post" is the alias. The alias is subsequently used whenever the source is referenced. The following example show some instances @@ -201,7 +201,7 @@ You can also instantiate a ``QueryBuilder`` from a ``DocumentRepsitory`` instance, doing so will automatically select only those records which are associated with the ``DocumentRepository``:: - $postsRepository = $dm->getRepository('Blog\Post'); + $postsRepository = $dm->getRepository(Post::class); $qb = $postsRepository->createQueryBuilder('p'); $posts = $qb->getQuery()->execute(); @@ -254,8 +254,7 @@ From Single Source .. code-block:: php - // select documents of class Foo\Bar. - $qb->from()->document('Blog\Post', 'p'); + $qb->from()->document(Post::class, 'p'); The above example will setup the query builder to select documents only of class ``Blog\Post`` using the *alias name* "p". The alias name is the alias used @@ -274,8 +273,8 @@ The following will retrieve a collection of ``Blog\Post`` documents for active u // select documents from a join $qb->from('p')->joinInner() - ->left()->document('Blog\Post', 'p')->end() - ->right()->document('Blog\User', 'u')->end() + ->left()->document(Post::class, 'p')->end() + ->right()->document(User::class', 'u')->end() ->condition()->equi('p.username', 'u.username'); $qb->where() @@ -297,9 +296,12 @@ Joining with an Association The following is another example which joins on an *association*. The ``CmsUser`` class is associated with a single address:: - $qb->fromDocument('Doctrine\Tests\Models\CMS\CmsUser', 'u'); + use Doctrine\Tests\Models\CMS\CmsAddress; + use Doctrine\Tests\Models\CMS\CmsUser; + + $qb->fromDocument(CmsUser::class, 'u'); ->addJoinInner() - ->right()->document('Doctrine\Tests\Models\CMS\CmsAddress', 'a')->end() + ->right()->document(CmsAddress::class, 'a')->end() ->condition()->equi('u.address', 'a.uuid'); ->where()->eq()->field('a.city')->literal('Lyon'); $users = $qb->getQuery()->execute(); @@ -319,7 +321,7 @@ node, this is currently only useful when :ref:`hydrating to PHPCR nodes `. The default (object) hydration will *always* hydrate all fields regardless of what you specify:: - $qb->from('Demo\User', 'u'); + $qb->from(User::class, 'u'); $qb->select() ->field('u.firstname') ->field('u.lastname'); @@ -355,7 +357,7 @@ Specifying selection criteria You can specify selection criteria using the ``where`` factory node:: // setup our document source with alias "u" - $qb->from('Blog\User', 'u'); + $qb->from(User::class, 'u'); // where name is "daniel" $qb->where() @@ -434,7 +436,7 @@ Querying translated documents If your documents contain :doc:`translated fields `, the query builder automatically handles them both for ``where`` and ``orderBy`` -when using the annotation or child translation strategy. +when using the attribute or child translation strategy. It will use the "current" locale according to the LocaleChooser. If you want to query in a different locale, you can also specify the locale explicitly:: @@ -443,7 +445,7 @@ to query in a different locale, you can also specify the locale explicitly:: $qb ->setLocale('fr') ->from() - ->document('Demo\Document', 'd') + ->document(Document::class, 'd') ->end() ->where()->fieldIsset('d.title')->end() ->orderBy() diff --git a/docs/en/reference/query.rst b/docs/en/reference/query.rst index ba35b1f11..a73091a89 100644 --- a/docs/en/reference/query.rst +++ b/docs/en/reference/query.rst @@ -84,7 +84,7 @@ to specify an array of parameters as the first argument:: // is equivalenet to $query = // get new query - $docs = $query->execute(array(), Query::HYDRATE_DOCUMENT); + $docs = $query->execute([], Query::HYDRATE_DOCUMENT); .. note:: @@ -131,4 +131,3 @@ should be retrieved:: $query->setOffset(50); $query->setMaxResults(150); $res = $query->getResult(); // will return a maximum of 100 results from result index 50 - diff --git a/docs/en/reference/tools.rst b/docs/en/reference/tools.rst index 26ffb7053..b014e5b93 100644 --- a/docs/en/reference/tools.rst +++ b/docs/en/reference/tools.rst @@ -70,62 +70,6 @@ This command needs to be run once on a new repository to prepare it for use with Failing to do so will throw you errors when you try to store a document that uses a node type different from nt:unstructured, like a file or folder. -.. - TODO: would be nice to provide this as well - - Convert Mapping Information - --------------------------- - - Convert mapping information between supported formats. - - This is an **execute one-time** command. It should not be necessary for - you to call this method multiple times, especially when using the ``--from-database`` - flag. - - Converting an existing database schema into mapping files only solves about 70-80% - of the necessary mapping information. Additionally the detection from an existing - database cannot detect inverse associations, inheritance types, - entities with foreign keys as primary keys and many of the - semantical operations on associations such as cascade. - - .. note:: - - There is no need to convert YAML or XML mapping files to annotations - every time you make changes. All mapping drivers are first class citizens - in Doctrine 2 and can be used as runtime mapping for the ORM. See the - docs on XML and YAML Mapping for an example how to register this metadata - drivers as primary mapping source. - - To convert some mapping information between the various supported - formats you can use the ``ClassMetadataExporter`` to get exporter - instances for the different formats:: - - $cme = new \Doctrine\ORM\Tools\Export\ClassMetadataExporter(); - - Once you have a instance you can use it to get an exporter. For - example, the yml exporter:: - - $exporter = $cme->getExporter('yml', '/path/to/export/yml'); - - Now you can export some ``ClassMetadata`` instances:: - - $classes = array( - $em->getClassMetadata('Entities\User'), - $em->getClassMetadata('Entities\Profile') - ); - $exporter->setMetadata($classes); - $exporter->export(); - - This functionality is also available from the command line to - convert your loaded mapping information to another format. The - ``orm:convert-mapping`` command accepts two arguments, the type to - convert to and the path to generate it: - - .. code-block:: bash - - $ php doctrine orm:convert-mapping xml /path/to/mapping-path-converted-to-xml - - Adding your own commands ------------------------ diff --git a/docs/en/reference/versioning.rst b/docs/en/reference/versioning.rst index 4063fc753..37e28b717 100644 --- a/docs/en/reference/versioning.rst +++ b/docs/en/reference/versioning.rst @@ -74,21 +74,15 @@ Due to implementation limitations, the Locale field is `required` on all transla .. code-block:: php - use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCR; + use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; - /** - * @PHPCR\Document(versionable="full") - */ + #[PHPCR\Document(versionable: 'full')] class MyPersistentClass { - /** - * @PHPCR\VersionName - */ + #[PHPCR\VersionName] private $versionName; - /** - * @PHPCR\VersionCreated - */ + #[PHPCR\VersionCreated] private $versionCreated; } @@ -117,8 +111,8 @@ Be aware that these two are different things: You get this document with the findVersionByName method. It is read-only. The document class you use needs not be the same. You can define a *version* document that is the same as your base document, but all fields are read - only and you use the VersionName and VersionCreated annotations on it. It - also does not need the versionable document attribute. (You do not create + only and you use the VersionName and VersionCreated mappings on it. The document + mapping also does not need the versionable document parameter. (You do not create versions of old versions, you only create versions of the main document.) You can track some information about old versions in PHPCR-ODM. Both are only diff --git a/docs/en/reference/working-with-objects.rst b/docs/en/reference/working-with-objects.rst index 7e3dccbc2..f7191275e 100644 --- a/docs/en/reference/working-with-objects.rst +++ b/docs/en/reference/working-with-objects.rst @@ -99,31 +99,21 @@ want. Take the following example of a single ``Article`` document fetched from newly opened DocumentManager:: - use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCR; + use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; - /** - * @PHPCR\Document - */ + #[PHPCR\Document] class Article { - /** - * @PHPCR\Id - */ + #[PHPCR\Id] private $id; - /** - * @PHPCR\Field(type="string") - */ + #[PHPCR\Field(type: 'string')] private $headline; - /** - * @PHPCR\ReferenceOne - */ + #[PHPCR\ReferenceOne] private $author; - /** - * @PHPCR\Referrers(referrerDocument="Comment", referencedBy="article") - */ + #[PHPCR\Referrers(referrerDocument: Comment::class, referencedBy: 'article')] private $comments; public function __construct { @@ -254,7 +244,7 @@ as follows: * If X is a pre-existing managed document, it is ignored by the persist operation. However, the persist operation is cascaded to documents referenced by X if the relationships from X to these - other documents are mapped with ``cascade=PERSIST`` or ``cascade=ALL`` (see + other documents are mapped with ``cascade: 'PERSIST'`` or ``cascade: 'ALL'`` (see "Transitive Persistence"); * If X is a removed document, it becomes managed; * If X is a detached document, an exception will be thrown on @@ -292,11 +282,11 @@ as follows: * If X is a new document, it is ignored by the remove operation. However, the remove operation is cascaded to documents referenced by X, if the relationship from X to these other documents is mapped - with ``cascade=REMOVE`` or ``cascade=ALL`` (see "Transitive Persistence"); + with ``cascade: 'REMOVE'`` or ``cascade: 'ALL'`` (see "Transitive Persistence"); * If X is a managed document, the remove operation causes it to become removed. The remove operation is cascaded to documents referenced by X, if the relationships from X to these other - documents is mapped with ``cascade=REMOVE`` or ``cascade=ALL`` (see + documents is mapped with ``cascade: 'REMOVE'`` or ``cascade: 'ALL'`` (see "Transitive Persistence"); * If X is a detached document, an ``InvalidArgumentException`` will be thrown; @@ -313,7 +303,7 @@ the document explicitly removed. By default, references and referring documents are not deleted. You can enable this by configuring cascading removal on the association mapping. If an association -is marked as ``CASCADE=REMOVE``, PHPCR-ODM will follow this association. If +is marked as ``cascade: 'REMOVE'``, PHPCR-ODM will follow this association. If its a Single association it will pass this document to ``DocumentManager::remove()``. If the association is a collection, Doctrine will loop over all its elements and pass them to``DocumentManager::remove()``. @@ -349,14 +339,14 @@ as follows: * If X is a managed document, the detach operation causes it to become detached. The detach operation is cascaded to documents referenced by X, if the relationships from X to these other - documents is mapped with ``cascade=DETACH`` or ``cascade=ALL`` (see + documents is mapped with ``cascade: 'DETACH'`` or ``cascade: 'ALL'`` (see "Transitive Persistence"). Documents which previously referenced X will continue to reference X; * If X is a new or detached document, it is ignored by the detach operation; * If X is a removed document, the detach operation is cascaded to documents referenced by X, if the relationships from X to these - other documents is mapped with ``cascade=DETACH`` or ``cascade=ALL`` (see + other documents is mapped with ``cascade: 'DETACH'`` or ``cascade: 'ALL'`` (see "Transitive Persistence"). Documents which previously referenced X will continue to reference X. @@ -409,7 +399,7 @@ as follows: For all such Y referenced by X, X' is set to reference Y'. (Note that if X is managed then X is the same object as X'.); * If X is a document merged to X', with a reference to another - document Y, where ``cascade=MERGE`` or ``cascade=ALL`` is not specified, then + document Y, where ``cascade: 'MERGE'`` or ``cascade: 'ALL'`` is not specified, then navigation of the same association from X' yields a reference to a managed object Y' with the same persistent identity as Y. @@ -619,7 +609,7 @@ identifier (PHPCR path) using the example:: /** @var $em DocumentManager */ - $user = $em->find('MyProject\Domain\User', $id); + $user = $em->find(User::class, $id); The return value is either the found document instance or null if no instance could be found with the given identifier. @@ -644,25 +634,25 @@ methods on a repository as follows:: /** @var $dm DocumentManager */ // All users that are 20 years old - $users = $dm->getRepository('MyProject\Domain\User')->findBy(array('age' => 20)); + $users = $dm->getRepository(User::Class)->findBy(['age' => 20]); // All users that are 20 years old and have a surname of 'Miller' - $users = $dm->getRepository('MyProject\Domain\User')->findBy(array('age' => 20, 'surname' => 'Miller')); + $users = $dm->getRepository(User::Class)->findBy(['age' => 20, 'surname' => 'Miller']); // A single user by its nickname - $user = $dm->getRepository('MyProject\Domain\User')->findOneBy(array('nickname' => 'romanb')); + $user = $dm->getRepository(User::Class)->findOneBy(['nickname' => 'romanb']); .. warning:: Note that due to the nature of PHPCR, the primary identifier is no field. - You can thus not use ``findBy(array('id' => '/my/path'))`` but should + You can thus not use ``findBy(['id' => '/my/path'])`` but should pass the ID into the ``find`` method. There is also findMany if you need to fetch several documents. You can also query by references through the repository:: - $number = $dm->find('MyProject\Domain\Phonenumber', '/path/to/phone/number'); - $user = $dm->getRepository('MyProject\Domain\User')->findOneBy(array('phone' => $number->getUuid())); + $number = $dm->find(PhoneNumber::class, '/path/to/phone/number'); + $user = $dm->getRepository(User::Class)->findOneBy(['phone' => $number->getUuid()]); Be careful that this only works by passing the uuid of the associated document, not yet by passing the associated document itself. @@ -671,8 +661,8 @@ The ``DocumentRepository::findBy()`` method additionally accepts orderings, limit and offset as second to fourth parameters:: $tenUsers = $dm - ->getRepository('MyProject\Domain\User') - ->findBy(array('age' => 20), array('name' => 'ASC'), 10, 0); + ->getRepository(User::Class) + ->findBy(['age' => 20], ['name' => 'ASC'], 10, 0); .. note:: @@ -685,10 +675,10 @@ calls through its use of ``__call``. Thus, the following two examples are equivalent:: // A single user by its nickname - $user = $dm->getRepository('MyProject\Domain\User')->findOneBy(array('nickname' => 'romanb')); + $user = $dm->getRepository(User::Class)->findOneBy(['nickname' => 'romanb']); // A single user by its nickname (__call magic) - $user = $dm->getRepository('MyProject\Domain\User')->findOneByNickname('romanb'); + $user = $dm->getRepository(User::Class)->findOneByNickname('romanb'); By Lazy Loading @@ -738,9 +728,7 @@ in a central location:: use Doctrine\ODM\PHPCR\DocumentRepository; - /** - * @PHPCR\Document(repositoryClass="MyDomain\Model\UserRepository") - */ + #[PHPCR\Document(repositoryClass: UserRepository::class)] class User { @@ -760,4 +748,4 @@ You can access your repository now by calling:: /** @var $dm DocumentManager */ - $admins = $dm->getRepository('MyDomain\Model\User')->getAllAdminUsers(); + $admins = $dm->getRepository(User::class)->getAllAdminUsers(); diff --git a/docs/en/reference/xml-mapping.rst b/docs/en/reference/xml-mapping.rst index cb161321a..7c4b4e774 100644 --- a/docs/en/reference/xml-mapping.rst +++ b/docs/en/reference/xml-mapping.rst @@ -2,9 +2,9 @@ XML Mapping =========== This chapter gives a brief overview of the XML mapping by example. In general, -the attributes correspond to their annotation counterparts with the difference that -the attribute names are slugified as opposed to being camelCase -(``referring-document`` instead of ``referringDocument``). See :doc:`annotations-mapping`. +the attributes correspond to their attribute counterparts with the difference that +the parameter names are slugified as opposed to being camelCase +(``referring-document`` instead of ``referringDocument``). See :doc:`attributes-mapping`. The following example implements all of the possible XML mapping elements: diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Children.php b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Children.php index 050abd0f1..f0af2ed6b 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Children.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Children.php @@ -28,6 +28,8 @@ class Children { /** + * This actually can be null too, but the legacy doctrine annotation driver gets confused if we declare a union type. + * * @var array */ public $filter; diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Reference.php b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Reference.php index f34b40946..4e110b09a 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Reference.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Reference.php @@ -25,16 +25,16 @@ class Reference { /** - * The PHPCR property name to use - * * @var string */ - public $property; + public $targetDocument; /** + * The PHPCR property name to use + * * @var string */ - public $targetDocument; + public $property; /** * @var string diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Child.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Child.php index c6f2e877e..6f01ca7e8 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Child.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Child.php @@ -4,8 +4,16 @@ use Attribute; use Doctrine\ODM\PHPCR\Mapping\Annotations\Child as BaseChild; +use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; #[Attribute(Attribute::TARGET_PROPERTY)] -final class Child extends BaseChild +final class Child extends BaseChild implements MappingAttribute { + public function __construct( + string $nodeName = null, + array $cascade = [], + ) { + $this->nodeName = $nodeName; + $this->cascade = $cascade; + } } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Children.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Children.php index 5800b4502..8ff32c14e 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Children.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Children.php @@ -2,8 +2,22 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; +use Attribute; use Doctrine\ODM\PHPCR\Mapping\Annotations\Children as BaseChildren; +use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; -final class Children extends BaseChildren +#[Attribute(Attribute::TARGET_PROPERTY)] +final class Children extends BaseChildren implements MappingAttribute { + public function __construct( + array|string $filter = null, + int $fetchDepth = -1, + bool $ignoreUntranslated = true, + array $cascade = [], + ) { + $this->filter = $filter ? (array) $filter : null; + $this->fetchDepth = $fetchDepth; + $this->ignoreUntranslated = $ignoreUntranslated; + $this->cascade = $cascade; + } } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Depth.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Depth.php index 9d7a5f738..3e09f984e 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Depth.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Depth.php @@ -4,8 +4,9 @@ use Attribute; use Doctrine\ODM\PHPCR\Mapping\Annotations\Depth as BaseDepth; +use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; #[Attribute(Attribute::TARGET_PROPERTY)] -final class Depth extends BaseDepth +final class Depth extends BaseDepth implements MappingAttribute { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Document.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Document.php index fbb261f2d..c900a04f7 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Document.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Document.php @@ -4,8 +4,32 @@ use Attribute; use Doctrine\ODM\PHPCR\Mapping\Annotations\Document as BaseDocument; +use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; #[Attribute(Attribute::TARGET_CLASS)] -final class Document extends BaseDocument +class Document extends BaseDocument implements MappingAttribute { + public function __construct( + string $nodeType = null, + string $repositoryClass = null, + string $translator = null, + array $mixins = null, + bool $inheritMixins = true, + string $versionable = null, + bool $referenceable = false, + bool $uniqueNodeType = false, + array $childClasses = [], + bool $isLeaf = false, + ) { + $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; + $this->isLeaf = $isLeaf; + } } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Field.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Field.php index 9f097ee81..a450b8158 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Field.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Field.php @@ -4,8 +4,25 @@ use Attribute; use Doctrine\ODM\PHPCR\Mapping\Annotations\Field as BaseField; +use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; #[Attribute(Attribute::TARGET_PROPERTY)] -final class Field extends BaseField +class Field extends BaseField implements MappingAttribute { + public function __construct( + string $property = null, + string $type = 'undefined', + bool $multivalue = false, + string $assoc = null, + bool $nullable = false, + 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 95d6cc044..c412e0e94 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Id.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Id.php @@ -4,8 +4,18 @@ use Attribute; use Doctrine\ODM\PHPCR\Mapping\Annotations\Id as BaseId; +use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; #[Attribute(Attribute::TARGET_PROPERTY)] -final class Id extends BaseId +final class Id extends BaseId implements MappingAttribute { + public function __construct( + bool $id = true, + string $type = 'string', + 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 2452d5c1e..36e950959 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Locale.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Locale.php @@ -4,8 +4,9 @@ use Attribute; use Doctrine\ODM\PHPCR\Mapping\Annotations\Locale as BaseLocale; +use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; #[Attribute(Attribute::TARGET_PROPERTY)] -final class Locale extends BaseLocale +final class Locale extends BaseLocale implements MappingAttribute { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/MappedSuperclass.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/MappedSuperclass.php index ad5635422..f70deea50 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/MappedSuperclass.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/MappedSuperclass.php @@ -3,9 +3,8 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; use Attribute; -use Doctrine\ODM\PHPCR\Mapping\Annotations\MappedSuperclass as BaseMappedSuperclass; #[Attribute(Attribute::TARGET_CLASS)] -final class MappedSuperclass extends BaseMappedSuperclass +final class MappedSuperclass extends Document { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/MixedReferrers.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/MixedReferrers.php index 6800c376d..62c43e0e6 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/MixedReferrers.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/MixedReferrers.php @@ -4,8 +4,13 @@ use Attribute; use Doctrine\ODM\PHPCR\Mapping\Annotations\MixedReferrers as BaseMixedReferrers; +use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; #[Attribute(Attribute::TARGET_PROPERTY)] -final class MixedReferrers extends BaseMixedReferrers +final class MixedReferrers extends BaseMixedReferrers implements MappingAttribute { + public function __construct(string $referenceType = null) + { + $this->referenceType = $referenceType; + } } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Node.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Node.php index 4ac12f01a..55a86366c 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Node.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Node.php @@ -4,8 +4,9 @@ use Attribute; use Doctrine\ODM\PHPCR\Mapping\Annotations\Node as BaseNode; +use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; #[Attribute(Attribute::TARGET_PROPERTY)] -final class Node extends BaseNode +final class Node extends BaseNode implements MappingAttribute { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Nodename.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Nodename.php index 0f5240af1..b3d0845e6 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Nodename.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Nodename.php @@ -4,8 +4,9 @@ use Attribute; use Doctrine\ODM\PHPCR\Mapping\Annotations\Nodename as BaseNodename; +use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; #[Attribute(Attribute::TARGET_PROPERTY)] -final class Nodename extends BaseNodename +final class Nodename extends BaseNodename implements MappingAttribute { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/ParentDocument.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/ParentDocument.php index caeb8d0ce..8b60a5e68 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/ParentDocument.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/ParentDocument.php @@ -4,8 +4,9 @@ use Attribute; use Doctrine\ODM\PHPCR\Mapping\Annotations\ParentDocument as BaseParentDocument; +use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; #[Attribute(Attribute::TARGET_PROPERTY)] -final class ParentDocument extends BaseParentDocument +final class ParentDocument extends BaseParentDocument implements MappingAttribute { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostLoad.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostLoad.php index c29dbee6b..311818f34 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostLoad.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostLoad.php @@ -4,8 +4,9 @@ use Attribute; use Doctrine\ODM\PHPCR\Mapping\Annotations\PostLoad as BasePostLoad; +use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; #[Attribute(Attribute::TARGET_METHOD)] -final class PostLoad extends BasePostLoad +final class PostLoad extends BasePostLoad implements MappingAttribute { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostPersist.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostPersist.php index a32a966d1..aad5e81bc 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostPersist.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostPersist.php @@ -4,8 +4,9 @@ use Attribute; use Doctrine\ODM\PHPCR\Mapping\Annotations\PostPersist as BasePostPersist; +use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; #[Attribute(Attribute::TARGET_METHOD)] -final class PostPersist extends BasePostPersist +final class PostPersist extends BasePostPersist implements MappingAttribute { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostRemove.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostRemove.php index cb5561aa1..d4314a3c1 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostRemove.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostRemove.php @@ -4,8 +4,9 @@ use Attribute; use Doctrine\ODM\PHPCR\Mapping\Annotations\PostRemove as BasePostRemove; +use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; #[Attribute(Attribute::TARGET_METHOD)] -final class PostRemove extends BasePostRemove +final class PostRemove extends BasePostRemove implements MappingAttribute { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostUpdate.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostUpdate.php index 2fe376b37..c99e4feef 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostUpdate.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostUpdate.php @@ -4,8 +4,9 @@ use Attribute; use Doctrine\ODM\PHPCR\Mapping\Annotations\PostUpdate as BasePostUpdate; +use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; #[Attribute(Attribute::TARGET_METHOD)] -final class PostUpdate extends BasePostUpdate +final class PostUpdate extends BasePostUpdate implements MappingAttribute { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PrePersist.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PrePersist.php index 15695d47b..64a31e2c5 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PrePersist.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PrePersist.php @@ -4,8 +4,9 @@ use Attribute; use Doctrine\ODM\PHPCR\Mapping\Annotations\PrePersist as BasePrePersist; +use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; #[Attribute(Attribute::TARGET_METHOD)] -final class PrePersist extends BasePrePersist +final class PrePersist extends BasePrePersist implements MappingAttribute { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PreRemove.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PreRemove.php index dd4611ee9..596543561 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PreRemove.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PreRemove.php @@ -4,8 +4,9 @@ use Attribute; use Doctrine\ODM\PHPCR\Mapping\Annotations\PreRemove as BasePreRemove; +use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; #[Attribute(Attribute::TARGET_METHOD)] -final class PreRemove extends BasePreRemove +final class PreRemove extends BasePreRemove implements MappingAttribute { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PreUpdate.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PreUpdate.php index 0f94321fa..0bacc4678 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PreUpdate.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PreUpdate.php @@ -4,8 +4,9 @@ use Attribute; use Doctrine\ODM\PHPCR\Mapping\Annotations\PreUpdate as BasePreUpdate; +use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; #[Attribute(Attribute::TARGET_METHOD)] -final class PreUpdate extends BasePreUpdate +final class PreUpdate extends BasePreUpdate implements MappingAttribute { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Reference.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Reference.php new file mode 100644 index 000000000..64fd52a56 --- /dev/null +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Reference.php @@ -0,0 +1,24 @@ +property = $property; + $this->targetDocument = $targetDocument; + $this->strategy = $strategy; + $this->cascade = $cascade; + } +} diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/ReferenceMany.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/ReferenceMany.php index 5b3dcd6e6..b10c87202 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/ReferenceMany.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/ReferenceMany.php @@ -3,9 +3,8 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; use Attribute; -use Doctrine\ODM\PHPCR\Mapping\Annotations\ReferenceMany as BaseReferenceMany; #[Attribute(Attribute::TARGET_PROPERTY)] -final class ReferenceMany extends BaseReferenceMany +final class ReferenceMany extends Reference { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/ReferenceOne.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/ReferenceOne.php index ec62ead4a..1ee210760 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/ReferenceOne.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/ReferenceOne.php @@ -3,9 +3,8 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; use Attribute; -use Doctrine\ODM\PHPCR\Mapping\Annotations\ReferenceOne as BaseReferenceOne; #[Attribute(Attribute::TARGET_PROPERTY)] -final class ReferenceOne extends BaseReferenceOne +final class ReferenceOne extends Reference { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Referrers.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Referrers.php index e9f3909c9..dd7a0c1ea 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Referrers.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Referrers.php @@ -4,8 +4,21 @@ use Attribute; use Doctrine\ODM\PHPCR\Mapping\Annotations\Referrers as BaseReferrers; +use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; #[Attribute(Attribute::TARGET_PROPERTY)] -final class Referrers extends BaseReferrers +final class Referrers extends BaseReferrers implements MappingAttribute { + /** + * @param string[] $cascade + */ + public function __construct( + string $referencedBy, + string $referringDocument, + array $cascade = [] + ) { + $this->referencedBy = $referencedBy; + $this->referringDocument = $referringDocument; + $this->cascade = $cascade; + } } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Uuid.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Uuid.php index 6ed6f5cd3..36e0d7abd 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Uuid.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Uuid.php @@ -3,9 +3,18 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; use Attribute; -use Doctrine\ODM\PHPCR\Mapping\Annotations\Uuid as BaseUuid; #[Attribute(Attribute::TARGET_PROPERTY)] -final class Uuid extends BaseUuid +final class Uuid extends Field { + public function __construct( + string $property = 'jcr:uuid', + string $type = 'string', + bool $multivalue = false, + string $assoc = null, + bool $nullable = false, + bool $translated = false, + ) { + parent::__construct($property, $type, $multivalue, $assoc, $nullable, $translated); + } } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/VersionCreated.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/VersionCreated.php index 8d3e6ba12..7e46e2dbb 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/VersionCreated.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/VersionCreated.php @@ -4,8 +4,9 @@ use Attribute; use Doctrine\ODM\PHPCR\Mapping\Annotations\VersionCreated as BaseVersionCreated; +use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; #[Attribute(Attribute::TARGET_PROPERTY)] -final class VersionCreated extends BaseVersionCreated +final class VersionCreated extends BaseVersionCreated implements MappingAttribute { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/VersionName.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/VersionName.php index d997f2165..73e1000a2 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/VersionName.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/VersionName.php @@ -4,8 +4,9 @@ use Attribute; use Doctrine\ODM\PHPCR\Mapping\Annotations\VersionName as BaseVersionName; +use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; #[Attribute(Attribute::TARGET_PROPERTY)] -final class VersionName extends BaseVersionName +final class VersionName extends BaseVersionName implements MappingAttribute { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/ClassMetadata.php b/lib/Doctrine/ODM/PHPCR/Mapping/ClassMetadata.php index 7db1c37c6..c82488426 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/ClassMetadata.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/ClassMetadata.php @@ -614,7 +614,7 @@ public function setIdentifier($identifier) /** * Registers a custom repository class for the document class. * - * @param string $repositoryClassName the class name of the custom repository + * @param class-string $repositoryClassName the class name of the custom repository */ public function setCustomRepositoryClassName($repositoryClassName) { diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Driver/AnnotationDriver.php b/lib/Doctrine/ODM/PHPCR/Mapping/Driver/AnnotationDriver.php index 374d5ff9c..0d482accc 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Driver/AnnotationDriver.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Driver/AnnotationDriver.php @@ -25,6 +25,9 @@ use Doctrine\Persistence\Mapping\ClassMetadata; use Doctrine\Persistence\Mapping\Driver\AnnotationDriver as AbstractAnnotationDriver; use Doctrine\Persistence\Mapping\Driver\MappingDriver; +use Doctrine\ODM\PHPCR\Mapping\Annotations\Document; +use Doctrine\ODM\PHPCR\Mapping\Annotations\MappedSuperclass; +use Doctrine\ODM\PHPCR\Mapping\ClassMetadata as PhpcrClassMetadata; /** * The AnnotationDriver reads the mapping metadata from docblock annotations. @@ -47,16 +50,17 @@ class AnnotationDriver extends AbstractAnnotationDriver implements MappingDriver * Document annotation classes, ordered by precedence. */ protected $entityAnnotationClasses = [ - 'Doctrine\\ODM\\PHPCR\\Mapping\\Annotations\\Document' => 0, - 'Doctrine\\ODM\\PHPCR\\Mapping\\Annotations\\MappedSuperclass' => 1, + Document::class => 0, + MappedSuperclass::class => 1, ]; /** * {@inheritdoc} + * + * @param PhpcrClassMetadata $metadata */ public function loadMetadataForClass($className, ClassMetadata $metadata) { - /** @var $metadata \Doctrine\ODM\PHPCR\Mapping\ClassMetadata */ $reflClass = $metadata->getReflectionClass(); $documentAnnots = []; @@ -184,7 +188,7 @@ public function loadMetadataForClass($className, ClassMetadata $metadata) } foreach ($reflClass->getMethods() as $method) { - if ($method->isPublic() && $method->getDeclaringClass()->getName() == $metadata->name) { + 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); diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Driver/AttributeDriver.php b/lib/Doctrine/ODM/PHPCR/Mapping/Driver/AttributeDriver.php new file mode 100644 index 000000000..587e925fc --- /dev/null +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Driver/AttributeDriver.php @@ -0,0 +1,248 @@ +. + */ + +namespace Doctrine\ODM\PHPCR\Mapping\Driver; + +use Doctrine\ODM\PHPCR\Event; +use Doctrine\ODM\PHPCR\Mapping\Attributes as ODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes\Document; +use Doctrine\ODM\PHPCR\Mapping\Attributes\MappedSuperclass; +use Doctrine\ODM\PHPCR\Mapping\ClassMetadata; +use Doctrine\ODM\PHPCR\Mapping\MappingException; +use Doctrine\Persistence\Mapping\ClassMetadata as PersistenceClassMetadata; +use Doctrine\Persistence\Mapping\Driver\ColocatedMappingDriver; +use Doctrine\Persistence\Mapping\Driver\MappingDriver; +use ReflectionClass; + +/** + * Read mapping metadata from PHP attributes. + * + * @license http://www.opensource.org/licenses/MIT-license.php MIT license + * + * @see www.doctrine-project.org + * @since 1.8 + * + * @author David Buchmann + */ +class AttributeDriver implements MappingDriver +{ + use ColocatedMappingDriver; + + /** + * Document attribute classes, ordered by precedence. + */ + private const DOCUMENT_ATTRIBUTE_CLASSES = [ + Document::class => 0, + MappedSuperclass::class => 1, + ]; + + private AttributeReader $reader; + + /** + * @param array $paths + */ + public function __construct(array $paths) + { + $this->reader = new AttributeReader(); + $this->addPaths($paths); + } + + public function isTransient($className) + { + $classAttributes = $this->reader->getClassAttributes(new ReflectionClass($className)); + + foreach ($classAttributes as $a) { + if (array_key_exists($a::class, self::DOCUMENT_ATTRIBUTE_CLASSES)) { + return false; + } + } + + return true; + } + + public function loadMetadataForClass($className, PersistenceClassMetadata $metadata): void + { + \assert($metadata instanceof ClassMetadata); + $reflectionClass = $metadata->getReflectionClass(); + $classAttributes = $this->reader->getClassAttributes($reflectionClass); + + // Evaluate document attribute + if (array_key_exists(ODM\Document::class, $classAttributes)) { + $documentAttribute = $classAttributes[ODM\Document::class]; + \assert($documentAttribute instanceof ODM\Document); + } elseif (isset($classAttributes[ODM\MappedSuperclass::class])) { + $documentAttribute = $classAttributes[ODM\MappedSuperclass::class]; + \assert($documentAttribute instanceof ODM\MappedSuperclass); + $metadata->isMappedSuperclass = true; + } else { + throw MappingException::classIsNotAValidDocument($className); + } + + if (null !== $documentAttribute->referenceable) { + $metadata->setReferenceable($documentAttribute->referenceable); + } + + if (null !== $documentAttribute->versionable) { + $metadata->setVersioned($documentAttribute->versionable); + } + + if (null !== $documentAttribute->uniqueNodeType) { + $metadata->setUniqueNodeType($documentAttribute->uniqueNodeType); + } + + if (null !== $documentAttribute->mixins) { + $metadata->setMixins($documentAttribute->mixins); + } + + if (null !== $documentAttribute->inheritMixins) { + $metadata->setInheritMixins($documentAttribute->inheritMixins); + } + + if (null !== $documentAttribute->nodeType) { + $metadata->setNodeType($documentAttribute->nodeType); + } + + if (null !== $documentAttribute->repositoryClass) { + $metadata->setCustomRepositoryClassName($documentAttribute->repositoryClass); + } + + if (null !== $documentAttribute->translator) { + $metadata->setTranslator($documentAttribute->translator); + } + + if ([] !== $documentAttribute->childClasses) { + $metadata->setChildClasses($documentAttribute->childClasses); + } + + $metadata->setIsLeaf($documentAttribute->isLeaf); + + foreach ($reflectionClass->getProperties() as $property) { + if ($metadata->isInheritedField($property->name) + && $metadata->name !== $property->getDeclaringClass()->getName() + ) { + continue; + } + + $mapping = []; + $mapping['fieldName'] = $property->getName(); + + foreach ($this->reader->getPropertyAttributes($property) as $fieldAttribute) { + if ($fieldAttribute instanceof ODM\Field) { + $mapping = array_merge($mapping, (array) $fieldAttribute); + $metadata->mapField($mapping); + } elseif ($fieldAttribute instanceof ODM\Id) { + $mapping = array_merge($mapping, (array) $fieldAttribute); + $metadata->mapId($mapping); + } elseif ($fieldAttribute instanceof ODM\Node) { + $mapping = array_merge($mapping, (array) $fieldAttribute); + $metadata->mapNode($mapping); + } elseif ($fieldAttribute instanceof ODM\Nodename) { + $mapping = array_merge($mapping, (array) $fieldAttribute); + $metadata->mapNodename($mapping); + } elseif ($fieldAttribute instanceof ODM\ParentDocument) { + $mapping = array_merge($mapping, (array) $fieldAttribute); + $mapping['cascade'] = $this->getCascadeMode($fieldAttribute->cascade); + $metadata->mapParentDocument($mapping); + } elseif ($fieldAttribute instanceof ODM\Child) { + $mapping = array_merge($mapping, (array) $fieldAttribute); + $mapping['cascade'] = $this->getCascadeMode($fieldAttribute->cascade); + $metadata->mapChild($mapping); + } elseif ($fieldAttribute instanceof ODM\Children) { + $mapping = array_merge($mapping, (array) $fieldAttribute); + $mapping['cascade'] = $this->getCascadeMode($fieldAttribute->cascade); + $metadata->mapChildren($mapping); + } elseif ($fieldAttribute instanceof ODM\ReferenceOne) { + $mapping = array_merge($mapping, (array) $fieldAttribute); + $mapping['cascade'] = $this->getCascadeMode($fieldAttribute->cascade); + $metadata->mapManyToOne($mapping); + } elseif ($fieldAttribute instanceof ODM\ReferenceMany) { + $mapping = array_merge($mapping, (array) $fieldAttribute); + $mapping['cascade'] = $this->getCascadeMode($fieldAttribute->cascade); + $metadata->mapManyToMany($mapping); + } elseif ($fieldAttribute instanceof ODM\Referrers) { + $mapping = array_merge($mapping, (array) $fieldAttribute); + $mapping['cascade'] = $this->getCascadeMode($fieldAttribute->cascade); + $metadata->mapReferrers($mapping); + } elseif ($fieldAttribute instanceof ODM\MixedReferrers) { + $mapping = array_merge($mapping, (array) $fieldAttribute); + $metadata->mapMixedReferrers($mapping); + } elseif ($fieldAttribute instanceof ODM\Locale) { + $mapping = array_merge($mapping, (array) $fieldAttribute); + $metadata->mapLocale($mapping); + } elseif ($fieldAttribute instanceof ODM\Depth) { + $mapping = array_merge($mapping, (array) $fieldAttribute); + $metadata->mapDepth($mapping); + } elseif ($fieldAttribute instanceof ODM\VersionName) { + $mapping = array_merge($mapping, (array) $fieldAttribute); + $metadata->mapVersionName($mapping); + } elseif ($fieldAttribute instanceof ODM\VersionCreated) { + $mapping = array_merge($mapping, (array) $fieldAttribute); + $metadata->mapVersionCreated($mapping); + } + } + } + + foreach ($reflectionClass->getMethods() as $method) { + if ($method->isPublic() && $method->getDeclaringClass()->getName() == $metadata->name) { + foreach ($this->reader->getMethodAttributes($method) as $methodAttribute) { + if ($methodAttribute instanceof ODM\PrePersist) { + $metadata->addLifecycleCallback($method->getName(), Event::prePersist); + } elseif ($methodAttribute instanceof ODM\PostPersist) { + $metadata->addLifecycleCallback($method->getName(), Event::postPersist); + } elseif ($methodAttribute instanceof ODM\PreUpdate) { + $metadata->addLifecycleCallback($method->getName(), Event::preUpdate); + } elseif ($methodAttribute instanceof ODM\PostUpdate) { + $metadata->addLifecycleCallback($method->getName(), Event::postUpdate); + } elseif ($methodAttribute instanceof ODM\PreRemove) { + $metadata->addLifecycleCallback($method->getName(), Event::preRemove); + } elseif ($methodAttribute instanceof ODM\PostRemove) { + $metadata->addLifecycleCallback($method->getName(), Event::postRemove); + } elseif ($methodAttribute instanceof ODM\PostLoad) { + $metadata->addLifecycleCallback($method->getName(), Event::postLoad); + } + } + } + } + + $metadata->validateClassMapping(); + } + + /** + * Gathers a list of cascade options found in the given cascade element. + * + * @param array $cascadeList + * + * @return int a bitmask of cascade options + */ + private function getCascadeMode(array $cascadeList) + { + $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(PersistenceClassMetadata::class); diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Driver/AttributeReader.php b/lib/Doctrine/ODM/PHPCR/Mapping/Driver/AttributeReader.php new file mode 100644 index 000000000..9eb620dc9 --- /dev/null +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Driver/AttributeReader.php @@ -0,0 +1,77 @@ + + * + * @template T of MappingAttribute + */ + public function getClassAttributes(ReflectionClass $class): array + { + return $this->convertToAttributeInstances($class->getAttributes()); + } + + /** + * @return class-string-map + * + * @template T of MappingAttribute + */ + public function getMethodAttributes(ReflectionMethod $method): array + { + return $this->convertToAttributeInstances($method->getAttributes()); + } + + /** + * @return class-string-map + * + * @template T of MappingAttribute + */ + public function getPropertyAttributes(ReflectionProperty $property): array + { + return $this->convertToAttributeInstances($property->getAttributes()); + } + + /** + * @param array $attributes + * + * @return class-string-map + * + * @template T of MappingAttribute + */ + private function convertToAttributeInstances(array $attributes): array + { + $instances = []; + + foreach ($attributes as $attribute) { + $attributeName = $attribute->getName(); + assert(is_string($attributeName)); + // Make sure we only get Doctrine Attributes + if (! is_subclass_of($attributeName, MappingAttribute::class)) { + continue; + } + + $instance = $attribute->newInstance(); + assert($instance instanceof MappingAttribute); + + $instances[$attributeName] = $instance; + } + + return $instances; + } +} diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/MappingAttribute.php b/lib/Doctrine/ODM/PHPCR/Mapping/MappingAttribute.php new file mode 100644 index 000000000..5f4cc33cb --- /dev/null +++ b/lib/Doctrine/ODM/PHPCR/Mapping/MappingAttribute.php @@ -0,0 +1,8 @@ +loadDriver(); + $attributeDriver->addPaths([__DIR__.'/Model']); + + return $attributeDriver; + } + + /** + * Overwriting private parent properties isn't supported with annotations. + * + * @doesNotPerformAssertions + */ + public function testParentWithPrivatePropertyMapping(): void + { + } +} diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ChildClassesAndLeafObject.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ChildClassesAndLeafObject.php index 5748a1e89..6ecd3f0c0 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ChildClassesAndLeafObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ChildClassesAndLeafObject.php @@ -3,6 +3,7 @@ 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 @@ -11,8 +12,10 @@ * "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 76cb7637c..5068fae34 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ChildClassesObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ChildClassesObject.php @@ -3,6 +3,7 @@ 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 @@ -11,8 +12,10 @@ * "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 60752267b..76b86cd41 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ChildMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ChildMappingObject.php @@ -3,20 +3,25 @@ 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 db6f61d84..0da86de0a 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ChildrenMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ChildrenMappingObject.php @@ -3,20 +3,25 @@ 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 6b036d27c..21aa1c838 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ClassInheritanceChildMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ClassInheritanceChildMappingObject.php @@ -3,6 +3,7 @@ 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 @@ -10,6 +11,7 @@ * * @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 5db5722a5..c5062ea21 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ClassInheritanceChildOverridesMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ClassInheritanceChildOverridesMappingObject.php @@ -3,6 +3,7 @@ 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 @@ -17,6 +18,14 @@ * versionable="full" * ) */ +#[PHPCR\Document( + nodeType: 'nt:test-override', + 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 04c25de48..f624844f6 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ClassInheritanceParentMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ClassInheritanceParentMappingObject.php @@ -3,6 +3,7 @@ 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 @@ -17,8 +18,16 @@ * versionable="simple" * ) */ +#[PHPCR\Document( + nodeType: 'nt:test', + repositoryClass: DocumentRepository::class, + translator: 'foo', + mixins: ['mix:foo', 'mix:bar'], + 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 8852e8678..bb4d5e96e 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/DefaultMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/DefaultMappingObject.php @@ -3,14 +3,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 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 111fca085..b9acd0883 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/DepthMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/DepthMappingObject.php @@ -3,17 +3,21 @@ 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 f40ca9772..09084e0c9 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/FieldMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/FieldMappingObject.php @@ -3,50 +3,65 @@ 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 bb20f4eab..b1d09f54a 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/InheritedMixinMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/InheritedMixinMappingObject.php @@ -3,17 +3,21 @@ 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 b2d1a1bbc..2c6f0a345 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/IsLeafObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/IsLeafObject.php @@ -3,14 +3,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(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 c95112e80..ef14b6681 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/LifecycleCallbackMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/LifecycleCallbackMappingObject.php @@ -3,48 +3,58 @@ 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 5502a0a36..813d28f4c 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/MappedSuperclassMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/MappedSuperclassMappingObject.php @@ -3,14 +3,24 @@ 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', + repositoryClass: DocumentRepository::class, + translator: 'children', + mixins: ['mix:one', 'mix:two'], + versionable: 'simple', + referenceable: true, +)] 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 9d3b6a069..d7ea787ab 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/MixinMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/MixinMappingObject.php @@ -3,23 +3,29 @@ 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')] 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/NodeMappingObject.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/NodeMappingObject.php index 755e2ac72..6a66e6f7c 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/NodeMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/NodeMappingObject.php @@ -3,17 +3,21 @@ 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 1c5c2ebee..0ee41e477 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/NodeTypeMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/NodeTypeMappingObject.php @@ -3,14 +3,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(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 f20975836..d94e667b0 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/NodenameMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/NodenameMappingObject.php @@ -3,17 +3,21 @@ 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 97751419b..1b27bdac3 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ParentDocumentMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ParentDocumentMappingObject.php @@ -3,17 +3,21 @@ 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 5a2b7d0c5..d1e3ea989 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferenceManyMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferenceManyMappingObject.php @@ -3,20 +3,25 @@ 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 d6086ce61..2f40fc9de 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferenceOneMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferenceOneMappingObject.php @@ -3,20 +3,25 @@ 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 32ae8e9b5..79691c266 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferenceableChildMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferenceableChildMappingObject.php @@ -3,6 +3,7 @@ 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 @@ -10,8 +11,10 @@ * * @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 6e5217962..421a14729 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferenceableChildReferenceableFalseMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferenceableChildReferenceableFalseMappingObject.php @@ -3,6 +3,7 @@ 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 @@ -10,6 +11,7 @@ * * @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 9737cf4f5..2129c64f2 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferenceableMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferenceableMappingObject.php @@ -3,14 +3,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(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 c4a5a585d..6a70e70fe 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferrersMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferrersMappingObject.php @@ -3,34 +3,41 @@ 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 74d60248b..680e2f936 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReplaceMixinMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReplaceMixinMappingObject.php @@ -3,23 +3,29 @@ 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 cea4730f8..624a8640b 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/RepositoryMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/RepositoryMappingObject.php @@ -3,14 +3,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(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 1b39618b5..e94037246 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/StringExtendedMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/StringExtendedMappingObject.php @@ -3,12 +3,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 extends a class which contains string properties * * @PHPCRODM\Document(translator="attribute") */ +#[PHPCR\Document(translator: 'attribute')] class StringExtendedMappingObject extends StringMappingObject { /** @@ -16,8 +18,10 @@ class StringExtendedMappingObject extends StringMappingObject * * @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 8b1c26ce6..0214cfea2 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/StringMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/StringMappingObject.php @@ -2,6 +2,7 @@ namespace Doctrine\Tests\ODM\PHPCR\Mapping\Model; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; /** @@ -9,11 +10,14 @@ * * @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 e5f3afc6d..0b26a28f3 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/TranslatorMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/TranslatorMappingObject.php @@ -3,12 +3,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 translator and translatable * * @PHPCRODM\Document(translator="attribute") */ +#[PHPCR\Document(translator: 'attribute')] class TranslatorMappingObject { /** @@ -16,6 +18,7 @@ class TranslatorMappingObject * * @PHPCRODM\Id */ + #[PHPCR\Id] private $id; /** @@ -23,6 +26,7 @@ class TranslatorMappingObject * * @PHPCRODM\Locale */ + #[PHPCR\Locale] private $doclocale; /** @@ -30,6 +34,7 @@ class TranslatorMappingObject * * @PHPCRODM\Field(type="date") */ + #[PHPCR\Field(type: 'date')] private $publishDate; /** @@ -37,6 +42,7 @@ class TranslatorMappingObject * * @PHPCRODM\Field(type="string", translated=true) */ + #[PHPCR\Field(type: 'string', translated: true)] private $topic; /** @@ -44,5 +50,6 @@ class TranslatorMappingObject * * @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 41116f57e..8cb81649b 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/TranslatorMappingObjectNoStrategy.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/TranslatorMappingObjectNoStrategy.php @@ -3,19 +3,20 @@ 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 { /** - * The path - * * @PHPCRODM\Id */ + #[PHPCR\Id] private $id; /** @@ -23,6 +24,7 @@ class TranslatorMappingObjectNoStrategy * * @PHPCRODM\Locale */ + #[PHPCR\Locale] private $doclocale; /** @@ -30,6 +32,7 @@ class TranslatorMappingObjectNoStrategy * * @PHPCRODM\Field(type="date") */ + #[PHPCR\Field(type: 'date')] private $publishDate; /** @@ -37,6 +40,7 @@ class TranslatorMappingObjectNoStrategy * * @PHPCRODM\Field(type="string", translated=true) */ + #[PHPCR\Field(type: 'string', translated: true)] private $topic; /** @@ -44,5 +48,6 @@ class TranslatorMappingObjectNoStrategy * * @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 6a9cebb31..e04c532f0 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/UniqueNodeTypeMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/UniqueNodeTypeMappingObject.php @@ -3,14 +3,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 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 4313aa678..6e371c3ba 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/UuidMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/UuidMappingObject.php @@ -3,15 +3,19 @@ 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()*/ + /** @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 349d2c8db..6419b2e29 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/UuidMappingObjectNotReferenceable.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/UuidMappingObjectNotReferenceable.php @@ -3,17 +3,21 @@ 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() */ + /** @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 da55da9a5..5c8aea4aa 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/VersionableMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/VersionableMappingObject.php @@ -3,20 +3,25 @@ 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; } From 4c4cb4dbc0d9eb934635183ba8c9c4dfc3cfcc6b Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Sun, 3 Dec 2023 09:06:41 +0100 Subject: [PATCH 07/14] prepare release --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 527685974..e781d8d62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,8 @@ Changelog 1.x === -1.8.0 (unreleased) ------------------- +1.8.0 +----- * Add support for PHP attributes (only for the annotations that are not deprecated) * Drop support for PHP 7. From 625d832c246b2293716103ecba462a0e82a235fa Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Sun, 3 Dec 2023 09:25:03 +0100 Subject: [PATCH 08/14] cleanup 1.x changes --- .../ODM/PHPCR/Mapping/Annotations/Id.php | 2 +- .../PHPCR/Mapping/Annotations/Reference.php | 4 +- .../ODM/PHPCR/Mapping/Attributes/Child.php | 3 +- .../ODM/PHPCR/Mapping/Attributes/Children.php | 3 +- .../ODM/PHPCR/Mapping/Attributes/Depth.php | 3 +- .../ODM/PHPCR/Mapping/Attributes/Document.php | 3 +- .../ODM/PHPCR/Mapping/Attributes/Field.php | 6 +-- .../ODM/PHPCR/Mapping/Attributes/Id.php | 3 +- .../ODM/PHPCR/Mapping/Attributes/Locale.php | 3 +- .../Mapping/Attributes/MappedSuperclass.php | 4 +- .../Mapping/Attributes/MixedReferrers.php | 3 +- .../ODM/PHPCR/Mapping/Attributes/Node.php | 3 +- .../ODM/PHPCR/Mapping/Attributes/Nodename.php | 3 +- .../Mapping/Attributes/ParentDocument.php | 3 +- .../ODM/PHPCR/Mapping/Attributes/PostLoad.php | 3 +- .../PHPCR/Mapping/Attributes/PostPersist.php | 3 +- .../PHPCR/Mapping/Attributes/PostRemove.php | 3 +- .../PHPCR/Mapping/Attributes/PostUpdate.php | 3 +- .../PHPCR/Mapping/Attributes/PrePersist.php | 3 +- .../PHPCR/Mapping/Attributes/PreRemove.php | 3 +- .../PHPCR/Mapping/Attributes/PreUpdate.php | 3 +- .../Mapping/Attributes/ReferenceMany.php | 4 +- .../PHPCR/Mapping/Attributes/ReferenceOne.php | 4 +- .../PHPCR/Mapping/Attributes/Referrers.php | 3 +- .../ODM/PHPCR/Mapping/Attributes/Uuid.php | 4 +- .../Mapping/Attributes/VersionCreated.php | 3 +- .../PHPCR/Mapping/Attributes/VersionName.php | 3 +- .../PHPCR/Mapping/Driver/AttributeDriver.php | 9 ++--- .../PHPCR/Mapping/Driver/AttributeReader.php | 38 +++++-------------- .../ODM/PHPCR/Mapping/MappingAttribute.php | 6 ++- .../Functional/EventObjectUpdateTest.php | 8 ++-- .../Tests/ODM/PHPCR/Functional/ProxyTest.php | 2 +- .../Translation/TranslationTest.php | 4 +- .../Mapping/AbstractMappingDriverTest.php | 8 ++-- .../ODM/PHPCR/Mapping/AttributeDriverTest.php | 2 +- .../Mapping/Model/StringMappingObject.php | 2 +- 36 files changed, 58 insertions(+), 109 deletions(-) diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Id.php b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Id.php index 9f348c4a7..1b8482cda 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Id.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Id.php @@ -12,5 +12,5 @@ class Id { public bool $id = true; public string $type = 'string'; - public string $strategy; + public ?string $strategy = null; } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Reference.php b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Reference.php index 3d336af6d..c7db1ad99 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Reference.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Reference.php @@ -8,9 +8,7 @@ class Reference { /** - * The PHPCR property name to use - * - * @var string + * The PHPCR property name to use. */ public string $property; diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Child.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Child.php index 6f01ca7e8..d5fb7cbab 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Child.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Child.php @@ -2,11 +2,10 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Attribute; use Doctrine\ODM\PHPCR\Mapping\Annotations\Child as BaseChild; use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[\Attribute(\Attribute::TARGET_PROPERTY)] final class Child extends BaseChild implements MappingAttribute { public function __construct( diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Children.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Children.php index 8ff32c14e..9408ef0cf 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Children.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Children.php @@ -2,11 +2,10 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Attribute; use Doctrine\ODM\PHPCR\Mapping\Annotations\Children as BaseChildren; use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[\Attribute(\Attribute::TARGET_PROPERTY)] final class Children extends BaseChildren implements MappingAttribute { public function __construct( diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Depth.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Depth.php index 3e09f984e..513b3fc60 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Depth.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Depth.php @@ -2,11 +2,10 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Attribute; use Doctrine\ODM\PHPCR\Mapping\Annotations\Depth as BaseDepth; use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[\Attribute(\Attribute::TARGET_PROPERTY)] final class Depth extends BaseDepth implements MappingAttribute { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Document.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Document.php index c900a04f7..cb289d493 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Document.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Document.php @@ -2,11 +2,10 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Attribute; use Doctrine\ODM\PHPCR\Mapping\Annotations\Document as BaseDocument; use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; -#[Attribute(Attribute::TARGET_CLASS)] +#[\Attribute(\Attribute::TARGET_CLASS)] class Document extends BaseDocument implements MappingAttribute { public function __construct( diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Field.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Field.php index a450b8158..6bd9791e5 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Field.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Field.php @@ -2,11 +2,10 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Attribute; use Doctrine\ODM\PHPCR\Mapping\Annotations\Field as BaseField; use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[\Attribute(\Attribute::TARGET_PROPERTY)] class Field extends BaseField implements MappingAttribute { public function __construct( @@ -16,8 +15,7 @@ public function __construct( string $assoc = null, bool $nullable = false, bool $translated = false, - ) - { + ) { $this->property = $property; $this->type = $type; $this->multivalue = $multivalue; diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Id.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Id.php index c412e0e94..b63ae4842 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Id.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Id.php @@ -2,11 +2,10 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Attribute; use Doctrine\ODM\PHPCR\Mapping\Annotations\Id as BaseId; use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[\Attribute(\Attribute::TARGET_PROPERTY)] final class Id extends BaseId implements MappingAttribute { public function __construct( diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Locale.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Locale.php index 36e950959..a859c3bbd 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Locale.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Locale.php @@ -2,11 +2,10 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Attribute; use Doctrine\ODM\PHPCR\Mapping\Annotations\Locale as BaseLocale; use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[\Attribute(\Attribute::TARGET_PROPERTY)] final class Locale extends BaseLocale implements MappingAttribute { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/MappedSuperclass.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/MappedSuperclass.php index f70deea50..5e59f8222 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/MappedSuperclass.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/MappedSuperclass.php @@ -2,9 +2,7 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Attribute; - -#[Attribute(Attribute::TARGET_CLASS)] +#[\Attribute(\Attribute::TARGET_CLASS)] final class MappedSuperclass extends Document { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/MixedReferrers.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/MixedReferrers.php index 62c43e0e6..8a1513668 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/MixedReferrers.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/MixedReferrers.php @@ -2,11 +2,10 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Attribute; use Doctrine\ODM\PHPCR\Mapping\Annotations\MixedReferrers as BaseMixedReferrers; use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[\Attribute(\Attribute::TARGET_PROPERTY)] final class MixedReferrers extends BaseMixedReferrers implements MappingAttribute { public function __construct(string $referenceType = null) diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Node.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Node.php index 55a86366c..4a4d6c6ae 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Node.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Node.php @@ -2,11 +2,10 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Attribute; use Doctrine\ODM\PHPCR\Mapping\Annotations\Node as BaseNode; use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[\Attribute(\Attribute::TARGET_PROPERTY)] final class Node extends BaseNode implements MappingAttribute { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Nodename.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Nodename.php index b3d0845e6..9941c301c 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Nodename.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Nodename.php @@ -2,11 +2,10 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Attribute; use Doctrine\ODM\PHPCR\Mapping\Annotations\Nodename as BaseNodename; use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[\Attribute(\Attribute::TARGET_PROPERTY)] final class Nodename extends BaseNodename implements MappingAttribute { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/ParentDocument.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/ParentDocument.php index 8b60a5e68..782b8d8e4 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/ParentDocument.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/ParentDocument.php @@ -2,11 +2,10 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Attribute; use Doctrine\ODM\PHPCR\Mapping\Annotations\ParentDocument as BaseParentDocument; use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[\Attribute(\Attribute::TARGET_PROPERTY)] final class ParentDocument extends BaseParentDocument implements MappingAttribute { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostLoad.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostLoad.php index 311818f34..a85f65a28 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostLoad.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostLoad.php @@ -2,11 +2,10 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Attribute; use Doctrine\ODM\PHPCR\Mapping\Annotations\PostLoad as BasePostLoad; use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; -#[Attribute(Attribute::TARGET_METHOD)] +#[\Attribute(\Attribute::TARGET_METHOD)] final class PostLoad extends BasePostLoad implements MappingAttribute { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostPersist.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostPersist.php index aad5e81bc..98f7fe949 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostPersist.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostPersist.php @@ -2,11 +2,10 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Attribute; use Doctrine\ODM\PHPCR\Mapping\Annotations\PostPersist as BasePostPersist; use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; -#[Attribute(Attribute::TARGET_METHOD)] +#[\Attribute(\Attribute::TARGET_METHOD)] final class PostPersist extends BasePostPersist implements MappingAttribute { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostRemove.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostRemove.php index d4314a3c1..724be8fd4 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostRemove.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostRemove.php @@ -2,11 +2,10 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Attribute; use Doctrine\ODM\PHPCR\Mapping\Annotations\PostRemove as BasePostRemove; use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; -#[Attribute(Attribute::TARGET_METHOD)] +#[\Attribute(\Attribute::TARGET_METHOD)] final class PostRemove extends BasePostRemove implements MappingAttribute { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostUpdate.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostUpdate.php index c99e4feef..23f76cfa6 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostUpdate.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostUpdate.php @@ -2,11 +2,10 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Attribute; use Doctrine\ODM\PHPCR\Mapping\Annotations\PostUpdate as BasePostUpdate; use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; -#[Attribute(Attribute::TARGET_METHOD)] +#[\Attribute(\Attribute::TARGET_METHOD)] final class PostUpdate extends BasePostUpdate implements MappingAttribute { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PrePersist.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PrePersist.php index 64a31e2c5..66f334d74 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PrePersist.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PrePersist.php @@ -2,11 +2,10 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Attribute; use Doctrine\ODM\PHPCR\Mapping\Annotations\PrePersist as BasePrePersist; use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; -#[Attribute(Attribute::TARGET_METHOD)] +#[\Attribute(\Attribute::TARGET_METHOD)] final class PrePersist extends BasePrePersist implements MappingAttribute { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PreRemove.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PreRemove.php index 596543561..fa293a292 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PreRemove.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PreRemove.php @@ -2,11 +2,10 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Attribute; use Doctrine\ODM\PHPCR\Mapping\Annotations\PreRemove as BasePreRemove; use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; -#[Attribute(Attribute::TARGET_METHOD)] +#[\Attribute(\Attribute::TARGET_METHOD)] final class PreRemove extends BasePreRemove implements MappingAttribute { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PreUpdate.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PreUpdate.php index 0bacc4678..005401f7c 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PreUpdate.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PreUpdate.php @@ -2,11 +2,10 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Attribute; use Doctrine\ODM\PHPCR\Mapping\Annotations\PreUpdate as BasePreUpdate; use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; -#[Attribute(Attribute::TARGET_METHOD)] +#[\Attribute(\Attribute::TARGET_METHOD)] final class PreUpdate extends BasePreUpdate implements MappingAttribute { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/ReferenceMany.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/ReferenceMany.php index b10c87202..7b9102a41 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/ReferenceMany.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/ReferenceMany.php @@ -2,9 +2,7 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Attribute; - -#[Attribute(Attribute::TARGET_PROPERTY)] +#[\Attribute(\Attribute::TARGET_PROPERTY)] final class ReferenceMany extends Reference { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/ReferenceOne.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/ReferenceOne.php index 1ee210760..5f9f2ed57 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/ReferenceOne.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/ReferenceOne.php @@ -2,9 +2,7 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Attribute; - -#[Attribute(Attribute::TARGET_PROPERTY)] +#[\Attribute(\Attribute::TARGET_PROPERTY)] final class ReferenceOne extends Reference { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Referrers.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Referrers.php index dd7a0c1ea..b5a04f00c 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Referrers.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Referrers.php @@ -2,11 +2,10 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Attribute; use Doctrine\ODM\PHPCR\Mapping\Annotations\Referrers as BaseReferrers; use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[\Attribute(\Attribute::TARGET_PROPERTY)] final class Referrers extends BaseReferrers implements MappingAttribute { /** diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Uuid.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Uuid.php index 36e0d7abd..db1e77dcc 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Uuid.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Uuid.php @@ -2,9 +2,7 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Attribute; - -#[Attribute(Attribute::TARGET_PROPERTY)] +#[\Attribute(\Attribute::TARGET_PROPERTY)] final class Uuid extends Field { public function __construct( diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/VersionCreated.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/VersionCreated.php index 7e46e2dbb..f722885f3 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/VersionCreated.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/VersionCreated.php @@ -2,11 +2,10 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Attribute; use Doctrine\ODM\PHPCR\Mapping\Annotations\VersionCreated as BaseVersionCreated; use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[\Attribute(\Attribute::TARGET_PROPERTY)] final class VersionCreated extends BaseVersionCreated implements MappingAttribute { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/VersionName.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/VersionName.php index 73e1000a2..403752f6e 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/VersionName.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/VersionName.php @@ -2,11 +2,10 @@ namespace Doctrine\ODM\PHPCR\Mapping\Attributes; -use Attribute; use Doctrine\ODM\PHPCR\Mapping\Annotations\VersionName as BaseVersionName; use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[\Attribute(\Attribute::TARGET_PROPERTY)] final class VersionName extends BaseVersionName implements MappingAttribute { } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Driver/AttributeDriver.php b/lib/Doctrine/ODM/PHPCR/Mapping/Driver/AttributeDriver.php index 587e925fc..1f0d8b587 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Driver/AttributeDriver.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Driver/AttributeDriver.php @@ -28,7 +28,6 @@ use Doctrine\Persistence\Mapping\ClassMetadata as PersistenceClassMetadata; use Doctrine\Persistence\Mapping\Driver\ColocatedMappingDriver; use Doctrine\Persistence\Mapping\Driver\MappingDriver; -use ReflectionClass; /** * Read mapping metadata from PHP attributes. @@ -65,7 +64,7 @@ public function __construct(array $paths) public function isTransient($className) { - $classAttributes = $this->reader->getClassAttributes(new ReflectionClass($className)); + $classAttributes = $this->reader->getClassAttributes(new \ReflectionClass($className)); foreach ($classAttributes as $a) { if (array_key_exists($a::class, self::DOCUMENT_ATTRIBUTE_CLASSES)) { @@ -203,7 +202,7 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad foreach ($this->reader->getMethodAttributes($method) as $methodAttribute) { if ($methodAttribute instanceof ODM\PrePersist) { $metadata->addLifecycleCallback($method->getName(), Event::prePersist); - } elseif ($methodAttribute instanceof ODM\PostPersist) { + } elseif ($methodAttribute instanceof ODM\PostPersist) { $metadata->addLifecycleCallback($method->getName(), Event::postPersist); } elseif ($methodAttribute instanceof ODM\PreUpdate) { $metadata->addLifecycleCallback($method->getName(), Event::preUpdate); @@ -213,7 +212,7 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad $metadata->addLifecycleCallback($method->getName(), Event::preRemove); } elseif ($methodAttribute instanceof ODM\PostRemove) { $metadata->addLifecycleCallback($method->getName(), Event::postRemove); - } elseif ($methodAttribute instanceof ODM\PostLoad) { + } elseif ($methodAttribute instanceof ODM\PostLoad) { $metadata->addLifecycleCallback($method->getName(), Event::postLoad); } } @@ -226,8 +225,6 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad /** * Gathers a list of cascade options found in the given cascade element. * - * @param array $cascadeList - * * @return int a bitmask of cascade options */ private function getCascadeMode(array $cascadeList) diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Driver/AttributeReader.php b/lib/Doctrine/ODM/PHPCR/Mapping/Driver/AttributeReader.php index 9eb620dc9..8a2efa1c1 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Driver/AttributeReader.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Driver/AttributeReader.php @@ -5,54 +5,36 @@ namespace Doctrine\ODM\PHPCR\Mapping\Driver; use Doctrine\ODM\PHPCR\Mapping\MappingAttribute; -use ReflectionAttribute; -use ReflectionClass; -use ReflectionMethod; -use ReflectionProperty; - -use function assert; -use function is_string; -use function is_subclass_of; /** @internal */ final class AttributeReader { /** - * @psalm-return class-string-map - * - * @template T of MappingAttribute + * @return MappingAttribute[] */ - public function getClassAttributes(ReflectionClass $class): array + public function getClassAttributes(\ReflectionClass $class): array { return $this->convertToAttributeInstances($class->getAttributes()); } /** - * @return class-string-map - * - * @template T of MappingAttribute + * @return MappingAttribute[] */ - public function getMethodAttributes(ReflectionMethod $method): array + public function getMethodAttributes(\ReflectionMethod $method): array { return $this->convertToAttributeInstances($method->getAttributes()); } /** - * @return class-string-map - * - * @template T of MappingAttribute + * @return MappingAttribute[] */ - public function getPropertyAttributes(ReflectionProperty $property): array + public function getPropertyAttributes(\ReflectionProperty $property): array { return $this->convertToAttributeInstances($property->getAttributes()); } /** - * @param array $attributes - * - * @return class-string-map - * - * @template T of MappingAttribute + * @return MappingAttribute[] */ private function convertToAttributeInstances(array $attributes): array { @@ -60,14 +42,14 @@ private function convertToAttributeInstances(array $attributes): array foreach ($attributes as $attribute) { $attributeName = $attribute->getName(); - assert(is_string($attributeName)); + \assert(\is_string($attributeName)); // Make sure we only get Doctrine Attributes - if (! is_subclass_of($attributeName, MappingAttribute::class)) { + if (!\is_subclass_of($attributeName, MappingAttribute::class)) { continue; } $instance = $attribute->newInstance(); - assert($instance instanceof MappingAttribute); + \assert($instance instanceof MappingAttribute); $instances[$attributeName] = $instance; } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/MappingAttribute.php b/lib/Doctrine/ODM/PHPCR/Mapping/MappingAttribute.php index 5f4cc33cb..798a1b00c 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/MappingAttribute.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/MappingAttribute.php @@ -3,6 +3,8 @@ namespace Doctrine\ODM\PHPCR\Mapping; /** - * A marker interface for mapping attributes. + * A marker interface for mapping attributes. */ -interface MappingAttribute {} +interface MappingAttribute +{ +} diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/EventObjectUpdateTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/EventObjectUpdateTest.php index 7446c03a5..3b461a7d4 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/EventObjectUpdateTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/EventObjectUpdateTest.php @@ -53,7 +53,7 @@ public function testComputingBetweenEvents(): void $this->dm->flush(); $this->assertInstanceOf('stdClass', $entity->status); - $this->assertObjectHasAttribute('value', $entity->status); + $this->assertObjectHasProperty('value', $entity->status); $this->assertEquals($entity->status->value, 'active'); $this->assertObjectNotHasAttribute('foo', $entity->status); @@ -64,7 +64,7 @@ public function testComputingBetweenEvents(): void $this->dm->flush(); $this->assertInstanceOf('stdClass', $entity->status); - $this->assertObjectHasAttribute('value', $entity->status); + $this->assertObjectHasProperty('value', $entity->status); $this->assertEquals($entity->status->value, 'inactive'); $this->assertObjectNotHasAttribute('foo', $entity->status); $this->assertEquals($entity->text, 'test2'); @@ -74,7 +74,7 @@ public function testComputingBetweenEvents(): void $entity = $this->dm->find(null, $entity->id); $this->assertInstanceOf('stdClass', $entity->status); - $this->assertObjectHasAttribute('value', $entity->status); + $this->assertObjectHasProperty('value', $entity->status); $this->assertEquals($entity->status->value, 'inactive'); $this->assertObjectNotHasAttribute('foo', $entity->status); $this->assertEquals($entity->text, 'test2'); @@ -84,7 +84,7 @@ public function testComputingBetweenEvents(): void $this->dm->flush(); $this->assertInstanceOf('stdClass', $entity->status); - $this->assertObjectHasAttribute('value', $entity->status); + $this->assertObjectHasProperty('value', $entity->status); $this->assertEquals($entity->status->value, 'active'); $this->assertEquals($entity->text, 'test2'); } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/ProxyTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/ProxyTest.php index 8e584cebe..333b53360 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/ProxyTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/ProxyTest.php @@ -37,7 +37,7 @@ public function testProxyProperty(): void $user = $this->dm->getReference(get_class($user), $user->id); - $this->assertObjectHasAttribute('name', $user, 'User is not set on demand'); + $this->assertObjectHasProperty('name', $user, 'User is not set on demand'); $this->assertEquals('Dominik', $user->name, 'User is not loaded on demand'); } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/Translation/TranslationTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Translation/TranslationTest.php index d878add1b..458d7a576 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/Translation/TranslationTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Translation/TranslationTest.php @@ -53,10 +53,10 @@ public function testLoadAnnotations(): void $this->assertFieldMetadataEquals(true, $metadata, 'text', 'translated'); $this->assertFieldMetadataEquals(true, $metadata, 'assoc', 'translated'); - $this->assertObjectHasAttribute('translator', $metadata); + $this->assertObjectHasProperty('translator', $metadata); $this->assertEquals('attribute', $metadata->translator); - $this->assertObjectHasAttribute('localeMapping', $metadata); + $this->assertObjectHasProperty('localeMapping', $metadata); $this->assertEquals('locale', $metadata->localeMapping); } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/AbstractMappingDriverTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/AbstractMappingDriverTest.php index b34cfa156..dcccbcbc2 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/AbstractMappingDriverTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/AbstractMappingDriverTest.php @@ -314,7 +314,7 @@ public function testLoadNodenameMapping(): ClassMetadata */ public function testNodenameMapping(ClassMetadata $class): void { - $this->assertObjectHasAttribute('nodename', $class); + $this->assertObjectHasProperty('nodename', $class); $this->assertEquals('namefield', $class->nodename); } @@ -331,7 +331,7 @@ public function testLoadParentDocumentMapping(): ClassMetadata */ public function testParentDocumentMapping(ClassMetadata $class): void { - $this->assertObjectHasAttribute('parentMapping', $class); + $this->assertObjectHasProperty('parentMapping', $class); $this->assertEquals('parent', $class->parentMapping); } @@ -348,7 +348,7 @@ public function testLoadDepthMapping(): ClassMetadata */ public function testDepthMapping(ClassMetadata $class): void { - $this->assertObjectHasAttribute('depthMapping', $class); + $this->assertObjectHasProperty('depthMapping', $class); $this->assertSame('depth', $class->depthMapping); } @@ -788,7 +788,7 @@ public function testStringExtendedMapping(): void */ public function testUuidMapping(ClassMetadata $class): void { - $this->assertObjectHasAttribute('uuidFieldName', $class); + $this->assertObjectHasProperty('uuidFieldName', $class); $this->assertEquals('uuid', $class->uuidFieldName); $this->assertEquals('string', $class->mappings['uuid']['type']); $this->assertEquals('jcr:uuid', $class->mappings['uuid']['property']); diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/AttributeDriverTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/AttributeDriverTest.php index 7b1c57fb8..b9a4c3d43 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/AttributeDriverTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/AttributeDriverTest.php @@ -10,7 +10,7 @@ */ class AttributeDriverTest extends AbstractMappingDriverTest { - protected function loadDriver(): MappingDriver + protected function loadDriver(): AttributeDriver { return new AttributeDriver([]); } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/StringMappingObject.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/StringMappingObject.php index 804477934..46eb46d5e 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/StringMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/StringMappingObject.php @@ -2,8 +2,8 @@ namespace Doctrine\Tests\ODM\PHPCR\Mapping\Model; -use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; /** * A class that contains string properties. From fb19358b280c361dc8eaeccb6e72477f3c5a67af Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Sun, 3 Dec 2023 10:36:35 +0100 Subject: [PATCH 09/14] convert provided documents to attributes instead of annotations --- CHANGELOG.md | 5 ++ .../ODM/PHPCR/Document/AbstractFile.php | 23 ++++---- lib/Doctrine/ODM/PHPCR/Document/File.php | 19 +++--- lib/Doctrine/ODM/PHPCR/Document/Folder.php | 13 ++--- lib/Doctrine/ODM/PHPCR/Document/Generic.php | 31 +++++----- lib/Doctrine/ODM/PHPCR/Document/Resource.php | 58 +++++++------------ .../ODM/PHPCR/Mapping/Attributes/Child.php | 4 +- .../ODM/PHPCR/Mapping/Attributes/Children.php | 4 +- .../PHPCR/Mapping/Attributes/Reference.php | 4 +- .../PHPCR/Mapping/Attributes/Referrers.php | 4 +- .../Mapping/Driver/BuiltinDocumentsDriver.php | 19 ++---- 11 files changed, 78 insertions(+), 106 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e781d8d62..adcb9f3f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ Changelog 1.x === +1.8.1 (unreleased) +------------------ + +* Convert provided documents to use attributes instead of annotations. + 1.8.0 ----- diff --git a/lib/Doctrine/ODM/PHPCR/Document/AbstractFile.php b/lib/Doctrine/ODM/PHPCR/Document/AbstractFile.php index 7e6814ffa..c12d454ec 100644 --- a/lib/Doctrine/ODM/PHPCR/Document/AbstractFile.php +++ b/lib/Doctrine/ODM/PHPCR/Document/AbstractFile.php @@ -20,31 +20,30 @@ namespace Doctrine\ODM\PHPCR\Document; use Doctrine\ODM\PHPCR\HierarchyInterface; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as ODM; /** * This class represents an abstract "file" - * - * @PHPCRODM\MappedSuperclass(mixins="mix:created") */ +#[ODM\MappedSuperclass(mixins: ['mix:created'])] abstract class AbstractFile implements HierarchyInterface { - /** @PHPCRODM\Id(strategy="parent") */ + #[ODM\Id(strategy: 'parent')] protected $id; - /** @PHPCRODM\Node */ + #[ODM\Node] protected $node; - /** @PHPCRODM\Nodename */ + #[ODM\Nodename] protected $nodename; - /** @PHPCRODM\ParentDocument */ + #[ODM\ParentDocument] protected $parent; - /** @PHPCRODM\Field(type="date", property="jcr:created") */ + #[ODM\Field(property: 'jcr:created', type: 'date')] protected $created; - /** @PHPCRODM\Field(type="string", property="jcr:createdBy") */ + #[ODM\Field(property: 'jcr:createdBy', type: 'string')] protected $createdBy; /** @@ -52,7 +51,7 @@ abstract class AbstractFile implements HierarchyInterface * * @param string $id of the node * - * @return $this + * @return self */ public function setId($id) { @@ -86,7 +85,7 @@ public function getNodename() * * @param string $name the name of the file * - * @return $this + * @return self */ public function setNodename($name) { @@ -121,7 +120,7 @@ public function getParent() * @param object $parent Document that is the parent of this node. Could be * a Folder or otherwise resolve to nt:folder * - * @return $this + * @return self */ public function setParentDocument($parent) { diff --git a/lib/Doctrine/ODM/PHPCR/Document/File.php b/lib/Doctrine/ODM/PHPCR/Document/File.php index 72b29cc4e..51c38a9b0 100644 --- a/lib/Doctrine/ODM/PHPCR/Document/File.php +++ b/lib/Doctrine/ODM/PHPCR/Document/File.php @@ -20,21 +20,20 @@ namespace Doctrine\ODM\PHPCR\Document; use Doctrine\ODM\PHPCR\Exception\RuntimeException; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as ODM; /** * This class represents a JCR file, aka nt:file. * * @see http://wiki.apache.org/jackrabbit/nt:file - * - * @PHPCRODM\Document(nodeType="nt:file", mixins={}, referenceable=true) */ +#[ODM\Document(nodeType: 'nt:file', mixins: [], referenceable: true)] class File extends AbstractFile { /** - * @var resource - * @PHPCRODM\Child(nodeName="jcr:content", cascade="all") + * @var Resource */ + #[ODM\Child(nodeName: 'jcr:content', cascade: 'all')] protected $content; /** @@ -45,7 +44,7 @@ class File extends AbstractFile * * @throws RuntimeException if the filename does not point to a file that can be read * - * @return $this + * @return self */ public function setFileContentFromFilesystem($filename) { @@ -74,9 +73,9 @@ public function setFileContentFromFilesystem($filename) /** * Set the content for this file from the given Resource. * - * @param resource $content + * @param Resource $content * - * @return $this + * @return self */ public function setContent(Resource $content) { @@ -107,7 +106,7 @@ public function getContent() * * @param resource|string $content the content for the file * - * @return $this + * @return self */ public function setFileContent($content) { @@ -129,7 +128,7 @@ public function setFileContent($content) /** * Get a stream for the content of this file. * - * @return stream the content for the file + * @return resource the content for the file */ public function getFileContentAsStream() { diff --git a/lib/Doctrine/ODM/PHPCR/Document/Folder.php b/lib/Doctrine/ODM/PHPCR/Document/Folder.php index 01e371f05..cfe0e3ca8 100644 --- a/lib/Doctrine/ODM/PHPCR/Document/Folder.php +++ b/lib/Doctrine/ODM/PHPCR/Document/Folder.php @@ -22,7 +22,7 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ODM\PHPCR\HierarchyInterface; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as ODM; /** * This class represents a Folder in the repository, aka nt:folder @@ -31,21 +31,20 @@ * * To add files or folders to a folder, create the new File/Folder and set * this document as parent, then persist the new File/Folder. - * - * @PHPCRODM\Document(nodeType="nt:folder", mixins={}) */ +#[ODM\Document(nodeType: 'nt:folder', mixins: [])] class Folder extends AbstractFile { /** * @var ArrayCollection - * @PHPCRODM\Children(cascade="all") */ + #[ODM\Children(cascade: 'all')] protected $children; /** * @var AbstractFile - * @PHPCRODM\Child(cascade="all") */ + #[ODM\Child(cascade: 'all')] protected $child; /** @@ -63,7 +62,7 @@ public function getChildren() * * @param $children ArrayCollection * - * @return $this + * @return self */ public function setChildren(ArrayCollection $children) { @@ -78,7 +77,7 @@ public function setChildren(ArrayCollection $children) * * @param $child HierarchyInterface * - * @return $this + * @return self */ public function addChild(HierarchyInterface $child) { diff --git a/lib/Doctrine/ODM/PHPCR/Document/Generic.php b/lib/Doctrine/ODM/PHPCR/Document/Generic.php index 43341f728..84fa010e8 100644 --- a/lib/Doctrine/ODM/PHPCR/Document/Generic.php +++ b/lib/Doctrine/ODM/PHPCR/Document/Generic.php @@ -21,7 +21,7 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as ODM; use PHPCR\NodeInterface; /** @@ -29,39 +29,38 @@ * * 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. - * - * @PHPCRODM\Document() */ +#[ODM\Document] class Generic { - /** @PHPCRODM\Id(strategy="parent") */ + #[ODM\Id(strategy: 'parent')] protected $id; - /** @PHPCRODM\Node */ + #[ODM\Node] protected $node; - /** @PHPCRODM\Nodename */ + #[ODM\Nodename] protected $nodename; - /** @PHPCRODM\ParentDocument */ + #[ODM\ParentDocument] protected $parent; /** * @var Collection - * @PHPCRODM\Children */ + #[ODM\Children] protected $children; /** * @var Collection - * @PHPCRODM\MixedReferrers */ + #[ODM\MixedReferrers] protected $referrers; /** * Id (path) of this document * - * @return string the id + * @return string */ public function getId() { @@ -93,7 +92,7 @@ public function getNodename() * * @param string $name the name of the document * - * @return $this + * @return self */ public function setNodename($name) { @@ -127,7 +126,7 @@ public function getParent() * * @param object $parent Document that is the parent of this node.. * - * @return $this + * @return self */ public function setParentDocument($parent) { @@ -164,7 +163,7 @@ public function getChildren() * * @param $children ArrayCollection * - * @return $this + * @return self */ public function setChildren(ArrayCollection $children) { @@ -178,7 +177,7 @@ public function setChildren(ArrayCollection $children) * * @param $child * - * @return $this + * @return self */ public function addChild($child) { @@ -209,7 +208,7 @@ public function getReferrers() * * @param $referrers ArrayCollection * - * @return $this; + * @return self; */ public function setReferrers(ArrayCollection $referrers) { @@ -223,7 +222,7 @@ public function setReferrers(ArrayCollection $referrers) * * @param $referrer * - * @return $this; + * @return self; */ public function addReferrer($referrer) { diff --git a/lib/Doctrine/ODM/PHPCR/Document/Resource.php b/lib/Doctrine/ODM/PHPCR/Document/Resource.php index b25764060..f96726930 100644 --- a/lib/Doctrine/ODM/PHPCR/Document/Resource.php +++ b/lib/Doctrine/ODM/PHPCR/Document/Resource.php @@ -20,63 +20,45 @@ namespace Doctrine\ODM\PHPCR\Document; use Doctrine\ODM\PHPCR\Exception\BadMethodCallException; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as ODM; use PHPCR\NodeInterface; /** * This class represents a jcr nt:resource and is used by the File document * * @see http://wiki.apache.org/jackrabbit/nt:resource - * - * @PHPCRODM\Document(nodeType="nt:resource") */ +#[ODM\Document(nodeType: 'nt:resource')] class Resource { - /** - * @PHPCRODM\Id - */ + #[ODM\Id] protected $id; /** * @var NodeInterface - * - * @PHPCRODM\Node */ + #[ODM\Node] protected $node; - /** - * @PHPCRODM\Nodename - */ + #[ODM\Nodename] protected $nodename; - /** - * @PHPCRODM\ParentDocument - */ + #[ODM\ParentDocument] protected $parent; - /** - * @PHPCRODM\Field(type="binary", property="jcr:data") - */ + #[ODM\Field(property: 'jcr:data', type: 'binary')] protected $data; - /** - * @PHPCRODM\Field(type="string", property="jcr:mimeType") - */ + #[ODM\Field(property: 'jcr:mimeType', type: 'string')] protected $mimeType = 'application/octet-stream'; - /** - * @PHPCRODM\Field(type="string", property="jcr:encoding", nullable=true) - */ + #[ODM\Field(property: 'jcr:encoding', type: 'string', nullable: true)] protected $encoding; - /** - * @PHPCRODM\Field(type="date", property="jcr:lastModified") - */ + #[ODM\Field(property: 'jcr:lastModified', type: 'date')] protected $lastModified; - /** - * @PHPCRODM\Field(type="string", property="jcr:lastModifiedBy") - */ + #[ODM\Field(property: 'jcr:lastModifiedBy', type: 'string')] protected $lastModifiedBy; /** @@ -97,7 +79,7 @@ public function getNodename() * * @param string $name the name of the resource * - * @return $this + * @return self */ public function setNodename($name) { @@ -131,7 +113,7 @@ public function getParent() * * @param object $parent document that is the parent of this node * - * @return $this + * @return self */ public function setParentDocument($parent) { @@ -153,9 +135,9 @@ public function setParent($parent) /** * Set the data from a binary stream. * - * @param stream $data the contents of this resource + * @param resource $data the contents of this resource * - * @return $this + * @return self */ public function setData($data) { @@ -167,7 +149,7 @@ public function setData($data) /** * Get the binary data stream of this resource. * - * @param stream + * @return resource */ public function getData() { @@ -201,7 +183,7 @@ public function getSize() * * @param string $mimeType * - * @return $this + * @return self */ public function setMimeType($mimeType) { @@ -225,7 +207,7 @@ public function getMimeType() * * @param string $encoding * - * @return $this + * @return self */ public function setEncoding($encoding) { @@ -252,7 +234,7 @@ public function getEncoding() * * @param \DateTime $lastModified * - * @return $this + * @return self */ public function setLastModified($lastModified) { @@ -279,7 +261,7 @@ public function getLastModified() * * @param string $lastModifiedBy * - * @return $this + * @return self */ public function setLastModifiedBy($lastModifiedBy) { diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Child.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Child.php index 6f01ca7e8..54a60fc9a 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Child.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Child.php @@ -11,9 +11,9 @@ final class Child extends BaseChild implements MappingAttribute { public function __construct( string $nodeName = null, - array $cascade = [], + array|string $cascade = [], ) { $this->nodeName = $nodeName; - $this->cascade = $cascade; + $this->cascade = (array) $cascade; } } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Children.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Children.php index 8ff32c14e..4e58f0486 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Children.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Children.php @@ -13,11 +13,11 @@ public function __construct( array|string $filter = null, int $fetchDepth = -1, bool $ignoreUntranslated = true, - array $cascade = [], + array|string $cascade = [], ) { $this->filter = $filter ? (array) $filter : null; $this->fetchDepth = $fetchDepth; $this->ignoreUntranslated = $ignoreUntranslated; - $this->cascade = $cascade; + $this->cascade = (array) $cascade; } } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Reference.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Reference.php index 64fd52a56..478a4e89e 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Reference.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Reference.php @@ -14,11 +14,11 @@ public function __construct( string $property = null, string $targetDocument = null, string $strategy = 'weak', - array $cascade = [] + array|string $cascade = [] ) { $this->property = $property; $this->targetDocument = $targetDocument; $this->strategy = $strategy; - $this->cascade = $cascade; + $this->cascade = (array) $cascade; } } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Referrers.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Referrers.php index dd7a0c1ea..311d53ef4 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Referrers.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Referrers.php @@ -15,10 +15,10 @@ final class Referrers extends BaseReferrers implements MappingAttribute public function __construct( string $referencedBy, string $referringDocument, - array $cascade = [] + array|string $cascade = [] ) { $this->referencedBy = $referencedBy; $this->referringDocument = $referringDocument; - $this->cascade = $cascade; + $this->cascade = (array) $cascade; } } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Driver/BuiltinDocumentsDriver.php b/lib/Doctrine/ODM/PHPCR/Mapping/Driver/BuiltinDocumentsDriver.php index 85630e53d..b25be99e1 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Driver/BuiltinDocumentsDriver.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Driver/BuiltinDocumentsDriver.php @@ -2,7 +2,6 @@ namespace Doctrine\ODM\PHPCR\Mapping\Driver; -use Doctrine\Common\Annotations\AnnotationReader; use Doctrine\Persistence\Mapping\ClassMetadata; use Doctrine\Persistence\Mapping\Driver\MappingDriver; @@ -24,27 +23,17 @@ class BuiltinDocumentsDriver implements MappingDriver */ const NAME_SPACE = 'Doctrine\ODM\PHPCR\Document'; - /** - * @var MappingDriver - */ - private $wrappedDriver; - - /** - * @var AnnotationDriver - */ - private $builtinDriver; + private MappingDriver $wrappedDriver; + private AttributeDriver $builtinDriver; /** * Create with a driver to wrap - * - * @param MappingDriver $nestedDriver */ public function __construct(MappingDriver $wrappedDriver) { $this->wrappedDriver = $wrappedDriver; - $reader = new AnnotationReader(); - $this->builtinDriver = new AnnotationDriver($reader, [realpath(__DIR__.'/../../Document')]); + $this->builtinDriver = new AttributeDriver([realpath(__DIR__.'/../../Document')]); } /** @@ -52,7 +41,7 @@ public function __construct(MappingDriver $wrappedDriver) */ public function loadMetadataForClass($className, ClassMetadata $class) { - if (0 === strpos($className, self::NAME_SPACE)) { + if (str_starts_with($className, self::NAME_SPACE)) { $this->builtinDriver->loadMetadataForClass($className, $class); return; From ba5abaf8f83a326f7825eabe7900d9a6d8234bfe Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Sun, 3 Dec 2023 12:02:36 +0100 Subject: [PATCH 10/14] convert tests to use attributes instead of annotations --- .../ODM/PHPCR/Document/AbstractFile.php | 16 +-- lib/Doctrine/ODM/PHPCR/Document/File.php | 6 +- lib/Doctrine/ODM/PHPCR/Document/Folder.php | 8 +- lib/Doctrine/ODM/PHPCR/Document/Generic.php | 16 +-- lib/Doctrine/ODM/PHPCR/Document/Resource.php | 22 +-- .../ODM/PHPCR/Functional/BasicCrudTest.php | 90 +++++-------- .../PHPCR/Functional/DocumentManagerTest.php | 14 +- .../Functional/EventObjectUpdateTest.php | 12 +- .../Tests/ODM/PHPCR/Functional/FileTest.php | 14 +- .../Functional/FindTypeValidationTest.php | 26 ++-- .../ODM/PHPCR/Functional/FixPHPCR1Test.php | 12 +- .../PHPCR/Functional/Hierarchy/ChildTest.php | 46 +++---- .../Functional/Hierarchy/ChildrenTest.php | 58 +++----- .../PHPCR/Functional/Hierarchy/ParentTest.php | 24 ++-- .../Tests/ODM/PHPCR/Functional/MixinTest.php | 11 +- .../ODM/PHPCR/Functional/PropertyNameTest.php | 14 +- .../ODM/PHPCR/Functional/PropertyTest.php | 32 +++-- .../Functional/ProtectedPropertyTest.php | 30 ++--- .../Tests/ODM/PHPCR/Functional/ProxyTest.php | 30 ++--- .../ODM/PHPCR/Functional/QuerySql2Test.php | 14 +- .../ODM/PHPCR/Functional/ReferenceTest.php | 18 +-- .../ODM/PHPCR/Functional/ReferrerTest.php | 127 +++++++----------- .../PHPCR/Functional/TargetDocumentTest.php | 22 ++- .../Translation/TranslationHierarchyTest.php | 30 ++--- .../Versioning/FullVersioningTest.php | 20 ++- .../Versioning/SimpleVersioningTest.php | 20 ++- .../Versioning/VersioningTestAbstract.php | 12 +- 27 files changed, 312 insertions(+), 432 deletions(-) diff --git a/lib/Doctrine/ODM/PHPCR/Document/AbstractFile.php b/lib/Doctrine/ODM/PHPCR/Document/AbstractFile.php index c12d454ec..d9da4a959 100644 --- a/lib/Doctrine/ODM/PHPCR/Document/AbstractFile.php +++ b/lib/Doctrine/ODM/PHPCR/Document/AbstractFile.php @@ -20,30 +20,30 @@ namespace Doctrine\ODM\PHPCR\Document; use Doctrine\ODM\PHPCR\HierarchyInterface; -use Doctrine\ODM\PHPCR\Mapping\Attributes as ODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; /** * This class represents an abstract "file" */ -#[ODM\MappedSuperclass(mixins: ['mix:created'])] +#[PHPCR\MappedSuperclass(mixins: ['mix:created'])] abstract class AbstractFile implements HierarchyInterface { - #[ODM\Id(strategy: 'parent')] + #[PHPCR\Id(strategy: 'parent')] protected $id; - #[ODM\Node] + #[PHPCR\Node] protected $node; - #[ODM\Nodename] + #[PHPCR\Nodename] protected $nodename; - #[ODM\ParentDocument] + #[PHPCR\ParentDocument] protected $parent; - #[ODM\Field(property: 'jcr:created', type: 'date')] + #[PHPCR\Field(property: 'jcr:created', type: 'date')] protected $created; - #[ODM\Field(property: 'jcr:createdBy', type: 'string')] + #[PHPCR\Field(property: 'jcr:createdBy', type: 'string')] protected $createdBy; /** diff --git a/lib/Doctrine/ODM/PHPCR/Document/File.php b/lib/Doctrine/ODM/PHPCR/Document/File.php index 51c38a9b0..2620c3948 100644 --- a/lib/Doctrine/ODM/PHPCR/Document/File.php +++ b/lib/Doctrine/ODM/PHPCR/Document/File.php @@ -20,20 +20,20 @@ namespace Doctrine\ODM\PHPCR\Document; use Doctrine\ODM\PHPCR\Exception\RuntimeException; -use Doctrine\ODM\PHPCR\Mapping\Attributes as ODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; /** * This class represents a JCR file, aka nt:file. * * @see http://wiki.apache.org/jackrabbit/nt:file */ -#[ODM\Document(nodeType: 'nt:file', mixins: [], referenceable: true)] +#[PHPCR\Document(nodeType: 'nt:file', mixins: [], referenceable: true)] class File extends AbstractFile { /** * @var Resource */ - #[ODM\Child(nodeName: 'jcr:content', cascade: 'all')] + #[PHPCR\Child(nodeName: 'jcr:content', cascade: 'all')] protected $content; /** diff --git a/lib/Doctrine/ODM/PHPCR/Document/Folder.php b/lib/Doctrine/ODM/PHPCR/Document/Folder.php index cfe0e3ca8..7bf935ce8 100644 --- a/lib/Doctrine/ODM/PHPCR/Document/Folder.php +++ b/lib/Doctrine/ODM/PHPCR/Document/Folder.php @@ -22,7 +22,7 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ODM\PHPCR\HierarchyInterface; -use Doctrine\ODM\PHPCR\Mapping\Attributes as ODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; /** * This class represents a Folder in the repository, aka nt:folder @@ -32,19 +32,19 @@ * To add files or folders to a folder, create the new File/Folder and set * this document as parent, then persist the new File/Folder. */ -#[ODM\Document(nodeType: 'nt:folder', mixins: [])] +#[PHPCR\Document(nodeType: 'nt:folder', mixins: [])] class Folder extends AbstractFile { /** * @var ArrayCollection */ - #[ODM\Children(cascade: 'all')] + #[PHPCR\Children(cascade: 'all')] protected $children; /** * @var AbstractFile */ - #[ODM\Child(cascade: 'all')] + #[PHPCR\Child(cascade: 'all')] protected $child; /** diff --git a/lib/Doctrine/ODM/PHPCR/Document/Generic.php b/lib/Doctrine/ODM/PHPCR/Document/Generic.php index 84fa010e8..9cb13eaad 100644 --- a/lib/Doctrine/ODM/PHPCR/Document/Generic.php +++ b/lib/Doctrine/ODM/PHPCR/Document/Generic.php @@ -21,7 +21,7 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; -use Doctrine\ODM\PHPCR\Mapping\Attributes as ODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; use PHPCR\NodeInterface; /** @@ -30,31 +30,31 @@ * 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. */ -#[ODM\Document] +#[PHPCR\Document] class Generic { - #[ODM\Id(strategy: 'parent')] + #[PHPCR\Id(strategy: 'parent')] protected $id; - #[ODM\Node] + #[PHPCR\Node] protected $node; - #[ODM\Nodename] + #[PHPCR\Nodename] protected $nodename; - #[ODM\ParentDocument] + #[PHPCR\ParentDocument] protected $parent; /** * @var Collection */ - #[ODM\Children] + #[PHPCR\Children] protected $children; /** * @var Collection */ - #[ODM\MixedReferrers] + #[PHPCR\MixedReferrers] protected $referrers; /** diff --git a/lib/Doctrine/ODM/PHPCR/Document/Resource.php b/lib/Doctrine/ODM/PHPCR/Document/Resource.php index f96726930..21e74784e 100644 --- a/lib/Doctrine/ODM/PHPCR/Document/Resource.php +++ b/lib/Doctrine/ODM/PHPCR/Document/Resource.php @@ -20,7 +20,7 @@ namespace Doctrine\ODM\PHPCR\Document; use Doctrine\ODM\PHPCR\Exception\BadMethodCallException; -use Doctrine\ODM\PHPCR\Mapping\Attributes as ODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; use PHPCR\NodeInterface; /** @@ -28,37 +28,37 @@ * * @see http://wiki.apache.org/jackrabbit/nt:resource */ -#[ODM\Document(nodeType: 'nt:resource')] +#[PHPCR\Document(nodeType: 'nt:resource')] class Resource { - #[ODM\Id] + #[PHPCR\Id] protected $id; /** * @var NodeInterface */ - #[ODM\Node] + #[PHPCR\Node] protected $node; - #[ODM\Nodename] + #[PHPCR\Nodename] protected $nodename; - #[ODM\ParentDocument] + #[PHPCR\ParentDocument] protected $parent; - #[ODM\Field(property: 'jcr:data', type: 'binary')] + #[PHPCR\Field(property: 'jcr:data', type: 'binary')] protected $data; - #[ODM\Field(property: 'jcr:mimeType', type: 'string')] + #[PHPCR\Field(property: 'jcr:mimeType', type: 'string')] protected $mimeType = 'application/octet-stream'; - #[ODM\Field(property: 'jcr:encoding', type: 'string', nullable: true)] + #[PHPCR\Field(property: 'jcr:encoding', type: 'string', nullable: true)] protected $encoding; - #[ODM\Field(property: 'jcr:lastModified', type: 'date')] + #[PHPCR\Field(property: 'jcr:lastModified', type: 'date')] protected $lastModified; - #[ODM\Field(property: 'jcr:lastModifiedBy', type: 'string')] + #[PHPCR\Field(property: 'jcr:lastModifiedBy', type: 'string')] protected $lastModifiedBy; /** diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/BasicCrudTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/BasicCrudTest.php index 9152398fe..805f520c5 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/BasicCrudTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/BasicCrudTest.php @@ -8,7 +8,7 @@ use Doctrine\ODM\PHPCR\Exception\RuntimeException; use Doctrine\ODM\PHPCR\Id\IdException; use Doctrine\ODM\PHPCR\Id\RepositoryIdInterface; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; use Doctrine\Tests\ODM\PHPCR\PHPCRFunctionalTestCase; use PHPCR\NodeInterface; use PHPCR\PropertyType; @@ -660,81 +660,71 @@ public function testChangeset(): void } } -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class User { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Node */ + #[PHPCR\Node] public $node; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $username; - /** @PHPCRODM\Field(type="string", nullable=true) */ + #[PHPCR\Field(type: 'string', nullable: true)] public $note; - /** @PHPCRODM\Field(type="long", multivalue=true, nullable=true) */ + #[PHPCR\Field(type: 'long', multivalue: true, nullable: true)] public $numbers; - /** @PHPCRODM\Field(type="string", assoc="", nullable=true) */ + #[PHPCR\Field(type: 'string', assoc: '', nullable: true)] public $parameters; - /** @PHPCRODM\Field(type="long", assoc="", nullable=true) */ + #[PHPCR\Field(type: 'long', assoc: '', nullable: true)] public $assocNumbers; } -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class User2 { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $username; } -/** - * @PHPCRODM\Document(repositoryClass="Doctrine\Tests\ODM\PHPCR\Functional\User3Repository") - */ +#[PHPCR\Document(repositoryClass: User3Repository::class)] class User3 { - /** @PHPCRODM\Id(strategy="repository") */ + #[PHPCR\Id(strategy: 'repository')] public $id; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $username; } -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class User5 { - /** @PHPCRODM\Nodename */ + #[PHPCR\Nodename] public $nodename; - /** @PHPCRODM\ParentDocument */ + #[PHPCR\ParentDocument] public $parent; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $username; - /** @PHPCRODM\Field(type="long", multivalue=true, nullable=true) */ + #[PHPCR\Field(type: 'long', multivalue: true, nullable: true)] public $numbers; } -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class User6 extends User5 { - /** @PHPCRODM\Id(strategy="auto") */ + #[PHPCR\Id(strategy: 'auto')] public $id; } @@ -753,56 +743,48 @@ public function generateId($document, $parent = null) } } -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class TeamUser extends User { - /** @PHPCRODM\ParentDocument */ + #[PHPCR\ParentDocument] public $parent; } -/** - * @PHPCRODM\Document(versionable="full") - */ +#[PHPCR\Document(versionable: 'full')] class VersionTestObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Node */ + #[PHPCR\Node] public $node; - /** @PHPCRODM\VersionName */ + #[PHPCR\VersionName] public $versionName; - /** @PHPCRODM\VersionCreated */ + #[PHPCR\VersionCreated] public $versionCreated; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $username; - /** @PHPCRODM\Field(type="long", multivalue=true, nullable=true) */ + #[PHPCR\Field(type: 'long', multivalue: true, nullable: true)] public $numbers; } -/** - * @PHPCRODM\Document(referenceable=true) - */ +#[PHPCR\Document(referenceable: true)] class UserWithUuid extends User { - /** @PHPCRODM\Uuid */ + #[PHPCR\Uuid] public $uuid; } -/** - * @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/Functional/DocumentManagerTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/DocumentManagerTest.php index 6449f19cb..ba57cc6ab 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/DocumentManagerTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/DocumentManagerTest.php @@ -3,7 +3,7 @@ namespace Doctrine\Tests\ODM\PHPCR\Functional; use Doctrine\ODM\PHPCR\DocumentManager; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; use Doctrine\Tests\ODM\PHPCR\PHPCRFunctionalTestCase; use PHPCR\Util\UUIDHelper; @@ -43,20 +43,18 @@ public function testFindManyWithNonExistingUuuid(): void } } -/** - * @PHPCRODM\Document(referenceable=true) - */ +#[PHPCR\Document(referenceable: true)] class TestUser { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Node */ + #[PHPCR\Node] public $node; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $username; - /** @PHPCRODM\Uuid */ + #[PHPCR\Uuid] public $uuid; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/EventObjectUpdateTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/EventObjectUpdateTest.php index 8825a93cb..9ecf6afd0 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/EventObjectUpdateTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/EventObjectUpdateTest.php @@ -4,7 +4,7 @@ use Doctrine\ODM\PHPCR\DocumentManager; use Doctrine\ODM\PHPCR\Event; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; use Doctrine\Persistence\Event\LifecycleEventArgs; use Doctrine\Tests\ODM\PHPCR\PHPCRFunctionalTestCase; @@ -90,18 +90,16 @@ public function testComputingBetweenEvents(): void } } -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class SomeEntity { - /** @PHPCRODM\Id() */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Field(type="string", nullable=true) */ + #[PHPCR\Field(type: 'string', nullable: true)] public $status; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $text; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/FileTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/FileTest.php index 74799fa4b..a28b7d791 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/FileTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/FileTest.php @@ -4,7 +4,7 @@ use Doctrine\ODM\PHPCR\Document\File; use Doctrine\ODM\PHPCR\DocumentManager; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; use Doctrine\Tests\ODM\PHPCR\PHPCRFunctionalTestCase; use PHPCR\NodeInterface; @@ -83,23 +83,21 @@ public function testCreatedDate(): void } } -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class FileTestObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Node */ + #[PHPCR\Node] public $node; - /** @PHPCRODM\Field(type="string", nullable=true) */ + #[PHPCR\Field(type: 'string', nullable: true)] public $name; /** * @var File - * @PHPCRODM\Child */ + #[PHPCR\Child] public $file; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/FindTypeValidationTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/FindTypeValidationTest.php index ae2330b63..f6b7a0f9c 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/FindTypeValidationTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/FindTypeValidationTest.php @@ -3,7 +3,7 @@ namespace Doctrine\Tests\ODM\PHPCR\Functional; use Doctrine\ODM\PHPCR\DocumentManager; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; use Doctrine\Tests\ODM\PHPCR\PHPCRFunctionalTestCase; use PHPCR\NodeInterface; use PHPCR\PropertyType; @@ -135,38 +135,34 @@ public function testManyNotInstanceOf(): void } } -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class TypeUser { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Node */ + #[PHPCR\Node] public $node; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $username; - /** @PHPCRODM\Field(type="string", nullable=true) */ + #[PHPCR\Field(type: 'string', nullable: true)] public $note; - /** @PHPCRODM\Field(type="long", multivalue=true, nullable=true) */ + #[PHPCR\Field(type: 'long', multivalue: true, nullable: true)] public $numbers; - /** @PHPCRODM\Field(type="string", assoc="", nullable=true) */ + #[PHPCR\Field(type: 'string', assoc: '', nullable: true)] public $parameters; - /** @PHPCRODM\Field(type="long", assoc="", nullable=true) */ + #[PHPCR\Field(type: 'long', assoc: '', nullable: true)] public $assocNumbers; } -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class TypeTeamUser extends TypeUser { - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $name; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/FixPHPCR1Test.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/FixPHPCR1Test.php index 467819cb4..9f5556b67 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/FixPHPCR1Test.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/FixPHPCR1Test.php @@ -4,7 +4,7 @@ use Doctrine\ODM\PHPCR\Document\File; use Doctrine\ODM\PHPCR\DocumentManager; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; use Doctrine\Tests\ODM\PHPCR\PHPCRFunctionalTestCase; use PHPCR\NodeInterface; @@ -47,17 +47,15 @@ public function testCreateFromFile(): void } } -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class FixPHPCR1TestObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Node */ + #[PHPCR\Node] public $node; - /** @PHPCRODM\Child(cascade="persist") */ + #[PHPCR\Child(cascade: 'persist')] public $file; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/Hierarchy/ChildTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Hierarchy/ChildTest.php index b20c9a306..ece4f1f0c 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/Hierarchy/ChildTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Hierarchy/ChildTest.php @@ -5,7 +5,7 @@ use Doctrine\Common\Proxy\Proxy; use Doctrine\ODM\PHPCR\DocumentManager; use Doctrine\ODM\PHPCR\Id\IdException; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; use Doctrine\ODM\PHPCR\PHPCRException; use Doctrine\Tests\ODM\PHPCR\PHPCRFunctionalTestCase; use PHPCR\NodeInterface; @@ -439,68 +439,60 @@ public function testChildOfReference(): void } } -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class ChildChildTestObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Node */ + #[PHPCR\Node] public $node; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $name; - /** @PHPCRODM\Nodename */ + #[PHPCR\Nodename] public $nodename; } -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class ChildTestObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Node */ + #[PHPCR\Node] public $node; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $name; - /** @PHPCRODM\Child(nodeName="test", cascade="persist") */ + #[PHPCR\Child(nodeName: 'test', cascade: 'persist')] public $child; } -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class ChildReferrerTestObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $name; - /** @PHPCRODM\ReferenceOne(targetDocument="ChildReferenceableTestObj", cascade="persist") */ + #[PHPCR\ReferenceOne(targetDocument: ChildReferenceableTestObj::class, cascade: 'persist')] public $reference; } -/** - * @PHPCRODM\Document(referenceable=true) - */ +#[PHPCR\Document(referenceable: true)] class ChildReferenceableTestObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $name; - /** @PHPCRODM\Child(nodeName="test", cascade="persist") */ + #[PHPCR\Child(nodeName: 'test', cascade: 'persist')] public $aChild; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/Hierarchy/ChildrenTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Hierarchy/ChildrenTest.php index 773846b60..fc1359686 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/Hierarchy/ChildrenTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Hierarchy/ChildrenTest.php @@ -7,7 +7,7 @@ use Doctrine\ODM\PHPCR\DocumentManager; use Doctrine\ODM\PHPCR\DocumentRepository; use Doctrine\ODM\PHPCR\Id\RepositoryIdInterface; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCR; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; use Doctrine\ODM\PHPCR\PHPCRException; use Doctrine\Persistence\Event\LifecycleEventArgs; use Doctrine\Tests\ODM\PHPCR\PHPCRFunctionalTestCase; @@ -696,9 +696,7 @@ public function testMoveByUpdateId(): void } } -/** - * @PHPCR\Document(repositoryClass="Doctrine\Tests\ODM\PHPCR\Functional\Hierarchy\ChildrenTestObjRepository") - */ +#[PHPCR\Document(repositoryClass: ChildrenTestObjRepository::class)] class ChildrenTestObj { public function __construct() @@ -707,19 +705,19 @@ public function __construct() $this->allChildren = new ArrayCollection(); } - /** @PHPCR\Id(strategy="repository") */ + #[PHPCR\Id(strategy: 'repository')] public $id; - /** @PHPCR\Field(type="string", nullable=true) */ + #[PHPCR\Field(type: 'string', nullable: true)] public $name; - /** @PHPCR\Children(filter="*A", fetchDepth=1, cascade="persist") */ + #[PHPCR\Children(filter: '*A', fetchDepth: 1, cascade: 'persist')] public $aChildren; /** * @var ChildrenCollection - * @PHPCR\Children(fetchDepth=2, cascade="persist") */ + #[PHPCR\Children(fetchDepth: 2, cascade: 'persist')] public $allChildren; } @@ -744,66 +742,52 @@ public function generateId($document, $parent = null) } } -/** - * @PHPCR\Document() - */ +#[PHPCR\Document] class ChildrenAutonameTestObj { - /** @PHPCR\Id(strategy="auto") */ + #[PHPCR\Id(strategy: 'auto')] public $id; - /** @PHPCR\ParentDocument() */ + #[PHPCR\ParentDocument] public $parent; } -/** - * @PHPCR\Document() - */ +#[PHPCR\Document] class ChildrenParentAndNameTestObj { - /** - * @PHPCR\ParentDocument - */ + #[PHPCR\ParentDocument] public $parent; - /** - * @PHPCR\Id(strategy="parent") - */ + #[PHPCR\Id(strategy: 'parent')] public $id; - /** - * @PHPCR\Nodename - */ + #[PHPCR\Nodename] public $name; } -/** - * @PHPCR\Document() - */ +#[PHPCR\Document] class ChildrenReferrerTestObj { - /** @PHPCR\Id */ + #[PHPCR\Id] public $id; - /** @PHPCR\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $name; - /** @PHPCR\ReferenceOne(targetDocument="ChildrenReferenceableTestObj", cascade="persist") */ + #[PHPCR\ReferenceOne(targetDocument: ChildrenReferenceableTestObj::class, cascade: 'persist')] public $reference; } -/** - * @PHPCR\Document(referenceable=true) - */ +#[PHPCR\Document(referenceable: true)] class ChildrenReferenceableTestObj { - /** @PHPCR\Id */ + #[PHPCR\Id] public $id; - /** @PHPCR\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $name; - /** @PHPCR\Children(cascade="persist") */ + #[PHPCR\Children(cascade: 'persist')] public $allChildren; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/Hierarchy/ParentTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Hierarchy/ParentTest.php index 8249ab00e..721c6a221 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/Hierarchy/ParentTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Hierarchy/ParentTest.php @@ -6,7 +6,7 @@ use Doctrine\ODM\PHPCR\Document\Generic; use Doctrine\ODM\PHPCR\DocumentManager; use Doctrine\ODM\PHPCR\Id\IdException; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; use Doctrine\ODM\PHPCR\PHPCRException; use Doctrine\Tests\ODM\PHPCR\PHPCRFunctionalTestCase; use PHPCR\NodeInterface; @@ -272,35 +272,31 @@ public function testIllegalNameManagedChild(): void } } -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class NameDoc { - /** @PHPCRODM\ParentDocument */ + #[PHPCR\ParentDocument] public $parent; - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Node */ + #[PHPCR\Node] public $node; - /** @PHPCRODM\Nodename */ + #[PHPCR\Nodename] public $nodename; - /** @PHPCRODM\Children(cascade="persist") */ + #[PHPCR\Children(cascade: 'persist')] public $children; - /** @PHPCRODM\Child(cascade="persist") */ + #[PHPCR\Child(cascade: 'persist')] public $child; } -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class NameDocWithRef extends NameDoc { - /** @PHPCRODM\ReferenceOne(cascade="persist") */ + #[PHPCR\ReferenceOne(cascade: 'persist')] public $ref; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/MixinTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/MixinTest.php index 0d2e201fe..15a09f0d7 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/MixinTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/MixinTest.php @@ -3,7 +3,7 @@ namespace Doctrine\Tests\ODM\PHPCR\Functional; use Doctrine\ODM\PHPCR\DocumentManager; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; use Doctrine\Tests\ODM\PHPCR\Mapping\Model\MixinMappingObject; use Doctrine\Tests\ODM\PHPCR\PHPCRFunctionalTestCase; use PHPCR\NodeInterface; @@ -118,17 +118,16 @@ public function testChangingProtectedPropertyToNullThrowsException(): void /** * A class that contains mapped children via properties - * - * @PHPCRODM\Document(mixins={"mix:created"}) */ +#[PHPCR\Document(mixins: ['mix:created'])] class TestObject { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Field(type="date", property="jcr:created") */ + #[PHPCR\Field(property: 'jcr:created', type: 'date')] public $created; - /** @PHPCRODM\Field(type="string", property="change_me") */ + #[PHPCR\Field(property: 'change_me', type: 'string')] public $changeMe; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/PropertyNameTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/PropertyNameTest.php index b30ca7bf9..4853e16d6 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/PropertyNameTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/PropertyNameTest.php @@ -3,7 +3,7 @@ namespace Doctrine\Tests\ODM\PHPCR\Functional; use Doctrine\ODM\PHPCR\DocumentManager; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; use Doctrine\Tests\ODM\PHPCR\PHPCRFunctionalTestCase; use PHPCR\NodeInterface; @@ -57,20 +57,18 @@ public function testPropertyname(): void } } -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class TestObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Node */ + #[PHPCR\Node] public $node; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $name; - /** @PHPCRODM\Field(type="string", property="myname") */ + #[PHPCR\Field(property: 'myname', type: 'string')] public $othername; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/PropertyTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/PropertyTest.php index 234213805..66745c95b 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/PropertyTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/PropertyTest.php @@ -3,7 +3,7 @@ namespace Doctrine\Tests\ODM\PHPCR\Functional; use Doctrine\ODM\PHPCR\DocumentManager; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; use Doctrine\Tests\ODM\PHPCR\PHPCRFunctionalTestCase; use PHPCR\NodeInterface; use PHPCR\PropertyType; @@ -116,49 +116,47 @@ public function testPropertyname(): void } } -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class PropertyTestObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Node */ + #[PHPCR\Node] public $node; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $string; //binary tested in its own test - /** @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/Functional/ProtectedPropertyTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/ProtectedPropertyTest.php index 184e56749..39b2382fd 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/ProtectedPropertyTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/ProtectedPropertyTest.php @@ -3,7 +3,7 @@ namespace Doctrine\Tests\ODM\PHPCR\Functional; use Doctrine\ODM\PHPCR\DocumentManager; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; use Doctrine\Tests\ODM\PHPCR\PHPCRFunctionalTestCase; use Jackalope\Session; use PHPCR\NodeType\ConstraintViolationException; @@ -105,44 +105,40 @@ public function testModificationWithProtectedProperty(): void } } -/** - * @PHPCRODM\Document(nodeType="test:protected_property_test") - */ +#[PHPCR\Document(nodeType: 'test:protected_property_test')] class ProtectedPropertyTestObj { - /** @PHPCRODM\Id() */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\ReferenceOne(strategy="hard") */ + #[PHPCR\ReferenceOne(strategy: 'hard')] public $reference; - /** @PHPCRODM\Field(type="date", property="jcr:created") */ + #[PHPCR\Field(property: 'jcr:created', type: 'date')] public $created; - /** @PHPCRODM\Field(type="string", property="jcr:createdBy") */ + #[PHPCR\Field(property: 'jcr:createdBy', type: 'string')] public $createdBy; - /** @PHPCRODM\Field(type="string", nullable=true) */ + #[PHPCR\Field(type: 'string', nullable: true)] public $changeme; } -/** - * @PHPCRODM\Document(nodeType="test:protected_property_test2") - */ +#[PHPCR\Document(nodeType: 'test:proctected_property_test2')] class ProtectedPropertyTestObj2 { - /** @PHPCRODM\Id() */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\ReferenceOne(strategy="hard") */ + #[PHPCR\ReferenceOne(strategy: 'hard')] public $reference; - /** @PHPCRODM\ReferenceOne(strategy="hard") */ + #[PHPCR\ReferenceOne(strategy: 'hard')] public $reference2; - /** @PHPCRODM\Field(type="date", property="jcr:created") */ + #[PHPCR\Field(property: 'jcr:created', type: 'date')] public $created; - /** @PHPCRODM\Field(type="string", property="jcr:createdBy") */ + #[PHPCR\Field(property: 'jcr:createdBy', type: 'string')] public $createdBy; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/ProxyTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/ProxyTest.php index 9d285ade6..8fa1fa518 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/ProxyTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/ProxyTest.php @@ -4,7 +4,7 @@ use Doctrine\Common\Proxy\Proxy; use Doctrine\ODM\PHPCR\DocumentManager; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\ODM\PHPCR\PHPCRFunctionalTestCase; @@ -152,44 +152,38 @@ public function testProxyAwakesOnNodeName(): void } } -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class ParentDoc { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Children(cascade="persist") */ + #[PHPCR\Children(cascade: 'persist')] public $children; } -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class DocWithoutId { - /** @PHPCRODM\ParentDocument */ + #[PHPCR\ParentDocument] public $parent; - /** @PHPCRODM\Nodename */ + #[PHPCR\Nodename] public $nodename; } -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class ChildWithFields { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\ParentDocument */ + #[PHPCR\ParentDocument] public $parent; - /** @PHPCRODM\Nodename */ + #[PHPCR\Nodename] public $nodename; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $title; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/QuerySql2Test.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/QuerySql2Test.php index 40421f81f..5584ba332 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/QuerySql2Test.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/QuerySql2Test.php @@ -3,7 +3,7 @@ namespace Doctrine\Tests\ODM\PHPCR\Functional; use Doctrine\ODM\PHPCR\DocumentManager; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; use Doctrine\ODM\PHPCR\Query\Query; use Doctrine\Tests\ODM\PHPCR\PHPCRFunctionalTestCase; use PHPCR\NodeInterface; @@ -142,20 +142,18 @@ public function testQueryLimit(): void } } -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class QuerySql2TestObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Node */ + #[PHPCR\Node] public $node; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $username; - /** @PHPCRODM\Field(type="long", multivalue=true) */ + #[PHPCR\Field(type: 'long', multivalue: true)] public $numbers; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/ReferenceTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/ReferenceTest.php index d897dc3ca..525a915a6 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/ReferenceTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/ReferenceTest.php @@ -3,7 +3,7 @@ namespace Doctrine\Tests\ODM\PHPCR\Functional; use Doctrine\ODM\PHPCR\DocumentManager; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; use Doctrine\ODM\PHPCR\PHPCRException; use Doctrine\Tests\Models\References\HardRefTestObj; use Doctrine\Tests\Models\References\NonRefTestObj; @@ -1351,26 +1351,22 @@ public function testCascadeRemoveByCollection(): void } } -/** - * @PHPCRODM\Document(referenceable=true) - */ +#[PHPCR\Document(referenceable: true)] class ReferenceRefTestObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Referrers(referringDocument="ReferenceTestObj", referencedBy="reference", cascade={"persist"}) */ + #[PHPCR\Referrers(referencedBy: 'reference', referringDocument: ReferenceTestObj::class, cascade: 'persist')] public $referrers; } -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class ReferenceTestObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\ReferenceMany(targetDocument="ReferenceRefTestObj", cascade={"persist", "remove"}) */ + #[PHPCR\ReferenceMany(targetDocument: ReferenceRefTestObj::class, cascade: ['persist', 'remove'])] public $reference; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/ReferrerTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/ReferrerTest.php index ae630683b..3fbbb41f8 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/ReferrerTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/ReferrerTest.php @@ -3,7 +3,7 @@ namespace Doctrine\Tests\ODM\PHPCR\Functional; use Doctrine\ODM\PHPCR\DocumentManager; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; use Doctrine\ODM\PHPCR\Translation\LocaleChooser\LocaleChooser; use Doctrine\ODM\PHPCR\Translation\TranslationStrategy\AttributeTranslationStrategy; use Doctrine\Tests\ODM\PHPCR\PHPCRFunctionalTestCase; @@ -636,192 +636,165 @@ public function testCascadeRemoveByCollection(): void } } -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class HardReferrerTestObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\ReferenceOne(targetDocument="HardReferrerRefTestObj", strategy="hard") */ + #[PHPCR\ReferenceOne(targetDocument: HardReferrerRefTestObj::class, strategy: 'hard')] public $referenceToHard; - /** @PHPCRODM\ReferenceOne(targetDocument="WeakReferrerRefTestObj", strategy="hard") */ + #[PHPCR\ReferenceOne(targetDocument: WeakReferrerRefTestObj::class, strategy: 'hard')] public $referenceToWeak; - /** @PHPCRODM\ReferenceOne(targetDocument="AllReferrerRefTestObj", strategy="hard") */ + #[PHPCR\ReferenceOne(targetDocument: AllReferrerRefTestObj::class, strategy: 'hard')] public $referenceToAll; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $name; } -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class WeakReferrerTestObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; /** * Should implicitly default to strategy="weak" - * - * @PHPCRODM\ReferenceOne(targetDocument="WeakReferrerRefTestObj", cascade="persist") */ + #[PHPCR\ReferenceOne(targetDocument: WeakReferrerRefTestObj::class, cascade: 'persist')] public $referenceToWeak; - /** @PHPCRODM\ReferenceOne(targetDocument="HardReferrerRefTestObj", strategy="weak", cascade="persist") */ + #[PHPCR\ReferenceOne(targetDocument: HardReferrerRefTestObj::class, strategy: 'weak', cascade: 'persist')] public $referenceToHard; - /** @PHPCRODM\ReferenceOne(targetDocument="AllReferrerRefTestObj", strategy="weak", cascade="persist") */ + #[PHPCR\ReferenceOne(targetDocument: AllReferrerRefTestObj::class, strategy: 'weak', cascade: 'persist')] public $referenceToAll; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $name; } -/** - * @PHPCRODM\Document(referenceable=true) - */ +#[PHPCR\Document(referenceable: true)] class WeakReferrerRefTestObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\MixedReferrers(referenceType="weak") */ + #[PHPCR\MixedReferrers(referenceType: 'weak')] public $referrers; } -/** - * @PHPCRODM\Document(referenceable=true) - */ +#[PHPCR\Document(referenceable: true)] class HardReferrerRefTestObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\MixedReferrers(referenceType="hard") */ + #[PHPCR\MixedReferrers(referenceType: 'hard')] public $referrers; } -/** - * @PHPCRODM\Document(referenceable=true) - */ +#[PHPCR\Document(referenceable: true)] class AllReferrerRefTestObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\MixedReferrers() */ + #[PHPCR\MixedReferrers] public $referrers; } -/** - * @PHPCRODM\Document(referenceable=true) - */ +#[PHPCR\Document(referenceable: true)] class AllReferrerRefNamedPropTestObj extends ReferrerRefTestObj { - /** @PHPCRODM\Referrers(referencedBy="namedReference",referringDocument="ReferrerNamedPropTestObj") */ + #[PHPCR\Referrers(referencedBy: 'namedReference', referringDocument: ReferrerNamedPropTestObj::class)] public $referrers; } -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class ReferrerTestObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $name; - /** @PHPCRODM\ReferenceOne(targetDocument="ReferrerRefTestObj", cascade="persist") */ + #[PHPCR\ReferenceOne(targetDocument: ReferrerRefTestObj::class, cascade: 'persist')] public $reference; } -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class OtherReferrerTestObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $name; - /** @PHPCRODM\ReferenceOne(targetDocument="ReferrerRefTestObj", property="named-reference", cascade="persist") */ + #[PHPCR\ReferenceOne(targetDocument: ReferrerRefTestObj::class, property: 'named-reference', cascade: 'persist')] public $namedReference; } -/** - * @PHPCRODM\Document(translator="attribute") - */ +#[PHPCR\Document(translator: 'attribute')] class ReferrerTestObjMultilang { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Field(type="string", translated=true) */ + #[PHPCR\Field(type: 'string', translated: true)] public $name; - /** @PHPCRODM\ReferenceOne(targetDocument="ReferrerRefTestObj", cascade="persist") */ + #[PHPCR\ReferenceOne(targetDocument: ReferrerRefTestObj::class, cascade: 'persist')] public $reference; - /** @PHPCRODM\Locale */ + #[PHPCR\Locale] protected $locale; } -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class ReferrerNamedPropTestObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $name; - /** @PHPCRODM\ReferenceOne(targetDocument="ReferrerRefTestObj", property="named-reference", cascade="persist") */ + #[PHPCR\ReferenceOne(targetDocument: ReferrerRefTestObj::class, property: 'named-reference', cascade: 'persist')] public $namedReference; } -/** - * @PHPCRODM\Document(referenceable=true) - */ +#[PHPCR\Document(referenceable: true)] class ReferrerRefTestObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\MixedReferrers() */ + #[PHPCR\MixedReferrers] public $referrers; } -/** - * @PHPCRODM\Document(referenceable=true) - */ +#[PHPCR\Document(referenceable: true)] class ReferrerRefTestObj2 { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Referrers(referringDocument="ReferrerTestObj2", referencedBy="reference", cascade={"persist", "remove"}) */ + #[PHPCR\Referrers(referencedBy: 'reference', referringDocument: ReferrerTestObj2::class, cascade: ['persist', 'remove'])] public $referrers; } -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class ReferrerTestObj2 { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\ReferenceOne(targetDocument="ReferrerRefTestObj2", cascade="persist") */ + #[PHPCR\ReferenceOne(targetDocument: ReferrerRefTestObj2::class, cascade: 'persist')] public $reference; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/TargetDocumentTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/TargetDocumentTest.php index be7460f69..6868ac5a6 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/TargetDocumentTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/TargetDocumentTest.php @@ -3,7 +3,7 @@ namespace Doctrine\Tests\ODM\PHPCR\Functional; use Doctrine\ODM\PHPCR\DocumentManager; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; use Doctrine\Tests\Models\References\RefType1TestObj; use Doctrine\Tests\Models\References\RefType2TestObj; use Doctrine\Tests\ODM\PHPCR\PHPCRFunctionalTestCase; @@ -82,32 +82,28 @@ public function testReferenceOneDifferentTargetDocuments(): void } } -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class ReferenceManyObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $name; - /** @PHPCRODM\ReferenceMany(cascade="persist") */ + #[PHPCR\ReferenceMany(cascade: 'persist')] public $references; } -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class ReferenceOneObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Field(type="string", nullable=true) */ + #[PHPCR\Field(type: 'string', nullable: true)] public $name; - /** @PHPCRODM\ReferenceOne(cascade="persist") */ + #[PHPCR\ReferenceOne(cascade: 'persist')] public $reference; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/Translation/TranslationHierarchyTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Translation/TranslationHierarchyTest.php index 8cc1bf459..4e814ef90 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/Translation/TranslationHierarchyTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Translation/TranslationHierarchyTest.php @@ -4,7 +4,7 @@ use Doctrine\Common\Proxy\Proxy; use Doctrine\ODM\PHPCR\DocumentManager; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; use Doctrine\ODM\PHPCR\Translation\LocaleChooser\LocaleChooser; use Doctrine\Tests\Models\Translation\Article; use Doctrine\Tests\ODM\PHPCR\PHPCRFunctionalTestCase; @@ -201,44 +201,40 @@ public function testRefreshProxyUsesFallback(): void } } -/** - * @PHPCRODM\Document(translator="child", referenceable=true) - */ +#[PHPCR\Document(translator: 'child', referenceable: true)] class ParentObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Locale */ + #[PHPCR\Locale] public $locale; - /** @PHPCRODM\Nodename */ + #[PHPCR\Nodename] public $name; - /** @PHPCRODM\ParentDocument */ + #[PHPCR\ParentDocument] public $parent; - /** @PHPCRODM\Children(cascade={"all"}) */ + #[PHPCR\Children(cascade: 'all')] public $children; } -/** - * @PHPCRODM\Document(translator="child", referenceable=true) - */ +#[PHPCR\Document(translator: 'child', referenceable: true)] class ChildObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Locale */ + #[PHPCR\Locale] public $locale; - /** @PHPCRODM\Nodename */ + #[PHPCR\Nodename] public $name; - /** @PHPCRODM\ParentDocument */ + #[PHPCR\ParentDocument] public $parent; - /** @PHPCRODM\Field(type="string", translated=true) */ + #[PHPCR\Field(type: 'string', translated: true)] public $text; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/Versioning/FullVersioningTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Versioning/FullVersioningTest.php index 01254d441..8d15eced0 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/Versioning/FullVersioningTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Versioning/FullVersioningTest.php @@ -2,32 +2,30 @@ namespace Doctrine\Tests\ODM\PHPCR\Functional\Versioning; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCRODM\Document(versionable="full") - */ +#[PHPCR\Document(versionable: 'full')] class FullVersionTestObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Node */ + #[PHPCR\Node] public $node; - /** @PHPCRODM\VersionName */ + #[PHPCR\VersionName] public $versionName; - /** @PHPCRODM\VersionCreated */ + #[PHPCR\VersionCreated] public $versionCreated; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $username; - /** @PHPCRODM\Field(type="long", multivalue=true) */ + #[PHPCR\Field(type: 'long', multivalue: true)] public $numbers; - /** @PHPCRODM\ReferenceOne(strategy="weak") */ + #[PHPCR\ReferenceOne(strategy: 'weak')] public $reference; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/Versioning/SimpleVersioningTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Versioning/SimpleVersioningTest.php index 7423de7fb..c39cd0e94 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/Versioning/SimpleVersioningTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Versioning/SimpleVersioningTest.php @@ -2,32 +2,30 @@ namespace Doctrine\Tests\ODM\PHPCR\Functional\Versioning; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCRODM\Document(versionable="simple") - */ +#[PHPCR\Document(versionable: 'simple')] class SimpleVersionTestObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Node */ + #[PHPCR\Node] public $node; - /** @PHPCRODM\VersionName */ + #[PHPCR\VersionName] public $versionName; - /** @PHPCRODM\VersionCreated */ + #[PHPCR\VersionCreated] public $versionCreated; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $username; - /** @PHPCRODM\Field(type="long", multivalue=true) */ + #[PHPCR\Field(type: 'long', multivalue: true)] public $numbers; - /** @PHPCRODM\ReferenceOne(strategy="weak") */ + #[PHPCR\ReferenceOne(strategy: 'weak')] public $reference; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/Versioning/VersioningTestAbstract.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Versioning/VersioningTestAbstract.php index e7594a4c2..1bd3e4e53 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/Versioning/VersioningTestAbstract.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Versioning/VersioningTestAbstract.php @@ -4,7 +4,7 @@ use Doctrine\ODM\PHPCR\DocumentManager; use Doctrine\ODM\PHPCR\Exception\InvalidArgumentException; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; use Doctrine\Tests\Models\Versioning\FullVersionableArticle; use Doctrine\Tests\Models\Versioning\FullVersionableArticleWithChildren; use Doctrine\Tests\Models\Versioning\NonVersionableArticle; @@ -398,17 +398,15 @@ public function testUnversionedChildrenOnParentVersion(): void } } -/** - * @PHPCRODM\Document(referenceable=true) - */ +#[PHPCR\Document(referenceable: true)] class ReferenceTestObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Node */ + #[PHPCR\Node] public $node; - /** @PHPCRODM\Field(type="string", property="username") */ + #[PHPCR\Field(property: 'username', type: 'string')] public $content; } From 4ce52b9de11778db5f024940f955b2096d7622fb Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Sun, 3 Dec 2023 12:13:33 +0100 Subject: [PATCH 11/14] fix test setup --- .../ODM/PHPCR/Mapping/Attributes/Document.php | 12 ++--- .../PHPCR/Mapping/Driver/AttributeDriver.php | 2 +- tests/Doctrine/Tests/Models/Blog/Comment.php | 9 ++-- tests/Doctrine/Tests/Models/Blog/Post.php | 12 ++--- tests/Doctrine/Tests/Models/Blog/User.php | 16 +++---- .../Doctrine/Tests/Models/CMS/CmsAddress.php | 20 ++++---- .../Doctrine/Tests/Models/CMS/CmsArticle.php | 19 ++++---- .../Tests/Models/CMS/CmsArticleFolder.php | 14 ++---- .../Tests/Models/CMS/CmsArticlePerson.php | 12 ++--- .../Tests/Models/CMS/CmsAuditItem.php | 12 ++--- .../Tests/Models/CMS/CmsBlogFolder.php | 18 ++----- .../Tests/Models/CMS/CmsBlogInvalidChild.php | 12 ++--- .../Doctrine/Tests/Models/CMS/CmsBlogPost.php | 12 ++--- tests/Doctrine/Tests/Models/CMS/CmsGroup.php | 12 ++--- tests/Doctrine/Tests/Models/CMS/CmsItem.php | 14 +++--- tests/Doctrine/Tests/Models/CMS/CmsPage.php | 16 +++---- .../Tests/Models/CMS/CmsPageTranslatable.php | 30 ++++-------- .../Doctrine/Tests/Models/CMS/CmsProfile.php | 19 +++----- .../Doctrine/Tests/Models/CMS/CmsTeamUser.php | 14 ++---- tests/Doctrine/Tests/Models/CMS/CmsUser.php | 30 ++++++------ .../Tests/Models/CMS/CmsUserTranslatable.php | 30 ++++++------ .../Models/References/HardRefTestObj.php | 10 ++-- .../Tests/Models/References/NonRefTestObj.php | 8 ++-- .../References/ParentNoNodeNameTestObj.php | 12 ++--- .../Tests/Models/References/ParentTestObj.php | 14 +++--- .../References/ParentWithChildrenTestObj.php | 16 +++---- .../References/RefAnnotationTestObj.php | 8 ++-- .../References/RefCascadeManyTestObj.php | 11 ++--- .../Models/References/RefCascadeTestObj.php | 10 ++-- .../Tests/Models/References/RefDifTestObj.php | 12 ++--- .../Models/References/RefManyTestObj.php | 10 ++-- .../References/RefManyTestObjForCascade.php | 10 ++-- .../References/RefManyTestObjPathStrategy.php | 10 ++-- .../RefManyWithParentTestObjForCascade.php | 10 ++-- .../Tests/Models/References/RefRefTestObj.php | 10 ++-- .../Tests/Models/References/RefTestObj.php | 10 ++-- .../Models/References/RefTestObjByPath.php | 10 ++-- .../Models/References/RefTestPrivateObj.php | 10 ++-- .../Models/References/RefType1TestObj.php | 10 ++-- .../Models/References/RefType2TestObj.php | 10 ++-- .../Tests/Models/References/UuidTestObj.php | 10 ++-- .../References/UuidTestTwoUuidFieldsObj.php | 12 ++--- .../Models/References/WeakRefTestObj.php | 10 ++-- .../Tests/Models/Translation/Article.php | 47 ++++++++----------- .../Translation/ChildTranslationArticle.php | 6 +-- .../Translation/ChildTranslationComment.php | 6 +-- .../Tests/Models/Translation/Comment.php | 20 +++----- .../Tests/Models/Translation/DatedComment.php | 10 ++-- .../Models/Translation/DerivedArticle.php | 6 +-- .../Models/Translation/InvalidMapping.php | 14 ++---- .../Translation/NoLocalePropertyArticle.php | 16 +++---- .../Versioning/ExtendedVersionableArticle.php | 12 ++--- .../Versioning/FullVersionableArticle.php | 18 ++++--- .../FullVersionableArticleWithChildren.php | 10 ++-- .../InconsistentVersionableArticle.php | 15 +++--- .../Versioning/InvalidVersionableArticle.php | 14 +++--- .../Versioning/NonVersionableArticle.php | 14 +++--- .../Models/Versioning/VersionableArticle.php | 14 +++--- .../Mapping/AnnotationMappingTest.php | 3 +- .../Functional/ProtectedPropertyTest.php | 2 +- .../Translation/TranslationHierarchyTest.php | 1 + .../ODM/PHPCR/PHPCRFunctionalTestCase.php | 10 ++-- 62 files changed, 325 insertions(+), 481 deletions(-) diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Document.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Document.php index c900a04f7..ea351cc91 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Document.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Document.php @@ -14,12 +14,12 @@ public function __construct( string $repositoryClass = null, string $translator = null, array $mixins = null, - bool $inheritMixins = true, + bool|null $inheritMixins = null, string $versionable = null, - bool $referenceable = false, - bool $uniqueNodeType = false, - array $childClasses = [], - bool $isLeaf = false, + bool|null $referenceable = null, + bool|null $uniqueNodeType = null, + string|array|null $childClasses = null, + bool|null $isLeaf = null, ) { $this->nodeType = $nodeType; $this->repositoryClass = $repositoryClass; @@ -29,7 +29,7 @@ public function __construct( $this->versionable = $versionable; $this->referenceable = $referenceable; $this->uniqueNodeType = $uniqueNodeType; - $this->childClasses = $childClasses; + $this->childClasses = $childClasses ? (array) $childClasses : null; $this->isLeaf = $isLeaf; } } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Driver/AttributeDriver.php b/lib/Doctrine/ODM/PHPCR/Mapping/Driver/AttributeDriver.php index 587e925fc..b38325cc0 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Driver/AttributeDriver.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Driver/AttributeDriver.php @@ -126,7 +126,7 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad $metadata->setTranslator($documentAttribute->translator); } - if ([] !== $documentAttribute->childClasses) { + if ($documentAttribute->childClasses) { $metadata->setChildClasses($documentAttribute->childClasses); } diff --git a/tests/Doctrine/Tests/Models/Blog/Comment.php b/tests/Doctrine/Tests/Models/Blog/Comment.php index 048c9c95e..634f62fd1 100644 --- a/tests/Doctrine/Tests/Models/Blog/Comment.php +++ b/tests/Doctrine/Tests/Models/Blog/Comment.php @@ -4,20 +4,19 @@ namespace Doctrine\Tests\Models\Blog; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; /** * Comment will be a child of the Post in the test scenario * * Used for Join tests - * - * @PHPCRODM\Document() */ +#[PHPCR\Document] class Comment { - /** @PHPCRODM\Id() */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $title; } diff --git a/tests/Doctrine/Tests/Models/Blog/Post.php b/tests/Doctrine/Tests/Models/Blog/Post.php index 1dad0e175..8b980b604 100644 --- a/tests/Doctrine/Tests/Models/Blog/Post.php +++ b/tests/Doctrine/Tests/Models/Blog/Post.php @@ -4,19 +4,17 @@ namespace Doctrine\Tests\Models\Blog; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class Post { - /** @PHPCRODM\Id() */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $title; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $username; } diff --git a/tests/Doctrine/Tests/Models/Blog/User.php b/tests/Doctrine/Tests/Models/Blog/User.php index 83499357b..887007789 100644 --- a/tests/Doctrine/Tests/Models/Blog/User.php +++ b/tests/Doctrine/Tests/Models/Blog/User.php @@ -4,25 +4,23 @@ namespace Doctrine\Tests\Models\Blog; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class User { - /** @PHPCRODM\Id() */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $username; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $name; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $status; - /** @PHPCRODM\Field(type="long", nullable=true) */ + #[PHPCR\Field(type: 'long', nullable: true)] public $age; } diff --git a/tests/Doctrine/Tests/Models/CMS/CmsAddress.php b/tests/Doctrine/Tests/Models/CMS/CmsAddress.php index 6e3a056b8..eeb866abc 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsAddress.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsAddress.php @@ -6,31 +6,27 @@ use Doctrine\ODM\PHPCR\DocumentRepository; use Doctrine\ODM\PHPCR\Id\RepositoryIdInterface; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCRODM\Document(repositoryClass="Doctrine\Tests\Models\CMS\CmsAddressRepository", referenceable=true) - */ +#[PHPCR\Document(repositoryClass: CmsAddressRepository::class, referenceable: true)] class CmsAddress { - /** @PHPCRODM\Id(strategy="repository") */ + #[PHPCR\Id(strategy: 'repository')] public $id; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $country; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $zip; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $city; - /** @PHPCRODM\ReferenceOne(targetDocument="CmsUser") */ + #[PHPCR\ReferenceOne(targetDocument: CmsUser::class)] public $user; - /** - * @PHPCRODM\Uuid - */ + #[PHPCR\Uuid] public $uuid; public function getId() diff --git a/tests/Doctrine/Tests/Models/CMS/CmsArticle.php b/tests/Doctrine/Tests/Models/CMS/CmsArticle.php index 4badcade8..91c2716da 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsArticle.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsArticle.php @@ -3,31 +3,30 @@ namespace Doctrine\Tests\Models\CMS; use Doctrine\Common\Collections\ArrayCollection; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; +use mysql_xdevapi\CrudOperationBindable; -/** - * @PHPCRODM\Document - */ +#[PHPCR\Document] class CmsArticle { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $topic; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $text; - /** @PHPCRODM\ReferenceOne(targetDocument="CmsUser") */ + #[PHPCR\ReferenceOne(targetDocument: CmsUser::class)] public $user; public $comments; - /** @PHPCRODM\ReferenceMany(targetDocument="CmsArticlePerson") */ + #[PHPCR\ReferenceMany(targetDocument: CmsArticlePerson::class)] public $persons; - /** @PHPCRODM\Field(type="binary", nullable=true) */ + #[PHPCR\Field(type: 'binary', nullable: true)] public $attachments; public function __construct() diff --git a/tests/Doctrine/Tests/Models/CMS/CmsArticleFolder.php b/tests/Doctrine/Tests/Models/CMS/CmsArticleFolder.php index 256f12581..4c6116a98 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsArticleFolder.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsArticleFolder.php @@ -2,20 +2,14 @@ namespace Doctrine\Tests\Models\CMS; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCRODM\Document(childClasses={"Doctrine\Tests\Models\CMS\CmsArticle"}) - */ +#[PHPCR\Document(childClasses: CmsArticle::class)] class CmsArticleFolder { - /** - * @PHPCRODM\Id - */ + #[PHPCR\Id] public $id; - /** - * @PHPCRODM\Children() - */ + #[PHPCR\Children] public $articles; } diff --git a/tests/Doctrine/Tests/Models/CMS/CmsArticlePerson.php b/tests/Doctrine/Tests/Models/CMS/CmsArticlePerson.php index 3401cfa30..c1a0d3157 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsArticlePerson.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsArticlePerson.php @@ -5,20 +5,18 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ODM\PHPCR\DocumentRepository; use Doctrine\ODM\PHPCR\Id\RepositoryIdInterface; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCRODM\Document(repositoryClass="Doctrine\Tests\Models\CMS\CmsArticlePersonRepository", referenceable=true) - */ +#[PHPCR\Document(repositoryClass: CmsArticlePersonRepository::class, referenceable: true)] class CmsArticlePerson { - /** @PHPCRODM\Id(strategy="repository") */ + #[PHPCR\Id(strategy: 'repository')] public $id; - /** @PHPCRODM\Field(type="string", nullable=true) */ + #[PHPCR\Field(type: 'string', nullable: true)] public $name; - /** @PHPCRODM\Referrers(referencedBy="persons", referringDocument="Doctrine\Tests\Models\CMS\CmsArticle", cascade="persist") */ + #[PHPCR\Referrers(referencedBy: 'persons', referringDocument: CmsArticle::class, cascade: 'persist')] public $articlesReferrers; public function __construct() diff --git a/tests/Doctrine/Tests/Models/CMS/CmsAuditItem.php b/tests/Doctrine/Tests/Models/CMS/CmsAuditItem.php index e6f13c661..9235deef9 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsAuditItem.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsAuditItem.php @@ -2,19 +2,17 @@ namespace Doctrine\Tests\Models\CMS; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCRODM\Document - */ +#[PHPCR\Document] class CmsAuditItem { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $message; - /** @PHPCRODM\Field(type="string", nullable=true) */ + #[PHPCR\Field(type: 'string', nullable: true)] public $username; } diff --git a/tests/Doctrine/Tests/Models/CMS/CmsBlogFolder.php b/tests/Doctrine/Tests/Models/CMS/CmsBlogFolder.php index 96bc31121..0a8e961d5 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsBlogFolder.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsBlogFolder.php @@ -2,24 +2,14 @@ namespace Doctrine\Tests\Models\CMS; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCRODM\Document( - * childClasses={ - * "Doctrine\Tests\Models\CMS\CmsBlogPost" - * } - * ) - */ +#[PHPCR\Document(childClasses: CmsBlogPost::class)] class CmsBlogFolder { - /** - * @PHPCRODM\Id() - */ + #[PHPCR\Id] public $id; - /** - * @PHPCRODM\Children() - */ + #[PHPCR\Children] public $posts; } diff --git a/tests/Doctrine/Tests/Models/CMS/CmsBlogInvalidChild.php b/tests/Doctrine/Tests/Models/CMS/CmsBlogInvalidChild.php index 7b600bc68..a15f89d0e 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsBlogInvalidChild.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsBlogInvalidChild.php @@ -4,19 +4,17 @@ namespace Doctrine\Tests\Models\CMS; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class CmsBlogInvalidChild { - /** @PHPCRODM\Id(strategy="parent") */ + #[PHPCR\Id(strategy: 'parent')] public $id; - /** @PHPCRODM\NodeName() */ + #[PHPCR\Nodename] public $name; - /** @PHPCRODM\ParentDocument() */ + #[PHPCR\ParentDocument] public $parent; } diff --git a/tests/Doctrine/Tests/Models/CMS/CmsBlogPost.php b/tests/Doctrine/Tests/Models/CMS/CmsBlogPost.php index 0ab1b832f..b30666054 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsBlogPost.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsBlogPost.php @@ -4,19 +4,17 @@ namespace Doctrine\Tests\Models\CMS; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCRODM\Document(isLeaf=true) - */ +#[PHPCR\Document(isLeaf: true)] class CmsBlogPost { - /** @PHPCRODM\Id(strategy="parent") */ + #[PHPCR\Id(strategy: 'parent')] public $id; - /** @PHPCRODM\NodeName() */ + #[PHPCR\Nodename] public $name; - /** @PHPCRODM\ParentDocument() */ + #[PHPCR\ParentDocument] public $parent; } diff --git a/tests/Doctrine/Tests/Models/CMS/CmsGroup.php b/tests/Doctrine/Tests/Models/CMS/CmsGroup.php index bff793511..c95a170c6 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsGroup.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsGroup.php @@ -6,20 +6,18 @@ namespace Doctrine\Tests\Models\CMS; -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 CmsGroup { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $name; - /** @PHPCRODM\ReferenceMany(targetDocument="CmsUser", cascade="persist") */ + #[PHPCR\ReferenceMany(targetDocument: CmsUser::class, cascade: 'persist')] public $users; public function setName($name) diff --git a/tests/Doctrine/Tests/Models/CMS/CmsItem.php b/tests/Doctrine/Tests/Models/CMS/CmsItem.php index 067d1087e..d26536793 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsItem.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsItem.php @@ -4,23 +4,21 @@ use Doctrine\ODM\PHPCR\DocumentRepository; use Doctrine\ODM\PHPCR\Id\RepositoryIdInterface; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCRODM\Document(repositoryClass="Doctrine\Tests\Models\CMS\CmsItemRepository", referenceable=true) - */ +#[PHPCR\Document(repositoryClass: CmsItemRepository::class, referenceable: true)] class CmsItem { - /** @PHPCRODM\Id(strategy="repository") */ + #[PHPCR\Id(strategy: 'repository')] public $id; - /** @PHPCRODM\Node */ + #[PHPCR\Node] public $node; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $name; - /** @PHPCRODM\ReferenceOne(strategy="hard", cascade="persist") */ + #[PHPCR\ReferenceOne(strategy: 'hard', cascade: 'persist')] public $documentTarget; public function getId() diff --git a/tests/Doctrine/Tests/Models/CMS/CmsPage.php b/tests/Doctrine/Tests/Models/CMS/CmsPage.php index 7b9165fd5..1108f8b08 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsPage.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsPage.php @@ -4,26 +4,24 @@ use Doctrine\ODM\PHPCR\DocumentRepository; use Doctrine\ODM\PHPCR\Id\RepositoryIdInterface; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCRODM\Document(repositoryClass="Doctrine\Tests\Models\CMS\CmsPageRepository", referenceable=true) - */ +#[PHPCR\Document(repositoryClass: CmsPageRepository::class, referenceable: true)] class CmsPage { - /** @PHPCRODM\Id(strategy="repository") */ + #[PHPCR\Id(strategy: 'repository')] public $id; - /** @PHPCRODM\Node */ + #[PHPCR\Node] public $node; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $content; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $title; - /** @PHPCRODM\MixedReferrers(referenceType="hard") */ + #[PHPCR\MixedReferrers(referenceType: 'hard')] public $items = []; public function getId() diff --git a/tests/Doctrine/Tests/Models/CMS/CmsPageTranslatable.php b/tests/Doctrine/Tests/Models/CMS/CmsPageTranslatable.php index c67dc3f86..b94ca0c20 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsPageTranslatable.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsPageTranslatable.php @@ -4,41 +4,27 @@ use Doctrine\ODM\PHPCR\DocumentRepository; use Doctrine\ODM\PHPCR\Id\RepositoryIdInterface; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCRODM\Document(repositoryClass="Doctrine\Tests\Models\CMS\CmsPageTranslatableRepository", referenceable=true, translator="attribute") - */ +#[PHPCR\Document(repositoryClass: CmsPageTranslatableRepository::class, translator: 'attribute', referenceable: true)] class CmsPageTranslatable { - /** - * @PHPCRODM\Id(strategy="repository") - */ + #[PHPCR\Id(strategy: 'repository')] public $id; - /** - * @PHPCRODM\Node - */ + #[PHPCR\Node] public $node; - /** - * @PHPCRODM\Locale - */ + #[PHPCR\Locale] public $locale; - /** - * @PHPCRODM\Field(type="string") - */ + #[PHPCR\Field(type: 'string')] public $content; - /** - * @PHPCRODM\Field(type="string", translated=true) - */ + #[PHPCR\Field(type: 'string', translated: true)] public $title; - /** - * @PHPCRODM\MixedReferrers(referenceType="hard") - */ + #[PHPCR\MixedReferrers(referenceType: 'hard')] public $items = []; public function getId() diff --git a/tests/Doctrine/Tests/Models/CMS/CmsProfile.php b/tests/Doctrine/Tests/Models/CMS/CmsProfile.php index d518a4e78..a893cc475 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsProfile.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsProfile.php @@ -4,28 +4,21 @@ use Doctrine\ODM\PHPCR\DocumentRepository; use Doctrine\ODM\PHPCR\Id\RepositoryIdInterface; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCRODM\Document( - * nodeType="phpcr:cms_profile", - * referenceable=true, - * repositoryClass="Doctrine\Tests\Models\CMS\CmsProfileRepository", - * uniqueNodeType=true - * ) - */ +#[PHPCR\Document(nodeType: 'phpcr:cms_profile', repositoryClass: CmsProfileRepository::class, referenceable: true, uniqueNodeType: true)] class CmsProfile { - /** @PHPCRODM\Id(strategy="repository") */ + #[PHPCR\Id(strategy: 'repository')] public $id; - /** @PHPCRODM\Uuid */ + #[PHPCR\Uuid] public $uuid; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $data; - /** @PHPCRODM\ReferenceOne(targetDocument="CmsUser", cascade="persist") */ + #[PHPCR\ReferenceOne(targetDocument: CmsUser::class, cascade: 'persist')] public $user; public function getId() diff --git a/tests/Doctrine/Tests/Models/CMS/CmsTeamUser.php b/tests/Doctrine/Tests/Models/CMS/CmsTeamUser.php index d73d3a580..a03e7e142 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsTeamUser.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsTeamUser.php @@ -4,21 +4,15 @@ use Doctrine\ODM\PHPCR\DocumentRepository; use Doctrine\ODM\PHPCR\Id\RepositoryIdInterface; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCRODM\Document(repositoryClass="Doctrine\Tests\Models\CMS\CmsTeamUserRepository") - */ +#[PHPCR\Document(repositoryClass: CmsTeamUserRepository::class)] class CmsTeamUser extends CmsUser { - /** - * @PHPCRODM\ParentDocument - */ + #[PHPCR\ParentDocument] public $parent; - /** - * @PHPCRODM\Nodename - */ + #[PHPCR\Nodename] public $nodename; public function setParentDocument($parent) diff --git a/tests/Doctrine/Tests/Models/CMS/CmsUser.php b/tests/Doctrine/Tests/Models/CMS/CmsUser.php index 799f23d80..13ffbaaa5 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsUser.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsUser.php @@ -5,47 +5,45 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ODM\PHPCR\DocumentRepository; use Doctrine\ODM\PHPCR\Id\RepositoryIdInterface; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCRODM\Document(repositoryClass="Doctrine\Tests\Models\CMS\CmsUserRepository", referenceable=true) - */ +#[PHPCR\Document(repositoryClass: CmsUserRepository::class, referenceable: true)] class CmsUser { - /** @PHPCRODM\Id(strategy="repository") */ + #[PHPCR\Id(strategy: 'repository')] public $id; - /** @PHPCRODM\Node */ + #[PHPCR\Node] public $node; - /** @PHPCRODM\Field(type="string", nullable=true) */ + #[PHPCR\Field(type: 'string', nullable: true)] public $status; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $username; - /** @PHPCRODM\Field(type="string", nullable=true) */ + #[PHPCR\Field(type: 'string', nullable: true)] public $name; - /** @PHPCRODM\ReferenceOne(targetDocument="CmsAddress", cascade="persist") */ + #[PHPCR\ReferenceOne(targetDocument: CmsAddress::class, cascade: 'persist')] public $address; - /** @PHPCRODM\ReferenceMany(targetDocument="CmsArticle", cascade="persist") */ + #[PHPCR\ReferenceMany(targetDocument: CmsArticle::class, cascade: 'persist')] public $articles; - /** @PHPCRODM\ReferenceMany(targetDocument="CmsGroup") */ + #[PHPCR\ReferenceMany(targetDocument: CmsGroup::class)] public $groups; - /** @PHPCRODM\ReferenceMany(targetDocument="CmsProfile") */ + #[PHPCR\ReferenceMany(targetDocument: CmsProfile::class)] public $profiles; - /** @PHPCRODM\Children() */ + #[PHPCR\Children] public $children; - /** @PHPCRODM\Child(nodeName="assistant", cascade="persist") */ + #[PHPCR\Child(nodeName: 'assistant', cascade: 'persist')] public $child; - /** @PHPCRODM\Referrers(referencedBy="user", referringDocument="Doctrine\Tests\Models\CMS\CmsArticle", cascade="persist") */ + #[PHPCR\Referrers(referencedBy: 'user', referringDocument: CmsArticle::class, cascade: 'persist')] public $articlesReferrers; public function __construct() diff --git a/tests/Doctrine/Tests/Models/CMS/CmsUserTranslatable.php b/tests/Doctrine/Tests/Models/CMS/CmsUserTranslatable.php index 98f0fdc87..25033024a 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsUserTranslatable.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsUserTranslatable.php @@ -5,47 +5,45 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ODM\PHPCR\DocumentRepository; use Doctrine\ODM\PHPCR\Id\RepositoryIdInterface; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCRODM\Document(repositoryClass="Doctrine\Tests\Models\CMS\CmsUserTranslatableRepository", translator="attribute", referenceable=true) - */ +#[PHPCR\Document(repositoryClass: CmsUserTranslatableRepository::class, translator: 'attribute', referenceable: true)] class CmsUserTranslatable { - /** @PHPCRODM\Id(strategy="repository") */ + #[PHPCR\Id(strategy: 'repository')] public $id; - /** @PHPCRODM\Locale */ + #[PHPCR\Locale] public $locale = 'en'; - /** @PHPCRODM\Node */ + #[PHPCR\Node] public $node; - /** @PHPCRODM\Field(type="string", nullable=true) */ + #[PHPCR\Field(type: 'string', nullable: true)] public $status; - /** @PHPCRODM\Field(type="string", translated=true) */ + #[PHPCR\Field(type: 'string', translated: true)] public $username; - /** @PHPCRODM\Field(type="string", nullable=true) */ + #[PHPCR\Field(type: 'string', nullable: true)] public $name; - /** @PHPCRODM\ReferenceOne(targetDocument="CmsAddress", cascade="persist") */ + #[PHPCR\ReferenceOne(targetDocument: CmsArticlePerson::class, cascade: 'persist')] public $address; - /** @PHPCRODM\ReferenceMany(targetDocument="CmsArticle", cascade="persist") */ + #[PHPCR\ReferenceMany(targetDocument: CmsArticle::class, cascade: 'persist')] public $articles; - /** @PHPCRODM\ReferenceMany(targetDocument="CmsGroup") */ + #[PHPCR\ReferenceMany(targetDocument: CmsGroup::class)] public $groups; - /** @PHPCRODM\Children() */ + #[PHPCR\Children] public $children; - /** @PHPCRODM\Child(nodeName="assistant", cascade="persist") */ + #[PHPCR\Child(nodeName: 'assistant', cascade: 'persist')] public $child; - /** @PHPCRODM\Referrers(referencedBy="user", referringDocument="Doctrine\Tests\Models\CMS\CmsArticle", cascade="persist") */ + #[PHPCR\Referrers(referencedBy: 'user', referringDocument: CmsArticle::class, cascade: 'persist')] public $articlesReferrers; public function __construct() diff --git a/tests/Doctrine/Tests/Models/References/HardRefTestObj.php b/tests/Doctrine/Tests/Models/References/HardRefTestObj.php index 60200a9fc..9a078ebad 100644 --- a/tests/Doctrine/Tests/Models/References/HardRefTestObj.php +++ b/tests/Doctrine/Tests/Models/References/HardRefTestObj.php @@ -2,16 +2,14 @@ namespace Doctrine\Tests\Models\References; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class HardRefTestObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\ReferenceOne(targetDocument="RefRefTestObj", strategy="hard", cascade="persist") */ + #[PHPCR\ReferenceOne(targetDocument: RefRefTestObj::class, strategy: 'hard', cascade: 'persist')] public $reference; } diff --git a/tests/Doctrine/Tests/Models/References/NonRefTestObj.php b/tests/Doctrine/Tests/Models/References/NonRefTestObj.php index d22a2ab72..c9be8bc77 100644 --- a/tests/Doctrine/Tests/Models/References/NonRefTestObj.php +++ b/tests/Doctrine/Tests/Models/References/NonRefTestObj.php @@ -2,13 +2,11 @@ namespace Doctrine\Tests\Models\References; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCRODM\Document(referenceable=false) - */ +#[PHPCR\Document(referenceable: false)] class NonRefTestObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; } diff --git a/tests/Doctrine/Tests/Models/References/ParentNoNodeNameTestObj.php b/tests/Doctrine/Tests/Models/References/ParentNoNodeNameTestObj.php index 27c040686..e1fecad27 100644 --- a/tests/Doctrine/Tests/Models/References/ParentNoNodeNameTestObj.php +++ b/tests/Doctrine/Tests/Models/References/ParentNoNodeNameTestObj.php @@ -2,20 +2,18 @@ namespace Doctrine\Tests\Models\References; -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 ParentNoNodeNameTestObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\ParentDocument */ + #[PHPCR\ParentDocument] public $parent; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $name; public function getParentDocument() diff --git a/tests/Doctrine/Tests/Models/References/ParentTestObj.php b/tests/Doctrine/Tests/Models/References/ParentTestObj.php index 2af6bf32f..6421872c4 100644 --- a/tests/Doctrine/Tests/Models/References/ParentTestObj.php +++ b/tests/Doctrine/Tests/Models/References/ParentTestObj.php @@ -2,23 +2,21 @@ namespace Doctrine\Tests\Models\References; -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 ParentTestObj { - /** @PHPCRODM\Id(strategy="parent") */ + #[PHPCR\Id(strategy: 'parent')] public $id; - /** @PHPCRODM\ParentDocument */ + #[PHPCR\ParentDocument] public $parent; - /** @PHPCRODM\Nodename */ + #[PHPCR\Nodename] public $nodename; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $name; public function getParentDocument() diff --git a/tests/Doctrine/Tests/Models/References/ParentWithChildrenTestObj.php b/tests/Doctrine/Tests/Models/References/ParentWithChildrenTestObj.php index 3b07a206c..ee6912d6f 100644 --- a/tests/Doctrine/Tests/Models/References/ParentWithChildrenTestObj.php +++ b/tests/Doctrine/Tests/Models/References/ParentWithChildrenTestObj.php @@ -2,22 +2,20 @@ namespace Doctrine\Tests\Models\References; -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 ParentWithChildrenTestObj { - /** @PHPCRODM\Id(strategy="parent") */ + #[PHPCR\Id(strategy: 'parent')] public $id; - /** @PHPCRODM\ParentDocument */ + #[PHPCR\ParentDocument] public $parent; - /** @PHPCRODM\Nodename */ + #[PHPCR\Nodename] public $nodename; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $name; - /** @PHPCRODM\Children() */ + #[PHPCR\Children] public $children; public function getParentDocument() diff --git a/tests/Doctrine/Tests/Models/References/RefAnnotationTestObj.php b/tests/Doctrine/Tests/Models/References/RefAnnotationTestObj.php index e09267ec7..5e8f54b45 100644 --- a/tests/Doctrine/Tests/Models/References/RefAnnotationTestObj.php +++ b/tests/Doctrine/Tests/Models/References/RefAnnotationTestObj.php @@ -2,13 +2,11 @@ namespace Doctrine\Tests\Models\References; -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 RefAnnotationTestObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; } diff --git a/tests/Doctrine/Tests/Models/References/RefCascadeManyTestObj.php b/tests/Doctrine/Tests/Models/References/RefCascadeManyTestObj.php index 5a49b7668..59b5ef8a9 100644 --- a/tests/Doctrine/Tests/Models/References/RefCascadeManyTestObj.php +++ b/tests/Doctrine/Tests/Models/References/RefCascadeManyTestObj.php @@ -3,20 +3,19 @@ namespace Doctrine\Tests\Models\References; use Doctrine\Common\Collections\ArrayCollection; -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 RefCascadeManyTestObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; /** @PHPCRODM\ReferenceMany(targetDocument="RefRefTestObj", cascade="persist") */ + #[PHPCR\ReferenceMany(targetDocument: RefRefTestObj::class, cascade: 'persist')] public $references; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $name; public function __construct() diff --git a/tests/Doctrine/Tests/Models/References/RefCascadeTestObj.php b/tests/Doctrine/Tests/Models/References/RefCascadeTestObj.php index 9818bc77f..acb6d7442 100644 --- a/tests/Doctrine/Tests/Models/References/RefCascadeTestObj.php +++ b/tests/Doctrine/Tests/Models/References/RefCascadeTestObj.php @@ -2,16 +2,14 @@ namespace Doctrine\Tests\Models\References; -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 RefCascadeTestObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\ReferenceOne(targetDocument="RefRefTestObj", cascade="persist") */ + #[PHPCR\ReferenceOne(targetDocument: RefRefTestObj::class, cascade: 'persist')] public $reference; } diff --git a/tests/Doctrine/Tests/Models/References/RefDifTestObj.php b/tests/Doctrine/Tests/Models/References/RefDifTestObj.php index 48362d4c4..01110a558 100644 --- a/tests/Doctrine/Tests/Models/References/RefDifTestObj.php +++ b/tests/Doctrine/Tests/Models/References/RefDifTestObj.php @@ -2,19 +2,17 @@ namespace Doctrine\Tests\Models\References; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class RefDifTestObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\ReferenceOne(targetDocument="RefType1TestObj", cascade="persist") */ + #[PHPCR\ReferenceOne(targetDocument: RefType1TestObj::class, cascade: 'persist')] public $referenceType1; - /** @PHPCRODM\ReferenceOne(targetDocument="RefType2TestObj", cascade="persist") */ + #[PHPCR\ReferenceOne(targetDocument: RefType2TestObj::class, cascade: 'persist')] public $referenceType2; } diff --git a/tests/Doctrine/Tests/Models/References/RefManyTestObj.php b/tests/Doctrine/Tests/Models/References/RefManyTestObj.php index fd2e1ca9d..a25f8501e 100644 --- a/tests/Doctrine/Tests/Models/References/RefManyTestObj.php +++ b/tests/Doctrine/Tests/Models/References/RefManyTestObj.php @@ -3,17 +3,15 @@ namespace Doctrine\Tests\Models\References; use Doctrine\Common\Collections\ArrayCollection; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class RefManyTestObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\ReferenceMany(targetDocument="RefRefTestObj", cascade="persist", property="myReferences") */ + #[PHPCR\ReferenceMany(property: 'myReferences', targetDocument: RefRefTestObj::class, cascade: 'persist')] public $references; public function __construct() diff --git a/tests/Doctrine/Tests/Models/References/RefManyTestObjForCascade.php b/tests/Doctrine/Tests/Models/References/RefManyTestObjForCascade.php index 2d5596a33..036d1654e 100644 --- a/tests/Doctrine/Tests/Models/References/RefManyTestObjForCascade.php +++ b/tests/Doctrine/Tests/Models/References/RefManyTestObjForCascade.php @@ -2,16 +2,14 @@ namespace Doctrine\Tests\Models\References; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class RefManyTestObjForCascade { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\ReferenceMany(targetDocument="RefCascadeManyTestObj", cascade="persist") */ + #[PHPCR\ReferenceMany(targetDocument: RefCascadeManyTestObj::class, cascade: 'persist')] public $references; } diff --git a/tests/Doctrine/Tests/Models/References/RefManyTestObjPathStrategy.php b/tests/Doctrine/Tests/Models/References/RefManyTestObjPathStrategy.php index 2da76ac99..5d7dc0236 100644 --- a/tests/Doctrine/Tests/Models/References/RefManyTestObjPathStrategy.php +++ b/tests/Doctrine/Tests/Models/References/RefManyTestObjPathStrategy.php @@ -3,17 +3,15 @@ namespace Doctrine\Tests\Models\References; use Doctrine\Common\Collections\ArrayCollection; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class RefManyTestObjPathStrategy { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\ReferenceMany(targetDocument="RefRefTestObj", cascade="persist", property="myReferences", strategy="path") */ + #[PHPCR\ReferenceMany(property: 'myReferences', targetDocument: RefRefTestObj::class, strategy: 'path', cascade: 'persist')] public $references; public function __construct() diff --git a/tests/Doctrine/Tests/Models/References/RefManyWithParentTestObjForCascade.php b/tests/Doctrine/Tests/Models/References/RefManyWithParentTestObjForCascade.php index 0a6da2149..84d42d5d9 100644 --- a/tests/Doctrine/Tests/Models/References/RefManyWithParentTestObjForCascade.php +++ b/tests/Doctrine/Tests/Models/References/RefManyWithParentTestObjForCascade.php @@ -2,17 +2,15 @@ namespace Doctrine\Tests\Models\References; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class RefManyWithParentTestObjForCascade { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\ReferenceMany(cascade="all") */ + #[PHPCR\ReferenceMany(cascade: 'all')] public $references; public function setReferences($references) diff --git a/tests/Doctrine/Tests/Models/References/RefRefTestObj.php b/tests/Doctrine/Tests/Models/References/RefRefTestObj.php index d334b986a..5deea5432 100644 --- a/tests/Doctrine/Tests/Models/References/RefRefTestObj.php +++ b/tests/Doctrine/Tests/Models/References/RefRefTestObj.php @@ -2,17 +2,15 @@ namespace Doctrine\Tests\Models\References; -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 RefRefTestObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $name; public function getId() diff --git a/tests/Doctrine/Tests/Models/References/RefTestObj.php b/tests/Doctrine/Tests/Models/References/RefTestObj.php index 833b7607a..0657d2219 100644 --- a/tests/Doctrine/Tests/Models/References/RefTestObj.php +++ b/tests/Doctrine/Tests/Models/References/RefTestObj.php @@ -2,16 +2,14 @@ namespace Doctrine\Tests\Models\References; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class RefTestObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\ReferenceOne(targetDocument="RefRefTestObj", cascade="persist", property="myReference") */ + #[PHPCR\ReferenceOne(property: 'myReference', targetDocument: RefRefTestObj::class, cascade: 'persist')] public $reference; } diff --git a/tests/Doctrine/Tests/Models/References/RefTestObjByPath.php b/tests/Doctrine/Tests/Models/References/RefTestObjByPath.php index 381177090..68cd1b942 100644 --- a/tests/Doctrine/Tests/Models/References/RefTestObjByPath.php +++ b/tests/Doctrine/Tests/Models/References/RefTestObjByPath.php @@ -2,16 +2,14 @@ namespace Doctrine\Tests\Models\References; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class RefTestObjByPath { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\ReferenceOne(targetDocument="RefRefTestObj", strategy="path", cascade="persist") */ + #[PHPCR\ReferenceOne(targetDocument: RefRefTestObj::class, strategy: 'path', cascade: 'persist')] public $reference; } diff --git a/tests/Doctrine/Tests/Models/References/RefTestPrivateObj.php b/tests/Doctrine/Tests/Models/References/RefTestPrivateObj.php index 58eb4c6a4..a3fe786a4 100644 --- a/tests/Doctrine/Tests/Models/References/RefTestPrivateObj.php +++ b/tests/Doctrine/Tests/Models/References/RefTestPrivateObj.php @@ -2,17 +2,15 @@ namespace Doctrine\Tests\Models\References; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class RefTestPrivateObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\ReferenceOne(cascade="persist") */ + #[PHPCR\ReferenceOne(cascade: 'persist')] private $reference; public function getReference() diff --git a/tests/Doctrine/Tests/Models/References/RefType1TestObj.php b/tests/Doctrine/Tests/Models/References/RefType1TestObj.php index 9bde3de7c..19c82dedc 100644 --- a/tests/Doctrine/Tests/Models/References/RefType1TestObj.php +++ b/tests/Doctrine/Tests/Models/References/RefType1TestObj.php @@ -2,16 +2,14 @@ namespace Doctrine\Tests\Models\References; -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 RefType1TestObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $name; } diff --git a/tests/Doctrine/Tests/Models/References/RefType2TestObj.php b/tests/Doctrine/Tests/Models/References/RefType2TestObj.php index c48108cf2..755aca576 100644 --- a/tests/Doctrine/Tests/Models/References/RefType2TestObj.php +++ b/tests/Doctrine/Tests/Models/References/RefType2TestObj.php @@ -2,16 +2,14 @@ namespace Doctrine\Tests\Models\References; -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 RefType2TestObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $name; } diff --git a/tests/Doctrine/Tests/Models/References/UuidTestObj.php b/tests/Doctrine/Tests/Models/References/UuidTestObj.php index 497cb0e0e..bac09a672 100644 --- a/tests/Doctrine/Tests/Models/References/UuidTestObj.php +++ b/tests/Doctrine/Tests/Models/References/UuidTestObj.php @@ -2,16 +2,14 @@ namespace Doctrine\Tests\Models\References; -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 UuidTestObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Uuid */ + #[PHPCR\Uuid] public $uuid1; } diff --git a/tests/Doctrine/Tests/Models/References/UuidTestTwoUuidFieldsObj.php b/tests/Doctrine/Tests/Models/References/UuidTestTwoUuidFieldsObj.php index c319ee35c..12d5d516f 100644 --- a/tests/Doctrine/Tests/Models/References/UuidTestTwoUuidFieldsObj.php +++ b/tests/Doctrine/Tests/Models/References/UuidTestTwoUuidFieldsObj.php @@ -2,19 +2,17 @@ namespace Doctrine\Tests\Models\References; -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 UuidTestTwoUuidFieldsObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Uuid */ + #[PHPCR\Uuid] public $uuid1; - /** @PHPCRODM\Uuid */ + #[PHPCR\Uuid] public $uuid2; } diff --git a/tests/Doctrine/Tests/Models/References/WeakRefTestObj.php b/tests/Doctrine/Tests/Models/References/WeakRefTestObj.php index 9ab8a1996..47dec5232 100644 --- a/tests/Doctrine/Tests/Models/References/WeakRefTestObj.php +++ b/tests/Doctrine/Tests/Models/References/WeakRefTestObj.php @@ -2,16 +2,14 @@ namespace Doctrine\Tests\Models\References; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class WeakRefTestObj { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\ReferenceOne(targetDocument="RefRefTestObj", strategy="weak", cascade="persist") */ + #[PHPCR\ReferenceOne(targetDocument: RefRefTestObj::class, strategy: 'weak', cascade: 'persist')] public $reference; } diff --git a/tests/Doctrine/Tests/Models/Translation/Article.php b/tests/Doctrine/Tests/Models/Translation/Article.php index 969f52f5c..f52f15848 100644 --- a/tests/Doctrine/Tests/Models/Translation/Article.php +++ b/tests/Doctrine/Tests/Models/Translation/Article.php @@ -3,73 +3,64 @@ namespace Doctrine\Tests\Models\Translation; use Doctrine\Common\Collections\ArrayCollection; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCRODM\Document(translator="attribute", referenceable=true) - */ +#[PHPCR\Document(translator: 'attribute', referenceable: true)] class Article { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** - * @PHPCRODM\Locale - */ + #[PHPCR\Locale] public $locale = 'en'; - /** @PHPCRODM\Node */ + #[PHPCR\Node] public $node; - /** @PHPCRODM\Nodename */ + #[PHPCR\Nodename] public $nodename; - /** - * @PHPCRODM\ParentDocument */ + #[PHPCR\ParentDocument] public $parent; // untranslated: - /** @PHPCRODM\Field(type="date", nullable=true) */ + #[PHPCR\Field(type: 'date', nullable: true)] public $publishDate; // untranslated: - /** @PHPCRODM\Field(type="string", nullable=true) */ + #[PHPCR\Field(type: 'string', nullable: true)] public $author; - /** @PHPCRODM\Field(type="string", translated=true) */ + #[PHPCR\Field(type: 'string', translated: true)] public $topic; - /** @PHPCRODM\Field(type="string", translated=true) */ + #[PHPCR\Field(type: 'string', translated: true)] public $text; - /** @PHPCRODM\Children() */ + #[PHPCR\Children] public $children; - /** @PHPCRODM\Child */ + #[PHPCR\Child] public $child; - /** @PHPCRODM\ReferenceMany() */ + #[PHPCR\ReferenceMany] public $relatedArticles = []; - /** @PHPCRODM\Field(type="string", translated=true, nullable=true) */ + #[PHPCR\Field(type: 'string', nullable: true, translated: true)] public $nullable; - /** @PHPCRODM\Field(type="string", translated=true, nullable=true, property="custom-property-name") */ + #[PHPCR\Field(property: 'custom-property-name', type: 'string', nullable: true, translated: true)] public $customPropertyName; - /** @PHPCRODM\Field(type="string", translated=true, assoc="", nullable=true)*/ + #[PHPCR\Field(type: 'string', assoc: '', nullable: true, translated: true)] public $assoc; - /** - * @PHPCRODM\Field(type="string", assoc="", translated=true, nullable=true) - */ + #[PHPCR\Field(type: 'string', assoc: '', nullable: true, translated: true)] protected $settings; - /** - * @PHPCRODM\Field(type="string", assoc="", property="custom-settings", translated=true, nullable=true) - */ + #[PHPCR\Field(property: 'custom-settings', type: 'string', assoc: '', nullable: true, translated: true)] public $customNameSettings; public function __construct() diff --git a/tests/Doctrine/Tests/Models/Translation/ChildTranslationArticle.php b/tests/Doctrine/Tests/Models/Translation/ChildTranslationArticle.php index a85932bfe..7ebd2dd92 100644 --- a/tests/Doctrine/Tests/Models/Translation/ChildTranslationArticle.php +++ b/tests/Doctrine/Tests/Models/Translation/ChildTranslationArticle.php @@ -2,11 +2,9 @@ namespace Doctrine\Tests\Models\Translation; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCRODM\Document(translator="child", referenceable=true) - */ +#[PHPCR\Document(translator: 'child', referenceable: true)] class ChildTranslationArticle extends Article { } diff --git a/tests/Doctrine/Tests/Models/Translation/ChildTranslationComment.php b/tests/Doctrine/Tests/Models/Translation/ChildTranslationComment.php index 63f4012ed..886de4703 100644 --- a/tests/Doctrine/Tests/Models/Translation/ChildTranslationComment.php +++ b/tests/Doctrine/Tests/Models/Translation/ChildTranslationComment.php @@ -2,11 +2,9 @@ namespace Doctrine\Tests\Models\Translation; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCRODM\Document(translator="child") - */ +#[PHPCR\Document(translator: 'child')] class ChildTranslationComment extends Comment { } diff --git a/tests/Doctrine/Tests/Models/Translation/Comment.php b/tests/Doctrine/Tests/Models/Translation/Comment.php index 2cb2c8582..f81c92cac 100644 --- a/tests/Doctrine/Tests/Models/Translation/Comment.php +++ b/tests/Doctrine/Tests/Models/Translation/Comment.php @@ -2,30 +2,24 @@ namespace Doctrine\Tests\Models\Translation; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCRODM\Document(translator="attribute") - */ +#[PHPCR\Document(translator: 'attribute')] class Comment { - /** @PHPCRODM\Id(strategy="parent") */ + #[PHPCR\Id(strategy: 'parent')] public $id; - /** - * @PHPCRODM\Nodename() - */ + #[PHPCR\Nodename] public $name; - /** - * @PHPCRODM\Locale - */ + #[PHPCR\Locale] public $locale = 'en'; - /** @PHPCRODM\ParentDocument */ + #[PHPCR\ParentDocument] public $parent; - /** @PHPCRODM\Field(type="string", translated=true,nullable=true) */ + #[PHPCR\Field(type: 'string', nullable: true, translated: true)] private $text; /** diff --git a/tests/Doctrine/Tests/Models/Translation/DatedComment.php b/tests/Doctrine/Tests/Models/Translation/DatedComment.php index 4b4a83fa3..7585b5c2d 100644 --- a/tests/Doctrine/Tests/Models/Translation/DatedComment.php +++ b/tests/Doctrine/Tests/Models/Translation/DatedComment.php @@ -2,15 +2,11 @@ namespace Doctrine\Tests\Models\Translation; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCRODM\Document(translator="attribute") - */ +#[PHPCR\Document(translator: 'attribute')] class DatedComment extends Comment { - /** - * @PHPCRODM\Date - */ + #[PHPCR\Field(type: 'date')] public $date; } diff --git a/tests/Doctrine/Tests/Models/Translation/DerivedArticle.php b/tests/Doctrine/Tests/Models/Translation/DerivedArticle.php index efc20addd..b45c0a7a7 100644 --- a/tests/Doctrine/Tests/Models/Translation/DerivedArticle.php +++ b/tests/Doctrine/Tests/Models/Translation/DerivedArticle.php @@ -2,11 +2,9 @@ namespace Doctrine\Tests\Models\Translation; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCRODM\Document - */ +#[PHPCR\Document] class DerivedArticle extends Article { } diff --git a/tests/Doctrine/Tests/Models/Translation/InvalidMapping.php b/tests/Doctrine/Tests/Models/Translation/InvalidMapping.php index 41ede9e72..8ecb98c29 100644 --- a/tests/Doctrine/Tests/Models/Translation/InvalidMapping.php +++ b/tests/Doctrine/Tests/Models/Translation/InvalidMapping.php @@ -9,21 +9,17 @@ namespace Doctrine\Tests\Models\Translation; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCRODM\Document(translator="some_unexisting_strategy") - */ +#[PHPCR\Document(translator: 'some_unexisting_strategy')] class InvalidMapping { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** - * @PHPCRODM\Locale - */ + #[PHPCR\Locale] public $locale = 'en'; - /** @PHPCRODM\Field(type="string", translated=true) */ + #[PHPCR\Field(type: 'string', translated: true)] public $topic; } diff --git a/tests/Doctrine/Tests/Models/Translation/NoLocalePropertyArticle.php b/tests/Doctrine/Tests/Models/Translation/NoLocalePropertyArticle.php index 0452a1847..576dfa489 100644 --- a/tests/Doctrine/Tests/Models/Translation/NoLocalePropertyArticle.php +++ b/tests/Doctrine/Tests/Models/Translation/NoLocalePropertyArticle.php @@ -2,7 +2,7 @@ namespace Doctrine\Tests\Models\Translation; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; /** * Translatable document that does not provide an explicit locale field. @@ -13,27 +13,25 @@ * This class is supposed to throw an exception when it is read by the ODM !!! */ -/** - * @PHPCRODM\Document(translator="attribute") - */ +#[PHPCR\Document(translator: 'attribute')] class NoLocalePropertyArticle { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; // untranslated: - /** @PHPCRODM\Field(type="date") */ + #[PHPCR\Field(type: 'date')] public $publishDate; // untranslated: - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $author; - /** @PHPCRODM\Field(type="string", translated=true) */ + #[PHPCR\Field(type: 'string', translated: true)] public $topic; - /** @PHPCRODM\Field(type="string", translated=true) */ + #[PHPCR\Field(type: 'string', translated: true)] public $text; } diff --git a/tests/Doctrine/Tests/Models/Versioning/ExtendedVersionableArticle.php b/tests/Doctrine/Tests/Models/Versioning/ExtendedVersionableArticle.php index ca4430cdc..777981fbd 100644 --- a/tests/Doctrine/Tests/Models/Versioning/ExtendedVersionableArticle.php +++ b/tests/Doctrine/Tests/Models/Versioning/ExtendedVersionableArticle.php @@ -2,20 +2,18 @@ namespace Doctrine\Tests\Models\Versioning; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCRODM\Document(versionable="full") - */ +#[PHPCR\Document(versionable: 'full')] class ExtendedVersionableArticle extends FullVersionableArticle { - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $author; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $topic; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] private $text; public function getText() diff --git a/tests/Doctrine/Tests/Models/Versioning/FullVersionableArticle.php b/tests/Doctrine/Tests/Models/Versioning/FullVersionableArticle.php index 2b162dae1..ff810454d 100644 --- a/tests/Doctrine/Tests/Models/Versioning/FullVersionableArticle.php +++ b/tests/Doctrine/Tests/Models/Versioning/FullVersionableArticle.php @@ -2,29 +2,27 @@ namespace Doctrine\Tests\Models\Versioning; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCRODM\Document(versionable="full") - */ +#[PHPCR\Document(versionable: 'full')] class FullVersionableArticle { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $author; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $topic; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] private $text; - /** @PHPCRODM\VersionName */ + #[PHPCR\VersionName] public $versionName; - /** @PHPCRODM\VersionCreated */ + #[PHPCR\VersionCreated] public $versionCreated; public function getText() diff --git a/tests/Doctrine/Tests/Models/Versioning/FullVersionableArticleWithChildren.php b/tests/Doctrine/Tests/Models/Versioning/FullVersionableArticleWithChildren.php index c9972672d..0cc0f137b 100644 --- a/tests/Doctrine/Tests/Models/Versioning/FullVersionableArticleWithChildren.php +++ b/tests/Doctrine/Tests/Models/Versioning/FullVersionableArticleWithChildren.php @@ -3,16 +3,12 @@ namespace Doctrine\Tests\Models\Versioning; use Doctrine\Common\Collections\ArrayCollection; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCRODM\Document(versionable="full") - */ +#[PHPCR\Document(versionable: 'full')] class FullVersionableArticleWithChildren extends FullVersionableArticle { - /** - * @PHPCRODM\Children - */ + #[PHPCR\Children] public $childArticles; public function __construct() diff --git a/tests/Doctrine/Tests/Models/Versioning/InconsistentVersionableArticle.php b/tests/Doctrine/Tests/Models/Versioning/InconsistentVersionableArticle.php index 6f47cb677..767752e96 100644 --- a/tests/Doctrine/Tests/Models/Versioning/InconsistentVersionableArticle.php +++ b/tests/Doctrine/Tests/Models/Versioning/InconsistentVersionableArticle.php @@ -2,28 +2,27 @@ namespace Doctrine\Tests\Models\Versioning; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; /** * This document has a Version annotated field but it is not marked as versionable - * - * @PHPCRODM\Document */ +#[PHPCR\Document] class InconsistentVersionableArticle { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $author; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $topic; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] private $text; - /** @PHPCRODM\VersionName */ + #[PHPCR\VersionName] public $versionName; public function getText() diff --git a/tests/Doctrine/Tests/Models/Versioning/InvalidVersionableArticle.php b/tests/Doctrine/Tests/Models/Versioning/InvalidVersionableArticle.php index 73ade8a02..26068e98d 100644 --- a/tests/Doctrine/Tests/Models/Versioning/InvalidVersionableArticle.php +++ b/tests/Doctrine/Tests/Models/Versioning/InvalidVersionableArticle.php @@ -2,23 +2,21 @@ namespace Doctrine\Tests\Models\Versioning; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCRODM\Document(versionable="some_invalid_versioning_type") - */ +#[PHPCR\Document(versionable: 'some_invalid_versioning_tpye')] class InvalidVersionableArticle { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $author; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $topic; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] private $text; public function getText() diff --git a/tests/Doctrine/Tests/Models/Versioning/NonVersionableArticle.php b/tests/Doctrine/Tests/Models/Versioning/NonVersionableArticle.php index 2b6c0a38f..8b5cf2803 100644 --- a/tests/Doctrine/Tests/Models/Versioning/NonVersionableArticle.php +++ b/tests/Doctrine/Tests/Models/Versioning/NonVersionableArticle.php @@ -2,23 +2,21 @@ namespace Doctrine\Tests\Models\Versioning; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCRODM\Document - */ +#[PHPCR\Document] class NonVersionableArticle { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $author; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $topic; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] private $text; public function getText() diff --git a/tests/Doctrine/Tests/Models/Versioning/VersionableArticle.php b/tests/Doctrine/Tests/Models/Versioning/VersionableArticle.php index 2721bb49f..87f9df5af 100644 --- a/tests/Doctrine/Tests/Models/Versioning/VersionableArticle.php +++ b/tests/Doctrine/Tests/Models/Versioning/VersionableArticle.php @@ -2,23 +2,21 @@ namespace Doctrine\Tests\Models\Versioning; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCRODM\Document(versionable="simple") - */ +#[PHPCR\Document(versionable: 'simple')] class VersionableArticle { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $author; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $topic; - /** @PHPCRODM\Field(type="string", nullable=true) */ + #[PHPCR\Field(type: 'string', nullable: true)] private $text; public function getText() diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/Mapping/AnnotationMappingTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Mapping/AnnotationMappingTest.php index 5584a234d..589382e83 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/Mapping/AnnotationMappingTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Mapping/AnnotationMappingTest.php @@ -10,7 +10,6 @@ use Doctrine\ODM\PHPCR\Mapping\MappingException; use Doctrine\ODM\PHPCR\Translation\LocaleChooser\LocaleChooser; use Doctrine\Tests\ODM\PHPCR\PHPCRFunctionalTestCase; -use PHPCR\NodeInterface; /** * @group functional @@ -24,7 +23,7 @@ class AnnotationMappingTest extends PHPCRFunctionalTestCase public function setUp(): void { - $this->dm = $this->createDocumentManager([__DIR__]); + $this->dm = $this->createDocumentManager([__DIR__], true); $this->resetFunctionalNode($this->dm); } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/ProtectedPropertyTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/ProtectedPropertyTest.php index 39b2382fd..d732ca8f3 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/ProtectedPropertyTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/ProtectedPropertyTest.php @@ -124,7 +124,7 @@ class ProtectedPropertyTestObj public $changeme; } -#[PHPCR\Document(nodeType: 'test:proctected_property_test2')] +#[PHPCR\Document(nodeType: 'test:protected_property_test2')] class ProtectedPropertyTestObj2 { #[PHPCR\Id] diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/Translation/TranslationHierarchyTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Translation/TranslationHierarchyTest.php index 4e814ef90..3908ec97e 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/Translation/TranslationHierarchyTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Translation/TranslationHierarchyTest.php @@ -197,6 +197,7 @@ public function testRefreshProxyUsesFallback(): void $doc = $this->dm->find(null, '/functional/thename'); + $this->assertInstanceOf(ParentObj::class, $doc->child); $this->assertEquals('french', $doc->child->children['c1']->text); } } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/PHPCRFunctionalTestCase.php b/tests/Doctrine/Tests/ODM/PHPCR/PHPCRFunctionalTestCase.php index 4e2493ccb..450139971 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/PHPCRFunctionalTestCase.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/PHPCRFunctionalTestCase.php @@ -7,6 +7,7 @@ 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; use PHPCR\NodeInterface; @@ -22,7 +23,7 @@ abstract class PHPCRFunctionalTestCase extends TestCase */ private $sessions = []; - public function createDocumentManager(array $paths = null): DocumentManager + public function createDocumentManager(array $paths = null, bool $annotations = false): DocumentManager { AnnotationReader::addGlobalIgnoredName('group'); @@ -30,14 +31,17 @@ public function createDocumentManager(array $paths = null): DocumentManager $paths = [__DIR__.'/../../Models']; } - $metaDriver = new AnnotationDriver(new AnnotationReader(), $paths); + $metaDriver = $annotations + ? new AnnotationDriver(new AnnotationReader(), $paths) + : new AttributeDriver($paths) + ; $factoryclass = $GLOBALS['DOCTRINE_PHPCR_FACTORY'] ?? RepositoryFactoryJackrabbit::class; if (RepositoryFactoryDoctrineDBAL::class === ltrim($factoryclass, '\\')) { $params = []; foreach ($GLOBALS as $key => $value) { - if (0 === strpos($key, 'jackalope.doctrine.dbal.')) { + if (str_starts_with($key, 'jackalope.doctrine.dbal.')) { $params[substr($key, strlen('jackalope.doctrine.dbal.'))] = $value; } } From 117d8ec68103113d1265f737964b9edc9ad32857 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Mon, 4 Dec 2023 10:50:23 +0100 Subject: [PATCH 12/14] link attributes documentation in toc --- docs/en/index.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/en/index.rst b/docs/en/index.rst index 46517211e..870bfa0e1 100644 --- a/docs/en/index.rst +++ b/docs/en/index.rst @@ -36,7 +36,8 @@ Mapping Objects onto a Document Repository :doc:`Inheritance ` * **Mapping Driver References**: - :doc:`Docblock Annotations ` | + :doc:`PHP Attributes ` | + :doc:`Docblock Annotations (deprecated) ` | :doc:`XML ` | :doc:`YAML ` | :doc:`Metadata Drivers ` From 2e397e8be5483f67b7b94ce2db98bed640712ab2 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Mon, 4 Dec 2023 11:04:01 +0100 Subject: [PATCH 13/14] fix typos and add attributes mapping test --- CHANGELOG.md | 2 +- cli-config.doctrine_dbal.php.dist | 2 +- cli-config.jackrabbit.php.dist | 2 +- .../reference/installation-configuration.rst | 2 +- docs/en/reference/versioning.rst | 2 +- .../RegisterSystemNodeTypesCommand.php | 2 +- .../Attribute/AttributeMappingTest.php | 355 ++++++++++++++++++ 7 files changed, 361 insertions(+), 6 deletions(-) create mode 100644 tests/Doctrine/Tests/ODM/PHPCR/Functional/Mapping/Attribute/AttributeMappingTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index adcb9f3f1..fe20d251b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -355,7 +355,7 @@ maintenance release of the 1.0 family with bugfixes - Doctrine\Common\Persistence\Event\LifecycleEventArgs Only the MoveEventArgs remain specific to PHPCR-ODM. * **2013-09-27**: Removed deprecated legacy handling for the mapping that - allowed using "name" instead of "property" to configure PHCPR property in mapping. + allowed using "name" instead of "property" to configure PHPCR property in mapping. * **2013-09-26**: [Model] add HierarchyInterface for objects that resolve to nt:HierarchyNode, the method AbstractFile::addChild is diff --git a/cli-config.doctrine_dbal.php.dist b/cli-config.doctrine_dbal.php.dist index f5c86eb9b..d6746bbc6 100644 --- a/cli-config.doctrine_dbal.php.dist +++ b/cli-config.doctrine_dbal.php.dist @@ -2,7 +2,7 @@ /** * The config file is responsible to make class loading work and initialize a * DocumentManagerHelper that contains the doctrine document manager with a - * Session of your phcpr implementation. + * Session of your phpcr implementation. * The array $extraCommands can be used to inject implementation specific commands. * Add instances of commands for eventual implementation specific commands to this array. */ diff --git a/cli-config.jackrabbit.php.dist b/cli-config.jackrabbit.php.dist index 421d2c4ef..b3e0b6bfa 100644 --- a/cli-config.jackrabbit.php.dist +++ b/cli-config.jackrabbit.php.dist @@ -2,7 +2,7 @@ /** * The config file is responsible to make class loading work and initialize a * DocumentManagerHelper that contains the doctrine document manager with a - * Session of your phcpr implementation. + * Session of your phpcr implementation. * The array $extraCommands can be used to inject implementation specific commands. * Add instances of commands for eventual implementation specific commands to this array. */ diff --git a/docs/en/reference/installation-configuration.rst b/docs/en/reference/installation-configuration.rst index 0ae7fc8e1..c2a698b51 100644 --- a/docs/en/reference/installation-configuration.rst +++ b/docs/en/reference/installation-configuration.rst @@ -39,7 +39,7 @@ storage. You can force one of the available providers in your projects composer. Each of the providers requires some additional setup. The following sections will briefly list how to set each of them up. Please refer to the documentation of the provider you choose for details. -Install Jackalope-Jackrabbit PHCPR provider +Install Jackalope-Jackrabbit PHPCR provider ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Jackalope-Jackrabbit uses the Java backend jackrabbit for storage. diff --git a/docs/en/reference/versioning.rst b/docs/en/reference/versioning.rst index 37e28b717..932f65623 100644 --- a/docs/en/reference/versioning.rst +++ b/docs/en/reference/versioning.rst @@ -125,7 +125,7 @@ Note that all fields of a document are automatically versioned, you can not exclude anything from being versioned. Referenced documents are not versioned at the same time, but it is stored to which document the reference pointed at this time. Children and parents are not versioned by default. Children can be -versioned by defining a PHCPR node type that specifies to cascade versioning. +versioned by defining a PHPCR node type that specifies to cascade versioning. This feature however is untested with PHPCR-ODM, if you have feedback please tell us. diff --git a/lib/Doctrine/ODM/PHPCR/Tools/Console/Command/RegisterSystemNodeTypesCommand.php b/lib/Doctrine/ODM/PHPCR/Tools/Console/Command/RegisterSystemNodeTypesCommand.php index 7c6adf1b8..fa8636b8a 100644 --- a/lib/Doctrine/ODM/PHPCR/Tools/Console/Command/RegisterSystemNodeTypesCommand.php +++ b/lib/Doctrine/ODM/PHPCR/Tools/Console/Command/RegisterSystemNodeTypesCommand.php @@ -25,7 +25,7 @@ use Symfony\Component\Console\Output\OutputInterface; /** - * Command to register the phcpr-odm required node types. + * Command to register the phpcr-odm required node types. * * This command registers the necessary node types to get phpcr odm working */ diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/Mapping/Attribute/AttributeMappingTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Mapping/Attribute/AttributeMappingTest.php new file mode 100644 index 000000000..b04d086ef --- /dev/null +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Mapping/Attribute/AttributeMappingTest.php @@ -0,0 +1,355 @@ +dm = $this->createDocumentManager([__DIR__]); + $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 +} + +#[PHPCR\Document] +class Testclass +{ + #[PHPCR\Id] + public $id; + + #[PHPCR\Node] + public $node; + + #[PHPCR\Field(type: 'string')] + public $text; + + #[PHPCR\Depth] + public $depth; + + public int $callback_run = 0; + + #[PHPCR\PostPersist] + public function callback(): void + { + ++$this->callback_run; + } +} + +#[PHPCR\Document] +class ExtendingClass extends Testclass +{ + #[PHPCR\ReferenceOne] + public $reference; + + public int $extending_run = 0; + + #[PHPCR\PostPersist] + public function extendingCallback(): void + { + ++$this->extending_run; + } +} + +#[PHPCR\Document] +class SecondLevel extends ExtendingClass +{ +} + +#[PHPCR\Document] +class SecondLevelWithDuplicate extends ExtendingClass +{ + #[PHPCR\Field(type: 'long')] + public $text; +} + +#[PHPCR\Document(translator: 'attribute')] +class SecondLevelWithDuplicateOverwrite extends ExtendingClass +{ + #[PHPCR\Locale] + public $locale; + + #[PHPCR\Field(type: 'string', translated: true)] + public $text; +} + +#[PHPCR\Document] +class ParentIdStrategy +{ + #[PHPCR\Nodename] + public $name; + + #[PHPCR\ParentDocument] + public $parent; +} + +#[PHPCR\Document] +class ParentIdStrategyDifferentOrder +{ + #[PHPCR\Nodename] + public $name; + + #[PHPCR\ParentDocument] + public $parent; + + #[PHPCR\Id] + public $id; +} + +#[PHPCR\Document] +class AutoNameIdStrategy +{ + #[PHPCR\ParentDocument] + public $parent; +} + +#[PHPCR\Document] +class AssignedIdStrategy +{ + #[PHPCR\Id(strategy: 'assigned')] + public $id; + + #[PHPCR\Nodename] + public $name; + + #[PHPCR\ParentDocument] + public $parent; +} + +#[PHPCR\Document(repositoryClass: Repository::class)] +class RepositoryIdStrategy +{ + public $title; + + #[PHPCR\Id(strategy: 'repository')] + public $id; +} +class Repository extends DocumentRepository implements RepositoryIdInterface +{ + public function generateId($document, $parent = null) + { + return '/functional/'.str_replace(' ', '-', $document->title); + } +} + +/** + * Invalid document missing a parent mapping for the id strategy + */ +#[PHPCR\Document] +class ParentIdNoParentStrategy +{ + #[PHPCR\Id(strategy: 'parent')] + public $id; + + #[PHPCR\Nodename] + public $name; +} + +/** + * Invalid document not having a parent mapping. + */ +#[PHPCR\Document] +class AutoNameIdNoParentStrategy +{ + #[PHPCR\Id(strategy: 'auto')] + public $id; +} + +/** + * + * Invalid document not having an id at all. + */ +#[PHPCR\Document] +class NoId +{ +} + +#[PHPCR\Document] +class StandardCase +{ + #[PHPCR\Id] + public $id; +} From cedafd56620f94f95e6b62be4feee9d6d812f18b Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Sun, 3 Dec 2023 10:19:09 +0100 Subject: [PATCH 14/14] remove obsolete annotation mapping adjust phpdoc annotations to work around https://github.com/phpstan/phpstan/issues/10399 --- CHANGELOG.md | 2 +- cli-config.doctrine_dbal.php.dist | 5 +- cli-config.jackrabbit.php.dist | 5 +- composer.json | 2 +- .../ODM/PHPCR/Document/AbstractFile.php | 2 +- lib/Doctrine/ODM/PHPCR/Document/File.php | 4 + lib/Doctrine/ODM/PHPCR/Document/Generic.php | 10 +- lib/Doctrine/ODM/PHPCR/Document/Resource.php | 14 +- lib/Doctrine/ODM/PHPCR/DocumentManager.php | 2 +- .../ODM/PHPCR/DocumentManagerInterface.php | 2 +- .../ODM/PHPCR/Mapping/Annotations/Child.php | 22 - .../PHPCR/Mapping/Annotations/Children.php | 26 -- .../ODM/PHPCR/Mapping/Annotations/Depth.php | 13 - .../PHPCR/Mapping/Annotations/Document.php | 28 -- .../ODM/PHPCR/Mapping/Annotations/Field.php | 13 - .../ODM/PHPCR/Mapping/Annotations/Id.php | 16 - .../ODM/PHPCR/Mapping/Annotations/Locale.php | 13 - .../Mapping/Annotations/MappedSuperclass.php | 13 - .../Mapping/Annotations/MixedReferrers.php | 14 - .../ODM/PHPCR/Mapping/Annotations/Node.php | 13 - .../PHPCR/Mapping/Annotations/Nodename.php | 15 - .../Mapping/Annotations/ParentDocument.php | 20 - .../PHPCR/Mapping/Annotations/PostLoad.php | 13 - .../PHPCR/Mapping/Annotations/PostPersist.php | 13 - .../PHPCR/Mapping/Annotations/PostRemove.php | 13 - .../PHPCR/Mapping/Annotations/PostUpdate.php | 13 - .../PHPCR/Mapping/Annotations/PrePersist.php | 13 - .../PHPCR/Mapping/Annotations/PreRemove.php | 13 - .../PHPCR/Mapping/Annotations/PreUpdate.php | 13 - .../PHPCR/Mapping/Annotations/Property.php | 19 - .../PHPCR/Mapping/Annotations/Reference.php | 22 - .../Mapping/Annotations/ReferenceMany.php | 13 - .../Mapping/Annotations/ReferenceOne.php | 13 - .../PHPCR/Mapping/Annotations/Referrers.php | 24 -- .../Annotations/TranslatableProperty.php | 11 - .../ODM/PHPCR/Mapping/Annotations/Uuid.php | 15 - .../Mapping/Annotations/VersionCreated.php | 13 - .../PHPCR/Mapping/Annotations/VersionName.php | 13 - .../ODM/PHPCR/Mapping/Attributes/Child.php | 15 +- .../ODM/PHPCR/Mapping/Attributes/Children.php | 22 +- .../ODM/PHPCR/Mapping/Attributes/Depth.php | 3 +- .../ODM/PHPCR/Mapping/Attributes/Document.php | 38 +- .../ODM/PHPCR/Mapping/Attributes/Field.php | 21 +- .../ODM/PHPCR/Mapping/Attributes/Id.php | 12 +- .../ODM/PHPCR/Mapping/Attributes/Locale.php | 3 +- .../Mapping/Attributes/MixedReferrers.php | 9 +- .../ODM/PHPCR/Mapping/Attributes/Node.php | 3 +- .../ODM/PHPCR/Mapping/Attributes/Nodename.php | 3 +- .../Mapping/Attributes/ParentDocument.php | 15 +- .../ODM/PHPCR/Mapping/Attributes/PostLoad.php | 3 +- .../PHPCR/Mapping/Attributes/PostPersist.php | 3 +- .../PHPCR/Mapping/Attributes/PostRemove.php | 3 +- .../PHPCR/Mapping/Attributes/PostUpdate.php | 3 +- .../PHPCR/Mapping/Attributes/PrePersist.php | 3 +- .../PHPCR/Mapping/Attributes/PreRemove.php | 3 +- .../PHPCR/Mapping/Attributes/PreUpdate.php | 3 +- .../PHPCR/Mapping/Attributes/Reference.php | 23 +- .../PHPCR/Mapping/Attributes/Referrers.php | 17 +- .../ODM/PHPCR/Mapping/Attributes/Uuid.php | 3 +- .../Mapping/Attributes/VersionCreated.php | 3 +- .../PHPCR/Mapping/Attributes/VersionName.php | 3 +- .../ODM/PHPCR/Mapping/ClassMetadata.php | 28 +- .../PHPCR/Mapping/Driver/AnnotationDriver.php | 245 ----------- .../PHPCR/Mapping/Driver/AttributeDriver.php | 12 +- .../ODM/PHPCR/Mapping/Driver/XmlDriver.php | 2 +- .../ODM/PHPCR/Mapping/MappingException.php | 2 +- .../DumpQueryBuilderReferenceCommand.php | 2 +- .../ODM/PHPCR/Tools/Helper/PrefetchHelper.php | 4 +- lib/Doctrine/ODM/PHPCR/UnitOfWork.php | 16 +- .../Doctrine/Tests/Models/CMS/CmsArticle.php | 1 - .../References/RefCascadeManyTestObj.php | 1 - .../Models/Translation/InvalidMapping.php | 2 +- .../Translation/NoLocalePropertyArticle.php | 3 +- .../InconsistentVersionableArticle.php | 2 +- .../ODM/PHPCR/DocumentClassMapperTest.php | 9 +- .../ODM/PHPCR/Event/MoveEventArgsTest.php | 2 +- .../ODM/PHPCR/Functional/EventManagerTest.php | 1 + .../Functional/EventObjectUpdateTest.php | 20 +- .../Functional/Hierarchy/ChildrenTest.php | 3 + .../Mapping/AnnotationMappingTest.php | 383 ------------------ .../{Attribute => }/AttributeMappingTest.php | 9 +- .../Tests/ODM/PHPCR/Functional/MixinTest.php | 2 +- .../ODM/PHPCR/Functional/ReferrerTest.php | 2 +- .../Translation/DocumentManagerTest.php | 2 +- .../Translation/TranslationTest.php | 8 +- ...AnnotationsTest.php => AttributesTest.php} | 20 +- .../ODM/PHPCR/Id/AssignedIdGeneratorTest.php | 2 +- .../ODM/PHPCR/Id/ParentIdGeneratorTest.php | 4 +- .../PHPCR/Id/RepositoryIdGeneratorTest.php | 2 +- .../Mapping/AbstractMappingDriverTest.php | 2 +- .../PHPCR/Mapping/AnnotationDriverTest.php | 37 -- .../ODM/PHPCR/Mapping/AttributeDriverTest.php | 2 +- .../Mapping/ClassMetadataFactoryTest.php | 13 +- .../ODM/PHPCR/Mapping/ClassMetadataTest.php | 36 +- .../Model/ChildClassesAndLeafObject.php | 6 - .../Mapping/Model/ChildClassesObject.php | 6 - .../Mapping/Model/ChildMappingObject.php | 6 - .../Mapping/Model/ChildrenMappingObject.php | 6 - .../ClassInheritanceChildMappingObject.php | 3 - ...InheritanceChildOverridesMappingObject.php | 14 +- .../ClassInheritanceParentMappingObject.php | 12 +- .../Mapping/Model/DefaultMappingObject.php | 4 - .../Mapping/Model/DepthMappingObject.php | 5 - .../Mapping/Model/FieldMappingObject.php | 16 - .../Model/InheritedMixinMappingObject.php | 5 - .../ODM/PHPCR/Mapping/Model/IsLeafObject.php | 4 - .../Model/LifecycleCallbackMappingObject.php | 11 - .../Model/MappedSuperclassMappingObject.php | 4 - .../Mapping/Model/MixinMappingObject.php | 11 +- .../PHPCR/Mapping/Model/NodeMappingObject.php | 5 - .../Mapping/Model/NodeTypeMappingObject.php | 4 - .../Mapping/Model/NodenameMappingObject.php | 5 - .../Model/ParentDocumentMappingObject.php | 5 - .../Model/ReferenceManyMappingObject.php | 6 - .../Model/ReferenceOneMappingObject.php | 6 - .../Model/ReferenceableChildMappingObject.php | 4 - ...leChildReferenceableFalseMappingObject.php | 3 - .../Model/ReferenceableMappingObject.php | 4 - .../Mapping/Model/ReferrersMappingObject.php | 16 - .../Model/ReplaceMixinMappingObject.php | 7 - .../Mapping/Model/RepositoryMappingObject.php | 4 - .../Model/StringExtendedMappingObject.php | 6 - .../Mapping/Model/StringMappingObject.php | 5 - .../Mapping/Model/TranslatorMappingObject.php | 13 - .../TranslatorMappingObjectNoStrategy.php | 14 - .../Model/UniqueNodeTypeMappingObject.php | 4 - .../PHPCR/Mapping/Model/UuidMappingObject.php | 6 - .../UuidMappingObjectNotReferenceable.php | 5 - .../Model/VersionableMappingObject.php | 6 - ...Mapping.Model.VersionableMappingObject.php | 4 +- .../ODM/PHPCR/PHPCRFunctionalTestCase.php | 11 +- .../Tests/ODM/PHPCR/Query/QueryTest.php | 8 +- tests/bootstrap.php | 6 - 133 files changed, 247 insertions(+), 1604 deletions(-) delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Child.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Children.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Depth.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Document.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Field.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Id.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Locale.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/MappedSuperclass.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/MixedReferrers.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Node.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Nodename.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/ParentDocument.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/PostLoad.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/PostPersist.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/PostRemove.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/PostUpdate.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/PrePersist.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/PreRemove.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/PreUpdate.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Property.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Reference.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/ReferenceMany.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/ReferenceOne.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Referrers.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/TranslatableProperty.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Uuid.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/VersionCreated.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Annotations/VersionName.php delete mode 100644 lib/Doctrine/ODM/PHPCR/Mapping/Driver/AnnotationDriver.php delete mode 100644 tests/Doctrine/Tests/ODM/PHPCR/Functional/Mapping/AnnotationMappingTest.php rename tests/Doctrine/Tests/ODM/PHPCR/Functional/Mapping/{Attribute => }/AttributeMappingTest.php (97%) rename tests/Doctrine/Tests/ODM/PHPCR/Functional/Versioning/{AnnotationsTest.php => AttributesTest.php} (87%) delete mode 100644 tests/Doctrine/Tests/ODM/PHPCR/Mapping/AnnotationDriverTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c5c8ae1d..77d4b1e79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ Changelog * DocumentManager::flush no longer saves the PHPCR session if there are no changes on the ODM layer. -* Removed deprecated annotations for fields. Use `@Field(type="...")` instead. +* Removed annotation mappings. Use attributes (or XML or YAML) instead. ### New Features diff --git a/cli-config.doctrine_dbal.php.dist b/cli-config.doctrine_dbal.php.dist index d6746bbc6..7d66902a8 100644 --- a/cli-config.doctrine_dbal.php.dist +++ b/cli-config.doctrine_dbal.php.dist @@ -37,10 +37,9 @@ if (isset($argv[1]) /* prepare the doctrine configuration */ $config = new \Doctrine\ODM\PHPCR\Configuration(); - $driver = new \Doctrine\ODM\PHPCR\Mapping\Driver\AnnotationDriver( - new \Doctrine\Common\Annotations\AnnotationReader(), + $driver = new \Doctrine\ODM\PHPCR\Mapping\Driver\AttributeDriver([ __DIR__ . '/lib/Doctrine/ODM/PHPCR/Document' - ); + ]); $config->setMetadataDriverImpl($driver); $dm = \Doctrine\ODM\PHPCR\DocumentManager::create($session, $config); diff --git a/cli-config.jackrabbit.php.dist b/cli-config.jackrabbit.php.dist index b3e0b6bfa..85876f9d5 100644 --- a/cli-config.jackrabbit.php.dist +++ b/cli-config.jackrabbit.php.dist @@ -35,10 +35,9 @@ $session = $repository->login($credentials, $workspace); /* prepare the doctrine configuration */ $config = new \Doctrine\ODM\PHPCR\Configuration(); -$driver = new \Doctrine\ODM\PHPCR\Mapping\Driver\AnnotationDriver( - new \Doctrine\Common\Annotations\AnnotationReader(), +$driver = new \Doctrine\ODM\PHPCR\Mapping\Driver\AttributeDriver([ __DIR__ . '/lib/Doctrine/ODM/PHPCR/Document' -); +]); $config->setMetadataDriverImpl($driver); $dm = \Doctrine\ODM\PHPCR\DocumentManager::create($session, $config); diff --git a/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']); -}