Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit db18161

Browse files
committed
Merge branch '2.13.x' into 2.14.x
* 2.13.x: Fix changeset computation for enum arrays (doctrine#10277) Psalm 5.2.0 (doctrine#10291) Run tools on PHP 8.2 (doctrine#10287)
2 parents 284e814 + bd11475 commit db18161

10 files changed

Lines changed: 50 additions & 20 deletions

File tree

.github/workflows/coding-standards.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ on:
2424

2525
jobs:
2626
coding-standards:
27-
uses: "doctrine/.github/.github/workflows/coding-standards.yml@2.1.0"
27+
uses: "doctrine/.github/.github/workflows/coding-standards.yml@3.0.0"

.github/workflows/release-on-milestone-closed.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77

88
jobs:
99
release:
10-
uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@2.1.0"
10+
uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@3.0.0"
1111
secrets:
1212
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
1313
GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }}

.github/workflows/static-analysis.yml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
name: "Static Analysis"
32

43
on:
@@ -31,18 +30,14 @@ jobs:
3130
strategy:
3231
fail-fast: false
3332
matrix:
34-
php-version:
35-
- "8.1"
3633
dbal-version:
3734
- "default"
3835
persistence-version:
3936
- "default"
4037
include:
41-
- php-version: "8.1"
42-
dbal-version: "2.13"
38+
- dbal-version: "2.13"
4339
persistence-version: "default"
44-
- php-version: "8.1"
45-
dbal-version: "default"
40+
- dbal-version: "default"
4641
persistence-version: "2.5"
4742

4843
steps:
@@ -53,7 +48,7 @@ jobs:
5348
uses: "shivammathur/setup-php@v2"
5449
with:
5550
coverage: "none"
56-
php-version: "${{ matrix.php-version }}"
51+
php-version: "8.2"
5752

5853
- name: "Require specific DBAL version"
5954
run: "composer require doctrine/dbal ^${{ matrix.dbal-version }} --no-update"
@@ -85,9 +80,6 @@ jobs:
8580

8681
strategy:
8782
fail-fast: false
88-
matrix:
89-
php-version:
90-
- "8.1"
9183

9284
steps:
9385
- name: "Checkout code"
@@ -97,7 +89,7 @@ jobs:
9789
uses: "shivammathur/setup-php@v2"
9890
with:
9991
coverage: "none"
100-
php-version: "${{ matrix.php-version }}"
92+
php-version: "8.2"
10193

10294
- name: "Require specific persistence version"
10395
run: "composer require doctrine/persistence ^3.1 --no-update"

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"symfony/cache": "^4.4 || ^5.4 || ^6.0",
5050
"symfony/var-exporter": "^4.4 || ^5.4 || ^6.2",
5151
"symfony/yaml": "^3.4 || ^4.0 || ^5.0 || ^6.0",
52-
"vimeo/psalm": "4.30.0 || 5.1.0"
52+
"vimeo/psalm": "4.30.0 || 5.2.0"
5353
},
5454
"conflict": {
5555
"doctrine/annotations": "<1.13 || >= 2.0"

lib/Doctrine/ORM/UnitOfWork.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -744,8 +744,18 @@ public function computeChangeSet(ClassMetadata $class, $entity)
744744

745745
$orgValue = $originalData[$propName];
746746

747-
if ($orgValue instanceof BackedEnum) {
748-
$orgValue = $orgValue->value;
747+
if (! empty($class->fieldMappings[$propName]['enumType'])) {
748+
if (is_array($orgValue)) {
749+
foreach ($orgValue as $id => $val) {
750+
if ($val instanceof BackedEnum) {
751+
$orgValue[$id] = $val->value;
752+
}
753+
}
754+
} else {
755+
if ($orgValue instanceof BackedEnum) {
756+
$orgValue = $orgValue->value;
757+
}
758+
}
749759
}
750760

751761
// skip if value haven't changed
@@ -804,6 +814,7 @@ public function computeChangeSet(ClassMetadata $class, $entity)
804814
}
805815

806816
if ($orgValue !== null && $assoc['orphanRemoval']) {
817+
assert(is_object($orgValue));
807818
$this->scheduleOrphanRemoval($orgValue);
808819
}
809820
}

phpstan-baseline.neon

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,11 @@ parameters:
505505
count: 1
506506
path: lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php
507507

508+
-
509+
message: "#^Access to an undefined property Doctrine\\\\ORM\\\\Query\\\\AST\\\\Node\\:\\:\\$pathExpression\\.$#"
510+
count: 1
511+
path: lib/Doctrine/ORM/Query/SqlWalker.php
512+
508513
-
509514
message: "#^Call to function is_string\\(\\) with Doctrine\\\\ORM\\\\Query\\\\AST\\\\Node will always evaluate to false\\.$#"
510515
count: 1

phpstan-params.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ parameters:
88
earlyTerminatingMethodCalls:
99
Doctrine\ORM\Query\Parser:
1010
- syntaxError
11-
phpVersion: 80100
11+
phpVersion: 80200
1212

1313
ignoreErrors:
1414
# Remove on 3.0.x

psalm-baseline.xml

Lines changed: 1 addition & 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="5.1.0@4defa177c89397c5e14737a80fe4896584130674">
2+
<files psalm-version="5.2.0@fb685a16df3050d4c18d8a4100fe83abe6458cba">
33
<file src="lib/Doctrine/ORM/AbstractQuery.php">
44
<DeprecatedClass occurrences="1">
55
<code>IterableResult</code>

psalm.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0"?>
22
<psalm
33
errorLevel="2"
4-
phpVersion="8.1"
4+
phpVersion="8.2"
55
resolveFromConfigFile="true"
66
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
77
xmlns="https://getpsalm.org/schema/config"

tests/Doctrine/Tests/ORM/Functional/EnumTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,28 @@ public function testEnumChangeSetsObjectHydrator(): void
300300
self::assertFalse($this->_em->getUnitOfWork()->isScheduledForUpdate($result[0]));
301301
}
302302

303+
public function testEnumArrayChangeSets(): void
304+
{
305+
$this->setUpEntitySchema([Scale::class]);
306+
307+
$scale = new Scale();
308+
$scale->supportedUnits = [Unit::Gram];
309+
310+
$this->_em->persist($scale);
311+
$this->_em->flush();
312+
$this->_em->clear();
313+
314+
$result = $this->_em->createQueryBuilder()
315+
->from(Scale::class, 's')
316+
->select('s')
317+
->getQuery()
318+
->getResult();
319+
320+
$this->_em->getUnitOfWork()->computeChangeSets();
321+
322+
self::assertFalse($this->_em->getUnitOfWork()->isScheduledForUpdate($result[0]));
323+
}
324+
303325
public function testFindByEnum(): void
304326
{
305327
$this->setUpEntitySchema([Card::class]);

0 commit comments

Comments
 (0)