Skip to content

Commit

Permalink
Improve phpdoc return type
Browse files Browse the repository at this point in the history
  • Loading branch information
franmomu committed May 22, 2021
1 parent 0a32d29 commit a226867
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/Doctrine/ODM/MongoDB/DocumentManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
use Doctrine\ODM\MongoDB\Proxy\Resolver\ProxyManagerClassNameResolver;
use Doctrine\ODM\MongoDB\Query\FilterCollection;
use Doctrine\ODM\MongoDB\Repository\DocumentRepository;
use Doctrine\ODM\MongoDB\Repository\GridFSRepository;
use Doctrine\ODM\MongoDB\Repository\RepositoryFactory;
use Doctrine\ODM\MongoDB\Repository\ViewRepository;
use Doctrine\Persistence\ObjectManager;
use Doctrine\Persistence\ObjectRepository;
use InvalidArgumentException;
Expand Down Expand Up @@ -563,8 +565,8 @@ public function unlock(object $document): void
* @param string $documentName The name of the Document.
* @psalm-param class-string<T> $documentName
*
* @return ObjectRepository The repository.
* @psalm-return ObjectRepository<T>
* @return ObjectRepository|DocumentRepository|GridFSRepository|ViewRepository The repository.
* @psalm-return DocumentRepository<T>|GridFSRepository<T>|ViewRepository<T>
*
* @template T of object
*/
Expand Down
4 changes: 4 additions & 0 deletions lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
* to a document database.
*
* @internal
*
* @method ClassMetadata[] getAllMetadata()
* @method ClassMetadata[] getLoadedMetadata()
* @method ClassMetadata getMetadataFor($className)
*/
final class ClassMetadataFactory extends AbstractClassMetadataFactory
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ abstract class AbstractRepositoryFactory implements RepositoryFactory
*/
private $repositoryList = [];

/**
* @psalm-param class-string<T> $documentName
*
* @psalm-return DocumentRepository<T>|GridFSRepository<T>|ViewRepository<T>
*
* @template T of object
*/
public function getRepository(DocumentManager $documentManager, string $documentName): ObjectRepository
{
$metadata = $documentManager->getClassMetadata($documentName);
Expand All @@ -45,7 +52,12 @@ public function getRepository(DocumentManager $documentManager, string $document
/**
* Create a new repository instance for a document class.
*
* @return ObjectRepository|GridFSRepository|ViewRepository
* @psalm-param class-string<T> $documentName
*
* @return ObjectRepository|DocumentRepository|GridFSRepository|ViewRepository
* @psalm-return DocumentRepository<T>|GridFSRepository<T>|ViewRepository<T>
*
* @template T of object
*/
protected function createRepository(DocumentManager $documentManager, string $documentName): ObjectRepository
{
Expand Down

0 comments on commit a226867

Please sign in to comment.