Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge release 2.9.2 into 2.10.x #2718

Merged
merged 4 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
{
}