apply more cs rules for php-cs

This commit is contained in:
2023-10-17 13:27:03 +02:00
parent 0b0cbed9db
commit bc2041cbdd
1485 changed files with 8169 additions and 9620 deletions

View File

@@ -22,8 +22,6 @@ use Doctrine\ORM\Query\ResultSetMapping;
use Doctrine\ORM\Query\ResultSetMappingBuilder;
use Doctrine\ORM\QueryBuilder;
use function count;
final readonly class UserRepository implements UserRepositoryInterface
{
private EntityRepository $repository;
@@ -127,7 +125,7 @@ final readonly class UserRepository implements UserRepositoryInterface
$converted['absenceStart'] = null !== $u['absencestart'] ? new \DateTimeImmutable($u['absencestart']) : null;
/** @phpstan-ignore-next-line phpstan does not take into account that all required keys will be present */
/* @phpstan-ignore-next-line phpstan does not take into account that all required keys will be present */
yield $converted;
}
}
@@ -160,14 +158,13 @@ final readonly class UserRepository implements UserRepositoryInterface
}
}
/**
* @param mixed|null $limit
* @param mixed|null $offset
*
* @return User[]
*/
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null): array
{
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
}
@@ -175,7 +172,7 @@ final readonly class UserRepository implements UserRepositoryInterface
/**
* @return array|User[]
*/
public function findByActive(?array $orderBy = null, ?int $limit = null, ?int $offset = null): array
public function findByActive(array $orderBy = null, int $limit = null, int $offset = null): array
{
return $this->findBy(['enabled' => true], $orderBy, $limit, $offset);
}
@@ -185,12 +182,12 @@ final readonly class UserRepository implements UserRepositoryInterface
*
* @return array|User[]
*/
public function findByNotHavingAttribute(string $key, ?int $limit = null, ?int $offset = null): array
public function findByNotHavingAttribute(string $key, int $limit = null, int $offset = null): array
{
$rsm = new ResultSetMappingBuilder($this->entityManager);
$rsm->addRootEntityFromClassMetadata(User::class, 'u');
$sql = 'SELECT ' . $rsm->generateSelectClause() . ' FROM users u WHERE NOT attributes ?? :key OR attributes IS NULL AND enabled IS TRUE';
$sql = 'SELECT '.$rsm->generateSelectClause().' FROM users u WHERE NOT attributes ?? :key OR attributes IS NULL AND enabled IS TRUE';
if (null !== $limit) {
$sql .= " LIMIT {$limit}";
@@ -203,7 +200,7 @@ final readonly class UserRepository implements UserRepositoryInterface
return $this->entityManager->createNativeQuery($sql, $rsm)->setParameter(':key', $key)->getResult();
}
public function findByUsernameOrEmail(string $pattern, ?array $orderBy = [], ?int $limit = null, ?int $offset = null): array
public function findByUsernameOrEmail(string $pattern, ?array $orderBy = [], int $limit = null, int $offset = null): array
{
$qb = $this->queryByUsernameOrEmail($pattern);
@@ -218,13 +215,13 @@ final readonly class UserRepository implements UserRepositoryInterface
}
foreach ($orderBy as $field => $order) {
$qb->addOrderBy('u.' . $field, $order);
$qb->addOrderBy('u.'.$field, $order);
}
return $qb->getQuery()->getResult();
}
public function findOneBy(array $criteria, ?array $orderBy = null): ?User
public function findOneBy(array $criteria, array $orderBy = null): ?User
{
return $this->repository->findOneBy($criteria, $orderBy);
}
@@ -248,17 +245,16 @@ final readonly class UserRepository implements UserRepositoryInterface
* and, then filter those users having some flags.
*
* @param \Chill\MainBundle\Entity\User[] $amongstUsers
* @param mixed $flag
*/
public function findUsersHavingFlags($flag, array $amongstUsers = []): array
{
$gcs = $this
->entityManager
->createQuery(
'SELECT DISTINCT gc ' .
'FROM ' . GroupCenter::class . ' gc ' .
'JOIN gc.permissionsGroup pg ' .
'WHERE ' .
'SELECT DISTINCT gc '.
'FROM '.GroupCenter::class.' gc '.
'JOIN gc.permissionsGroup pg '.
'WHERE '.
'JSONB_EXISTS_IN_ARRAY(pg.flags, :flag) = :true '
)
->setParameters([
@@ -267,7 +263,7 @@ final readonly class UserRepository implements UserRepositoryInterface
])
->getResult();
if (count($gcs) === 0) {
if (0 === \count($gcs)) {
return [];
}
@@ -280,8 +276,8 @@ final readonly class UserRepository implements UserRepositoryInterface
$orx = $qb->expr()->orX();
foreach ($gcs as $i => $gc) {
$orx->add(':gc_' . $i . ' MEMBER OF u.groupCenters');
$qb->setParameter('gc_' . $i, $gc);
$orx->add(':gc_'.$i.' MEMBER OF u.groupCenters');
$qb->setParameter('gc_'.$i, $gc);
}
$qb->andWhere($orx);