Skip to content

Commit

Permalink
Merge pull request #2718 from doctrine/2.9.x-merge-up-into-2.10.x
Browse files Browse the repository at this point in the history
Merge release 2.9.2 into 2.10.x
  • Loading branch information
GromNaN authored Jan 17, 2025
2 parents bf9f889 + 6be1b86 commit 5f2cbc4
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ jobs:
dependency-versions: "${{ matrix.dependencies }}"
composer-options: "--prefer-dist"

- name: "Install latest Python version"
uses: actions/setup-python@v5
with:
python-version: '3.13'

- id: setup-mongodb
uses: mongodb-labs/drivers-evergreen-tools@master
with:
Expand Down
3 changes: 2 additions & 1 deletion lib/Doctrine/ODM/MongoDB/Aggregation/Stage/AddFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
*
* @phpstan-import-type OperatorExpression from Expr
* @phpstan-type AddFieldsStageExpression array{'$addFields': array<string, OperatorExpression|mixed>}
* @final
*/
final class AddFields extends Operator
class AddFields extends Operator
{
/** @return AddFieldsStageExpression */
public function getExpression(): array
Expand Down
3 changes: 2 additions & 1 deletion lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Set.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
*
* @phpstan-import-type OperatorExpression from Expr
* @phpstan-type SetStageExpression array{'$set': array<string, OperatorExpression|mixed>}
* @final
*/
final class Set extends Operator
class Set extends Operator
{
/** @phpstan-return SetStageExpression */
public function getExpression(): array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
#[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_PROPERTY)]
final class DiscriminatorMap implements Annotation
{
/** @var array<string, class-string> */
/** @var array<class-string> */
public $value;

/** @param array<string, class-string> $value */
/** @param array<class-string> $value */
public function __construct(array $value)
{
$this->value = $value;
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ODM/MongoDB/Persisters/DocumentPersister.php
Original file line number Diff line number Diff line change
Expand Up @@ -1470,7 +1470,7 @@ private function getClassDiscriminatorValues(ClassMetadata $metadata): array

foreach ($metadata->subClasses as $className) {
$key = array_search($className, $metadata->discriminatorMap);
if (! $key) {
if ($key === false) {
continue;
}

Expand Down
46 changes: 46 additions & 0 deletions tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH2158Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

declare(strict_types=1);

namespace Doctrine\ODM\MongoDB\Tests\Functional\Ticket;

use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
use Doctrine\ODM\MongoDB\Tests\BaseTestCase;

class GH2158Test extends BaseTestCase
{
public function testDiscriminatorMapCreationType(): void
{
$obj = new GH2158FirstType();
$this->dm->persist($obj);
$this->dm->flush();

self::assertEquals($this->dm->find(GH2158Abstract::class, $obj->getId()), $obj);
}
}

#[ODM\Document(collection: 'documents')]
#[ODM\InheritanceType('SINGLE_COLLECTION')]
#[ODM\DiscriminatorField('type')]
#[ODM\DiscriminatorMap([0 => GH2158FirstType::class, 1 => GH2158SecondType::class])]
abstract class GH2158Abstract
{
/** @var string */
#[ODM\Id]
protected $id;

public function getId(): string
{
return $this->id;
}
}

#[ODM\Document]
class GH2158FirstType extends GH2158Abstract
{
}

#[ODM\Document]
class GH2158SecondType extends GH2158Abstract
{
}

0 comments on commit 5f2cbc4

Please sign in to comment.