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

Skip to content

Commit 2bfcb6e

Browse files
committed
Merge branch '2.14.x' into 3.0.x
* 2.14.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 9d8cadf + db18161 commit 2bfcb6e

10 files changed

Lines changed: 49 additions & 11 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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Static Analysis
1+
name: "Static Analysis"
22

33
on:
44
pull_request:
@@ -43,7 +43,7 @@ jobs:
4343
uses: shivammathur/setup-php@v2
4444
with:
4545
coverage: none
46-
php-version: "8.1"
46+
php-version: "8.2"
4747
tools: cs2pr
4848

4949
- name: Require specific DBAL version
@@ -74,7 +74,7 @@ jobs:
7474
uses: shivammathur/setup-php@v2
7575
with:
7676
coverage: none
77-
php-version: "8.1"
77+
php-version: "8.2"
7878
tools: cs2pr
7979

8080
- name: Require specific DBAL version

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"squizlabs/php_codesniffer": "3.7.1",
4545
"symfony/cache": "^5.4 || ^6.0",
4646
"symfony/var-exporter": "^5.4 || ^6.2",
47-
"vimeo/psalm": "5.1.0"
47+
"vimeo/psalm": "5.2.0"
4848
},
4949
"suggest": {
5050
"ext-dom": "Provides support for XSD validation for XML mapping files",

lib/Doctrine/ORM/UnitOfWork.php

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

639639
$orgValue = $originalData[$propName];
640640

641-
if ($orgValue instanceof BackedEnum) {
642-
$orgValue = $orgValue->value;
641+
if (! empty($class->fieldMappings[$propName]['enumType'])) {
642+
if (is_array($orgValue)) {
643+
foreach ($orgValue as $id => $val) {
644+
if ($val instanceof BackedEnum) {
645+
$orgValue[$id] = $val->value;
646+
}
647+
}
648+
} else {
649+
if ($orgValue instanceof BackedEnum) {
650+
$orgValue = $orgValue->value;
651+
}
652+
}
643653
}
644654

645655
// skip if value haven't changed
@@ -698,6 +708,7 @@ public function computeChangeSet(ClassMetadata $class, object $entity): void
698708
}
699709

700710
if ($orgValue !== null && $assoc['orphanRemoval']) {
711+
assert(is_object($orgValue));
701712
$this->scheduleOrphanRemoval($orgValue);
702713
}
703714
}

phpstan-baseline.neon

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,11 @@ parameters:
300300
count: 3
301301
path: lib/Doctrine/ORM/Query/Parser.php
302302

303+
-
304+
message: "#^Access to an undefined property Doctrine\\\\ORM\\\\Query\\\\AST\\\\Node\\:\\:\\$pathExpression\\.$#"
305+
count: 1
306+
path: lib/Doctrine/ORM/Query/SqlWalker.php
307+
303308
-
304309
message: "#^Call to function is_string\\(\\) with Doctrine\\\\ORM\\\\Query\\\\AST\\\\Node will always evaluate to false\\.$#"
305310
count: 1

phpstan-params.neon

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

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
<FalsableReturnStatement occurrences="1">
55
<code>! $filteredParameters-&gt;isEmpty() ? $filteredParameters-&gt;first() : null</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
@@ -298,6 +298,28 @@ public function testEnumChangeSetsObjectHydrator(): void
298298
self::assertFalse($this->_em->getUnitOfWork()->isScheduledForUpdate($result[0]));
299299
}
300300

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

0 commit comments

Comments
 (0)