Closed mustanggb closed 10 months ago
@mustanggb any chance you could provide us a PR with a failing test case? At a glance there seems to be a misconfiguration on your end, as per the error the repository is expecting an instance of ManagerRegistry
while it's given a DocumentManager
instead.
Okay I think I found the source:
/**
* @extends ServiceDocumentRepository<Product>
*/
class ProductRepository extends ServiceDocumentRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Product::class);
}
}
I also tried @template-extends ServiceDocumentRepository<Product>
but it gives the same problem.
However changing to @extends ServiceDocumentRepository
"fixes" it?
Could this be related to some of these:
Ah so this is static analysis error! Whatever you're using seems to be taking PHPDoc from ODM's definition https://github.com/doctrine/mongodb-odm/blob/d3c8966b95059e9b572b3f873440b93ac7dd3907/lib/Doctrine/ODM/MongoDB/Repository/DocumentRepository.php#L61 instead of bundle's trait.
Thanks for the help, it seems this is due to a missing param: #782
Fixed by 0a533e9ff176f727459aa33ec097231deec2213e.
Implementing a repository as per the Service Repositories docs:
i.e.
Kicks out an issue with
$registry
inparent::__construct($registry, Product::class);
of:I had a dig around in
ServiceRepositoryTrait
but wasn't able to figure out how to solve it.For reference, I also tested with the ORM's
ServiceEntityRepository
, but it did not experience the same problem.