Skip to content

Commit

Permalink
Merge branch '2.10.x' into 3.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
dunglas committed Sep 30, 2021
2 parents bb60e06 + f414e57 commit 18c153e
Show file tree
Hide file tree
Showing 29 changed files with 267 additions and 175 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"doctrine/annotations": "^1.13",
"doctrine/coding-standard": "^9.0",
"phpbench/phpbench": "^0.16.10 || ^1.0",
"phpstan/phpstan": "0.12.98",
"phpstan/phpstan": "0.12.99",
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.4",
"squizlabs/php_codesniffer": "3.6.0",
"symfony/cache": "^4.4 || ^5.2",
Expand Down
5 changes: 2 additions & 3 deletions docs/en/reference/events.rst
Original file line number Diff line number Diff line change
Expand Up @@ -659,9 +659,8 @@ postFlush
preUpdate
~~~~~~~~~

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

Changes to associations of the updated entity are never allowed in
Expand Down
2 changes: 1 addition & 1 deletion docs/en/reference/second-level-cache.rst
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ The Cache Mode controls how a particular query interacts with the second-level c
.. note::

The the default query cache mode is ```Cache::MODE_NORMAL```
The default query cache mode is ```Cache::MODE_NORMAL```

DELETE / UPDATE queries
~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
1 change: 0 additions & 1 deletion lib/Doctrine/ORM/AbstractQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,6 @@ public function getSingleResult($hydrationMode = null)
*
* @throws NoResultException If the query returned no result.
* @throws NonUniqueResultException If the query result is not unique.
* @throws NoResultException If the query returned no result.
*/
public function getSingleScalarResult()
{
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Id/IdentityGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class IdentityGenerator extends AbstractIdGenerator
/**
* The name of the sequence to pass to lastInsertId(), if any.
*
* @var string
* @var string|null
*/
private $sequenceName;

Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Mapping/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class Cache implements Annotation
*/
public $usage = 'READ_ONLY';

/** @var string Cache region name. */
/** @var string|null Cache region name. */
public $region;

public function __construct(string $usage = 'READ_ONLY', ?string $region = null)
Expand Down
6 changes: 3 additions & 3 deletions lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ class ClassMetadataInfo implements ClassMetadata
* )
* </code>
*
* @var mixed[]
* @var array<string, mixed>
* @psalm-var array{sequenceName: string, allocationSize: string, initialValue: string, quoted?: mixed}
* @todo Merge with tableGeneratorDefinition into generic generatorDefinition
*/
Expand Down Expand Up @@ -1146,7 +1146,7 @@ public function enableAssociationCache($fieldName, array $cache)
/**
* @param string $fieldName
* @param array $cache
* @psalm-param array{usage?: int, region?: string} $cache
* @psalm-param array{usage?: int, region?: string|null} $cache
*
* @return int[]|string[]
* @psalm-return array{usage: int, region: string|null}
Expand Down Expand Up @@ -3278,7 +3278,7 @@ public function setIdGenerator($generator)
/**
* Sets definition.
*
* @psalm-param array<string, string> $definition
* @psalm-param array<string, string|null> $definition
*
* @return void
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Mapping/CustomIdGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#[Attribute(Attribute::TARGET_PROPERTY)]
final class CustomIdGenerator implements Annotation
{
/** @var string */
/** @var string|null */
public $class;

public function __construct(?string $class = null)
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -688,11 +688,11 @@ private function getMethodCallbacks(ReflectionMethod $method): array
*
* @return mixed[]
* @psalm-return array{
* name: string,
* name: string|null,
* unique: bool,
* nullable: bool,
* onDelete: mixed,
* columnDefinition: string,
* columnDefinition: string|null,
* referencedColumnName: string
* }
*/
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -522,11 +522,11 @@ private function getMethodCallbacks(ReflectionMethod $method): array
*
* @return mixed[]
* @psalm-return array{
* name: string,
* name: string|null,
* unique: bool,
* nullable: bool,
* onDelete: mixed,
* columnDefinition: string,
* columnDefinition: string|null,
* referencedColumnName: string
* }
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Mapping/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#[Attribute(Attribute::TARGET_CLASS)]
final class Entity implements Annotation
{
/** @var string */
/** @var string|null */
public $repositoryClass;

/** @var bool */
Expand Down
18 changes: 9 additions & 9 deletions lib/Doctrine/ORM/Mapping/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@
#[Attribute(Attribute::TARGET_CLASS | Attribute::IS_REPEATABLE)]
final class Index implements Annotation
{
/** @var string */
/** @var string|null */
public $name;

/** @var array<string> */
/** @var array<string>|null */
public $columns;

/** @var array<string> */
/** @var array<string>|null */
public $fields;

/** @var array<string> */
/** @var array<string>|null */
public $flags;

/** @var array<string,mixed> */
/** @var array<string,mixed>|null */
public $options;

/**
* @param array<string> $columns
* @param array<string> $fields
* @param array<string> $flags
* @param array<string> $options
* @param array<string>|null $columns
* @param array<string>|null $fields
* @param array<string>|null $flags
* @param array<string>|null $options
*/
public function __construct(
?array $columns = null,
Expand Down
6 changes: 3 additions & 3 deletions lib/Doctrine/ORM/Mapping/InverseJoinColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#[Attribute(Attribute::TARGET_PROPERTY | Attribute::IS_REPEATABLE)]
final class InverseJoinColumn implements Annotation
{
/** @var string */
/** @var string|null */
public $name;

/** @var string */
Expand All @@ -25,13 +25,13 @@ final class InverseJoinColumn implements Annotation
/** @var mixed */
public $onDelete;

/** @var string */
/** @var string|null */
public $columnDefinition;

/**
* Field name used in non-object hydration (array/scalar).
*
* @var string
* @var string|null
*/
public $fieldName;

Expand Down
6 changes: 3 additions & 3 deletions lib/Doctrine/ORM/Mapping/JoinColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#[Attribute(Attribute::TARGET_PROPERTY | Attribute::IS_REPEATABLE)]
final class JoinColumn implements Annotation
{
/** @var string */
/** @var string|null */
public $name;

/** @var string */
Expand All @@ -30,13 +30,13 @@ final class JoinColumn implements Annotation
/** @var mixed */
public $onDelete;

/** @var string */
/** @var string|null */
public $columnDefinition;

/**
* Field name used in non-object hydration (array/scalar).
*
* @var string
* @var string|null
*/
public $fieldName;

Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ORM/Mapping/JoinTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
#[Attribute(Attribute::TARGET_PROPERTY)]
final class JoinTable implements Annotation
{
/** @var string */
/** @var string|null */
public $name;

/** @var string */
/** @var string|null */
public $schema;

/** @var array<\Doctrine\ORM\Mapping\JoinColumn> */
Expand Down
10 changes: 5 additions & 5 deletions lib/Doctrine/ORM/Mapping/ManyToMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ final class ManyToMany implements Annotation
/** @var string|null */
public $targetEntity;

/** @var string */
/** @var string|null */
public $mappedBy;

/** @var string */
/** @var string|null */
public $inversedBy;

/** @var array<string> */
/** @var string[]|null */
public $cascade;

/**
Expand All @@ -39,11 +39,11 @@ final class ManyToMany implements Annotation
/** @var bool */
public $orphanRemoval = false;

/** @var string */
/** @var string|null */
public $indexBy;

/**
* @param array<string> $cascade
* @param string[]|null $cascade
*/
public function __construct(
?string $targetEntity = null,
Expand Down
8 changes: 4 additions & 4 deletions lib/Doctrine/ORM/Mapping/ManyToOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
#[Attribute(Attribute::TARGET_PROPERTY)]
final class ManyToOne implements Annotation
{
/** @var string */
/** @var string|null */
public $targetEntity;

/** @var array<string> */
/** @var string[]|null */
public $cascade;

/**
Expand All @@ -29,11 +29,11 @@ final class ManyToOne implements Annotation
*/
public $fetch = 'LAZY';

/** @var string */
/** @var string|null */
public $inversedBy;

/**
* @param array<string> $cascade
* @param string[]|null $cascade
*/
public function __construct(
?string $targetEntity = null,
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Mapping/MappedSuperclass.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#[Attribute(Attribute::TARGET_CLASS)]
final class MappedSuperclass implements Annotation
{
/** @var string */
/** @var string|null */
public $repositoryClass;

public function __construct(?string $repositoryClass = null)
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Mapping/OneToMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ final class OneToMany implements Annotation
public $indexBy;

/**
* @param array<string> $cascade
* @param string[]|null $cascade
*/
public function __construct(
?string $mappedBy = null,
Expand Down
10 changes: 5 additions & 5 deletions lib/Doctrine/ORM/Mapping/OneToOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
#[Attribute(Attribute::TARGET_PROPERTY)]
final class OneToOne implements Annotation
{
/** @var string */
/** @var string|null */
public $targetEntity;

/** @var string */
/** @var string|null */
public $mappedBy;

/** @var string */
/** @var string|null */
public $inversedBy;

/** @var array<string> */
/** @var array<string>|null */
public $cascade;

/**
Expand All @@ -39,7 +39,7 @@ final class OneToOne implements Annotation
public $orphanRemoval = false;

/**
* @param array<string> $cascade
* @param array<string>|null $cascade
*/
public function __construct(
?string $mappedBy = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ public function loadCriteria(PersistentCollection $collection, Criteria $criteri
$targetClass = $this->em->getClassMetadata($mapping['targetEntity']);
$onConditions = $this->getOnConditionSQL($mapping);
$whereClauses = $params = [];
$paramTypes = [];

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

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

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

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

$stmt = $this->conn->executeQuery($sql, $params);
$stmt = $this->conn->executeQuery($sql, $params, $paramTypes);

return $this
->em
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ORM/Query/Expr/From.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class From
/** @var string */
protected $alias;

/** @var string */
/** @var string|null */
protected $indexBy;

/**
Expand Down Expand Up @@ -49,7 +49,7 @@ public function getAlias()
}

/**
* @return string
* @return string|null
*/
public function getIndexBy()
{
Expand Down
Loading

0 comments on commit 18c153e

Please sign in to comment.