diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index 7c276c769f5..1ce1a90c1b0 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -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" diff --git a/.github/workflows/release-on-milestone-closed.yml b/.github/workflows/release-on-milestone-closed.yml index 2dfa3c02645..c4389142616 100644 --- a/.github/workflows/release-on-milestone-closed.yml +++ b/.github/workflows/release-on-milestone-closed.yml @@ -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 }} diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index a23846d6139..c06ceae816c 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -1,4 +1,4 @@ -name: Static Analysis +name: "Static Analysis" on: pull_request: @@ -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 @@ -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 diff --git a/composer.json b/composer.json index 1b0050ea473..464d61d3c8a 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 32194697345..dedd7ad9e96 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -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 @@ -698,6 +708,7 @@ public function computeChangeSet(ClassMetadata $class, object $entity): void } if ($orgValue !== null && $assoc['orphanRemoval']) { + assert(is_object($orgValue)); $this->scheduleOrphanRemoval($orgValue); } } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 490d1f9a6c0..9c77672264f 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -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 diff --git a/phpstan-params.neon b/phpstan-params.neon index 784f63e2d2b..60abffb720f 100644 --- a/phpstan-params.neon +++ b/phpstan-params.neon @@ -8,4 +8,4 @@ parameters: earlyTerminatingMethodCalls: Doctrine\ORM\Query\Parser: - syntaxError - phpVersion: 80100 + phpVersion: 80200 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index fb112f610ab..814f9b067cd 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,5 +1,5 @@ - + ! $filteredParameters->isEmpty() ? $filteredParameters->first() : null diff --git a/psalm.xml b/psalm.xml index 1ef40e59f31..4fb23c64cf4 100644 --- a/psalm.xml +++ b/psalm.xml @@ -1,7 +1,7 @@ _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]);