phpstan / phpstan-doctrine

Doctrine extensions for PHPStan
MIT License
595 stars 97 forks source link

GetRepository return value mismatch for ODM\GridFSDocument #59

Closed josefsabl closed 2 years ago

josefsabl commented 5 years ago

I have this code:

$repository = $this->documentManager->getRepository(Document::class);
assert($repository instanceof \Doctrine\ODM\MongoDB\Repository\DefaultGridFSRepository);

The assert passes but I get this PhpStan error:

Instanceof between                                                   
Doctrine\ORM\EntityRepository<MyCompany\ODM\File\Document> and           
Doctrine\ODM\MongoDB\Repository\DefaultGridFSRepository will always  
evaluate to false. 

Note that the document for which I am getting a repository is not a standard document but rather GridFS file document which has some specifics.

The code snippet is taken from here.

alcaeus commented 5 years ago

Are you using the 2.0 beta version? I don’t believe the code for this has been updated to cover 2.0.

josefsabl commented 5 years ago

Are you using the 2.0 beta version?

Yes I am. Okay, thank you very much!

ondrejmirtes commented 2 years ago

Please try the latest version and report back, thanks.

github-actions[bot] commented 2 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.