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

@@ -19,7 +19,7 @@ final readonly class ThirdPartyACLAwareRepository implements ThirdPartyACLAwareR
{
public function __construct(private Security $security, private AuthorizationHelper $authorizationHelper, private ThirdPartyRepository $thirdPartyRepository) {}
public function buildQuery(?string $filterString = null): QueryBuilder
public function buildQuery(string $filterString = null): QueryBuilder
{
$qb = $this->thirdPartyRepository->createQueryBuilder('tp');
@@ -31,7 +31,7 @@ final readonly class ThirdPartyACLAwareRepository implements ThirdPartyACLAwareR
if (null !== $filterString) {
$qb->andWhere($qb->expr()->like('tp.canonicalized', 'LOWER(UNACCENT(:filterString))'))
->setParameter('filterString', '%' . $filterString . '%');
->setParameter('filterString', '%'.$filterString.'%');
}
return $qb;
@@ -51,13 +51,13 @@ final readonly class ThirdPartyACLAwareRepository implements ThirdPartyACLAwareR
string $role,
?string $filterString,
?array $orderBy = [],
?int $limit = null,
?int $offset = null
int $limit = null,
int $offset = null
): array {
$qb = $this->buildQuery($filterString);
foreach ($orderBy as $sort => $direction) {
$qb->addOrderBy('tp.' . $sort, $direction);
$qb->addOrderBy('tp.'.$sort, $direction);
}
$qb->setFirstResult($offset)

View File

@@ -17,9 +17,6 @@ use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query;
use Doctrine\ORM\QueryBuilder;
use Doctrine\Persistence\ObjectRepository;
use DomainException;
use function array_key_exists;
class ThirdPartyRepository implements ObjectRepository
{
@@ -32,7 +29,6 @@ class ThirdPartyRepository implements ObjectRepository
/**
* count amongst parties associated to $centers, with $terms parameters.
*
*/
public function countByMemberOfCenters(array $centers, array $terms = []): int
{
@@ -42,7 +38,7 @@ class ThirdPartyRepository implements ObjectRepository
return $qb->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);
}
@@ -66,7 +62,7 @@ class ThirdPartyRepository implements ObjectRepository
*
* @return array|ThirdParty[]
*/
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);
}
@@ -85,9 +81,9 @@ class ThirdPartyRepository implements ObjectRepository
* - is_active: is active = true / false
* - types: an array of types
*
* @param int $firstResult
* @param int $maxResults
* @param array $terms
* @param int $firstResult
* @param int $maxResults
* @param array $terms
* @param string[] $returnFormat a format for returning
*/
public function findByMemberOfCenters(array $centers, $firstResult = 0, $maxResults = 20, $terms = [], $returnFormat = ['entity']): array
@@ -117,7 +113,7 @@ class ThirdPartyRepository implements ObjectRepository
break;
default:
throw new DomainException('This return format is invalid');
throw new \DomainException('This return format is invalid');
}
$qb->setFirstResult($firstResult)
->setMaxResults($maxResults);
@@ -152,8 +148,8 @@ class ThirdPartyRepository implements ObjectRepository
$or = $qb->expr()->orX();
foreach ($centers as $center) {
$or->add($qb->expr()->isMemberOf(':center_' . $center->getId(), 'tp.centers'));
$qb->setParameter('center_' . $center->getId(), $center);
$or->add($qb->expr()->isMemberOf(':center_'.$center->getId(), 'tp.centers'));
$qb->setParameter('center_'.$center->getId(), $center);
}
$qb->where($or);
@@ -163,7 +159,7 @@ class ThirdPartyRepository implements ObjectRepository
private function setIsActiveCondition(QueryBuilder $qb, array $terms)
{
if (array_key_exists('is_active', $terms)) {
if (\array_key_exists('is_active', $terms)) {
$qb->andWhere(
$terms['is_active'] ? $qb->expr()->eq('tp.active', "'TRUE'") :
$qb->expr()->eq('tp.active', "'FALSE'")
@@ -177,25 +173,25 @@ class ThirdPartyRepository implements ObjectRepository
*/
private function setNameCondition(QueryBuilder $qb, array $terms)
{
if (array_key_exists('name', $terms) || array_key_exists('_default', $terms)) {
if (\array_key_exists('name', $terms) || \array_key_exists('_default', $terms)) {
$term = $terms['name'] ?? $terms['_default'];
if (null === $term || '' === $term) {
return;
}
$qb->andWhere($qb->expr()->like('UNACCENT(LOWER(tp.name))', 'UNACCENT(LOWER(:name))'));
$qb->setParameter('name', '%' . $term . '%');
$qb->setParameter('name', '%'.$term.'%');
}
}
private function setTypesCondition(QueryBuilder $qb, array $terms)
{
if (array_key_exists('types', $terms)) {
if (\array_key_exists('types', $terms)) {
$orx = $qb->expr()->orX();
foreach ($terms['types'] as $type) {
$orx->add('JSONB_EXISTS_IN_ARRAY(tp.type, :type_' . $type . ') = \'TRUE\'');
$qb->setParameter('type_' . $type, $type);
$orx->add('JSONB_EXISTS_IN_ARRAY(tp.type, :type_'.$type.') = \'TRUE\'');
$qb->setParameter('type_'.$type, $type);
}
$qb->andWhere($orx);
}