psalm / psalm-plugin-doctrine

Stubs to let Psalm understand Doctrine better
86 stars 43 forks source link

Fix new EntityManager#refresh in Doctrine ORM 2.14 #136

Closed michnovka closed 1 year ago

michnovka commented 1 year ago

Fixes https://github.com/psalm/psalm-plugin-doctrine/issues/135

michnovka commented 1 year ago

I am not sure if this is the proper fix tho. The error is complaining about Persistance interface. Any help please @orklah @weirdan ?

orklah commented 1 year ago

It seems to come from the Persistence\ObjectManagerInterface interface indeed. It would be this stub: https://github.com/psalm/psalm-plugin-doctrine/blob/62dd7fef85469c63739c0252c2d82151617921b5/stubs/ObjectManager.phpstub

However, we don't actually have a stub for refresh that would declare only one argument so a change here should not be needed. Unless they deployed some kind of migration path and Psalm would be confused about which signature it should take?

michnovka commented 1 year ago

This is the way I autowire the $entityManager.


class ResellerHelper
{
    public function __construct(
        private readonly EntityManagerInterface $entityManager,
    ) {
    }

so probably, I should fix the EntityManagerInterface also, otherwise this autowiring will fail with psalm. This is btw the exact same approach that is used for the EntityManager#find and EntityManagerInterface#find and $lockMode

michnovka commented 1 year ago

@orklah I have pushed new fix for both EntityManager and EntityManagerInterface stubs. Tested on my code and it does resolve the issue.

michnovka commented 1 year ago

@orklah can we merge this please?

orklah commented 1 year ago

Thanks!

michnovka commented 1 year ago

Thanks for merging. Can you please release at least a point release?