Skip to content

Commit

Permalink
Merge branch '2.13.x' into 2.14.x
Browse files Browse the repository at this point in the history
* 2.13.x:
  Fix changeset computation for enum arrays (#10277)
  Psalm 5.2.0 (#10291)
  Run tools on PHP 8.2 (#10287)
  • Loading branch information
derrabus committed Dec 12, 2022
2 parents 284e814 + bd11475 commit db18161
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 20 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
16 changes: 4 additions & 12 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

name: "Static Analysis"

on:
Expand Down Expand Up @@ -31,18 +30,14 @@ jobs:
strategy:
fail-fast: false
matrix:
php-version:
- "8.1"
dbal-version:
- "default"
persistence-version:
- "default"
include:
- php-version: "8.1"
dbal-version: "2.13"
- dbal-version: "2.13"
persistence-version: "default"
- php-version: "8.1"
dbal-version: "default"
- dbal-version: "default"
persistence-version: "2.5"

steps:
Expand All @@ -53,7 +48,7 @@ jobs:
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
php-version: "8.2"

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

strategy:
fail-fast: false
matrix:
php-version:
- "8.1"

steps:
- name: "Checkout code"
Expand All @@ -97,7 +89,7 @@ jobs:
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
php-version: "8.2"

- name: "Require specific persistence version"
run: "composer require doctrine/persistence ^3.1 --no-update"
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"symfony/cache": "^4.4 || ^5.4 || ^6.0",
"symfony/var-exporter": "^4.4 || ^5.4 || ^6.2",
"symfony/yaml": "^3.4 || ^4.0 || ^5.0 || ^6.0",
"vimeo/psalm": "4.30.0 || 5.1.0"
"vimeo/psalm": "4.30.0 || 5.2.0"
},
"conflict": {
"doctrine/annotations": "<1.13 || >= 2.0"
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 @@ -744,8 +744,18 @@ public function computeChangeSet(ClassMetadata $class, $entity)

$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 @@ -804,6 +814,7 @@ public function computeChangeSet(ClassMetadata $class, $entity)
}

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 @@ -505,6 +505,11 @@ parameters:
count: 1
path: lib/Doctrine/ORM/Query/ResultSetMappingBuilder.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,7 +8,7 @@ parameters:
earlyTerminatingMethodCalls:
Doctrine\ORM\Query\Parser:
- syntaxError
phpVersion: 80100
phpVersion: 80200

ignoreErrors:
# Remove on 3.0.x
Expand Down
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">
<DeprecatedClass occurrences="1">
<code>IterableResult</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 @@ -300,6 +300,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 db18161

Please sign in to comment.