UserRepository type hints added.

This commit is contained in:
Alexey Skobkin 2017-01-09 22:36:08 +03:00
parent dcf3f0f3e9
commit 973207d543

View file

@ -11,11 +11,9 @@ class UserRepository extends EntityRepository
/** /**
* Case-insensitive user search * Case-insensitive user search
* *
* @param string $login
* @return User|null
* @throws \Doctrine\ORM\NonUniqueResultException * @throws \Doctrine\ORM\NonUniqueResultException
*/ */
public function findUserByLogin(string $login) public function findUserByLogin(string $login): User
{ {
$qb = $this->createQueryBuilder('u'); $qb = $this->createQueryBuilder('u');
@ -31,12 +29,9 @@ class UserRepository extends EntityRepository
/** /**
* Case insensitive user LIKE %login% search * Case insensitive user LIKE %login% search
* *
* @param string $login
* @param int $limit
*
* @return User[] * @return User[]
*/ */
public function findUsersLikeLogin(string $login, int $limit = 10) public function findUsersLikeLogin(string $login, int $limit = 10): array
{ {
if (empty($login)) { if (empty($login)) {
return []; return [];
@ -54,10 +49,7 @@ class UserRepository extends EntityRepository
; ;
} }
/** public function getUsersCount(): int
* @return integer
*/
public function getUsersCount()
{ {
$qb = $this->createQueryBuilder('u'); $qb = $this->createQueryBuilder('u');
@ -65,10 +57,9 @@ class UserRepository extends EntityRepository
} }
/** /**
* @param integer $id
* @return User[] * @return User[]
*/ */
public function findUserSubscribersById(int $id) public function findUserSubscribersById(int $id): array
{ {
if (!is_int($id)) { if (!is_int($id)) {
throw new \InvalidArgumentException('$id must be an integer'); throw new \InvalidArgumentException('$id must be an integer');
@ -89,11 +80,9 @@ class UserRepository extends EntityRepository
/** /**
* Returns top users by subscribers count * Returns top users by subscribers count
* *
* @param int $limit
*
* @return TopUserDTO[] * @return TopUserDTO[]
*/ */
public function getTopUsers(int $limit = 30) public function getTopUsers(int $limit = 30): array
{ {
if (!is_int($limit)) { if (!is_int($limit)) {
throw new \InvalidArgumentException('$limit must be an integer'); throw new \InvalidArgumentException('$limit must be an integer');