diff --git a/.github/workflows/test-application.yaml b/.github/workflows/test-application.yaml index a2ac06a4a..59178334b 100644 --- a/.github/workflows/test-application.yaml +++ b/.github/workflows/test-application.yaml @@ -27,38 +27,31 @@ jobs: matrix: php-version: - - '7.4' - '8.0' - '8.1' - '8.2' + - '8.3' dependencies: [highest] symfony-version: ['*'] jackalope-version: ['1.*'] include: - - php-version: '7.4' - dependencies: lowest - symfony-version: '*' - - php-version: '7.4' - dependencies: highest - symfony-version: '5.4.*' - php-bench: true - - php-version: '8.0' - dependencies: lowest - symfony-version: '*' - - php-version: '8.0' - dependencies: highest - symfony-version: '6.*' - - php-version: '8.1' - dependencies: highest - symfony-version: '5.4.*' - - php-version: '8.2' - dependencies: highest - symfony-version: '6.*' - - php-version: '8.2' - dependencies: highest - symfony-version: '6.*' - jackalope-version: '2.*' - php-bench: true + - php-version: '8.0' + dependencies: lowest + symfony-version: '*' + - php-version: '8.0' + dependencies: highest + symfony-version: '6.*' + - php-version: '8.1' + dependencies: highest + symfony-version: '5.4.*' + - php-version: '8.2' + dependencies: highest + symfony-version: '6.*' + - php-version: '8.2' + dependencies: highest + symfony-version: '6.*' + jackalope-version: '2.*' + php-bench: true steps: - name: Checkout project @@ -116,38 +109,31 @@ jobs: matrix: php-version: - - '7.4' - '8.0' - '8.1' - '8.2' + - '8.3' dependencies: [highest] symfony-version: ['*'] jackalope-version: ['1.*'] include: - - php-version: '7.4' - dependencies: lowest - symfony-version: '*' - - php-version: '7.4' - dependencies: highest - symfony-version: '5.4.*' - php-bench: true - - php-version: '8.0' - dependencies: lowest - symfony-version: '*' - - php-version: '8.0' - dependencies: highest - symfony-version: '6.*' - - php-version: '8.1' - dependencies: highest - symfony-version: 5.4.* - - php-version: '8.2' - dependencies: highest - symfony-version: '6.*' - - php-version: '8.2' - dependencies: highest - symfony-version: '6.*' - jackalope-version: '2.*' - php-bench: true + - php-version: '8.0' + dependencies: lowest + symfony-version: '*' + - php-version: '8.0' + dependencies: highest + symfony-version: '6.*' + - php-version: '8.1' + dependencies: highest + symfony-version: 5.4.* + - php-version: '8.2' + dependencies: highest + symfony-version: '6.*' + - php-version: '8.2' + dependencies: highest + symfony-version: '6.*' + jackalope-version: '2.*' + php-bench: true steps: - name: Checkout project diff --git a/CHANGELOG.md b/CHANGELOG.md index cc128fe4a..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 @@ -30,6 +30,22 @@ Dropped support for PHP < 7.4 and Symfony < 5.4. 1.x === +1.8.1 (unreleased) +------------------ + +* Convert provided documents to use attributes instead of annotations. + +1.8.0 +----- + +* Add support for PHP attributes (only for the annotations that are not deprecated) +* Drop support for PHP 7. + +1.7.2 +----- + +* Maintenance release with doc and phpunit test cleanups. + 1.7.1 ----- @@ -364,7 +380,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/README.md b/README.md index f29b0d349..3aafdfc83 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=2.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/cli-config.doctrine_dbal.php.dist b/cli-config.doctrine_dbal.php.dist index f5c86eb9b..7d66902a8 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. */ @@ -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 421d2c4ef..85876f9d5 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. */ @@ -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 11d0b25fc..6435c9393 100644 --- a/composer.json +++ b/composer.json @@ -21,10 +21,10 @@ "minimum-stability": "beta", "prefer-stable": true, "require": { - "php": "^7.4 || ^8.0", + "php": "^8.0", "doctrine/collections": "^1.0 || ^2.0", "doctrine/common": "^2.4 || ^3.0", - "doctrine/annotations": "^1.13 || ^2.0", + "doctrine/annotations": "^1.14.3 || ^2.0", "doctrine/data-fixtures": "^1.0", "doctrine/event-manager": "^1.0 || ^2.0", "doctrine/persistence": "^2.4", @@ -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/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 ` 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..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. @@ -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..932f65623 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 @@ -131,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/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/Document/AbstractFile.php b/lib/Doctrine/ODM/PHPCR/Document/AbstractFile.php index 1665d2383..48ba09422 100644 --- a/lib/Doctrine/ODM/PHPCR/Document/AbstractFile.php +++ b/lib/Doctrine/ODM/PHPCR/Document/AbstractFile.php @@ -3,48 +3,35 @@ 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 PHPCR; use PHPCR\NodeInterface; /** * This class represents an abstract "file". - * - * @PHPCRODM\MappedSuperclass(mixins="mix:created") */ +#[PHPCR\MappedSuperclass(mixins: ['mix:created'])] abstract class AbstractFile implements HierarchyInterface { - /** - * @PHPCRODM\Id(strategy="parent") - */ + #[PHPCR\Id(strategy: 'parent')] protected string $id; - /** - * @PHPCRODM\Node - */ + #[PHPCR\Node] protected NodeInterface $node; - /** - * @PHPCRODM\Nodename - */ + #[PHPCR\Nodename] protected string $nodename = ''; - /** - * @PHPCRODM\ParentDocument - */ + #[PHPCR\ParentDocument] protected ?object $parent; - /** - * @PHPCRODM\Field(type="date", property="jcr:created") - */ + #[PHPCR\Field(property: 'jcr:created', type: 'date')] protected ?\DateTimeInterface $created = null; - /** - * @PHPCRODM\Field(type="string", property="jcr:createdBy") - */ + #[PHPCR\Field(property: 'jcr:createdBy', type: 'string')] protected ?string $createdBy = null; /** - * Set the id (the PHPCR path). + * Set the id (the PHPCR path). */ public function setId(string $id): self { diff --git a/lib/Doctrine/ODM/PHPCR/Document/File.php b/lib/Doctrine/ODM/PHPCR/Document/File.php index a7dba1993..a8c6b903b 100644 --- a/lib/Doctrine/ODM/PHPCR/Document/File.php +++ b/lib/Doctrine/ODM/PHPCR/Document/File.php @@ -3,20 +3,17 @@ 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 PHPCR; /** * 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) */ +#[PHPCR\Document(nodeType: 'nt:file', mixins: [], referenceable: true)] class File extends AbstractFile { - /** - * @PHPCRODM\Child(nodeName="jcr:content", cascade="all") - */ + #[PHPCR\Child(nodeName: 'jcr:content', cascade: 'all')] protected Resource $content; /** @@ -79,7 +76,9 @@ public function getContent(): Resource /** * Set the content for this file from the given resource or string. * - * @param mixed|string $content the content for the file as string or PHP stream + * @param resource|string $content the content for the file + * + * @phpstan-param closed-resource|string $content */ public function setFileContent($content): self { @@ -100,6 +99,10 @@ 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/Folder.php b/lib/Doctrine/ODM/PHPCR/Document/Folder.php index 8cd304486..e5d7220a6 100644 --- a/lib/Doctrine/ODM/PHPCR/Document/Folder.php +++ b/lib/Doctrine/ODM/PHPCR/Document/Folder.php @@ -5,7 +5,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 PHPCR; /** * This class represents a Folder in the repository, aka nt:folder. @@ -14,19 +14,17 @@ * * 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={}) */ +#[PHPCR\Document(nodeType: 'nt:folder', mixins: [])] class Folder extends AbstractFile { /** - * @PHPCRODM\Children(cascade="all") + * @var Collection */ + #[PHPCR\Children(cascade: 'all')] protected Collection $children; - /** - * @PHPCRODM\Child(cascade="all") - */ + #[PHPCR\Child(cascade: 'all')] protected AbstractFile $child; public function __construct() diff --git a/lib/Doctrine/ODM/PHPCR/Document/Generic.php b/lib/Doctrine/ODM/PHPCR/Document/Generic.php index e3ed65dda..6f928632a 100644 --- a/lib/Doctrine/ODM/PHPCR/Document/Generic.php +++ b/lib/Doctrine/ODM/PHPCR/Document/Generic.php @@ -4,47 +4,44 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; +use Doctrine\ODM\PHPCR\Exception\BadMethodCallException; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; use PHPCR\NodeInterface; /** * 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. - * - * @PHPCRODM\Document() + * 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 { /** - * @PHPCRODM\Id(strategy="parent") + * Id (path) of this document. */ + #[PHPCR\Id(strategy: 'parent')] protected string $id; - /** - * @PHPCRODM\Node - */ + #[PHPCR\Node] protected NodeInterface $node; - /** - * @PHPCRODM\Nodename - */ + #[PHPCR\Nodename] protected string $nodename = ''; - /** - * @PHPCRODM\ParentDocument - */ - protected ?object $parent = null; + #[PHPCR\ParentDocument] + protected ?object $parent; /** - * @PHPCRODM\Children + * @var Collection */ + #[PHPCR\Children] protected Collection $children; /** - * @PHPCRODM\MixedReferrers + * @var Collection */ + #[PHPCR\MixedReferrers] protected Collection $referrers; public function __construct() @@ -58,6 +55,10 @@ public function __construct() */ public function getId(): string { + if (!isset($this->id)) { + throw new BadMethodCallException('Do not call getId on unsaved objects.'); + } + return $this->id; } @@ -90,8 +91,12 @@ public function setNodename(string $name): self /** * The parent document of this document. */ - public function getParentDocument(): ?object + 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 436db9d58..f369183b7 100644 --- a/lib/Doctrine/ODM/PHPCR/Document/Resource.php +++ b/lib/Doctrine/ODM/PHPCR/Document/Resource.php @@ -3,64 +3,48 @@ 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 PHPCR; 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") */ +#[PHPCR\Document(nodeType: 'nt:resource')] class Resource { - /** - * @PHPCRODM\Id - */ + #[PHPCR\Id] protected string $id; - /** - * @PHPCRODM\Node - */ + #[PHPCR\Node] protected NodeInterface $node; - /** - * @PHPCRODM\Nodename - */ - protected string $nodename = ''; + #[PHPCR\Nodename] + protected string $nodename; - /** - * @PHPCRODM\ParentDocument - */ + #[PHPCR\ParentDocument] protected object $parent; /** - * A PHP resource. + * @var resource * - * @PHPCRODM\Field(type="binary", property="jcr:data") + * @phpstan-var closed-resource */ + #[PHPCR\Field(property: 'jcr:data', type: 'binary')] protected $data; - /** - * @PHPCRODM\Field(type="string", property="jcr:mimeType") - */ + #[PHPCR\Field(property: 'jcr:mimeType', type: 'string')] protected string $mimeType = 'application/octet-stream'; - /** - * @PHPCRODM\Field(type="string", property="jcr:encoding", nullable=true) - */ - protected ?string $encoding = null; + #[PHPCR\Field(property: 'jcr:encoding', type: 'string', nullable: true)] + protected string $encoding; - /** - * @PHPCRODM\Field(type="date", property="jcr:lastModified") - */ - protected ?\DateTimeInterface $lastModified = null; + #[PHPCR\Field(property: 'jcr:lastModified', type: 'date')] + protected \DateTimeInterface $lastModified; - /** - * @PHPCRODM\Field(type="string", property="jcr:lastModifiedBy") - */ - protected ?string $lastModifiedBy = null; + #[PHPCR\Field(property: 'jcr:lastModifiedBy', type: 'string')] + protected string $lastModifiedBy; /** * The node name of the file. @@ -104,6 +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 { @@ -114,6 +102,10 @@ public function setData($data): self /** * Get the binary data stream of this resource. + * + * @return resource + * + * @phpstan-return closed-resource */ public function getData() { @@ -135,7 +127,7 @@ public function getData() */ public function getSize(): int { - if (null === $this->node) { + if (!isset($this->node)) { throw new BadMethodCallException('Do not call Resource::getSize on unsaved objects, as it only reads the stored size.'); } 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 e57c31c15..000000000 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Child.php +++ /dev/null @@ -1,22 +0,0 @@ -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 new file mode 100644 index 000000000..7202a55a6 --- /dev/null +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Children.php @@ -0,0 +1,26 @@ +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 new file mode 100644 index 000000000..79daa456b --- /dev/null +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Depth.php @@ -0,0 +1,10 @@ +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 new file mode 100644 index 000000000..c2b31b45c --- /dev/null +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Field.php @@ -0,0 +1,19 @@ +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 new file mode 100644 index 000000000..1d4eea2f0 --- /dev/null +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/PostLoad.php @@ -0,0 +1,10 @@ +cascade = null === $cascade ? null : (array) $cascade; + } +} diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/ReferenceMany.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/ReferenceMany.php new file mode 100644 index 000000000..7b9102a41 --- /dev/null +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/ReferenceMany.php @@ -0,0 +1,8 @@ +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 new file mode 100644 index 000000000..9a16e8891 --- /dev/null +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Uuid.php @@ -0,0 +1,17 @@ +name = $className; } @@ -518,6 +516,8 @@ public function setIdentifier(string $identifier): void /** * Registers a custom repository class for the document class. + * + * @param class-string $repositoryClassName the class name of the custom repository */ public function setCustomRepositoryClassName(?string $repositoryClassName): void { @@ -570,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 )); @@ -685,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']); } } @@ -977,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 )); @@ -985,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 )); @@ -1082,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)); @@ -1604,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); @@ -1660,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 new file mode 100644 index 000000000..1a6832d81 --- /dev/null +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Driver/AttributeDriver.php @@ -0,0 +1,251 @@ +. + */ + +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; + +/** + * 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 (null !== $documentAttribute->childClasses) { + $metadata->setChildClasses($documentAttribute->childClasses); + } + + if (null !== $documentAttribute->isLeaf) { + $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. + * + * @return int a bitmask of cascade options + */ + 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); + 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..8a2efa1c1 --- /dev/null +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Driver/AttributeReader.php @@ -0,0 +1,59 @@ +convertToAttributeInstances($class->getAttributes()); + } + + /** + * @return MappingAttribute[] + */ + public function getMethodAttributes(\ReflectionMethod $method): array + { + return $this->convertToAttributeInstances($method->getAttributes()); + } + + /** + * @return MappingAttribute[] + */ + public function getPropertyAttributes(\ReflectionProperty $property): array + { + return $this->convertToAttributeInstances($property->getAttributes()); + } + + /** + * @return 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/Driver/BuiltinDocumentsDriver.php b/lib/Doctrine/ODM/PHPCR/Mapping/Driver/BuiltinDocumentsDriver.php index 508c82041..6a5181606 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; @@ -20,19 +19,19 @@ class BuiltinDocumentsDriver implements MappingDriver public const NAME_SPACE = 'Doctrine\ODM\PHPCR\Document'; private MappingDriver $wrappedDriver; - private AnnotationDriver $builtinDriver; + + private AttributeDriver $builtinDriver; 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')]); } public function loadMetadataForClass($className, ClassMetadata $class): void { - if (0 === strpos($className, self::NAME_SPACE)) { + if (str_starts_with($className, self::NAME_SPACE)) { $this->builtinDriver->loadMetadataForClass($className, $class); return; @@ -51,7 +50,7 @@ public function getAllClassNames(): array public function isTransient($className): bool { - if (0 === strpos($className, self::NAME_SPACE)) { + if (str_starts_with($className, self::NAME_SPACE)) { return $this->builtinDriver->isTransient($className); } 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/MappingAttribute.php b/lib/Doctrine/ODM/PHPCR/Mapping/MappingAttribute.php new file mode 100644 index 000000000..798a1b00c --- /dev/null +++ b/lib/Doctrine/ODM/PHPCR/Mapping/MappingAttribute.php @@ -0,0 +1,10 @@ +name )); } diff --git a/lib/Doctrine/ODM/PHPCR/Tools/Console/Command/RegisterSystemNodeTypesCommand.php b/lib/Doctrine/ODM/PHPCR/Tools/Console/Command/RegisterSystemNodeTypesCommand.php index 38822fa36..61088dfca 100644 --- a/lib/Doctrine/ODM/PHPCR/Tools/Console/Command/RegisterSystemNodeTypesCommand.php +++ b/lib/Doctrine/ODM/PHPCR/Tools/Console/Command/RegisterSystemNodeTypesCommand.php @@ -9,7 +9,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/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/Blog/Comment.php b/tests/Doctrine/Tests/Models/Blog/Comment.php index 04d812c9c..064471ed5 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 b8d29d8f5..6fb458139 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 4a3db951a..420c6b7f1 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsArticle.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsArticle.php @@ -3,31 +3,29 @@ 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; -/** - * @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 519bb09d4..2e096bb3c 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 378291414..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 84c2f7f9b..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 91edda7da..04331fa66 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 044dca7fa..4ff24f1c0 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 97a93f4df..537292a91 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 991652626..348b4269c 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 e4b085469..33470242b 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 dce23dc22..15ece8cb7 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 f2d8e8b68..ef331c26c 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 32a889e08..6f15f4c1a 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..3d713c0e2 100644 --- a/tests/Doctrine/Tests/Models/References/RefCascadeManyTestObj.php +++ b/tests/Doctrine/Tests/Models/References/RefCascadeManyTestObj.php @@ -3,20 +3,18 @@ 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 034d546e7..2faed8e8c 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..fb351c58a 100644 --- a/tests/Doctrine/Tests/Models/Translation/InvalidMapping.php +++ b/tests/Doctrine/Tests/Models/Translation/InvalidMapping.php @@ -3,27 +3,23 @@ /** * !!! 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 !!! */ 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..3eb1815d8 100644 --- a/tests/Doctrine/Tests/Models/Translation/NoLocalePropertyArticle.php +++ b/tests/Doctrine/Tests/Models/Translation/NoLocalePropertyArticle.php @@ -2,38 +2,35 @@ 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. * * !!! 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 !!! */ - -/** - * @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 c7c88e77e..62c741000 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/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/BasicCrudTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/BasicCrudTest.php index d901cb361..b8c786946 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; @@ -652,81 +652,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; } @@ -738,56 +728,48 @@ public function generateId(object $document, object $parent = null): string } } -/** - * @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/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 7446c03a5..640b11870 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; @@ -53,9 +53,9 @@ public function testComputingBetweenEvents(): void $this->dm->flush(); $this->assertInstanceOf('stdClass', $entity->status); - $this->assertObjectHasAttribute('value', $entity->status); - $this->assertEquals($entity->status->value, 'active'); - $this->assertObjectNotHasAttribute('foo', $entity->status); + $this->assertObjectHasProperty('value', $entity->status); + $this->assertSame('active', $entity->status->value); + $this->assertObjectNotHasProperty('foo', $entity->status); $entity->status->value = 'inactive'; $entity->status->foo = 'bar2'; @@ -64,44 +64,42 @@ public function testComputingBetweenEvents(): void $this->dm->flush(); $this->assertInstanceOf('stdClass', $entity->status); - $this->assertObjectHasAttribute('value', $entity->status); - $this->assertEquals($entity->status->value, 'inactive'); - $this->assertObjectNotHasAttribute('foo', $entity->status); - $this->assertEquals($entity->text, 'test2'); + $this->assertObjectHasProperty('value', $entity->status); + $this->assertSame('inactive', $entity->status->value); + $this->assertObjectNotHasProperty('foo', $entity->status); + $this->assertSame('test2', $entity->text); $this->dm->clear(); $entity = $this->dm->find(null, $entity->id); $this->assertInstanceOf('stdClass', $entity->status); - $this->assertObjectHasAttribute('value', $entity->status); - $this->assertEquals($entity->status->value, 'inactive'); - $this->assertObjectNotHasAttribute('foo', $entity->status); - $this->assertEquals($entity->text, 'test2'); + $this->assertObjectHasProperty('value', $entity->status); + $this->assertSame('inactive', $entity->status->value); + $this->assertObjectNotHasProperty('foo', $entity->status); + $this->assertSame('test2', $entity->text); $entity->status->value = 'active'; $this->dm->flush(); $this->assertInstanceOf('stdClass', $entity->status); - $this->assertObjectHasAttribute('value', $entity->status); - $this->assertEquals($entity->status->value, 'active'); - $this->assertEquals($entity->text, 'test2'); + $this->assertObjectHasProperty('value', $entity->status); + $this->assertSame('active', $entity->status->value); + $this->assertSame('test2', $entity->text); } } -/** - * @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 d42356895..191384c01 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,24 +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 c05a07a74..b4f98e69e 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\PropertyType; @@ -134,38 +134,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 51d897891..caf351f5e 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 3d667a782..103a37b3e 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 844d532bf..263ec2778 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\PersistentCollection; use Doctrine\ODM\PHPCR\PHPCRException; use Doctrine\Persistence\Event\LifecycleEventArgs; @@ -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'; @@ -697,9 +700,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() @@ -708,20 +709,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; } @@ -739,66 +739,52 @@ public function generateId(object $document, object $parent = null): string } } -/** - * @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 045b6df22..25f10d5cd 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; @@ -274,35 +274,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/Mapping/AnnotationMappingTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Mapping/AttributeMappingTest.php similarity index 82% rename from tests/Doctrine/Tests/ODM/PHPCR/Functional/Mapping/AnnotationMappingTest.php rename to tests/Doctrine/Tests/ODM/PHPCR/Functional/Mapping/AttributeMappingTest.php index caecc5774..d6e422012 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/Mapping/AnnotationMappingTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Mapping/AttributeMappingTest.php @@ -5,7 +5,7 @@ use Doctrine\ODM\PHPCR\DocumentManager; 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; use Doctrine\ODM\PHPCR\Mapping\ClassMetadata; use Doctrine\ODM\PHPCR\Mapping\MappingException; use Doctrine\ODM\PHPCR\Translation\LocaleChooser\LocaleChooser; @@ -14,7 +14,7 @@ /** * @group functional */ -class AnnotationMappingTest extends PHPCRFunctionalTestCase +class AttributeMappingTest extends PHPCRFunctionalTestCase { /** * @var DocumentManager @@ -27,7 +27,7 @@ public function setUp(): void $this->resetFunctionalNode($this->dm); } - public function testAnnotationInheritance(): void + public function testAttributeInheritance(): void { $extending = new ExtendingClass(); $extending->id = '/functional/extending'; @@ -195,140 +195,116 @@ public function testPersistRepository(): void // then a test per mapping implementation extending the abstract test and providing documents with the mapping } -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class Testclass { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; - /** @PHPCRODM\Node */ + #[PHPCR\Node] public $node; - /** @PHPCRODM\Field(type="string") */ + #[PHPCR\Field(type: 'string')] public $text; - /** @PHPCRODM\Depth */ + #[PHPCR\Depth] public $depth; - public $callback_run = 0; + public int $callback_run = 0; - /** - * @PHPCRODM\PostPersist - */ + #[PHPCR\PostPersist] public function callback(): void { ++$this->callback_run; } } -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class ExtendingClass extends Testclass { - /** @PHPCRODM\ReferenceOne */ + #[PHPCR\ReferenceOne] public $reference; - public $extending_run = 0; + public int $extending_run = 0; - /** - * @PHPCRODM\PostPersist - */ + #[PHPCR\PostPersist] public function extendingCallback(): void { ++$this->extending_run; } } -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class SecondLevel extends ExtendingClass { } -/** - * @PHPCRODM\Document() - */ +#[PHPCR\Document] class SecondLevelWithDuplicate extends ExtendingClass { - /** @PHPCRODM\Field(type="long") */ + #[PHPCR\Field(type: 'long')] public $text; } -/** - * @PHPCRODM\Document(translator="attribute") - */ +#[PHPCR\Document(translator: 'attribute')] class SecondLevelWithDuplicateOverwrite extends ExtendingClass { - /** @PHPCRODM\Locale */ + #[PHPCR\Locale] public $locale; - /** @PHPCRODM\Field(type="string", translated=true) */ + #[PHPCR\Field(type: 'string', translated: true)] public $text; } -/** - * @PHPCRODM\Document - */ +#[PHPCR\Document] class ParentIdStrategy { - /** @PHPCRODM\Nodename */ + #[PHPCR\Nodename] public $name; - /** @PHPCRODM\ParentDocument */ + #[PHPCR\ParentDocument] public $parent; } -/** - * @PHPCRODM\Document - */ +#[PHPCR\Document] class ParentIdStrategyDifferentOrder { - /** @PHPCRODM\Nodename */ + #[PHPCR\Nodename] public $name; - /** @PHPCRODM\ParentDocument */ + #[PHPCR\ParentDocument] public $parent; - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; } -/** - * @PHPCRODM\Document - */ +#[PHPCR\Document] class AutoNameIdStrategy { - /** @PHPCRODM\ParentDocument */ + #[PHPCR\ParentDocument] public $parent; } -/** - * @PHPCRODM\Document - */ +#[PHPCR\Document] class AssignedIdStrategy { - /** @PHPCRODM\Id(strategy="assigned") */ + #[PHPCR\Id(strategy: 'assigned')] public $id; - /** @PHPCRODM\Nodename */ + #[PHPCR\Nodename] public $name; - /** @PHPCRODM\ParentDocument */ + #[PHPCR\ParentDocument] public $parent; } -/** - * @PHPCRODM\Document(repositoryClass="Doctrine\Tests\ODM\PHPCR\Functional\Mapping\Repository") - */ +#[PHPCR\Document(repositoryClass: Repository::class)] class RepositoryIdStrategy { public $title; - /** @PHPCRODM\Id(strategy="repository") */ + #[PHPCR\Id(strategy: 'repository')] public $id; } class Repository extends DocumentRepository implements RepositoryIdInterface @@ -340,44 +316,39 @@ public function generateId(object $document, object $parent = null): string } /** - * @PHPCRODM\Document - * - * Invalid document missing a parent mapping for the id strategy + * Invalid document missing a parent mapping for the id strategy. */ +#[PHPCR\Document] class ParentIdNoParentStrategy { - /** @PHPCRODM\Id(strategy="parent") */ + #[PHPCR\Id(strategy: 'parent')] public $id; - /** @PHPCRODM\Nodename */ + #[PHPCR\Nodename] public $name; } /** - * @PHPCRODM\Document - * * Invalid document not having a parent mapping. */ +#[PHPCR\Document] class AutoNameIdNoParentStrategy { - /** @PHPCRODM\Id(strategy="auto") */ + #[PHPCR\Id(strategy: 'auto')] public $id; } /** - * @PHPCRODM\Document - * * Invalid document not having an id at all. */ +#[PHPCR\Document] class NoId { } -/** - * @PHPCRODM\Document - */ +#[PHPCR\Document] class StandardCase { - /** @PHPCRODM\Id */ + #[PHPCR\Id] public $id; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/MixinTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/MixinTest.php index 070e07b94..bd9ab70ba 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 e5f53002c..890208861 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 1fb69a85d..d7aeaf58f 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 f901ffd94..6476c8f7e 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; @@ -106,44 +106,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:protected_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 8e584cebe..7e0c013ab 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; @@ -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'); } @@ -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 0ee93abc9..65e22594f 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/QuerySql2Test.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/QuerySql2Test.php @@ -4,7 +4,7 @@ use Doctrine\ODM\PHPCR\DocumentManager; use Doctrine\ODM\PHPCR\DocumentRepository; -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\Query\InvalidQueryException; @@ -143,20 +143,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 d7d68609a..f564a0f46 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 141512616..cf30042f9 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; @@ -635,192 +635,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/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/TranslationHierarchyTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Translation/TranslationHierarchyTest.php index 7df14abfe..0c99cef7c 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; @@ -193,48 +193,45 @@ 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); } } -/** - * @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/Translation/TranslationTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Translation/TranslationTest.php index d878add1b..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); @@ -53,17 +53,17 @@ 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); } /** - * 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/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 186e20626..d02c31bee 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; @@ -399,17 +399,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; } 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 b34cfa156..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 */ @@ -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/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 new file mode 100644 index 000000000..b60132d0d --- /dev/null +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/AttributeDriverTest.php @@ -0,0 +1,34 @@ +loadDriver(); + $attributeDriver->addPaths([__DIR__.'/Model']); + + return $attributeDriver; + } + + /** + * Overwriting private parent properties isn't supported with attributes. + * + * @doesNotPerformAssertions + */ + public function testParentWithPrivatePropertyMapping(): void + { + } +} 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 e1e5d9f11..f83bc283e 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ChildClassesAndLeafObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ChildClassesAndLeafObject.php @@ -2,17 +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 93e94bf41..53d6db0a1 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ChildClassesObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ChildClassesObject.php @@ -2,17 +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 b41437346..91895dff7 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ChildMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ChildMappingObject.php @@ -2,21 +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 9859a55a6..969c31d2e 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ChildrenMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ChildrenMappingObject.php @@ -2,21 +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 7a942b571..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,13 @@ 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 31cb0c00b..847a0dd15 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ClassInheritanceChildOverridesMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ClassInheritanceChildOverridesMappingObject.php @@ -2,21 +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 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, + 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 bf9cdbe99..efb014362 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ClassInheritanceParentMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ClassInheritanceParentMappingObject.php @@ -2,23 +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 8852e8678..07ba5a6d4 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/DefaultMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/DefaultMappingObject.php @@ -2,15 +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 7aff8343b..7a734ce22 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/DepthMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/DepthMappingObject.php @@ -2,18 +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 291a719c9..ea99b216b 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/FieldMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/FieldMappingObject.php @@ -2,51 +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 8d85dfca3..95429af64 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/InheritedMixinMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/InheritedMixinMappingObject.php @@ -2,18 +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 6bcc3f9c1..170b91042 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/IsLeafObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/IsLeafObject.php @@ -2,15 +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 acdbbc043..9a7de9baa 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/LifecycleCallbackMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/LifecycleCallbackMappingObject.php @@ -2,49 +2,48 @@ 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 7787fef85..d6dc8efdc 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/MappedSuperclassMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/MappedSuperclassMappingObject.php @@ -2,15 +2,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\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 a19dabf46..560865e1d 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/MixinMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/MixinMappingObject.php @@ -2,24 +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(property: 'jcr:lastModified', type: 'date')] public $lastModified; - /** @PHPCRODM\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 fdfa6a0ed..c7f4b1511 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/NodeMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/NodeMappingObject.php @@ -2,18 +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 2f2a5122e..8086c37b7 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/NodeTypeMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/NodeTypeMappingObject.php @@ -2,15 +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 0df626b77..4ab5e25d8 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/NodenameMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/NodenameMappingObject.php @@ -2,18 +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 695965e6f..ae01c0efa 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ParentDocumentMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ParentDocumentMappingObject.php @@ -2,18 +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 7e7edea55..48baac1e3 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferenceManyMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferenceManyMappingObject.php @@ -2,21 +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 e98d0c2c5..2054b0390 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferenceOneMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferenceOneMappingObject.php @@ -2,21 +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 32ae8e9b5..206967cbe 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferenceableChildMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferenceableChildMappingObject.php @@ -2,16 +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 6e5217962..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,13 @@ 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 165c91397..cf92b73d9 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferenceableMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferenceableMappingObject.php @@ -2,15 +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 9e455dc11..815ab731b 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferrersMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReferrersMappingObject.php @@ -2,35 +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 8e16e2f34..908d39e45 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReplaceMixinMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/ReplaceMixinMappingObject.php @@ -2,24 +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 c3a9faf17..2f236271e 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/RepositoryMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/RepositoryMappingObject.php @@ -2,15 +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 c0f75cf6f..b4c2cb809 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/StringExtendedMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/StringExtendedMappingObject.php @@ -2,22 +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 1abff2340..e2d2c5f2b 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/StringMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/StringMappingObject.php @@ -2,18 +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 1fc78974d..573bc2822 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/TranslatorMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/TranslatorMappingObject.php @@ -2,47 +2,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 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 7fd6421b0..b800e0654 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/TranslatorMappingObjectNoStrategy.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/TranslatorMappingObjectNoStrategy.php @@ -2,47 +2,38 @@ 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; /** * 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 6a9cebb31..47d6e417b 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/UniqueNodeTypeMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/UniqueNodeTypeMappingObject.php @@ -2,15 +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 4313aa678..3125f7bd1 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/UuidMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/UuidMappingObject.php @@ -2,16 +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 349d2c8db..2e9965dad 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/UuidMappingObjectNotReferenceable.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/UuidMappingObjectNotReferenceable.php @@ -2,18 +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 08d88389c..bb37abb24 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/VersionableMappingObject.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/VersionableMappingObject.php @@ -2,21 +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 215e4ca6f..fd511af10 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/PHPCRFunctionalTestCase.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/PHPCRFunctionalTestCase.php @@ -2,11 +2,10 @@ 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; use PHPCR\NodeInterface; @@ -24,20 +23,18 @@ abstract class PHPCRFunctionalTestCase extends TestCase public function createDocumentManager(array $paths = null): DocumentManager { - AnnotationReader::addGlobalIgnoredName('group'); - if (empty($paths)) { $paths = [__DIR__.'/../../Models']; } - $metaDriver = new AnnotationDriver(new AnnotationReader(), $paths); + $metaDriver = 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; } } 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']); -}