mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-28 09:34:59 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -12,10 +12,8 @@ declare(strict_types=1);
|
||||
namespace Chill\PersonBundle\Repository\AccompanyingPeriod;
|
||||
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodInfo;
|
||||
use DateInterval;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use LogicException;
|
||||
use Symfony\Component\Clock\ClockInterface;
|
||||
|
||||
readonly class AccompanyingPeriodInfoRepository implements AccompanyingPeriodInfoRepositoryInterface
|
||||
@@ -29,14 +27,14 @@ readonly class AccompanyingPeriodInfoRepository implements AccompanyingPeriodInf
|
||||
$this->entityRepository = $em->getRepository($this->getClassName());
|
||||
}
|
||||
|
||||
public function findAccompanyingPeriodIdInactiveAfter(DateInterval $interval, array $statuses = []): array
|
||||
public function findAccompanyingPeriodIdInactiveAfter(\DateInterval $interval, array $statuses = []): array
|
||||
{
|
||||
$query = $this->em->createQuery();
|
||||
$baseDql = 'SELECT DISTINCT IDENTITY(ai.accompanyingPeriod) FROM '.AccompanyingPeriodInfo::class.' ai JOIN ai.accompanyingPeriod a WHERE NOT EXISTS
|
||||
(SELECT 1 FROM ' . AccompanyingPeriodInfo::class . ' aiz WHERE aiz.infoDate > :after AND IDENTITY(aiz.accompanyingPeriod) = IDENTITY(ai.accompanyingPeriod))';
|
||||
(SELECT 1 FROM '.AccompanyingPeriodInfo::class.' aiz WHERE aiz.infoDate > :after AND IDENTITY(aiz.accompanyingPeriod) = IDENTITY(ai.accompanyingPeriod))';
|
||||
|
||||
if ([] !== $statuses) {
|
||||
$dql = $baseDql . ' AND a.step IN (:statuses)';
|
||||
$dql = $baseDql.' AND a.step IN (:statuses)';
|
||||
$query->setParameter('statuses', $statuses);
|
||||
} else {
|
||||
$dql = $baseDql;
|
||||
@@ -47,14 +45,14 @@ readonly class AccompanyingPeriodInfoRepository implements AccompanyingPeriodInf
|
||||
->getSingleColumnResult();
|
||||
}
|
||||
|
||||
public function findAccompanyingPeriodIdActiveSince(DateInterval $interval, array $statuses = []): array
|
||||
public function findAccompanyingPeriodIdActiveSince(\DateInterval $interval, array $statuses = []): array
|
||||
{
|
||||
$query = $this->em->createQuery();
|
||||
$baseDql = 'SELECT DISTINCT IDENTITY(ai.accompanyingPeriod) FROM ' . AccompanyingPeriodInfo::class . ' ai
|
||||
$baseDql = 'SELECT DISTINCT IDENTITY(ai.accompanyingPeriod) FROM '.AccompanyingPeriodInfo::class.' ai
|
||||
JOIN ai.accompanyingPeriod a WHERE ai.infoDate > :after';
|
||||
|
||||
if ([] !== $statuses) {
|
||||
$dql = $baseDql . ' AND a.step IN (:statuses)';
|
||||
$dql = $baseDql.' AND a.step IN (:statuses)';
|
||||
$query->setParameter('statuses', $statuses);
|
||||
} else {
|
||||
$dql = $baseDql;
|
||||
@@ -67,7 +65,7 @@ readonly class AccompanyingPeriodInfoRepository implements AccompanyingPeriodInf
|
||||
|
||||
public function find($id): never
|
||||
{
|
||||
throw new LogicException("Calling an accompanying period info by his id does not make sense");
|
||||
throw new \LogicException('Calling an accompanying period info by his id does not make sense');
|
||||
}
|
||||
|
||||
public function findAll(): array
|
||||
@@ -75,7 +73,7 @@ readonly class AccompanyingPeriodInfoRepository implements AccompanyingPeriodInf
|
||||
return $this->entityRepository->findAll();
|
||||
}
|
||||
|
||||
public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array
|
||||
public function findBy(array $criteria, array $orderBy = null, int $limit = null, int $offset = null): array
|
||||
{
|
||||
return $this->entityRepository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
@@ -21,17 +21,17 @@ use Doctrine\Persistence\ObjectRepository;
|
||||
interface AccompanyingPeriodInfoRepositoryInterface extends ObjectRepository
|
||||
{
|
||||
/**
|
||||
* Return a list of id for inactive accompanying periods
|
||||
* Return a list of id for inactive accompanying periods.
|
||||
*
|
||||
* @param \DateInterval $interval
|
||||
* @param list<AccompanyingPeriod::STEP_*> $statuses
|
||||
*
|
||||
* @return list<int>
|
||||
*/
|
||||
public function findAccompanyingPeriodIdInactiveAfter(\DateInterval $interval, array $statuses = []): array;
|
||||
|
||||
/**
|
||||
* @param \DateInterval $interval
|
||||
* @param list<AccompanyingPeriod::STEP_*> $statuses
|
||||
*
|
||||
* @return list<int>
|
||||
*/
|
||||
public function findAccompanyingPeriodIdActiveSince(\DateInterval $interval, array $statuses = []): array;
|
||||
|
@@ -39,12 +39,12 @@ class AccompanyingPeriodWorkEvaluationDocumentRepository implements ObjectReposi
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null|mixed $limit
|
||||
* @param null|mixed $offset
|
||||
* @param mixed|null $limit
|
||||
* @param mixed|null $offset
|
||||
*
|
||||
* @return array|object[]|AccompanyingPeriodWorkEvaluationDocument[]
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
@@ -14,7 +14,6 @@ namespace Chill\PersonBundle\Repository\AccompanyingPeriod;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
@@ -54,7 +53,7 @@ class AccompanyingPeriodWorkEvaluationRepository implements ObjectRepository
|
||||
*
|
||||
* @return array|AccompanyingPeriodWorkEvaluation[]
|
||||
*/
|
||||
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);
|
||||
}
|
||||
@@ -93,14 +92,14 @@ class AccompanyingPeriodWorkEvaluationRepository implements ObjectRepository
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->eq('period.user', ':user'),
|
||||
$qb->expr()->exists(
|
||||
'SELECT 1 FROM ' . AccompanyingPeriodWork::class . ' subw JOIN subw.referrersHistory subw_ref_history WHERE subw.id = work.id AND subw_ref_history.user = :user'
|
||||
'SELECT 1 FROM '.AccompanyingPeriodWork::class.' subw JOIN subw.referrersHistory subw_ref_history WHERE subw.id = work.id AND subw_ref_history.user = :user'
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
->setParameters([
|
||||
'user' => $user,
|
||||
'now' => new DateTimeImmutable('now'),
|
||||
'now' => new \DateTimeImmutable('now'),
|
||||
]);
|
||||
|
||||
return $qb;
|
||||
|
@@ -15,7 +15,6 @@ use Chill\MainBundle\Entity\User;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
|
||||
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
@@ -47,13 +46,13 @@ final readonly class AccompanyingPeriodWorkRepository implements ObjectRepositor
|
||||
->getSingleScalarResult();
|
||||
}
|
||||
|
||||
public function countNearEndDateByUser(User $user, DateTimeImmutable $since, DateTimeImmutable $until): int
|
||||
public function countNearEndDateByUser(User $user, \DateTimeImmutable $since, \DateTimeImmutable $until): int
|
||||
{
|
||||
return $this->buildQueryNearEndDateByUser($user, $since, $until)
|
||||
->select('count(w)')->getQuery()->getSingleScalarResult();
|
||||
}
|
||||
|
||||
public function createQueryBuilder(string $alias, ?string $indexBy = null): QueryBuilder
|
||||
public function createQueryBuilder(string $alias, string $indexBy = null): QueryBuilder
|
||||
{
|
||||
return $this->repository->createQueryBuilder($alias, $indexBy);
|
||||
}
|
||||
@@ -68,7 +67,7 @@ final readonly class AccompanyingPeriodWorkRepository implements ObjectRepositor
|
||||
return $this->repository->findAll();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -91,8 +90,9 @@ final readonly class AccompanyingPeriodWorkRepository implements ObjectRepositor
|
||||
* * first, opened works
|
||||
* * then, closed works
|
||||
*
|
||||
* @param array{types?: list<SocialAction>, user?: list<User>, after?: \DateTimeImmutable|null, before?: \DateTimeImmutable|null} $filters
|
||||
*
|
||||
* @return AccompanyingPeriodWork[]
|
||||
* @param array{types?: list<SocialAction>, user?: list<User>, after?: null|\DateTimeImmutable, before?: null|\DateTimeImmutable} $filters
|
||||
*/
|
||||
public function findByAccompanyingPeriodOpenFirst(AccompanyingPeriod $period, array $filters, int $limit = 10, int $offset = 0): array
|
||||
{
|
||||
@@ -106,23 +106,23 @@ final readonly class AccompanyingPeriodWorkRepository implements ObjectRepositor
|
||||
// implement filters
|
||||
|
||||
if ([] !== ($filters['types'] ?? [])) {
|
||||
$sql .= " AND w.socialaction_id IN (:types)";
|
||||
$sql .= ' AND w.socialaction_id IN (:types)';
|
||||
}
|
||||
|
||||
if ([] !== ($filters['user'] ?? [])) {
|
||||
$sql .= " AND rw.user_id IN ("
|
||||
. implode(
|
||||
$sql .= ' AND rw.user_id IN ('
|
||||
.implode(
|
||||
', ',
|
||||
// we add a user_xx for each key of the 'user' list
|
||||
array_map(fn (User $u, int $idx) => ':user_' . $idx, $filters['user'], array_keys($filters['user']))
|
||||
array_map(fn (User $u, int $idx) => ':user_'.$idx, $filters['user'], array_keys($filters['user']))
|
||||
)
|
||||
. ")";
|
||||
.')';
|
||||
}
|
||||
|
||||
$sql .= " AND daterange(:after::date, :before::date) && daterange(w.startDate, w.endDate, '[]')";
|
||||
|
||||
// if the start and end date were inversed, we inverse the order to avoid an error
|
||||
if (null !== ($filters['after'] ?? null) && null !== ($filters['before']) && $filters['after'] > $filters['before']) {
|
||||
if (null !== ($filters['after'] ?? null) && null !== $filters['before'] && $filters['after'] > $filters['before']) {
|
||||
$before = $filters['after'];
|
||||
$after = $filters['before'];
|
||||
} else {
|
||||
@@ -137,7 +137,7 @@ final readonly class AccompanyingPeriodWorkRepository implements ObjectRepositor
|
||||
w.enddate DESC,
|
||||
w.id DESC";
|
||||
|
||||
$sql .= " LIMIT :limit OFFSET :offset";
|
||||
$sql .= ' LIMIT :limit OFFSET :offset';
|
||||
|
||||
$typeIds = [];
|
||||
foreach ($filters['types'] as $type) {
|
||||
@@ -153,14 +153,14 @@ final readonly class AccompanyingPeriodWorkRepository implements ObjectRepositor
|
||||
->setParameter('offset', $offset, Types::INTEGER);
|
||||
|
||||
foreach ($filters['user'] as $key => $user) {
|
||||
$nq->setParameter('user_' . $key, $user);
|
||||
$nq->setParameter('user_'.$key, $user);
|
||||
}
|
||||
|
||||
return $nq->getResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of types of social actions associated to the accompanying period
|
||||
* Return a list of types of social actions associated to the accompanying period.
|
||||
*
|
||||
* @return array<SocialAction>
|
||||
*/
|
||||
@@ -171,10 +171,8 @@ final readonly class AccompanyingPeriodWorkRepository implements ObjectRepositor
|
||||
->select('1')
|
||||
->from(AccompanyingPeriodWork::class, 'apw');
|
||||
|
||||
|
||||
$in->andWhere('apw.accompanyingPeriod = :period')->setParameter('period', $period);
|
||||
|
||||
|
||||
// join between the embedded exist query and the main query
|
||||
$in->andWhere('apw.socialAction = sa');
|
||||
|
||||
@@ -189,7 +187,7 @@ final readonly class AccompanyingPeriodWorkRepository implements ObjectRepositor
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
|
||||
public function findNearEndDateByUser(User $user, DateTimeImmutable $since, DateTimeImmutable $until, int $limit = 20, int $offset = 0): array
|
||||
public function findNearEndDateByUser(User $user, \DateTimeImmutable $since, \DateTimeImmutable $until, int $limit = 20, int $offset = 0): array
|
||||
{
|
||||
return $this->buildQueryNearEndDateByUser($user, $since, $until)
|
||||
->select('w')
|
||||
@@ -227,7 +225,7 @@ final readonly class AccompanyingPeriodWorkRepository implements ObjectRepositor
|
||||
return $qb;
|
||||
}
|
||||
|
||||
private function buildQueryNearEndDateByUser(User $user, DateTimeImmutable $since, DateTimeImmutable $until): QueryBuilder
|
||||
private function buildQueryNearEndDateByUser(User $user, \DateTimeImmutable $since, \DateTimeImmutable $until): QueryBuilder
|
||||
{
|
||||
$qb = $this->repository->createQueryBuilder('w');
|
||||
|
||||
@@ -240,7 +238,7 @@ final readonly class AccompanyingPeriodWorkRepository implements ObjectRepositor
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->eq('period.user', ':user'),
|
||||
$qb->expr()->exists(
|
||||
'SELECT 1 FROM ' . AccompanyingPeriodWork::class . ' subw JOIN subw.referrersHistory subw_ref_history WHERE subw.id = w.id AND subw_ref_history.user = :user and subw.ref_history.endDate IS NULL'
|
||||
'SELECT 1 FROM '.AccompanyingPeriodWork::class.' subw JOIN subw.referrersHistory subw_ref_history WHERE subw.id = w.id AND subw_ref_history.user = :user and subw.ref_history.endDate IS NULL'
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@@ -41,7 +41,7 @@ final readonly class ClosingMotiveRepository implements ClosingMotiveRepositoryI
|
||||
/**
|
||||
* @return array|ClosingMotive[]
|
||||
*/
|
||||
public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array
|
||||
public function findBy(array $criteria, array $orderBy = null, int $limit = null, int $offset = null): array
|
||||
{
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
@@ -51,15 +51,12 @@ final readonly class ClosingMotiveRepository implements ClosingMotiveRepositoryI
|
||||
return $this->findOneBy($criteria);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getActiveClosingMotive(bool $onlyLeaf = true)
|
||||
{
|
||||
$rsm = new ResultSetMappingBuilder($this->entityManager);
|
||||
$rsm->addRootEntityFromClassMetadata($this->repository->getClassName(), 'cm');
|
||||
|
||||
$sql = 'SELECT ' . (string) $rsm . '
|
||||
$sql = 'SELECT '.(string) $rsm.'
|
||||
FROM chill_person_accompanying_period_closingmotive AS cm
|
||||
WHERE
|
||||
active IS TRUE ';
|
||||
|
@@ -15,8 +15,5 @@ use Doctrine\Persistence\ObjectRepository;
|
||||
|
||||
interface ClosingMotiveRepositoryInterface extends ObjectRepository
|
||||
{
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getActiveClosingMotive(bool $onlyLeaf = true);
|
||||
}
|
||||
|
Reference in New Issue
Block a user