-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from weirdan/support-ServiceEntityRepository
Support ServiceEntityRepository (from doctrine-bundle)
- Loading branch information
Showing
4 changed files
with
107 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
namespace Doctrine\Bundle\DoctrineBundle\Repository; | ||
|
||
use Doctrine\Common\Persistence\ManagerRegistry; | ||
use Doctrine\ORM\EntityRepository; | ||
|
||
/** | ||
* @template T | ||
* @template-extends EntityRepository<T> | ||
*/ | ||
class ServiceEntityRepository extends EntityRepository implements ServiceEntityRepositoryInterface | ||
{ | ||
/** | ||
* @param string $entityClass The class name of the entity this repository manages | ||
*/ | ||
public function __construct(ManagerRegistry $registry, $entityClass) {} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
Feature: ServiceEntityRepository | ||
In order to use simplified repository safely | ||
As a Psalm user | ||
I need Psalm to typecheck ServiceEntityRepository | ||
|
||
Background: | ||
Given I have the following config | ||
""" | ||
<?xml version="1.0"?> | ||
<psalm totallyTyped="true"> | ||
<projectFiles> | ||
<directory name="."/> | ||
</projectFiles> | ||
<plugins> | ||
<pluginClass class="Weirdan\DoctrinePsalmPlugin\Plugin" /> | ||
</plugins> | ||
</psalm> | ||
""" | ||
And I have the following code preamble | ||
""" | ||
<?php | ||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; | ||
use Symfony\Bridge\Doctrine\RegistryInterface; | ||
interface I {} | ||
""" | ||
|
||
@ServiceEntityRepository::inheritance | ||
Scenario: Extending a ServiceEntityRepository | ||
Given I have the following code | ||
""" | ||
/** | ||
* @method I|null find($id, $lockMode = null, $lockVersion = null) | ||
* @method I|null findOneBy(array $criteria, array $orderBy = null) | ||
* @method I[] findAll() | ||
* @method I[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) | ||
* @template-extends ServiceEntityRepository<I> | ||
* @psalm-suppress PropertyNotSetInConstructor | ||
*/ | ||
class IRepository extends ServiceEntityRepository { | ||
public function __construct(RegistryInterface $registry) { | ||
parent::__construct($registry, I::class); | ||
} | ||
} | ||
""" | ||
When I run Psalm | ||
Then I see no errors |