Skip to content

Commit

Permalink
Merge branch '2.14.x' into 3.0.x
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
derrabus committed Dec 12, 2022
2 parents 9d8cadf + db18161 commit 2bfcb6e
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ on:

jobs:
coding-standards:
uses: "doctrine/.github/.github/workflows/coding-standards.yml@2.1.0"
uses: "doctrine/.github/.github/workflows/coding-standards.yml@3.0.0"
2 changes: 1 addition & 1 deletion .github/workflows/release-on-milestone-closed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
release:
uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@2.1.0"
uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@3.0.0"
secrets:
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Static Analysis
name: "Static Analysis"

on:
pull_request:
Expand Down Expand Up @@ -43,7 +43,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: "8.1"
php-version: "8.2"
tools: cs2pr

- name: Require specific DBAL version
Expand Down Expand Up @@ -74,7 +74,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: "8.1"
php-version: "8.2"
tools: cs2pr

- name: Require specific DBAL version
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"squizlabs/php_codesniffer": "3.7.1",
"symfony/cache": "^5.4 || ^6.0",
"symfony/var-exporter": "^5.4 || ^6.2",
"vimeo/psalm": "5.1.0"
"vimeo/psalm": "5.2.0"
},
"suggest": {
"ext-dom": "Provides support for XSD validation for XML mapping files",
Expand Down
15 changes: 13 additions & 2 deletions lib/Doctrine/ORM/UnitOfWork.php
Original file line number Diff line number Diff line change
Expand Up @@ -638,8 +638,18 @@ public function computeChangeSet(ClassMetadata $class, object $entity): void

$orgValue = $originalData[$propName];

if ($orgValue instanceof BackedEnum) {
$orgValue = $orgValue->value;
if (! empty($class->fieldMappings[$propName]['enumType'])) {
if (is_array($orgValue)) {
foreach ($orgValue as $id => $val) {
if ($val instanceof BackedEnum) {
$orgValue[$id] = $val->value;
}
}
} else {
if ($orgValue instanceof BackedEnum) {
$orgValue = $orgValue->value;
}
}
}

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

if ($orgValue !== null && $assoc['orphanRemoval']) {
assert(is_object($orgValue));
$this->scheduleOrphanRemoval($orgValue);
}
}
Expand Down
5 changes: 5 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,11 @@ parameters:
count: 3
path: lib/Doctrine/ORM/Query/Parser.php

-
message: "#^Access to an undefined property Doctrine\\\\ORM\\\\Query\\\\AST\\\\Node\\:\\:\\$pathExpression\\.$#"
count: 1
path: lib/Doctrine/ORM/Query/SqlWalker.php

-
message: "#^Call to function is_string\\(\\) with Doctrine\\\\ORM\\\\Query\\\\AST\\\\Node will always evaluate to false\\.$#"
count: 1
Expand Down
2 changes: 1 addition & 1 deletion phpstan-params.neon
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ parameters:
earlyTerminatingMethodCalls:
Doctrine\ORM\Query\Parser:
- syntaxError
phpVersion: 80100
phpVersion: 80200
2 changes: 1 addition & 1 deletion psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.1.0@4defa177c89397c5e14737a80fe4896584130674">
<files psalm-version="5.2.0@fb685a16df3050d4c18d8a4100fe83abe6458cba">
<file src="lib/Doctrine/ORM/AbstractQuery.php">
<FalsableReturnStatement occurrences="1">
<code>! $filteredParameters-&gt;isEmpty() ? $filteredParameters-&gt;first() : null</code>
Expand Down
2 changes: 1 addition & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<psalm
errorLevel="2"
phpVersion="8.1"
phpVersion="8.2"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
Expand Down
22 changes: 22 additions & 0 deletions tests/Doctrine/Tests/ORM/Functional/EnumTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,28 @@ public function testEnumChangeSetsObjectHydrator(): void
self::assertFalse($this->_em->getUnitOfWork()->isScheduledForUpdate($result[0]));
}

public function testEnumArrayChangeSets(): void
{
$this->setUpEntitySchema([Scale::class]);

$scale = new Scale();
$scale->supportedUnits = [Unit::Gram];

$this->_em->persist($scale);
$this->_em->flush();
$this->_em->clear();

$result = $this->_em->createQueryBuilder()
->from(Scale::class, 's')
->select('s')
->getQuery()
->getResult();

$this->_em->getUnitOfWork()->computeChangeSets();

self::assertFalse($this->_em->getUnitOfWork()->isScheduledForUpdate($result[0]));
}

public function testFindByEnum(): void
{
$this->setUpEntitySchema([Card::class]);
Expand Down

0 comments on commit 2bfcb6e

Please sign in to comment.