Skip to content

Commit d2c4729

Browse files
committed
Merge 3.4.x
2 parents df41fa2 + 04395f9 commit d2c4729

15 files changed

+172
-51
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@
3737
"symfony/var-exporter": "^6.3.9 || ^7.0"
3838
},
3939
"require-dev": {
40-
"doctrine/coding-standard": "^12.0",
40+
"doctrine/coding-standard": "^13.0",
4141
"phpbench/phpbench": "^1.0",
4242
"phpdocumentor/guides-cli": "^1.4",
4343
"phpstan/extension-installer": "^1.4",
4444
"phpstan/phpstan": "2.0.3",
4545
"phpstan/phpstan-deprecation-rules": "^2",
4646
"phpunit/phpunit": "^10.4.0",
4747
"psr/log": "^1 || ^2 || ^3",
48-
"squizlabs/php_codesniffer": "3.7.2",
48+
"squizlabs/php_codesniffer": "3.12.0",
4949
"symfony/cache": "^5.4 || ^6.2 || ^7.0"
5050
},
5151
"suggest": {

docs/en/reference/advanced-configuration.rst

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Configuration Options
7676
The following sections describe all the configuration options
7777
available on a ``Doctrine\ORM\Configuration`` instance.
7878

79-
Native Lazy Objects (***OPTIONAL***)
79+
Native Lazy Objects (**OPTIONAL**)
8080
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8181

8282
With PHP 8.4 we recommend that you use native lazy objects instead of
@@ -90,8 +90,8 @@ will become the only approach to lazy loading.
9090
<?php
9191
$config->enableNativeLazyObjects(true);
9292
93-
Proxy Directory (***REQUIRED***)
94-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
93+
Proxy Directory (**REQUIRED**)
94+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9595

9696
This setting is not required if you use native lazy objects with PHP 8.4
9797
and will be removed in the future.
@@ -107,8 +107,8 @@ classes. For a detailed explanation on proxy classes and how they
107107
are used in Doctrine, refer to the "Proxy Objects" section further
108108
down.
109109

110-
Proxy Namespace (***REQUIRED***)
111-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
110+
Proxy Namespace (**REQUIRED**)
111+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
112112

113113
This setting is not required if you use native lazy objects with PHP 8.4
114114
and will be removed in the future.
@@ -123,8 +123,8 @@ Gets or sets the namespace to use for generated proxy classes. For
123123
a detailed explanation on proxy classes and how they are used in
124124
Doctrine, refer to the "Proxy Objects" section further down.
125125

126-
Metadata Driver (***REQUIRED***)
127-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
126+
Metadata Driver (**REQUIRED**)
127+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
128128

129129
.. code-block:: php
130130
@@ -164,8 +164,8 @@ accept either a single directory as a string or an array of
164164
directories. With this feature a single driver can support multiple
165165
directories of Entities.
166166

167-
Metadata Cache (***RECOMMENDED***)
168-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
167+
Metadata Cache (**RECOMMENDED**)
168+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
169169

170170
.. code-block:: php
171171
@@ -186,8 +186,8 @@ For development you should use an array cache like
186186
``Symfony\Component\Cache\Adapter\ArrayAdapter``
187187
which only caches data on a per-request basis.
188188

189-
Query Cache (***RECOMMENDED***)
190-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
189+
Query Cache (**RECOMMENDED**)
190+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
191191

192192
.. code-block:: php
193193
@@ -209,8 +209,8 @@ For development you should use an array cache like
209209
``Symfony\Component\Cache\Adapter\ArrayAdapter``
210210
which only caches data on a per-request basis.
211211

212-
SQL Logger (***Optional***)
213-
~~~~~~~~~~~~~~~~~~~~~~~~~~~
212+
SQL Logger (**Optional**)
213+
~~~~~~~~~~~~~~~~~~~~~~~~~
214214

215215
.. code-block:: php
216216
@@ -222,8 +222,8 @@ Gets or sets the logger to use for logging all SQL statements
222222
executed by Doctrine. The logger class must implement the
223223
deprecated ``Doctrine\DBAL\Logging\SQLLogger`` interface.
224224

225-
Auto-generating Proxy Classes (***OPTIONAL***)
226-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
225+
Auto-generating Proxy Classes (**OPTIONAL**)
226+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
227227

228228
This setting is not required if you use native lazy objects with PHP 8.4
229229
and will be removed in the future.
@@ -469,7 +469,7 @@ correctly if sub-namespaces use different metadata driver
469469
implementations.
470470

471471

472-
Default Repository (***OPTIONAL***)
472+
Default Repository (**OPTIONAL**)
473473
-----------------------------------
474474

475475
Specifies the FQCN of a subclass of the EntityRepository.
@@ -484,7 +484,7 @@ That will be available for all entities without a custom repository class.
484484
The default value is ``Doctrine\ORM\EntityRepository``.
485485
Any repository class must be a subclass of EntityRepository otherwise you got an ORMException
486486

487-
Ignoring entities (***OPTIONAL***)
487+
Ignoring entities (**OPTIONAL**)
488488
-----------------------------------
489489

490490
Specifies the Entity FQCNs to ignore.

phpstan-dbal3.neon

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@ parameters:
2222
message: '~.*getTrimExpression.*expects int.*~'
2323
path: src/Query/AST/Functions/TrimFunction.php
2424

25+
-
26+
message: '~^Call to static method unquoted\(\) on an unknown class Doctrine\\DBAL\\Schema\\Name\\Identifier\.$~'
27+
path: src/Tools/SchemaTool.php
28+
29+
-
30+
message: '~^Instantiated class Doctrine\\DBAL\\Schema\\Name\\UnqualifiedName not found\.$~'
31+
path: src/Tools/SchemaTool.php
32+
33+
-
34+
message: '~^Call to an undefined method Doctrine\\DBAL\\Schema\\Table::addPrimaryKeyConstraint\(\)\.$~'
35+
path: src/Tools/SchemaTool.php
36+
2537
- '~^Class Doctrine\\DBAL\\Platforms\\SQLitePlatform not found\.$~'
2638

2739
# To be removed in 4.0

phpstan.neon

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@ parameters:
2020
message: '~^Method Doctrine\\ORM\\Persisters\\Entity\\BasicEntityPersister\:\:getArrayBindingType\(\) never returns .* so it can be removed from the return type\.$~'
2121
path: src/Persisters/Entity/BasicEntityPersister.php
2222

23+
-
24+
message: '~^Call to static method unquoted\(\) on an unknown class Doctrine\\DBAL\\Schema\\Name\\Identifier\.$~'
25+
path: src/Tools/SchemaTool.php
26+
27+
-
28+
message: '~^Instantiated class Doctrine\\DBAL\\Schema\\Name\\UnqualifiedName not found\.$~'
29+
path: src/Tools/SchemaTool.php
30+
31+
-
32+
message: '~^Call to an undefined method Doctrine\\DBAL\\Schema\\Table::addPrimaryKeyConstraint\(\)\.$~'
33+
path: src/Tools/SchemaTool.php
34+
2335
# Compatibility with DBAL 3
2436
# See https://github.com/doctrine/dbal/pull/3480
2537
-

src/AbstractQuery.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ public function getParameter(int|string $key): Parameter|null
286286
$key = Parameter::normalizeName($key);
287287

288288
$filteredParameters = $this->parameters->filter(
289-
static fn (Parameter $parameter): bool => $parameter->getName() === $key
289+
static fn (Parameter $parameter): bool => $parameter->getName() === $key,
290290
);
291291

292292
return ! $filteredParameters->isEmpty() ? $filteredParameters->first() : null;

src/ORMInvalidArgumentException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ private static function newEntityFoundThroughRelationshipMessage(AssociationMapp
185185
. ' configured to cascade persist operations for entity: ' . self::objToStr($entity) . '.'
186186
. ' To solve this issue: Either explicitly call EntityManager#persist()'
187187
. ' on this unknown entity or configure cascade persist'
188-
. ' this association in the mapping for example @ManyToOne(..,cascade={"persist"}).'
188+
. ' this association in the mapping for example #[ORM\ManyToOne(..., cascade: [\'persist\'])].'
189189
. ($entity instanceof Stringable
190190
? ''
191191
: ' If you cannot find out which entity causes the problem implement \''

src/QueryBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ public function getParameter(string|int $key): Parameter|null
508508
$key = Parameter::normalizeName($key);
509509

510510
$filteredParameters = $this->parameters->filter(
511-
static fn (Parameter $parameter): bool => $key === $parameter->getName()
511+
static fn (Parameter $parameter): bool => $key === $parameter->getName(),
512512
);
513513

514514
return ! $filteredParameters->isEmpty() ? $filteredParameters->first() : null;

src/Tools/Console/Command/MappingDescribeCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ private function getClassMetadata(
162162

163163
$matches = array_filter(
164164
$this->getMappedEntities($entityManager),
165-
static fn ($mappedEntity) => preg_match('{' . preg_quote($entityName) . '}', $mappedEntity)
165+
static fn ($mappedEntity) => preg_match('{' . preg_quote($entityName) . '}', $mappedEntity),
166166
);
167167

168168
if (! $matches) {

src/Tools/SchemaTool.php

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
use Doctrine\DBAL\Schema\AbstractAsset;
1010
use Doctrine\DBAL\Schema\AbstractSchemaManager;
1111
use Doctrine\DBAL\Schema\Index;
12+
use Doctrine\DBAL\Schema\Name\Identifier;
13+
use Doctrine\DBAL\Schema\Name\UnqualifiedName;
14+
use Doctrine\DBAL\Schema\PrimaryKeyConstraint;
1215
use Doctrine\DBAL\Schema\Schema;
1316
use Doctrine\DBAL\Schema\Table;
1417
use Doctrine\ORM\EntityManagerInterface;
@@ -32,6 +35,7 @@
3235
use function array_flip;
3336
use function array_intersect_key;
3437
use function assert;
38+
use function class_exists;
3539
use function count;
3640
use function current;
3741
use function implode;
@@ -282,7 +286,7 @@ public function getSchemaFromMetadata(array $classes): Schema
282286
}
283287

284288
if ($pkColumns !== []) {
285-
$table->setPrimaryKey($pkColumns);
289+
self::addPrimaryKeyConstraint($table, $pkColumns);
286290
}
287291
}
288292
} else {
@@ -306,7 +310,7 @@ public function getSchemaFromMetadata(array $classes): Schema
306310
}
307311

308312
if (! $table->hasIndex('primary')) {
309-
$table->setPrimaryKey($pkColumns);
313+
self::addPrimaryKeyConstraint($table, $pkColumns);
310314
}
311315

312316
// there can be unique indexes automatically created for join column
@@ -572,7 +576,7 @@ private function gatherRelationsSql(
572576
$blacklistedFks,
573577
);
574578

575-
$theJoinTable->setPrimaryKey($primaryKeyColumns);
579+
self::addPrimaryKeyConstraint($theJoinTable, $primaryKeyColumns);
576580
}
577581
}
578582
}
@@ -927,4 +931,20 @@ private function createSchemaForComparison(Schema $toSchema): Schema
927931
$config->setSchemaAssetsFilter($previousFilter);
928932
}
929933
}
934+
935+
/** @param string[] $primaryKeyColumns */
936+
private function addPrimaryKeyConstraint(Table $table, array $primaryKeyColumns): void
937+
{
938+
if (class_exists(PrimaryKeyConstraint::class)) {
939+
$primaryKeyColumnNames = [];
940+
941+
foreach ($primaryKeyColumns as $primaryKeyColumn) {
942+
$primaryKeyColumnNames[] = new UnqualifiedName(Identifier::unquoted($primaryKeyColumn));
943+
}
944+
945+
$table->addPrimaryKeyConstraint(new PrimaryKeyConstraint(null, $primaryKeyColumnNames, true));
946+
} else {
947+
$table->setPrimaryKey($primaryKeyColumns);
948+
}
949+
}
930950
}

src/UnitOfWork.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2024,7 +2024,7 @@ private function cascadeRefresh(object $entity, array &$visited, LockMode|int|nu
20242024

20252025
$associationMappings = array_filter(
20262026
$class->associationMappings,
2027-
static fn (AssociationMapping $assoc): bool => $assoc->isCascadeRefresh()
2027+
static fn (AssociationMapping $assoc): bool => $assoc->isCascadeRefresh(),
20282028
);
20292029

20302030
foreach ($associationMappings as $assoc) {
@@ -2065,7 +2065,7 @@ private function cascadeDetach(object $entity, array &$visited): void
20652065

20662066
$associationMappings = array_filter(
20672067
$class->associationMappings,
2068-
static fn (AssociationMapping $assoc): bool => $assoc->isCascadeDetach()
2068+
static fn (AssociationMapping $assoc): bool => $assoc->isCascadeDetach(),
20692069
);
20702070

20712071
foreach ($associationMappings as $assoc) {
@@ -2111,7 +2111,7 @@ private function cascadePersist(object $entity, array &$visited): void
21112111

21122112
$associationMappings = array_filter(
21132113
$class->associationMappings,
2114-
static fn (AssociationMapping $assoc): bool => $assoc->isCascadePersist()
2114+
static fn (AssociationMapping $assoc): bool => $assoc->isCascadePersist(),
21152115
);
21162116

21172117
foreach ($associationMappings as $assoc) {
@@ -2168,7 +2168,7 @@ private function cascadeRemove(object $entity, array &$visited): void
21682168

21692169
$associationMappings = array_filter(
21702170
$class->associationMappings,
2171-
static fn (AssociationMapping $assoc): bool => $assoc->isCascadeRemove()
2171+
static fn (AssociationMapping $assoc): bool => $assoc->isCascadeRemove(),
21722172
);
21732173

21742174
if ($associationMappings) {

0 commit comments

Comments
 (0)