Skip to content

Commit

Permalink
Merge pull request #47 from orklah/template-typeof
Browse files Browse the repository at this point in the history
Replace template-typeof
  • Loading branch information
weirdan authored Jan 19, 2020
2 parents f8ba5da + 28a7a9a commit f962d9e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 25 deletions.
13 changes: 5 additions & 8 deletions stubs/EntityManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,35 @@
class EntityManager implements EntityManagerInterface
{
/**
* @param class-string $entityName
* @param class-string<T> $entityName
*
* @return EntityRepository<T>
*
* @template T
* @template-typeof T $entityName
*/
public function getRepository(string $entityName)
{
}

/**
* @param class-string $entityName
* @param mixed $id
* @param class-string<T> $entityName
* @param mixed $id
*
* @return ?T
*
* @template T
* @template-typeof T $entityName
*/
public function find(string $entityName, $id, ?int $lockMode = null, ?int $lockVersion = null)
{
}

/**
* @param class-string $entityName
* @param mixed $id
* @param class-string<T> $entityName
* @param mixed $id
*
* @return T
*
* @template T
* @template-typeof T $entityName
*/
public function getReference(string $entityName, $id)
{
Expand Down
13 changes: 5 additions & 8 deletions stubs/EntityManagerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,31 @@
interface EntityManagerInterface extends ObjectManager
{
/**
* @param class-string $entityName
* @param class-string<T> $entityName
*
* @return EntityRepository<T>
*
* @template T
* @template-typeof T $entityName
*/
public function getRepository(string $entityName);

/**
* @param class-string $entityName
* @param mixed $id
* @param class-string<T> $entityName
* @param mixed $id
*
* @return ?T
*
* @template T
* @template-typeof T $entityName
*/
public function find(string $entityName, $id, ?int $lockMode = null, ?int $lockVersion = null);

/**
* @param class-string $entityName
* @param mixed $id
* @param class-string<T> $entityName
* @param mixed $id
*
* @return T
*
* @template T
* @template-typeof T $entityName
*/
public function getReference(string $entityName, $id);
}
9 changes: 3 additions & 6 deletions stubs/ObjectManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,29 @@
interface ObjectManager
{
/**
* @param class-string $className
* @param class-string<T> $className
*
* @return ObjectRepository<T>
*
* @template T
* @template-typeof T $className
*/
public function getRepository(string $className);

/**
* @param class-string $className
* @param class-string<T> $className
*
* @return Mapping\ClassMetadata<T>
*
* @template T
* @template-typeof T $className
*/
public function getClassMetadata(string $className);

/**
* @param class-string $className
* @param class-string<T> $className
*
* @return ?T
*
* @template T
* @template-typeof T $className
*/
public function find(string $className, $id);
}
2 changes: 1 addition & 1 deletion tests/acceptance/EntityRepository.feature
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Feature: EntityRepository
/**
* @template T
* @template-typeof T $entityClass
* @param class-string<T> $entityClass
* @psalm-suppress InvalidReturnType
* @return EntityRepository<T>
*/
Expand Down
3 changes: 1 addition & 2 deletions tests/acceptance/Paginator.feature
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ Feature: Paginator
/**
* @template T
* @template-typeof T $type
* @param class-string $type
* @param class-string<T> $type
* @return Paginator<T>
* @psalm-suppress InvalidReturnType
*/
Expand Down

0 comments on commit f962d9e

Please sign in to comment.