Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stubs/EntityManagerInterface.phpstub
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface EntityManagerInterface extends ObjectManager
*
* @return ?T
*
* @template T
* @template T of object
*/
public function find(string $entityName, $id, ?int $lockMode = null, ?int $lockVersion = null);

Expand Down
35 changes: 29 additions & 6 deletions stubs/EntityRepository.phpstub
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,22 @@ use Doctrine\Persistence\ObjectRepository;
*/
class EntityRepository implements ObjectRepository, Selectable
{
/** @var string */
/**
* @var class-string<T>
* @psalm-suppress PropertyNotSetInConstructor
*/
protected $_entityName;

/** @var EntityManagerInterface */
/**
* @var EntityManagerInterface
* @psalm-suppress PropertyNotSetInConstructor
*/
protected $_em;

/** @var Mapping\ClassMetadata */
/**
* @var Mapping\ClassMetadata
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be Mapping\ClassMetadata<T>?

* @psalm-suppress PropertyNotSetInConstructor
*/
protected $_class;

/** @param Mapping\ClassMetadata<T> $class */
Expand All @@ -44,16 +53,23 @@ class EntityRepository implements ObjectRepository, Selectable
}

/**
* @param ?int $limit
* @param ?int $offset
* @param array<string, mixed> $criteria
* @param array<string, string>|null $orderBy
* @param ?int $limit
* @param ?int $offset
*
* @return list<T>
*/
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null)
{
}

/** @return ?T */
/**
* @psalm-param array<string, mixed> $criteria
* @psalm-param array<string, string>|null $orderBy
*
* @return ?T
*/
public function findOneBy(array $criteria, ?array $orderBy = null)
{
}
Expand All @@ -64,4 +80,11 @@ class EntityRepository implements ObjectRepository, Selectable
public function matching(Criteria $criteria)
{
}

/**
* @return class-string<T>
*/
public function getClassName()
{
}
}
4 changes: 2 additions & 2 deletions stubs/ObjectManager.phpstub
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface ObjectManager
*
* @return Mapping\ClassMetadata<T>
*
* @template T
* @template T of object
*/
public function getClassMetadata(string $className);

Expand All @@ -27,7 +27,7 @@ interface ObjectManager
*
* @return ?T
*
* @template T
* @template T of object
*/
public function find(string $className, $id);
}
12 changes: 9 additions & 3 deletions stubs/ObjectRepository.phpstub
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,19 @@ interface ObjectRepository
public function findAll();

/**
* @param ?int $limit
* @param ?int $offset
* @param array<string, mixed> $criteria
* @param string[]|null $orderBy
* @param ?int $limit
* @param ?int $offset
*
* @return list<T>
*/
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null);

/** @return ?T */
/**
* @param array<string, mixed> $criteria
*
* @return ?T
*/
public function findOneBy(array $criteria);
}