Skip to content

Commit 1d7fdde

Browse files
committed
Merge branch '2.9.x' into merge/2.9.x
* 2.9.x: Minor rewording (doctrine#8435) Don't presume one-to-one lookup returned an entity (doctrine#9028) Minor change about double The (doctrine#9038) Remove duplicate comment (doctrine#9036) Fix docblock types for some nullable properties (doctrine#9024) Explicitly allow to use `Comparison` and `Composite` in JOIN conditions (doctrine#9022) Fix some typehints in QueryBuilder Bump PHPStan (doctrine#9014) Add tests for advanced types in collection matching Use types in collection persister Signed-off-by: Alexander M. Turek <me@derrabus.de>
2 parents 334ca18 + 5326736 commit 1d7fdde

29 files changed

+255
-174
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"doctrine/annotations": "^1.13",
4040
"doctrine/coding-standard": "^9.0",
4141
"phpbench/phpbench": "^0.16.10 || ^1.0",
42-
"phpstan/phpstan": "0.12.98",
42+
"phpstan/phpstan": "0.12.99",
4343
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.4",
4444
"squizlabs/php_codesniffer": "3.6.0",
4545
"symfony/cache": "^4.4 || ^5.2",

docs/en/reference/events.rst

+2-3
Original file line numberDiff line numberDiff line change
@@ -659,9 +659,8 @@ postFlush
659659
preUpdate
660660
~~~~~~~~~
661661

662-
PreUpdate is the most restrictive to use event, since it is called
663-
right before an update statement is called for an entity inside the
664-
``EntityManager#flush()`` method. Note that this event is not
662+
PreUpdate is called inside the ``EntityManager#flush()`` method,
663+
right before an SQL ``UPDATE`` statement. This event is not
665664
triggered when the computed changeset is empty.
666665

667666
Changes to associations of the updated entity are never allowed in

docs/en/reference/second-level-cache.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ The Cache Mode controls how a particular query interacts with the second-level c
579579
580580
.. note::
581581

582-
The the default query cache mode is ```Cache::MODE_NORMAL```
582+
The default query cache mode is ```Cache::MODE_NORMAL```
583583

584584
DELETE / UPDATE queries
585585
~~~~~~~~~~~~~~~~~~~~~~~

lib/Doctrine/ORM/AbstractQuery.php

-1
Original file line numberDiff line numberDiff line change
@@ -974,7 +974,6 @@ public function getSingleResult($hydrationMode = null)
974974
*
975975
* @throws NoResultException If the query returned no result.
976976
* @throws NonUniqueResultException If the query result is not unique.
977-
* @throws NoResultException If the query returned no result.
978977
*/
979978
public function getSingleScalarResult()
980979
{

lib/Doctrine/ORM/Id/IdentityGenerator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class IdentityGenerator extends AbstractIdGenerator
1616
/**
1717
* The name of the sequence to pass to lastInsertId(), if any.
1818
*
19-
* @var string
19+
* @var string|null
2020
*/
2121
private $sequenceName;
2222

lib/Doctrine/ORM/Mapping/Cache.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ final class Cache implements Annotation
2323
*/
2424
public $usage = 'READ_ONLY';
2525

26-
/** @var string Cache region name. */
26+
/** @var string|null Cache region name. */
2727
public $region;
2828

2929
public function __construct(string $usage = 'READ_ONLY', ?string $region = null)

lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ class ClassMetadataInfo implements ClassMetadata
621621
* )
622622
* </code>
623623
*
624-
* @var mixed[]
624+
* @var array<string, mixed>
625625
* @psalm-var array{sequenceName: string, allocationSize: string, initialValue: string, quoted?: mixed}
626626
* @todo Merge with tableGeneratorDefinition into generic generatorDefinition
627627
*/
@@ -1146,7 +1146,7 @@ public function enableAssociationCache($fieldName, array $cache)
11461146
/**
11471147
* @param string $fieldName
11481148
* @param array $cache
1149-
* @psalm-param array{usage?: int, region?: string} $cache
1149+
* @psalm-param array{usage?: int, region?: string|null} $cache
11501150
*
11511151
* @return int[]|string[]
11521152
* @psalm-return array{usage: int, region: string|null}
@@ -3278,7 +3278,7 @@ public function setIdGenerator($generator)
32783278
/**
32793279
* Sets definition.
32803280
*
3281-
* @psalm-param array<string, string> $definition
3281+
* @psalm-param array<string, string|null> $definition
32823282
*
32833283
* @return void
32843284
*/

lib/Doctrine/ORM/Mapping/CustomIdGenerator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#[Attribute(Attribute::TARGET_PROPERTY)]
1616
final class CustomIdGenerator implements Annotation
1717
{
18-
/** @var string */
18+
/** @var string|null */
1919
public $class;
2020

2121
public function __construct(?string $class = null)

lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -688,11 +688,11 @@ private function getMethodCallbacks(ReflectionMethod $method): array
688688
*
689689
* @return mixed[]
690690
* @psalm-return array{
691-
* name: string,
691+
* name: string|null,
692692
* unique: bool,
693693
* nullable: bool,
694694
* onDelete: mixed,
695-
* columnDefinition: string,
695+
* columnDefinition: string|null,
696696
* referencedColumnName: string
697697
* }
698698
*/

lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -522,11 +522,11 @@ private function getMethodCallbacks(ReflectionMethod $method): array
522522
*
523523
* @return mixed[]
524524
* @psalm-return array{
525-
* name: string,
525+
* name: string|null,
526526
* unique: bool,
527527
* nullable: bool,
528528
* onDelete: mixed,
529-
* columnDefinition: string,
529+
* columnDefinition: string|null,
530530
* referencedColumnName: string
531531
* }
532532
*/

lib/Doctrine/ORM/Mapping/Entity.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#[Attribute(Attribute::TARGET_CLASS)]
1616
final class Entity implements Annotation
1717
{
18-
/** @var string */
18+
/** @var string|null */
1919
public $repositoryClass;
2020

2121
/** @var bool */

lib/Doctrine/ORM/Mapping/Index.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,26 @@
1515
#[Attribute(Attribute::TARGET_CLASS | Attribute::IS_REPEATABLE)]
1616
final class Index implements Annotation
1717
{
18-
/** @var string */
18+
/** @var string|null */
1919
public $name;
2020

21-
/** @var array<string> */
21+
/** @var array<string>|null */
2222
public $columns;
2323

24-
/** @var array<string> */
24+
/** @var array<string>|null */
2525
public $fields;
2626

27-
/** @var array<string> */
27+
/** @var array<string>|null */
2828
public $flags;
2929

30-
/** @var array<string,mixed> */
30+
/** @var array<string,mixed>|null */
3131
public $options;
3232

3333
/**
34-
* @param array<string> $columns
35-
* @param array<string> $fields
36-
* @param array<string> $flags
37-
* @param array<string> $options
34+
* @param array<string>|null $columns
35+
* @param array<string>|null $fields
36+
* @param array<string>|null $flags
37+
* @param array<string>|null $options
3838
*/
3939
public function __construct(
4040
?array $columns = null,

lib/Doctrine/ORM/Mapping/InverseJoinColumn.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#[Attribute(Attribute::TARGET_PROPERTY | Attribute::IS_REPEATABLE)]
1111
final class InverseJoinColumn implements Annotation
1212
{
13-
/** @var string */
13+
/** @var string|null */
1414
public $name;
1515

1616
/** @var string */
@@ -25,13 +25,13 @@ final class InverseJoinColumn implements Annotation
2525
/** @var mixed */
2626
public $onDelete;
2727

28-
/** @var string */
28+
/** @var string|null */
2929
public $columnDefinition;
3030

3131
/**
3232
* Field name used in non-object hydration (array/scalar).
3333
*
34-
* @var string
34+
* @var string|null
3535
*/
3636
public $fieldName;
3737

lib/Doctrine/ORM/Mapping/JoinColumn.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#[Attribute(Attribute::TARGET_PROPERTY | Attribute::IS_REPEATABLE)]
1616
final class JoinColumn implements Annotation
1717
{
18-
/** @var string */
18+
/** @var string|null */
1919
public $name;
2020

2121
/** @var string */
@@ -30,13 +30,13 @@ final class JoinColumn implements Annotation
3030
/** @var mixed */
3131
public $onDelete;
3232

33-
/** @var string */
33+
/** @var string|null */
3434
public $columnDefinition;
3535

3636
/**
3737
* Field name used in non-object hydration (array/scalar).
3838
*
39-
* @var string
39+
* @var string|null
4040
*/
4141
public $fieldName;
4242

lib/Doctrine/ORM/Mapping/JoinTable.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
#[Attribute(Attribute::TARGET_PROPERTY)]
1616
final class JoinTable implements Annotation
1717
{
18-
/** @var string */
18+
/** @var string|null */
1919
public $name;
2020

21-
/** @var string */
21+
/** @var string|null */
2222
public $schema;
2323

2424
/** @var array<\Doctrine\ORM\Mapping\JoinColumn> */

lib/Doctrine/ORM/Mapping/ManyToMany.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ final class ManyToMany implements Annotation
1919
/** @var string|null */
2020
public $targetEntity;
2121

22-
/** @var string */
22+
/** @var string|null */
2323
public $mappedBy;
2424

25-
/** @var string */
25+
/** @var string|null */
2626
public $inversedBy;
2727

28-
/** @var array<string> */
28+
/** @var string[]|null */
2929
public $cascade;
3030

3131
/**
@@ -39,11 +39,11 @@ final class ManyToMany implements Annotation
3939
/** @var bool */
4040
public $orphanRemoval = false;
4141

42-
/** @var string */
42+
/** @var string|null */
4343
public $indexBy;
4444

4545
/**
46-
* @param array<string> $cascade
46+
* @param string[]|null $cascade
4747
*/
4848
public function __construct(
4949
?string $targetEntity = null,

lib/Doctrine/ORM/Mapping/ManyToOne.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
#[Attribute(Attribute::TARGET_PROPERTY)]
1616
final class ManyToOne implements Annotation
1717
{
18-
/** @var string */
18+
/** @var string|null */
1919
public $targetEntity;
2020

21-
/** @var array<string> */
21+
/** @var string[]|null */
2222
public $cascade;
2323

2424
/**
@@ -29,11 +29,11 @@ final class ManyToOne implements Annotation
2929
*/
3030
public $fetch = 'LAZY';
3131

32-
/** @var string */
32+
/** @var string|null */
3333
public $inversedBy;
3434

3535
/**
36-
* @param array<string> $cascade
36+
* @param string[]|null $cascade
3737
*/
3838
public function __construct(
3939
?string $targetEntity = null,

lib/Doctrine/ORM/Mapping/MappedSuperclass.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#[Attribute(Attribute::TARGET_CLASS)]
1616
final class MappedSuperclass implements Annotation
1717
{
18-
/** @var string */
18+
/** @var string|null */
1919
public $repositoryClass;
2020

2121
public function __construct(?string $repositoryClass = null)

lib/Doctrine/ORM/Mapping/OneToMany.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ final class OneToMany implements Annotation
3939
public $indexBy;
4040

4141
/**
42-
* @param array<string> $cascade
42+
* @param string[]|null $cascade
4343
*/
4444
public function __construct(
4545
?string $mappedBy = null,

lib/Doctrine/ORM/Mapping/OneToOne.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@
1515
#[Attribute(Attribute::TARGET_PROPERTY)]
1616
final class OneToOne implements Annotation
1717
{
18-
/** @var string */
18+
/** @var string|null */
1919
public $targetEntity;
2020

21-
/** @var string */
21+
/** @var string|null */
2222
public $mappedBy;
2323

24-
/** @var string */
24+
/** @var string|null */
2525
public $inversedBy;
2626

27-
/** @var array<string> */
27+
/** @var array<string>|null */
2828
public $cascade;
2929

3030
/**
@@ -39,7 +39,7 @@ final class OneToOne implements Annotation
3939
public $orphanRemoval = false;
4040

4141
/**
42-
* @param array<string> $cascade
42+
* @param array<string>|null $cascade
4343
*/
4444
public function __construct(
4545
?string $mappedBy = null,

lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ public function loadCriteria(PersistentCollection $collection, Criteria $criteri
222222
$targetClass = $this->em->getClassMetadata($mapping['targetEntity']);
223223
$onConditions = $this->getOnConditionSQL($mapping);
224224
$whereClauses = $params = [];
225+
$paramTypes = [];
225226

226227
if (! $mapping['isOwningSide']) {
227228
$associationSourceClass = $targetClass;
@@ -237,6 +238,7 @@ public function loadCriteria(PersistentCollection $collection, Criteria $criteri
237238
$params[] = $ownerMetadata->containsForeignIdentifier
238239
? $id[$ownerMetadata->getFieldForColumn($value)]
239240
: $id[$ownerMetadata->fieldNames[$value]];
241+
$paramTypes[] = PersisterHelper::getTypeOfColumn($value, $ownerMetadata, $this->em);
240242
}
241243

242244
$parameters = $this->expandCriteriaParameters($criteria);
@@ -247,6 +249,7 @@ public function loadCriteria(PersistentCollection $collection, Criteria $criteri
247249
$field = $this->quoteStrategy->getColumnName($name, $targetClass, $this->platform);
248250
$whereClauses[] = sprintf('te.%s %s ?', $field, $operator);
249251
$params[] = $value;
252+
$paramTypes[] = PersisterHelper::getTypeOfColumn($field, $targetClass, $this->em);
250253
}
251254

252255
$tableName = $this->quoteStrategy->getTableName($targetClass, $this->platform);
@@ -265,7 +268,7 @@ public function loadCriteria(PersistentCollection $collection, Criteria $criteri
265268

266269
$sql .= $this->getLimitSql($criteria);
267270

268-
$stmt = $this->conn->executeQuery($sql, $params);
271+
$stmt = $this->conn->executeQuery($sql, $params, $paramTypes);
269272

270273
return $this
271274
->em

lib/Doctrine/ORM/Query/Expr/From.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class From
1717
/** @var string */
1818
protected $alias;
1919

20-
/** @var string */
20+
/** @var string|null */
2121
protected $indexBy;
2222

2323
/**
@@ -49,7 +49,7 @@ public function getAlias()
4949
}
5050

5151
/**
52-
* @return string
52+
* @return string|null
5353
*/
5454
public function getIndexBy()
5555
{

0 commit comments

Comments
 (0)