Skip to content

Commit 56e0ac0

Browse files
authored
Merge 2.10.x into 2.11.x (#9248)
2 parents 4219506 + 12a70bb commit 56e0ac0

File tree

6 files changed

+70
-63
lines changed

6 files changed

+70
-63
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@
4141
"phpbench/phpbench": "^0.16.10 || ^1.0",
4242
"phpstan/phpstan": "1.2.0",
4343
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.4",
44-
"squizlabs/php_codesniffer": "3.6.1",
44+
"squizlabs/php_codesniffer": "3.6.2",
4545
"symfony/cache": "^4.4 || ^5.2",
4646
"symfony/yaml": "^3.4 || ^4.0 || ^5.0 || ^6.0",
47-
"vimeo/psalm": "4.13.1"
47+
"vimeo/psalm": "4.15.0"
4848
},
4949
"conflict": {
5050
"doctrine/annotations": "<1.13 || >= 2.0"

docs/en/reference/events.rst

Lines changed: 57 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -136,38 +136,38 @@ entity, see :ref:`Lifecycle Callbacks<lifecycle-callbacks>`.
136136
Events Overview
137137
---------------
138138

139-
+-----------------------------------------------------------------+-----------------------+-----------+
140-
| Event | Dispatched by | Lifecycle |
141-
| | | Callback |
142-
+=================================================================+=======================+===========+
143-
| :ref:`preRemove<reference-events-pre-remove>` | ``$em->remove()`` | Yes |
144-
+-----------------------------------------------------------------+-----------------------+-----------+
145-
| :ref:`postRemove<reference-events-post-update-remove-persist>` | ``$em->flush()`` | Yes |
146-
+-----------------------------------------------------------------+-----------------------+-----------+
147-
| :ref:`prePersist<reference-events-pre-persist>` | ``$em->persist()`` | Yes |
148-
| | on *initial* persist | |
149-
+-----------------------------------------------------------------+-----------------------+-----------+
150-
| :ref:`postPersist<reference-events-post-update-remove-persist>` | ``$em->flush()`` | Yes |
151-
+-----------------------------------------------------------------+-----------------------+-----------+
152-
| :ref:`preUpdate<reference-events-pre-update>` | ``$em->flush()`` | Yes |
153-
+-----------------------------------------------------------------+-----------------------+-----------+
154-
| :ref:`postUpdate<reference-events-post-update-remove-persist>` | ``$em->flush()`` | Yes |
155-
+-----------------------------------------------------------------+-----------------------+-----------+
156-
| :ref:`postLoad<reference-events-post-load>` | Loading from database | Yes |
157-
+-----------------------------------------------------------------+-----------------------+-----------+
158-
| :ref:`loadClassMetadata<reference-events-load-class-metadata>` | Loading of mapping | No |
159-
| | metadata | |
160-
+-----------------------------------------------------------------+-----------------------+-----------+
161-
| ``onClassMetadataNotFound`` | ``MappingException`` | No |
162-
+-----------------------------------------------------------------+-----------------------+-----------+
163-
| :ref:`preFlush<reference-events-pre-flush>` | ``$em->flush()`` | Yes |
164-
+-----------------------------------------------------------------+-----------------------+-----------+
165-
| :ref:`onFlush<reference-events-on-flush>` | ``$em->flush()`` | No |
166-
+-----------------------------------------------------------------+-----------------------+-----------+
167-
| :ref:`postFlush<reference-events-post-flush>` | ``$em->flush()`` | No |
168-
+-----------------------------------------------------------------+-----------------------+-----------+
169-
| ``onClear`` | ``$em->clear()`` | No |
170-
+-----------------------------------------------------------------+-----------------------+-----------+
139+
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
140+
| Event | Dispatched by | Lifecycle | Passed |
141+
| | | Callback | Argument |
142+
+=================================================================+=======================+===========+=====================================+
143+
| :ref:`preRemove<reference-events-pre-remove>` | ``$em->remove()`` | Yes | `_LifecycleEventArgs`_ |
144+
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
145+
| :ref:`postRemove<reference-events-post-update-remove-persist>` | ``$em->flush()`` | Yes | `_LifecycleEventArgs`_ |
146+
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
147+
| :ref:`prePersist<reference-events-pre-persist>` | ``$em->persist()`` | Yes | `_LifecycleEventArgs`_ |
148+
| | on *initial* persist | | |
149+
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
150+
| :ref:`postPersist<reference-events-post-update-remove-persist>` | ``$em->flush()`` | Yes | `_LifecycleEventArgs`_ |
151+
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
152+
| :ref:`preUpdate<reference-events-pre-update>` | ``$em->flush()`` | Yes | `_PreUpdateEventArgs`_ |
153+
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
154+
| :ref:`postUpdate<reference-events-post-update-remove-persist>` | ``$em->flush()`` | Yes | `_LifecycleEventArgs`_ |
155+
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
156+
| :ref:`postLoad<reference-events-post-load>` | Loading from database | Yes | `_LifecycleEventArgs`_ |
157+
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
158+
| :ref:`loadClassMetadata<reference-events-load-class-metadata>` | Loading of mapping | No | `_LoadClassMetadataEventArgs` |
159+
| | metadata | | |
160+
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
161+
| ``onClassMetadataNotFound`` | ``MappingException`` | No | `_OnClassMetadataNotFoundEventArgs` |
162+
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
163+
| :ref:`preFlush<reference-events-pre-flush>` | ``$em->flush()`` | Yes | `_PreFlushEventArgs`_ |
164+
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
165+
| :ref:`onFlush<reference-events-on-flush>` | ``$em->flush()`` | No | `_OnFlushEventArgs` |
166+
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
167+
| :ref:`postFlush<reference-events-post-flush>` | ``$em->flush()`` | No | `_PostFlushEventArgs` |
168+
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
169+
| ``onClear`` | ``$em->clear()`` | No | `_OnClearEventArgs` |
170+
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
171171

172172
Naming convention
173173
~~~~~~~~~~~~~~~~~
@@ -294,6 +294,9 @@ specific to a particular entity class's lifecycle.
294294
.. code-block:: attribute
295295
296296
<?php
297+
298+
use Doctrine\DBAL\Types\Types;
299+
use Doctrine\Persistence\Event\LifecycleEventArgs;
297300
298301
/**
299302
* #[Entity]
@@ -303,11 +306,11 @@ specific to a particular entity class's lifecycle.
303306
{
304307
// ...
305308
306-
#[Column(type: 'string', length: 255)]
309+
#[Column(type: Types::STRING, length: 255)]
307310
public $value;
308311
309312
#[PrePersist]
310-
public function doStuffOnPrePersist()
313+
public function doStuffOnPrePersist(LifecycleEventArgs $eventArgs)
311314
{
312315
$this->createdAt = date('Y-m-d H:i:s');
313316
}
@@ -318,15 +321,17 @@ specific to a particular entity class's lifecycle.
318321
$this->value = 'changed from prePersist callback!';
319322
}
320323
321-
#[PostLoad]
322-
public function doStuffOnPostLoad()
324+
#[PreUpdate]
325+
public function doStuffOnPreUpdate(PreUpdateEventArgs $eventArgs)
323326
{
324-
$this->value = 'changed from postLoad callback!';
327+
$this->value = 'changed from preUpdate callback!';
325328
}
326329
}
327330
.. code-block:: annotation
328331
329332
<?php
333+
334+
use Doctrine\Persistence\Event\LifecycleEventArgs;
330335
331336
/**
332337
* @Entity
@@ -340,7 +345,7 @@ specific to a particular entity class's lifecycle.
340345
public $value;
341346
342347
/** @PrePersist */
343-
public function doStuffOnPrePersist()
348+
public function doStuffOnPrePersist(LifecycleEventArgs $eventArgs)
344349
{
345350
$this->createdAt = date('Y-m-d H:i:s');
346351
}
@@ -351,10 +356,10 @@ specific to a particular entity class's lifecycle.
351356
$this->value = 'changed from prePersist callback!';
352357
}
353358
354-
/** @PostLoad */
355-
public function doStuffOnPostLoad()
359+
/** @PreUpdate */
360+
public function doStuffOnPreUpdate(PreUpdateEventArgs $eventArgs)
356361
{
357-
$this->value = 'changed from postLoad callback!';
362+
$this->value = 'changed from preUpdate callback!';
358363
}
359364
}
360365
.. code-block:: xml
@@ -370,7 +375,7 @@ specific to a particular entity class's lifecycle.
370375
<lifecycle-callbacks>
371376
<lifecycle-callback type="prePersist" method="doStuffOnPrePersist"/>
372377
<lifecycle-callback type="prePersist" method="doOtherStuffOnPrePersist"/>
373-
<lifecycle-callback type="postLoad" method="doStuffOnPostLoad"/>
378+
<lifecycle-callback type="preUpdate" method="doStuffOnPreUpdate"/>
374379
</lifecycle-callbacks>
375380
</entity>
376381
</doctrine-mapping>
@@ -384,7 +389,7 @@ specific to a particular entity class's lifecycle.
384389
type: string(255)
385390
lifecycleCallbacks:
386391
prePersist: [ doStuffOnPrePersist, doOtherStuffOnPrePersist ]
387-
postLoad: [ doStuffOnPostLoad ]
392+
preUpdate: [ doStuffOnPreUpdate ]
388393
389394
Lifecycle Callbacks Event Argument
390395
----------------------------------
@@ -1083,3 +1088,12 @@ and the EntityManager.
10831088
$em = $eventArgs->getEntityManager();
10841089
}
10851090
}
1091+
1092+
.. _LifecycleEventArgs: https://github.com/doctrine/orm/blob/HEAD/lib/Doctrine/ORM/Event/LifecycleEventArgs.php
1093+
.. _PreUpdateEventArgs: https://github.com/doctrine/orm/blob/HEAD/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php
1094+
.. _PreFlushEventArgs: https://github.com/doctrine/orm/blob/HEAD/lib/Doctrine/ORM/Event/PreFlushEventArgs.php
1095+
.. _PostFlushEventArgs: https://github.com/doctrine/orm/blob/HEAD/lib/Doctrine/ORM/Event/PostFlushEventArgs.php
1096+
.. _OnFlushEventArgs: https://github.com/doctrine/orm/blob/HEAD/lib/Doctrine/ORM/Event/OnFlushEventArgs.php
1097+
.. _OnClearEventArgs: https://github.com/doctrine/orm/blob/HEAD/lib/Doctrine/ORM/Event/OnClearEventArgs.php
1098+
.. _LoadClassMetadataEventArgs: https://github.com/doctrine/orm/blob/HEAD/lib/Doctrine/ORM/Event/LoadClassMetadataEventArgs.php
1099+
.. _OnClassMetadataNotFoundEventArgs: https://github.com/doctrine/orm/blob/HEAD/lib/Doctrine/ORM/Event/OnClassMetadataNotFoundEventArgs.php

doctrine-mapping.xsd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@
353353
<xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"/>
354354
</xs:choice>
355355
<xs:attribute name="name" type="xs:NMTOKEN" use="optional"/>
356-
<xs:attribute name="columns" type="xs:string" use="required"/>
356+
<xs:attribute name="columns" type="xs:string" use="optional"/>
357357
<xs:attribute name="fields" type="xs:string" use="optional"/>
358358
<xs:attribute name="flags" type="xs:string" use="optional"/>
359359
<xs:anyAttribute namespace="##other"/>

lib/Doctrine/ORM/Query/Filter/SQLFilter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ final protected function getConnection(): Connection
195195
* Gets the SQL query part to add to a query.
196196
*
197197
* @param string $targetTableAlias
198+
* @psalm-param ClassMetadata<object> $targetEntity
198199
*
199200
* @return string The constraint SQL if there is available, empty string otherwise.
200201
*/

psalm-baseline.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<files psalm-version="4.13.1@5cf660f63b548ccd4a56f62d916ee4d6028e01a3">
2+
<files psalm-version="v4.15.0@a1b5e489e6fcebe40cb804793d964e99fc347820">
33
<file src="lib/Doctrine/ORM/AbstractQuery.php">
44
<DeprecatedClass occurrences="1">
55
<code>IterableResult</code>
@@ -1043,6 +1043,9 @@
10431043
<code>$this-&gt;table</code>
10441044
<code>$this-&gt;table</code>
10451045
</PropertyTypeCoercion>
1046+
<RedundantCast occurrences="1">
1047+
<code>array_values</code>
1048+
</RedundantCast>
10461049
<RedundantConditionGivenDocblockType occurrences="3">
10471050
<code>$className !== null</code>
10481051
<code>$mapping !== false</code>

tests/Doctrine/Tests/OrmTestCase.php

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,23 +58,12 @@ abstract class OrmTestCase extends DoctrineTestCase
5858
/** @var Cache|null */
5959
protected $secondLevelCacheDriverImpl = null;
6060

61-
/**
62-
* @param mixed $alias
63-
*/
64-
protected function createAnnotationDriver(array $paths = [], $alias = null): AnnotationDriver
61+
protected function createAnnotationDriver(array $paths = []): AnnotationDriver
6562
{
66-
// Register the ORM Annotations in the AnnotationRegistry
67-
$reader = new Annotations\AnnotationReader();
68-
69-
if (class_exists(Annotations\PsrCachedReader::class)) {
70-
$reader = new Annotations\PsrCachedReader($reader, new ArrayAdapter());
71-
} else {
72-
$reader = new Annotations\CachedReader($reader, DoctrineProvider::wrap(new ArrayAdapter()));
73-
}
74-
75-
Annotations\AnnotationRegistry::registerFile(__DIR__ . '/../../../lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php');
76-
77-
return new AnnotationDriver($reader, (array) $paths);
63+
return new AnnotationDriver(
64+
new Annotations\PsrCachedReader(new Annotations\AnnotationReader(), new ArrayAdapter()),
65+
$paths
66+
);
7867
}
7968

8069
/**

0 commit comments

Comments
 (0)