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

Handle generic parameters in UnitOfWork #8710

Merged
merged 1 commit into from
May 25, 2021
Merged

Conversation

franmomu
Copy link
Contributor

@franmomu franmomu commented May 24, 2021

The following code:

$classMetadata = $this->entityManager->getClassMetadata(User::class);
$this->entityManager->getUnitOfWork()->recomputeSingleEntityChangeSet($classMetadata, $user);

Triggers this error in psalm:

Argument 1 of Doctrine\ORM\UnitOfWork::recomputeSingleEntityChangeSet expects Doctrine\ORM\Mapping\ClassMetadata<object>, Doctrine\ORM\Mapping\ClassMetadata<App\Entity\User> provided (see https://psalm.dev/004)
        $this->entityManager->getUnitOfWork()->recomputeSingleEntityChangeSet($classMetadata, $user);

Update: I've also changed some other methods.

@franmomu franmomu marked this pull request as draft May 24, 2021 08:26
@franmomu franmomu changed the title Make recomputeSingleEntityChangeSet handle generic params Handle generic parameters in UnitOfWork May 24, 2021
@franmomu franmomu marked this pull request as ready for review May 24, 2021 09:18
@martinssipenko
Copy link

martinssipenko commented May 24, 2021

I'm experiencing a similar issue reported by psalm for computeChangeSet method using the following example code, could this be related?

ERROR: InvalidArgument - x.php:12:9 - Argument 1 of Doctrine\ORM\UnitOfWork::computeChangeSet expects Doctrine\ORM\Mapping\ClassMetadata<object>, Doctrine\ORM\Mapping\ClassMetadata<Event> provided (see https://psalm.dev/004)
        $em->getClassMetadata(Event::class),
<?php

declare(strict_types=1);

require_once __DIR__ . '/vendor/autoload.php';

function test(\Doctrine\ORM\EntityManagerInterface $em): void
{
    $event = new Event();

    $em->getUnitOfWork()->computeChangeSet(
        $em->getClassMetadata(Event::class),
        $event,
    );
}

class Event {}

@greg0ire greg0ire changed the base branch from 2.8.x to 2.9.x May 25, 2021 10:57
@greg0ire
Copy link
Member

2.8.x is no longer maintained, so I'm retargeting to 2.9.x . Please rebase @franmomu 🙏

@franmomu
Copy link
Contributor Author

done!

@greg0ire greg0ire added this to the 2.9.2 milestone May 25, 2021
@greg0ire
Copy link
Member

@martinssipenko it does look really similar.

@greg0ire greg0ire added the Bug label May 25, 2021
@greg0ire greg0ire merged commit 46f0da9 into doctrine:2.9.x May 25, 2021
@greg0ire
Copy link
Member

Thanks @franmomu !

@franmomu franmomu deleted the recompute branch May 25, 2021 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants