DX: apply rector rules up to php8.0

This commit is contained in:
2023-04-15 01:05:37 +02:00
parent d8870e906f
commit dde3002100
714 changed files with 2348 additions and 9263 deletions

View File

@@ -36,11 +36,8 @@ abstract class AbstractCRUDController extends AbstractController
/**
* get the role given from the config.
*
* @param mixed $entity
* @param mixed $_format
*/
protected function getRoleFor(string $action, Request $request, $entity, $_format): string
protected function getRoleFor(string $action, Request $request, mixed $entity, mixed $_format): string
{
$actionConfig = $this->getActionConfig($action);
@@ -135,7 +132,7 @@ abstract class AbstractCRUDController extends AbstractController
*
* @param mixed $_format
*/
protected function countEntities(string $action, Request $request, $_format): int
protected function countEntities(string $action, Request $request, mixed $_format): int
{
return $this->buildQueryEntities($action, $request)
->select('COUNT(e)')
@@ -171,10 +168,8 @@ abstract class AbstractCRUDController extends AbstractController
* get the instance of the entity with the given id.
*
* @throw Symfony\Component\HttpKernel\Exception\NotFoundHttpException if the object is not found
*
* @param mixed $action
*/
protected function getEntity($action, string $id, Request $request): object
protected function getEntity(mixed $action, string $id, Request $request): object
{
$e = $this
->getDoctrine()
@@ -205,10 +200,8 @@ abstract class AbstractCRUDController extends AbstractController
/**
* Get the result of the query.
*
* @param mixed $query
*/
protected function getQueryResult(string $action, Request $request, string $_format, int $totalItems, PaginatorInterface $paginator, $query)
protected function getQueryResult(string $action, Request $request, string $_format, int $totalItems, PaginatorInterface $paginator, mixed $query)
{
return $query->getQuery()->getResult();
}
@@ -220,41 +213,32 @@ abstract class AbstractCRUDController extends AbstractController
/**
* Called on post check ACL.
*
* @param mixed $entity
*/
protected function onPostCheckACL(string $action, Request $request, string $_format, $entity): ?Response
protected function onPostCheckACL(string $action, Request $request, string $_format, mixed $entity): ?Response
{
return null;
}
/**
* Called on post fetch entity.
*
* @param mixed $entity
* @param mixed $_format
*/
protected function onPostFetchEntity(string $action, Request $request, $entity, $_format): ?Response
protected function onPostFetchEntity(string $action, Request $request, mixed $entity, mixed $_format): ?Response
{
return null;
}
/**
* Method used by indexAction.
*
* @param mixed $query
*/
protected function onPostIndexBuildQuery(string $action, Request $request, string $_format, int $totalItems, PaginatorInterface $paginator, $query): ?Response
protected function onPostIndexBuildQuery(string $action, Request $request, string $_format, int $totalItems, PaginatorInterface $paginator, mixed $query): ?Response
{
return null;
}
/**
* Method used by indexAction.
*
* @param mixed $entities
*/
protected function onPostIndexFetchQuery(string $action, Request $request, string $_format, int $totalItems, PaginatorInterface $paginator, $entities): ?Response
protected function onPostIndexFetchQuery(string $action, Request $request, string $_format, int $totalItems, PaginatorInterface $paginator, mixed $entities): ?Response
{
return null;
}
@@ -274,11 +258,8 @@ abstract class AbstractCRUDController extends AbstractController
/**
* Add ordering fields in the query build by self::queryEntities.
*
* @param mixed $query
* @param mixed $_format
*/
protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator, $_format)
protected function orderQuery(string $action, mixed $query, Request $request, PaginatorInterface $paginator, mixed $_format)
{
return $query;
}

View File

@@ -32,31 +32,18 @@ class ApiController extends AbstractCRUDController
/**
* Base method for handling api action.
*
* @param mixed $id
* @param string $_format
*
* @return void
*/
public function entityApi(Request $request, $id, ?string $_format = 'json'): Response
public function entityApi(Request $request, mixed $id, ?string $_format = 'json'): Response
{
switch ($request->getMethod()) {
case Request::METHOD_GET:
case Request::METHOD_HEAD:
return $this->entityGet('_entity', $request, $id, $_format);
case Request::METHOD_PUT:
case Request::METHOD_PATCH:
return $this->entityPut('_entity', $request, $id, $_format);
case Request::METHOD_POST:
return $this->entityPostAction('_entity', $request, $id);
case Request::METHOD_DELETE:
return $this->entityDelete('_entity', $request, $id, $_format);
default:
throw new BadRequestHttpException('This method is not implemented');
}
return match ($request->getMethod()) {
Request::METHOD_GET, Request::METHOD_HEAD => $this->entityGet('_entity', $request, $id, $_format),
Request::METHOD_PUT, Request::METHOD_PATCH => $this->entityPut('_entity', $request, $id, $_format),
Request::METHOD_POST => $this->entityPostAction('_entity', $request, $id),
Request::METHOD_DELETE => $this->entityDelete('_entity', $request, $id, $_format),
default => throw new BadRequestHttpException('This method is not implemented'),
};
}
public function entityDelete($action, Request $request, $id, string $_format): Response
@@ -115,13 +102,10 @@ class ApiController extends AbstractCRUDController
public function entityPost(Request $request, $_format): Response
{
switch ($request->getMethod()) {
case Request::METHOD_POST:
return $this->entityPostAction('_entity', $request, $_format);
default:
throw new BadRequestHttpException('This method is not implemented');
}
return match ($request->getMethod()) {
Request::METHOD_POST => $this->entityPostAction('_entity', $request, $_format),
default => throw new BadRequestHttpException('This method is not implemented'),
};
}
public function entityPut($action, Request $request, $id, string $_format): Response
@@ -199,14 +183,10 @@ class ApiController extends AbstractCRUDController
*/
public function indexApi(Request $request, string $_format)
{
switch ($request->getMethod()) {
case Request::METHOD_GET:
case REQUEST::METHOD_HEAD:
return $this->indexApiAction('_index', $request, $_format);
default:
throw $this->createNotFoundException('This method is not supported');
}
return match ($request->getMethod()) {
Request::METHOD_GET, REQUEST::METHOD_HEAD => $this->indexApiAction('_index', $request, $_format),
default => throw $this->createNotFoundException('This method is not supported'),
};
}
public function onBeforeSerialize(string $action, Request $request, $_format, $entity): ?Response
@@ -242,7 +222,7 @@ class ApiController extends AbstractCRUDController
* @throw BadRequestException if unable to deserialize the posted data
* @throw BadRequestException if the method is not POST or DELETE
*/
protected function addRemoveSomething(string $action, $id, Request $request, string $_format, string $property, string $postedDataType, array $postedDataContext = [], bool $forcePersist = false): Response
protected function addRemoveSomething(string $action, mixed $id, Request $request, string $_format, string $property, string $postedDataType, array $postedDataContext = [], bool $forcePersist = false): Response
{
$entity = $this->getEntity($action, $id, $request);
@@ -277,23 +257,11 @@ class ApiController extends AbstractCRUDController
'data: %s', $e->getMessage()), $e, 0);
}
switch ($request->getMethod()) {
case Request::METHOD_DELETE:
// oups... how to use property accessor to remove element ?
/* @phpstan-ignore-next-line as we do not find a simpler way to do this */
$entity->{'remove' . ucfirst($property)}($postedData);
break;
case Request::METHOD_POST:
/* @phpstan-ignore-next-line as we do not find a simpler way to do this */
$entity->{'add' . ucfirst($property)}($postedData);
break;
default:
throw new BadRequestHttpException('this method is not supported');
}
match ($request->getMethod()) {
Request::METHOD_DELETE => $entity->{'remove' . ucfirst($property)}($postedData),
Request::METHOD_POST => $entity->{'add' . ucfirst($property)}($postedData),
default => throw new BadRequestHttpException('this method is not supported'),
};
$errors = $this->validate($action, $request, $_format, $entity, [$postedData]);
@@ -319,21 +287,16 @@ class ApiController extends AbstractCRUDController
if ($response instanceof Response) {
return $response;
}
switch ($request->getMethod()) {
case Request::METHOD_DELETE:
return $this->json('', Response::HTTP_OK);
case Request::METHOD_POST:
return $this->json(
$postedData,
Response::HTTP_OK,
[],
$this->getContextForSerializationPostAlter($action, $request, $_format, $entity, [$postedData])
);
}
throw new Exception('Unable to handle such request method.');
return match ($request->getMethod()) {
Request::METHOD_DELETE => $this->json('', Response::HTTP_OK),
Request::METHOD_POST => $this->json(
$postedData,
Response::HTTP_OK,
[],
$this->getContextForSerializationPostAlter($action, $request, $_format, $entity, [$postedData])
),
default => throw new Exception('Unable to handle such request method.'),
};
}
/**
@@ -376,7 +339,7 @@ class ApiController extends AbstractCRUDController
* @param mixed $id
* @param mixed $_format
*/
protected function entityGet(string $action, Request $request, $id, $_format = 'html'): Response
protected function entityGet(string $action, Request $request, mixed $id, mixed $_format = 'html'): Response
{
$entity = $this->getEntity($action, $id, $request);
@@ -474,18 +437,11 @@ class ApiController extends AbstractCRUDController
protected function getContextForSerialization(string $action, Request $request, string $_format, $entity): array
{
switch ($request->getMethod()) {
case Request::METHOD_GET:
return ['groups' => ['read']];
case Request::METHOD_PUT:
case Request::METHOD_PATCH:
case Request::METHOD_POST:
return ['groups' => ['write']];
default:
throw new LogicException('get context for serialization is not implemented for this method');
}
return match ($request->getMethod()) {
Request::METHOD_GET => ['groups' => ['read']],
Request::METHOD_PUT, Request::METHOD_PATCH, Request::METHOD_POST => ['groups' => ['write']],
default => throw new LogicException('get context for serialization is not implemented for this method'),
};
}
/**
@@ -496,7 +452,7 @@ class ApiController extends AbstractCRUDController
*
* @param mixed $entity
*/
protected function getContextForSerializationPostAlter(string $action, Request $request, string $_format, $entity, array $more = []): array
protected function getContextForSerializationPostAlter(string $action, Request $request, string $_format, mixed $entity, array $more = []): array
{
return ['groups' => ['read']];
}
@@ -533,7 +489,7 @@ class ApiController extends AbstractCRUDController
* @param string $action
* @param mixed $_format
*/
protected function indexApiAction($action, Request $request, $_format)
protected function indexApiAction($action, Request $request, mixed $_format)
{
$this->onPreIndex($action, $request, $_format);
@@ -611,10 +567,8 @@ class ApiController extends AbstractCRUDController
/**
* Serialize collections.
*
* @param mixed $entities
*/
protected function serializeCollection(string $action, Request $request, string $_format, PaginatorInterface $paginator, $entities): Response
protected function serializeCollection(string $action, Request $request, string $_format, PaginatorInterface $paginator, mixed $entities): Response
{
$model = new Collection($entities, $paginator);

View File

@@ -62,17 +62,15 @@ class CRUDController extends AbstractController
*
* @param mixed $id
*/
public function edit(Request $request, $id): Response
public function edit(Request $request, mixed $id): Response
{
return $this->formEditAction('edit', $request, $id);
}
/**
* Get the context for the serialization.
*
* @param mixed $entity
*/
public function getContextForSerialization(string $action, Request $request, $entity, string $_format): array
public function getContextForSerialization(string $action, Request $request, mixed $entity, string $_format): array
{
return [];
}
@@ -125,7 +123,7 @@ class CRUDController extends AbstractController
*
* @param mixed $id
*/
public function view(Request $request, $id): Response
public function view(Request $request, mixed $id): Response
{
return $this->viewAction('view', $request, $id);
}
@@ -188,7 +186,7 @@ class CRUDController extends AbstractController
*
* @throws \Symfony\Component\Security\Core\Exception\AccessDeniedHttpException
*/
protected function checkACL(string $action, $entity)
protected function checkACL(string $action, mixed $entity)
{
$this->denyAccessUnlessGranted($this->getRoleFor($action), $entity);
}
@@ -228,7 +226,7 @@ class CRUDController extends AbstractController
* @param mixed $entity
* @param string $formClass
*/
protected function createFormFor(string $action, $entity, ?string $formClass = null, array $formOptions = []): FormInterface
protected function createFormFor(string $action, mixed $entity, ?string $formClass = null, array $formOptions = []): FormInterface
{
$formClass ??= $this->getFormClassFor($action);
@@ -491,7 +489,7 @@ class CRUDController extends AbstractController
*
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
*/
protected function formEditAction(string $action, Request $request, $id, ?string $formClass = null, array $formOptions = []): Response
protected function formEditAction(string $action, Request $request, mixed $id, ?string $formClass = null, array $formOptions = []): Response
{
$entity = $this->getEntity($action, $id, $request);
@@ -572,29 +570,15 @@ class CRUDController extends AbstractController
* Generate a success message when a form could be flushed successfully.
*
* @param string $action
* @param mixed $entity
*/
protected function generateFormSuccessMessage($action, $entity): string
protected function generateFormSuccessMessage($action, mixed $entity): string
{
switch ($action) {
case 'edit':
$msg = 'crud.edit.success';
break;
case 'new':
$msg = 'crud.new.success';
break;
case 'delete':
$msg = 'crud.delete.success';
break;
default:
$msg = 'crud.default.success';
}
$msg = match ($action) {
'edit' => 'crud.edit.success',
'new' => 'crud.new.success',
'delete' => 'crud.delete.success',
default => 'crud.default.success',
};
return $this->getTranslator()->trans($msg);
}
@@ -652,11 +636,10 @@ class CRUDController extends AbstractController
* get the instance of the entity with the given id.
*
* @param string $id
* @param mixed $action
*
* @return object
*/
protected function getEntity($action, $id, Request $request): ?object
protected function getEntity(mixed $action, $id, Request $request): ?object
{
return $this->getDoctrine()
->getRepository($this->getEntityClass())
@@ -763,33 +746,22 @@ class CRUDController extends AbstractController
*
* @return string the path to the template
*/
protected function getTemplateFor($action, $entity, Request $request)
protected function getTemplateFor($action, mixed $entity, Request $request)
{
if ($this->hasCustomTemplate($action, $entity, $request)) {
return $this->getActionConfig($action)['template'];
}
switch ($action) {
case 'new':
return '@ChillMain/CRUD/new.html.twig';
case 'edit':
return '@ChillMain/CRUD/edit.html.twig';
case 'index':
return '@ChillMain/CRUD/index.html.twig';
case 'view':
return '@ChillMain/CRUD/view.html.twig';
case 'delete':
return '@ChillMain/CRUD/delete.html.twig';
default:
throw new LogicException("the view for action {$action} is not "
. 'defined. You should override ' . __METHOD__ . ' to add this '
. 'action');
}
return match ($action) {
'new' => '@ChillMain/CRUD/new.html.twig',
'edit' => '@ChillMain/CRUD/edit.html.twig',
'index' => '@ChillMain/CRUD/index.html.twig',
'view' => '@ChillMain/CRUD/view.html.twig',
'delete' => '@ChillMain/CRUD/delete.html.twig',
default => throw new LogicException("the view for action {$action} is not "
. 'defined. You should override ' . __METHOD__ . ' to add this '
. 'action'),
};
}
protected function getTranslator(): TranslatorInterface
@@ -909,22 +881,17 @@ class CRUDController extends AbstractController
*
* @return \Symfony\Component\HttpFoundation\RedirectResponse
*/
protected function onBeforeRedirectAfterSubmission(string $action, $entity, FormInterface $form, Request $request)
protected function onBeforeRedirectAfterSubmission(string $action, mixed $entity, FormInterface $form, Request $request)
{
$next = $request->request->get('submit', 'save-and-close');
switch ($next) {
case 'save-and-close':
return $this->redirectToRoute('chill_crud_' . $this->getCrudName() . '_index');
case 'save-and-new':
return $this->redirectToRoute('chill_crud_' . $this->getCrudName() . '_new', $request->query->all());
default:
return $this->redirectToRoute('chill_crud_' . $this->getCrudName() . '_view', [
'id' => $entity->getId(),
]);
}
return match ($next) {
'save-and-close' => $this->redirectToRoute('chill_crud_' . $this->getCrudName() . '_index'),
'save-and-new' => $this->redirectToRoute('chill_crud_' . $this->getCrudName() . '_new', $request->query->all()),
default => $this->redirectToRoute('chill_crud_' . $this->getCrudName() . '_view', [
'id' => $entity->getId(),
]),
};
}
protected function onFormValid(string $action, object $entity, FormInterface $form, Request $request)
@@ -958,19 +925,15 @@ class CRUDController extends AbstractController
/**
* method used by indexAction.
*
* @param mixed $query
*/
protected function onPostIndexBuildQuery(string $action, Request $request, int $totalItems, PaginatorInterface $paginator, $query)
protected function onPostIndexBuildQuery(string $action, Request $request, int $totalItems, PaginatorInterface $paginator, mixed $query)
{
}
/**
* method used by indexAction.
*
* @param mixed $entities
*/
protected function onPostIndexFetchQuery(string $action, Request $request, int $totalItems, PaginatorInterface $paginator, $entities)
protected function onPostIndexFetchQuery(string $action, Request $request, int $totalItems, PaginatorInterface $paginator, mixed $entities)
{
}
@@ -1091,7 +1054,7 @@ class CRUDController extends AbstractController
* @param mixed $id
* @param mixed $_format
*/
protected function viewAction(string $action, Request $request, $id, $_format = 'html'): Response
protected function viewAction(string $action, Request $request, mixed $id, mixed $_format = 'html'): Response
{
$entity = $this->getEntity($action, $id, $request);

View File

@@ -36,17 +36,10 @@ class CRUDRoutesLoader extends Loader
Request::METHOD_DELETE,
];
protected array $apiCrudConfig = [];
protected array $crudConfig = [];
private bool $isLoaded = false;
public function __construct(array $crudConfig, array $apiCrudConfig)
public function __construct(protected array $crudConfig, protected array $apiCrudConfig)
{
$this->crudConfig = $crudConfig;
$this->apiCrudConfig = $apiCrudConfig;
parent::__construct();
}
@@ -104,23 +97,11 @@ class CRUDRoutesLoader extends Loader
// continue;
}
// compute default action
switch ($name) {
case '_entity':
$controllerAction = 'entityApi';
break;
case '_index':
$controllerAction = 'indexApi';
break;
default:
$controllerAction = $name . 'Api';
break;
}
$controllerAction = match ($name) {
'_entity' => 'entityApi',
'_index' => 'indexApi',
default => $name . 'Api',
};
$defaults = [
'_controller' => $controller . ':' . ($action['controller_action'] ?? $controllerAction),

View File

@@ -53,39 +53,23 @@ class ChillImportUsersCommand extends Command
protected bool $doChanges = true;
protected EntityManagerInterface $em;
protected array $groupCenters;
protected LoggerInterface $logger;
protected Writer $output;
protected UserPasswordEncoderInterface $passwordEncoder;
protected array $permissionGroups;
protected InputInterface $tempInput;
protected OutputInterface $tempOutput;
protected UserRepository $userRepository;
protected ValidatorInterface $validator;
public function __construct(
EntityManagerInterface $em,
LoggerInterface $logger,
UserPasswordEncoderInterface $passwordEncoder,
ValidatorInterface $validator,
UserRepository $userRepository
protected EntityManagerInterface $em,
protected LoggerInterface $logger,
protected UserPasswordEncoderInterface $passwordEncoder,
protected ValidatorInterface $validator,
protected UserRepository $userRepository
) {
$this->em = $em;
$this->passwordEncoder = $passwordEncoder;
$this->validator = $validator;
$this->logger = $logger;
$this->userRepository = $userRepository;
parent::__construct('chill:main:import-users');
}

View File

@@ -162,7 +162,7 @@ class ChillUserSendRenewPasswordCodeCommand extends Command
if (array_key_exists('email', $row)) {
return $userRepository->findOneByUsernameOrEmail(trim($row['email']));
}
} catch (\Doctrine\ORM\NoResultException $e) {
} catch (\Doctrine\ORM\NoResultException) {
// continue, we will try username
}
@@ -170,7 +170,7 @@ class ChillUserSendRenewPasswordCodeCommand extends Command
if (array_key_exists('username', $row)) {
return $userRepository->findOneByUsernameOrEmail(trim($row['username']));
}
} catch (\Doctrine\ORM\NoResultException $e) {
} catch (\Doctrine\ORM\NoResultException) {
return null;
}
}

View File

@@ -19,14 +19,10 @@ use Symfony\Component\Console\Output\OutputInterface;
class ExecuteCronJobCommand extends Command
{
private CronManagerInterface $cronManager;
public function __construct(
CronManagerInterface $cronManager
private CronManagerInterface $cronManager
) {
parent::__construct('chill:cron-job:execute');
$this->cronManager = $cronManager;
}
protected function configure()

View File

@@ -20,17 +20,11 @@ use Symfony\Component\Console\Output\OutputInterface;
class LoadAddressesBEFromBestAddressCommand extends Command
{
private AddressReferenceBEFromBestAddress $addressImporter;
private PostalCodeBEFromBestAddress $postalCodeBEFromBestAddressImporter;
public function __construct(
AddressReferenceBEFromBestAddress $addressImporter,
PostalCodeBEFromBestAddress $postalCodeBEFromBestAddressImporter
private AddressReferenceBEFromBestAddress $addressImporter,
private PostalCodeBEFromBestAddress $postalCodeBEFromBestAddressImporter
) {
parent::__construct();
$this->addressImporter = $addressImporter;
$this->postalCodeBEFromBestAddressImporter = $postalCodeBEFromBestAddressImporter;
}
protected function configure()

View File

@@ -19,12 +19,9 @@ use Symfony\Component\Console\Output\OutputInterface;
class LoadAddressesFRFromBANOCommand extends Command
{
private AddressReferenceFromBano $addressReferenceFromBano;
public function __construct(AddressReferenceFromBano $addressReferenceFromBano)
public function __construct(private AddressReferenceFromBano $addressReferenceFromBano)
{
parent::__construct();
$this->addressReferenceFromBano = $addressReferenceFromBano;
}
protected function configure()

View File

@@ -34,13 +34,6 @@ class LoadAndUpdateLanguagesCommand extends Command
private $ancientToExclude = ['ang', 'egy', 'fro', 'goh', 'grc', 'la', 'non', 'peo', 'pro', 'sga',
'dum', 'enm', 'frm', 'gmh', 'mga', 'akk', 'phn', 'zxx', 'got', 'und', ];
private $availableLanguages;
/**
* @var EntityManager
*/
private $entityManager;
// The regional version of language are language with _ in the code
// This array contains regional code to not exclude
private $regionalVersionToInclude = ['ro_MD'];
@@ -50,10 +43,8 @@ class LoadAndUpdateLanguagesCommand extends Command
*
* @param $availableLanguages
*/
public function __construct(EntityManager $entityManager, $availableLanguages)
public function __construct(private EntityManager $entityManager, private $availableLanguages)
{
$this->entityManager = $entityManager;
$this->availableLanguages = $availableLanguages;
parent::__construct();
}

View File

@@ -20,22 +20,13 @@ use Symfony\Component\Intl\Intl;
class LoadCountriesCommand extends Command
{
private $availableLanguages;
/**
* @var EntityManager
*/
private $entityManager;
/**
* LoadCountriesCommand constructor.
*
* @param $availableLanguages
*/
public function __construct(EntityManager $entityManager, $availableLanguages)
public function __construct(private EntityManager $entityManager, private $availableLanguages)
{
$this->entityManager = $entityManager;
$this->availableLanguages = $availableLanguages;
parent::__construct();
}

View File

@@ -18,12 +18,8 @@ use Symfony\Component\Console\Output\OutputInterface;
class LoadPostalCodeFR extends Command
{
private PostalCodeFRFromOpenData $loader;
public function __construct(PostalCodeFRFromOpenData $loader)
public function __construct(private PostalCodeFRFromOpenData $loader)
{
$this->loader = $loader;
parent::__construct();
}

View File

@@ -30,14 +30,8 @@ use function strlen;
class LoadPostalCodesCommand extends Command
{
private EntityManagerInterface $entityManager;
private ValidatorInterface $validator;
public function __construct(EntityManagerInterface $entityManager, ValidatorInterface $validator)
public function __construct(private EntityManagerInterface $entityManager, private ValidatorInterface $validator)
{
$this->entityManager = $entityManager;
$this->validator = $validator;
parent::__construct();
}

View File

@@ -26,17 +26,11 @@ use Symfony\Component\Security\Core\Encoder\MessageDigestPasswordEncoder;
*/
class SetPasswordCommand extends Command
{
/**
* @var EntityManager
*/
private $entityManager;
/**
* SetPasswordCommand constructor.
*/
public function __construct(EntityManager $entityManager)
public function __construct(private EntityManager $entityManager)
{
$this->entityManager = $entityManager;
parent::__construct();
}

View File

@@ -28,14 +28,8 @@ use function trim;
final class AddressReferenceAPIController extends ApiController
{
private AddressReferenceRepository $addressReferenceRepository;
private PaginatorFactory $paginatorFactory;
public function __construct(AddressReferenceRepository $addressReferenceRepository, PaginatorFactory $paginatorFactory)
public function __construct(private AddressReferenceRepository $addressReferenceRepository, private PaginatorFactory $paginatorFactory)
{
$this->addressReferenceRepository = $addressReferenceRepository;
$this->paginatorFactory = $paginatorFactory;
}
/**

View File

@@ -23,20 +23,8 @@ use Symfony\Component\Serializer\SerializerInterface;
class AddressToReferenceMatcherController
{
private Security $security;
private EntityManagerInterface $entityManager;
private SerializerInterface $serializer;
public function __construct(
Security $security,
EntityManagerInterface $entityManager,
SerializerInterface $serializer
) {
$this->security = $security;
$this->entityManager = $entityManager;
$this->serializer = $serializer;
public function __construct(private Security $security, private EntityManagerInterface $entityManager, private SerializerInterface $serializer)
{
}
/**

View File

@@ -47,10 +47,8 @@ class CenterController extends AbstractController
/**
* Displays a form to edit an existing Center entity.
*
* @param mixed $id
*/
public function editAction($id)
public function editAction(mixed $id)
{
$em = $this->getDoctrine()->getManager();
@@ -98,10 +96,8 @@ class CenterController extends AbstractController
/**
* Finds and displays a Center entity.
*
* @param mixed $id
*/
public function showAction($id)
public function showAction(mixed $id)
{
$em = $this->getDoctrine()->getManager();
@@ -118,10 +114,8 @@ class CenterController extends AbstractController
/**
* Edits an existing Center entity.
*
* @param mixed $id
*/
public function updateAction(Request $request, $id)
public function updateAction(Request $request, mixed $id)
{
$em = $this->getDoctrine()->getManager();

View File

@@ -47,54 +47,8 @@ use function unserialize;
*/
class ExportController extends AbstractController
{
private EntityManagerInterface $entityManager;
/**
* @var ExportManager
*/
private $exportManager;
/**
* @var FormFactoryInterface
*/
private $formFactory;
/**
* @var LoggerInterface
*/
private $logger;
/**
* @var ChillRedis
*/
private $redis;
/**
* @var SessionInterface
*/
private $session;
/**
* @var TranslatorInterface
*/
private $translator;
public function __construct(
ChillRedis $chillRedis,
ExportManager $exportManager,
FormFactoryInterface $formFactory,
LoggerInterface $logger,
SessionInterface $session,
TranslatorInterface $translator,
EntityManagerInterface $entityManager
) {
$this->entityManager = $entityManager;
$this->redis = $chillRedis;
$this->exportManager = $exportManager;
$this->formFactory = $formFactory;
$this->logger = $logger;
$this->session = $session;
$this->translator = $translator;
public function __construct(private ChillRedis $redis, private ExportManager $exportManager, private FormFactoryInterface $formFactory, private LoggerInterface $logger, private SessionInterface $session, private TranslatorInterface $translator, private EntityManagerInterface $entityManager)
{
}
public function downloadResultAction(Request $request, $alias)
@@ -221,22 +175,13 @@ class ExportController extends AbstractController
$step = $request->query->getAlpha('step', 'centers');
switch ($step) {
case 'centers':
return $this->selectCentersStep($request, $export, $alias);
case 'export':
return $this->exportFormStep($request, $export, $alias);
case 'formatter':
return $this->formatterFormStep($request, $export, $alias);
case 'generate':
return $this->forwardToGenerate($request, $export, $alias);
default:
throw $this->createNotFoundException("The given step '{$step}' is invalid");
}
return match ($step) {
'centers' => $this->selectCentersStep($request, $export, $alias),
'export' => $this->exportFormStep($request, $export, $alias),
'formatter' => $this->formatterFormStep($request, $export, $alias),
'generate' => $this->forwardToGenerate($request, $export, $alias),
default => throw $this->createNotFoundException("The given step '{$step}' is invalid"),
};
}
/**
@@ -284,13 +229,12 @@ class ExportController extends AbstractController
*
* @param string $alias
* @param array $data the data from previous step. Required for steps 'formatter' and 'generate_formatter'
* @param mixed $step
*/
protected function createCreateFormExport($alias, $step, $data = []): FormInterface
protected function createCreateFormExport($alias, mixed $step, $data = []): FormInterface
{
/** @var \Chill\MainBundle\Export\ExportManager $exportManager */
$exportManager = $this->exportManager;
$isGenerate = strpos($step, 'generate_') === 0;
$isGenerate = str_starts_with($step, 'generate_');
$builder = $this->formFactory
->createNamedBuilder(null, FormType::class, [], [
@@ -341,7 +285,7 @@ class ExportController extends AbstractController
*
* @return \Symfony\Component\HttpFoundation\Response
*/
protected function exportFormStep(Request $request, $export, $alias)
protected function exportFormStep(Request $request, \Chill\MainBundle\Export\DirectExportInterface|\Chill\MainBundle\Export\ExportInterface $export, $alias)
{
$exportManager = $this->exportManager;
@@ -405,7 +349,7 @@ class ExportController extends AbstractController
*
* @return \Symfony\Component\HttpFoundation\Response
*/
protected function formatterFormStep(Request $request, $export, $alias)
protected function formatterFormStep(Request $request, \Chill\MainBundle\Export\DirectExportInterface|\Chill\MainBundle\Export\ExportInterface $export, $alias)
{
// check we have data from the previous step (export step)
$data = $this->session->get('export_step', null);
@@ -462,7 +406,7 @@ class ExportController extends AbstractController
*
* @return \Symfony\Component\HttpFoundation\RedirectResponse
*/
protected function forwardToGenerate(Request $request, $export, $alias)
protected function forwardToGenerate(Request $request, \Chill\MainBundle\Export\DirectExportInterface|\Chill\MainBundle\Export\ExportInterface $export, $alias)
{
$dataCenters = $this->session->get('centers_step_raw', null);
$dataFormatter = $this->session->get('formatter_step_raw', null);
@@ -522,12 +466,10 @@ class ExportController extends AbstractController
}
/**
* @param \Chill\MainBundle\Export\DirectExportInterface|\Chill\MainBundle\Export\ExportInterface $export
* @param string $alias
*
* @return Response
*/
protected function selectCentersStep(Request $request, $export, $alias)
protected function selectCentersStep(Request $request, \Chill\MainBundle\Export\DirectExportInterface|\Chill\MainBundle\Export\ExportInterface $export, $alias)
{
/** @var \Chill\MainBundle\Export\ExportManager $exportManager */
$exportManager = $this->exportManager;
@@ -608,7 +550,7 @@ class ExportController extends AbstractController
*
* @return string the next/current step
*/
private function getNextStep($step, $export, $reverse = false)
private function getNextStep($step, \Chill\MainBundle\Export\DirectExportInterface|\Chill\MainBundle\Export\ExportInterface $export, $reverse = false)
{
switch ($step) {
case 'centers':

View File

@@ -24,30 +24,8 @@ use Symfony\Component\Serializer\SerializerInterface;
class GeographicalUnitByAddressApiController
{
private PaginatorFactory $paginatorFactory;
private GeographicalUnitRepositoryInterface $geographicalUnitRepository;
private Security $security;
private SerializerInterface $serializer;
/**
* @param PaginatorFactory $paginatorFactory
* @param GeographicalUnitRepositoryInterface $geographicalUnitRepository
* @param Security $security
* @param SerializerInterface $serializer
*/
public function __construct(
PaginatorFactory $paginatorFactory,
GeographicalUnitRepositoryInterface $geographicalUnitRepository,
Security $security,
SerializerInterface $serializer
) {
$this->paginatorFactory = $paginatorFactory;
$this->geographicalUnitRepository = $geographicalUnitRepository;
$this->security = $security;
$this->serializer = $serializer;
public function __construct(private PaginatorFactory $paginatorFactory, private GeographicalUnitRepositoryInterface $geographicalUnitRepository, private Security $security, private SerializerInterface $serializer)
{
}
/**

View File

@@ -33,28 +33,8 @@ use UnexpectedValueException;
*/
class NotificationApiController
{
private EntityManagerInterface $entityManager;
private NotificationRepository $notificationRepository;
private PaginatorFactory $paginatorFactory;
private Security $security;
private SerializerInterface $serializer;
public function __construct(
EntityManagerInterface $entityManager,
NotificationRepository $notificationRepository,
PaginatorFactory $paginatorFactory,
Security $security,
SerializerInterface $serializer
) {
$this->entityManager = $entityManager;
$this->notificationRepository = $notificationRepository;
$this->paginatorFactory = $paginatorFactory;
$this->security = $security;
$this->serializer = $serializer;
public function __construct(private EntityManagerInterface $entityManager, private NotificationRepository $notificationRepository, private PaginatorFactory $paginatorFactory, private Security $security, private SerializerInterface $serializer)
{
}
/**
@@ -116,20 +96,11 @@ class NotificationApiController
throw new RuntimeException('not possible to mark as read by this user');
}
switch ($target) {
case 'read':
$notification->markAsReadBy($user);
break;
case 'unread':
$notification->markAsUnreadBy($user);
break;
default:
throw new UnexpectedValueException("target not supported: {$target}");
}
match ($target) {
'read' => $notification->markAsReadBy($user),
'unread' => $notification->markAsUnreadBy($user),
default => throw new UnexpectedValueException("target not supported: {$target}"),
};
$this->entityManager->flush();

View File

@@ -41,44 +41,8 @@ use function in_array;
*/
class NotificationController extends AbstractController
{
private LoggerInterface $chillLogger;
private EntityManagerInterface $em;
private LoggerInterface $logger;
private NotificationHandlerManager $notificationHandlerManager;
private NotificationRepository $notificationRepository;
private PaginatorFactory $paginatorFactory;
private Security $security;
private TranslatorInterface $translator;
private UserRepository $userRepository;
public function __construct(
EntityManagerInterface $em,
LoggerInterface $chillLogger,
LoggerInterface $logger,
Security $security,
NotificationRepository $notificationRepository,
NotificationHandlerManager $notificationHandlerManager,
PaginatorFactory $paginatorFactory,
TranslatorInterface $translator,
UserRepository $userRepository
) {
$this->em = $em;
$this->logger = $logger;
$this->chillLogger = $chillLogger;
$this->security = $security;
$this->notificationRepository = $notificationRepository;
$this->notificationHandlerManager = $notificationHandlerManager;
$this->paginatorFactory = $paginatorFactory;
$this->translator = $translator;
$this->userRepository = $userRepository;
public function __construct(private EntityManagerInterface $em, private LoggerInterface $chillLogger, private LoggerInterface $logger, private Security $security, private NotificationRepository $notificationRepository, private NotificationHandlerManager $notificationHandlerManager, private PaginatorFactory $paginatorFactory, private TranslatorInterface $translator, private UserRepository $userRepository)
{
}
/**
@@ -117,7 +81,7 @@ class NotificationController extends AbstractController
try {
$handler = $this->notificationHandlerManager->getHandler($notification);
} catch (NotificationHandlerNotFound $e) {
} catch (NotificationHandlerNotFound) {
throw new BadRequestHttpException('no handler for this notification');
}

View File

@@ -96,7 +96,7 @@ class PasswordController extends AbstractController
/**
* @return Response|\Symfony\Component\HttpFoundation\RedirectResponse
*/
public function recoverAction(Request $request)
public function recoverAction(Request $request): \Symfony\Component\HttpFoundation\Response|\Symfony\Component\HttpFoundation\RedirectResponse
{
if (false === $this->isGranted(PasswordRecoverVoter::ASK_TOKEN)) {
return new Response($this->translator->trans('You are not allowed '
@@ -164,7 +164,7 @@ class PasswordController extends AbstractController
*
* @return Response|\Symfony\Component\HttpFoundation\RedirectResponse
*/
public function requestRecoverAction(Request $request)
public function requestRecoverAction(Request $request): \Symfony\Component\HttpFoundation\Response|\Symfony\Component\HttpFoundation\RedirectResponse
{
if (false === $this->isGranted(PasswordRecoverVoter::ASK_TOKEN)) {
return new Response($this->translator->trans('You are not allowed '

View File

@@ -24,16 +24,8 @@ use function json_decode;
class PermissionApiController extends AbstractController
{
private DenormalizerInterface $denormalizer;
private Security $security;
public function __construct(
DenormalizerInterface $denormalizer,
Security $security
) {
$this->denormalizer = $denormalizer;
$this->security = $security;
public function __construct(private DenormalizerInterface $denormalizer, private Security $security)
{
}
/**

View File

@@ -34,46 +34,11 @@ use function array_key_exists;
*/
class PermissionsGroupController extends AbstractController
{
/**
* @var RoleHierarchy
*/
private $roleHierarchy;
/**
* @var RoleProvider
*/
private $roleProvider;
/**
* @var TranslatableStringHelper
*/
private $translatableStringHelper;
/**
* @var TranslatorInterface
*/
private $translator;
/**
* @var ValidatorInterface
*/
private $validator;
/**
* PermissionsGroupController constructor.
*/
public function __construct(
TranslatableStringHelper $translatableStringHelper,
RoleProvider $roleProvider,
RoleHierarchy $roleHierarchy,
TranslatorInterface $translator,
ValidatorInterface $validator
) {
$this->translatableStringHelper = $translatableStringHelper;
$this->roleProvider = $roleProvider;
$this->roleHierarchy = $roleHierarchy;
$this->translator = $translator;
$this->validator = $validator;
public function __construct(private TranslatableStringHelper $translatableStringHelper, private RoleProvider $roleProvider, private RoleHierarchy $roleHierarchy, private TranslatorInterface $translator, private ValidatorInterface $validator)
{
}
/**
@@ -214,7 +179,7 @@ class PermissionsGroupController extends AbstractController
try {
$permissionsGroup->removeRoleScope($roleScope);
} catch (RuntimeException $ex) {
} catch (RuntimeException) {
$this->addFlash(
'notice',
$this->translator->trans("The role '%role%' and circle "
@@ -260,10 +225,8 @@ class PermissionsGroupController extends AbstractController
/**
* Displays a form to edit an existing PermissionsGroup entity.
*
* @param mixed $id
*/
public function editAction($id)
public function editAction(mixed $id)
{
$em = $this->getDoctrine()->getManager();
@@ -338,10 +301,8 @@ class PermissionsGroupController extends AbstractController
/**
* Finds and displays a PermissionsGroup entity.
*
* @param mixed $id
*/
public function showAction($id)
public function showAction(mixed $id)
{
$em = $this->getDoctrine()->getManager();
@@ -393,10 +354,8 @@ class PermissionsGroupController extends AbstractController
/**
* Edits an existing PermissionsGroup entity.
*
* @param mixed $id
*/
public function updateAction(Request $request, $id)
public function updateAction(Request $request, mixed $id)
{
$em = $this->getDoctrine()->getManager();

View File

@@ -26,20 +26,8 @@ use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
final class PostalCodeAPIController extends ApiController
{
private CountryRepository $countryRepository;
private PaginatorFactory $paginatorFactory;
private PostalCodeRepositoryInterface $postalCodeRepository;
public function __construct(
CountryRepository $countryRepository,
PostalCodeRepositoryInterface $postalCodeRepository,
PaginatorFactory $paginatorFactory
) {
$this->countryRepository = $countryRepository;
$this->postalCodeRepository = $postalCodeRepository;
$this->paginatorFactory = $paginatorFactory;
public function __construct(private CountryRepository $countryRepository, private PostalCodeRepositoryInterface $postalCodeRepository, private PaginatorFactory $paginatorFactory)
{
}
/**

View File

@@ -36,44 +36,8 @@ use function count;
class SavedExportController
{
private EntityManagerInterface $entityManager;
private ExportManager $exportManager;
private FormFactoryInterface $formFactory;
private SavedExportRepositoryInterface $savedExportRepository;
private Security $security;
private SessionInterface $session;
private EngineInterface $templating;
private TranslatorInterface $translator;
private UrlGeneratorInterface $urlGenerator;
public function __construct(
EngineInterface $templating,
EntityManagerInterface $entityManager,
ExportManager $exportManager,
FormFactoryInterface $formBuilder,
SavedExportRepositoryInterface $savedExportRepository,
Security $security,
SessionInterface $session,
TranslatorInterface $translator,
UrlGeneratorInterface $urlGenerator
) {
$this->exportManager = $exportManager;
$this->entityManager = $entityManager;
$this->formFactory = $formBuilder;
$this->savedExportRepository = $savedExportRepository;
$this->security = $security;
$this->session = $session;
$this->templating = $templating;
$this->translator = $translator;
$this->urlGenerator = $urlGenerator;
public function __construct(private EngineInterface $templating, private EntityManagerInterface $entityManager, private ExportManager $exportManager, private FormFactoryInterface $formFactory, private SavedExportRepositoryInterface $savedExportRepository, private Security $security, private SessionInterface $session, private TranslatorInterface $translator, private UrlGeneratorInterface $urlGenerator)
{
}
/**

View File

@@ -47,10 +47,8 @@ class ScopeController extends AbstractController
/**
* Displays a form to edit an existing Scope entity.
*
* @param mixed $id
*/
public function editAction($id)
public function editAction(mixed $id)
{
$em = $this->getDoctrine()->getManager();
@@ -98,10 +96,8 @@ class ScopeController extends AbstractController
/**
* Finds and displays a Scope entity.
*
* @param mixed $id
*/
public function showAction($id)
public function showAction(mixed $id)
{
$em = $this->getDoctrine()->getManager();
@@ -118,10 +114,8 @@ class ScopeController extends AbstractController
/**
* Edits an existing Scope entity.
*
* @param mixed $id
*/
public function updateAction(Request $request, $id)
public function updateAction(Request $request, mixed $id)
{
$em = $this->getDoctrine()->getManager();

View File

@@ -36,24 +36,8 @@ use function reset;
*/
class SearchController extends AbstractController
{
protected PaginatorFactory $paginatorFactory;
protected SearchApi $searchApi;
protected SearchProvider $searchProvider;
protected TranslatorInterface $translator;
public function __construct(
SearchProvider $searchProvider,
TranslatorInterface $translator,
PaginatorFactory $paginatorFactory,
SearchApi $searchApi
) {
$this->searchProvider = $searchProvider;
$this->translator = $translator;
$this->paginatorFactory = $paginatorFactory;
$this->searchApi = $searchApi;
public function __construct(protected SearchProvider $searchProvider, protected TranslatorInterface $translator, protected PaginatorFactory $paginatorFactory, protected SearchApi $searchApi)
{
}
public function advancedSearchAction($name, Request $request)
@@ -64,7 +48,7 @@ class SearchController extends AbstractController
/** @var Chill\MainBundle\Search\HasAdvancedSearchFormInterface $variable */
$search = $this->searchProvider
->getHasAdvancedFormByName($name);
} catch (\Chill\MainBundle\Search\UnknowSearchNameException $e) {
} catch (\Chill\MainBundle\Search\UnknowSearchNameException) {
throw $this->createNotFoundException('no advanced search for '
. "{$name}");
}

View File

@@ -22,20 +22,8 @@ use function count;
class TimelineCenterController extends AbstractController
{
protected PaginatorFactory $paginatorFactory;
protected TimelineBuilder $timelineBuilder;
private Security $security;
public function __construct(
TimelineBuilder $timelineBuilder,
PaginatorFactory $paginatorFactory,
Security $security
) {
$this->timelineBuilder = $timelineBuilder;
$this->paginatorFactory = $paginatorFactory;
$this->security = $security;
public function __construct(protected TimelineBuilder $timelineBuilder, protected PaginatorFactory $paginatorFactory, private Security $security)
{
}
/**

View File

@@ -28,10 +28,8 @@ class UserApiController extends ApiController
* "_format": "json"
* }
* )
*
* @param mixed $_format
*/
public function currentLocation($_format): JsonResponse
public function currentLocation(mixed $_format): JsonResponse
{
return $this->json(
$this->getUser()->getCurrentLocation(),
@@ -49,10 +47,8 @@ class UserApiController extends ApiController
* "_format": "json"
* }
* )
*
* @param mixed $_format
*/
public function whoami($_format): JsonResponse
public function whoami(mixed $_format): JsonResponse
{
return $this->json(
$this->getUser(),

View File

@@ -38,37 +38,15 @@ class UserController extends CRUDController
{
public const FORM_GROUP_CENTER_COMPOSED = 'composed_groupcenter';
protected ParameterBagInterface $parameterBag;
private LoggerInterface $logger;
private UserPasswordEncoderInterface $passwordEncoder;
private UserRepository $userRepository;
private ValidatorInterface $validator;
public function __construct(
LoggerInterface $chillLogger,
ValidatorInterface $validator,
UserPasswordEncoderInterface $passwordEncoder,
UserRepository $userRepository,
ParameterBagInterface $parameterBag
) {
$this->logger = $chillLogger;
$this->userRepository = $userRepository;
$this->validator = $validator;
$this->passwordEncoder = $passwordEncoder;
$this->parameterBag = $parameterBag;
public function __construct(private LoggerInterface $logger, private ValidatorInterface $validator, private UserPasswordEncoderInterface $passwordEncoder, private UserRepository $userRepository, protected ParameterBagInterface $parameterBag)
{
}
/**
* @Route("/{_locale}/admin/main/user/{uid}/add_link_groupcenter",
* name="admin_user_add_groupcenter")
*
* @param mixed $uid
*/
public function addLinkGroupCenterAction(Request $request, $uid): Response
public function addLinkGroupCenterAction(Request $request, mixed $uid): Response
{
$em = $this->getDoctrine()->getManager();
@@ -122,11 +100,8 @@ class UserController extends CRUDController
/**
* @Route("/{_locale}/admin/main/user/{uid}/delete_link_groupcenter/{gcid}",
* name="admin_user_delete_groupcenter")
*
* @param mixed $uid
* @param mixed $gcid
*/
public function deleteLinkGroupCenterAction($uid, $gcid, Request $request): RedirectResponse
public function deleteLinkGroupCenterAction(mixed $uid, mixed $gcid, Request $request): RedirectResponse
{
$em = $this->getDoctrine()->getManager();
@@ -421,10 +396,8 @@ class UserController extends CRUDController
/**
* Creates a form to delete a link to a GroupCenter.
*
* @param mixed $request
*/
private function createDeleteLinkGroupCenterForm(User $user, GroupCenter $groupCenter, $request): FormInterface
private function createDeleteLinkGroupCenterForm(User $user, GroupCenter $groupCenter, mixed $request): FormInterface
{
$returnPathParams = $request->query->has('returnPath') ? ['returnPath' => $request->query->get('returnPath')] : [];

View File

@@ -30,28 +30,8 @@ use Symfony\Component\Serializer\SerializerInterface;
class WorkflowApiController
{
private EntityManagerInterface $entityManager;
private EntityWorkflowRepository $entityWorkflowRepository;
private PaginatorFactory $paginatorFactory;
private Security $security;
private SerializerInterface $serializer;
public function __construct(
EntityManagerInterface $entityManager,
EntityWorkflowRepository $entityWorkflowRepository,
PaginatorFactory $paginatorFactory,
Security $security,
SerializerInterface $serializer
) {
$this->entityManager = $entityManager;
$this->entityWorkflowRepository = $entityWorkflowRepository;
$this->paginatorFactory = $paginatorFactory;
$this->security = $security;
$this->serializer = $serializer;
public function __construct(private EntityManagerInterface $entityManager, private EntityWorkflowRepository $entityWorkflowRepository, private PaginatorFactory $paginatorFactory, private Security $security, private SerializerInterface $serializer)
{
}
/**
@@ -160,46 +140,19 @@ class WorkflowApiController
$user = $this->security->getUser();
switch ($request->query->get('subscribe')) {
case 'final':
switch ($action) {
case 'subscribe':
$entityWorkflow->addSubscriberToFinal($user);
break;
case 'unsubscribe':
$entityWorkflow->removeSubscriberToFinal($user);
break;
default:
throw new LogicException();
}
break;
case 'step':
switch ($action) {
case 'subscribe':
$entityWorkflow->addSubscriberToStep($user);
break;
case 'unsubscribe':
$entityWorkflow->removeSubscriberToStep($user);
break;
default:
throw new LogicException();
}
break;
default:
throw new BadRequestHttpException('subscribe parameter must be equal to "step" or "final"');
}
match ($request->query->get('subscribe')) {
'final' => match ($action) {
'subscribe' => $entityWorkflow->addSubscriberToFinal($user),
'unsubscribe' => $entityWorkflow->removeSubscriberToFinal($user),
default => throw new LogicException(),
},
'step' => match ($action) {
'subscribe' => $entityWorkflow->addSubscriberToStep($user),
'unsubscribe' => $entityWorkflow->removeSubscriberToStep($user),
default => throw new LogicException(),
},
default => throw new BadRequestHttpException('subscribe parameter must be equal to "step" or "final"'),
};
$this->entityManager->flush();

View File

@@ -39,32 +39,8 @@ use function count;
class WorkflowController extends AbstractController
{
private EntityManagerInterface $entityManager;
private EntityWorkflowManager $entityWorkflowManager;
private EntityWorkflowRepository $entityWorkflowRepository;
private PaginatorFactory $paginatorFactory;
private Registry $registry;
private Security $security;
private TranslatorInterface $translator;
private ValidatorInterface $validator;
public function __construct(EntityWorkflowManager $entityWorkflowManager, EntityWorkflowRepository $entityWorkflowRepository, ValidatorInterface $validator, PaginatorFactory $paginatorFactory, Registry $registry, EntityManagerInterface $entityManager, TranslatorInterface $translator, Security $security)
public function __construct(private EntityWorkflowManager $entityWorkflowManager, private EntityWorkflowRepository $entityWorkflowRepository, private ValidatorInterface $validator, private PaginatorFactory $paginatorFactory, private Registry $registry, private EntityManagerInterface $entityManager, private TranslatorInterface $translator, private Security $security)
{
$this->entityWorkflowManager = $entityWorkflowManager;
$this->entityWorkflowRepository = $entityWorkflowRepository;
$this->validator = $validator;
$this->paginatorFactory = $paginatorFactory;
$this->registry = $registry;
$this->entityManager = $entityManager;
$this->translator = $translator;
$this->security = $security;
}
/**

View File

@@ -46,30 +46,11 @@ class CronManager implements CronManagerInterface
private const UPDATE_BEFORE_EXEC = 'UPDATE ' . CronJobExecution::class . ' cr SET cr.lastStart = :now WHERE cr.key = :key';
private CronJobExecutionRepositoryInterface $cronJobExecutionRepository;
private EntityManagerInterface $entityManager;
/**
* @var iterable<CronJobInterface>
*/
private iterable $jobs;
private LoggerInterface $logger;
/**
* @param CronJobInterface[] $jobs
*/
public function __construct(
CronJobExecutionRepositoryInterface $cronJobExecutionRepository,
EntityManagerInterface $entityManager,
iterable $jobs,
LoggerInterface $logger
) {
$this->cronJobExecutionRepository = $cronJobExecutionRepository;
$this->entityManager = $entityManager;
$this->jobs = $jobs;
$this->logger = $logger;
public function __construct(private CronJobExecutionRepositoryInterface $cronJobExecutionRepository, private EntityManagerInterface $entityManager, private iterable $jobs, private LoggerInterface $logger)
{
}
public function run(?string $forceJob = null): void
@@ -115,7 +96,7 @@ class CronManager implements CronManagerInterface
$this->logger->info(sprintf('%sSuccessfully run job', self::LOG_PREFIX), ['job' => $job->getKey()]);
return;
} catch (Exception $e) {
} catch (Exception) {
$this->logger->error(sprintf('%sRunning job failed', self::LOG_PREFIX), ['job' => $job->getKey()]);
$this->entityManager
->createQuery(self::UPDATE_AFTER_EXEC)

View File

@@ -93,10 +93,7 @@ class ChillMainExtension extends Extension implements
$this->widgetFactories[] = $factory;
}
/**
* @return \Chill\MainBundle\DependencyInjection\Configuration|object|\Symfony\Component\Config\Definition\ConfigurationInterface|null
*/
public function getConfiguration(array $config, ContainerBuilder $container)
public function getConfiguration(array $config, ContainerBuilder $container): \Chill\MainBundle\DependencyInjection\Configuration|object|\Symfony\Component\Config\Definition\ConfigurationInterface|null
{
return new Configuration($this->widgetFactories, $container);
}

View File

@@ -27,21 +27,16 @@ class ACLFlagsCompilerPass implements CompilerPassInterface
$reference = new Reference($id);
foreach ($tags as $tag) {
switch ($tag['scope']) {
case PermissionsGroupType::FLAG_SCOPE:
$permissionGroupType->addMethodCall('addFlagProvider', [$reference]);
break;
default:
throw new LogicException(
sprintf(
"This tag 'scope' is not implemented: %s, on service with id %s",
$tag['scope'],
$id
)
);
}
match ($tag['scope']) {
PermissionsGroupType::FLAG_SCOPE => $permissionGroupType->addMethodCall('addFlagProvider', [$reference]),
default => throw new LogicException(
sprintf(
"This tag 'scope' is not implemented: %s, on service with id %s",
$tag['scope'],
$id
)
),
};
}
}
}

View File

@@ -24,14 +24,11 @@ class Configuration implements ConfigurationInterface
{
use AddWidgetConfigurationTrait;
private ContainerBuilder $containerBuilder;
public function __construct(
array $widgetFactories,
ContainerBuilder $containerBuilder
private ContainerBuilder $containerBuilder
) {
$this->setWidgetFactories($widgetFactories);
$this->containerBuilder = $containerBuilder;
}
public function getConfigTreeBuilder()

View File

@@ -153,7 +153,7 @@ abstract class AbstractWidgetsCompilerPass implements CompilerPassInterface
$extension,
HasWidgetFactoriesExtensionInterface::class,
HasWidgetFactoriesExtensionInterface::class,
get_class($extensionClass)
$extensionClass::class
));
}
@@ -277,7 +277,7 @@ abstract class AbstractWidgetsCompilerPass implements CompilerPassInterface
if (empty($alias)) {
throw new LogicException(sprintf(
'the widget factory %s returns an empty alias',
get_class($factory)
$factory::class
));
}
@@ -285,13 +285,13 @@ abstract class AbstractWidgetsCompilerPass implements CompilerPassInterface
if (!is_array($factory->getAllowedPlaces())) {
throw new UnexpectedValueException("the method 'getAllowedPlaces' "
. 'should return a non-empty array. Unexpected value on ' .
get_class($factory));
$factory::class);
}
if (count($factory->getAllowedPlaces()) === 0) {
throw new LengthException("The method 'getAllowedPlaces' should "
. 'return a non-empty array, but returned 0 elements on ' .
get_class($factory) . '::getAllowedPlaces()');
$factory::class . '::getAllowedPlaces()');
}
// check the alias does not exists yet
@@ -365,12 +365,10 @@ abstract class AbstractWidgetsCompilerPass implements CompilerPassInterface
/**
* get the places where the service is allowed.
*
* @param mixed $place
* @param mixed $widgetAlias
*
* @return unknown
*/
private function isPlaceAllowedForWidget($place, $widgetAlias, ContainerBuilder $container)
private function isPlaceAllowedForWidget(mixed $place, mixed $widgetAlias, ContainerBuilder $container)
{
if ($this->widgetServices[$widgetAlias] instanceof WidgetFactoryInterface) {
if (

View File

@@ -73,20 +73,11 @@ class OverlapsI extends FunctionNode
protected function makeCase($sqlWalker, $part, string $position): string
{
switch ($position) {
case 'start':
$p = '-infinity';
break;
case 'end':
$p = 'infinity';
break;
default:
throw new Exception('Unexpected position value.');
}
$p = match ($position) {
'start' => '-infinity',
'end' => 'infinity',
default => throw new Exception('Unexpected position value.'),
};
if ($part instanceof PathExpression) {
return sprintf(

View File

@@ -22,11 +22,8 @@ use Symfony\Component\Security\Core\Security;
class TrackCreateUpdateSubscriber implements EventSubscriber
{
private Security $security;
public function __construct(Security $security)
public function __construct(private Security $security)
{
$this->security = $security;
}
public function getSubscribedEvents()

View File

@@ -20,14 +20,8 @@ class Point implements JsonSerializable
{
public static string $SRID = '4326';
private ?float $lat;
private ?float $lon;
private function __construct(?float $lon, ?float $lat)
private function __construct(private ?float $lon, private ?float $lat)
{
$this->lat = $lat;
$this->lon = $lon;
}
public static function fromArrayGeoJson(array $array): self

View File

@@ -91,28 +91,12 @@ class NativeDateIntervalType extends DateIntervalType
if (is_numeric($current)) {
$next = next($strings);
switch ($next) {
case 'year':
case 'years':
$unit = 'Y';
break;
case 'mon':
case 'mons':
$unit = 'M';
break;
case 'day':
case 'days':
$unit = 'D';
break;
default:
throw $this->createConversionException(implode('', $strings));
}
$unit = match ($next) {
'year', 'years' => 'Y',
'mon', 'mons' => 'M',
'day', 'days' => 'D',
default => throw $this->createConversionException(implode('', $strings)),
};
return $current . $unit;
}

View File

@@ -44,10 +44,8 @@ class PointType extends Type
/**
* @param mixed $value
*
* @return ?Point
*/
public function convertToPHPValue($value, AbstractPlatform $platform)
public function convertToPHPValue($value, AbstractPlatform $platform): ?\Chill\MainBundle\Doctrine\Model\Point
{
if (null === $value) {
return null;

View File

@@ -399,9 +399,6 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
return $this->streetNumber;
}
/**
* @return DateTime
*/
public function getValidFrom(): DateTime
{
return $this->validFrom;
@@ -567,7 +564,6 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
*
* @param string $streetAddress1
*
* @return Address
* @deprecated
*/
public function setStreetAddress1(?string $streetAddress1): self
@@ -582,7 +578,6 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
*
* @param string $streetAddress2
* @deprecated
* @return Address
*/
public function setStreetAddress2(?string $streetAddress2): self
{

View File

@@ -20,7 +20,7 @@ use Symfony\Component\Serializer\Annotation as Serializer;
* @ORM\Entity
* @ORM\Table(name="centers")
*/
class Center implements HasCenterInterface
class Center implements HasCenterInterface, \Stringable
{
/**
* @var Collection
@@ -59,7 +59,7 @@ class Center implements HasCenterInterface
/**
* @return string
*/
public function __toString()
public function __toString(): string
{
return $this->getName();
}
@@ -85,7 +85,7 @@ class Center implements HasCenterInterface
/**
* @return ArrayCollection|Collection
*/
public function getGroupCenters()
public function getGroupCenters(): \Doctrine\Common\Collections\ArrayCollection|\Doctrine\Common\Collections\Collection
{
return $this->groupCenters;
}

View File

@@ -79,9 +79,6 @@ class Civility
return $this->order;
}
/**
* @return Civility
*/
public function setAbbreviation(array $abbreviation): self
{
$this->abbreviation = $abbreviation;

View File

@@ -24,12 +24,6 @@ class CronJobExecution
public const SUCCESS = 1;
/**
* @ORM\Column(type="text", nullable=false)
* @ORM\Id
*/
private string $key;
/**
* @var DateTimeImmutable
* @ORM\Column(type="datetime_immutable", nullable=true, options={"default": null})
@@ -46,9 +40,12 @@ class CronJobExecution
*/
private ?int $lastStatus = null;
public function __construct(string $key)
{
$this->key = $key;
public function __construct(/**
* @ORM\Column(type="text", nullable=false)
* @ORM\Id
*/
private string $key
) {
$this->lastStart = new DateTimeImmutable('now');
}

View File

@@ -20,39 +20,31 @@ use Symfony\Component\Serializer\Annotation as Serializer;
*/
class SimpleGeographicalUnitDTO
{
/**
* @readonly
* @psalm-readonly
* @Serializer\Groups({"read"})
*/
public int $id;
/**
* @readonly
* @psalm-readonly
* @Serializer\Groups({"read"})
*/
public int $layerId;
/**
* @readonly
* @psalm-readonly
* @Serializer\Groups({"read"})
*/
public string $unitName;
/**
* @readonly
* @psalm-readonly
* @Serializer\Groups({"read"})
*/
public string $unitRefId;
public function __construct(int $id, string $unitName, string $unitRefId, int $layerId)
{
$this->id = $id;
$this->unitName = $unitName;
$this->unitRefId = $unitRefId;
$this->layerId = $layerId;
public function __construct(
/**
* @readonly
* @psalm-readonly
* @Serializer\Groups({"read"})
*/
public int $id,
/**
* @readonly
* @psalm-readonly
* @Serializer\Groups({"read"})
*/
public string $unitName,
/**
* @readonly
* @psalm-readonly
* @Serializer\Groups({"read"})
*/
public string $unitRefId,
/**
* @readonly
* @psalm-readonly
* @Serializer\Groups({"read"})
*/
public int $layerId
) {
}
}

View File

@@ -109,7 +109,7 @@ class PermissionsGroup
/**
* @return ArrayCollection|Collection
*/
public function getRoleScopes()
public function getRoleScopes(): \Doctrine\Common\Collections\ArrayCollection|\Doctrine\Common\Collections\Collection
{
return $this->roleScopes;
}

View File

@@ -32,7 +32,7 @@ use function in_array;
* "user": User::class
* })
*/
class User implements UserInterface
class User implements UserInterface, \Stringable
{
/**
* @ORM\Id
@@ -158,14 +158,12 @@ class User implements UserInterface
/**
* @return string
*/
public function __toString()
public function __toString(): string
{
return $this->getLabel();
}
/**
* @param \Chill\MainBundle\Entity\GroupCenter $groupCenter
*
* @return \Chill\MainBundle\Entity\User
*/
public function addGroupCenter(GroupCenter $groupCenter)
@@ -359,8 +357,6 @@ class User implements UserInterface
}
/**
* @param \Chill\MainBundle\Entity\GroupCenter $groupCenter
*
* @throws RuntimeException if the groupCenter is not in the collection
*/
public function removeGroupCenter(GroupCenter $groupCenter)

View File

@@ -294,7 +294,7 @@ class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface
/**
* @return ArrayCollection|Collection
*/
public function getSteps()
public function getSteps(): \Doctrine\Common\Collections\ArrayCollection|\Doctrine\Common\Collections\Collection
{
return $this->steps;
}
@@ -335,7 +335,7 @@ class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface
/**
* @return ArrayCollection|Collection
*/
public function getSubscriberToFinal()
public function getSubscriberToFinal(): \Doctrine\Common\Collections\ArrayCollection|\Doctrine\Common\Collections\Collection
{
return $this->subscriberToFinal;
}
@@ -343,7 +343,7 @@ class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface
/**
* @return ArrayCollection|Collection
*/
public function getSubscriberToStep()
public function getSubscriberToStep(): \Doctrine\Common\Collections\ArrayCollection|\Doctrine\Common\Collections\Collection
{
return $this->subscriberToStep;
}

View File

@@ -356,8 +356,6 @@ class EntityWorkflowStep
}
/**
* @return EntityWorkflowStep
*
* @internal
*/
public function setNext(?EntityWorkflowStep $next): self
@@ -368,8 +366,6 @@ class EntityWorkflowStep
}
/**
* @return EntityWorkflowStep
*
* @internal
*/
public function setPrevious(?EntityWorkflowStep $previous): self
@@ -409,10 +405,8 @@ class EntityWorkflowStep
/**
* @Assert\Callback
*
* @param mixed $payload
*/
public function validateOnCreation(ExecutionContextInterface $context, $payload): void
public function validateOnCreation(ExecutionContextInterface $context, mixed $payload): void
{
return;

View File

@@ -44,10 +44,6 @@ class ExportManager
*/
private array $aggregators = [];
private AuthorizationCheckerInterface $authorizationChecker;
private AuthorizationHelperInterface $authorizationHelper;
/**
* Collected Exports, injected by DI.
*
@@ -69,17 +65,15 @@ class ExportManager
*/
private array $formatters = [];
private LoggerInterface $logger;
/**
* @var \Symfony\Component\Security\Core\User\UserInterface
*/
private $user;
public function __construct(
LoggerInterface $logger,
AuthorizationCheckerInterface $authorizationChecker,
AuthorizationHelperInterface $authorizationHelper,
private LoggerInterface $logger,
private AuthorizationCheckerInterface $authorizationChecker,
private AuthorizationHelperInterface $authorizationHelper,
TokenStorageInterface $tokenStorage,
iterable $exports,
iterable $aggregators,
@@ -87,9 +81,6 @@ class ExportManager
//iterable $formatters,
//iterable $exportElementProvider
) {
$this->logger = $logger;
$this->authorizationChecker = $authorizationChecker;
$this->authorizationHelper = $authorizationHelper;
$this->user = $tokenStorage->getToken()->getUser();
$this->exports = iterator_to_array($exports);
$this->aggregators = iterator_to_array($aggregators);
@@ -163,7 +154,7 @@ class ExportManager
} elseif ($element instanceof FormatterInterface) {
$this->addFormatter($element, $alias);
} else {
throw new LogicException('This element ' . get_class($element) . ' '
throw new LogicException('This element ' . $element::class . ' '
. 'is not an instance of export element');
}
}
@@ -468,12 +459,10 @@ class ExportManager
* Return true if the current user has access to the ExportElement for every
* center, false if the user hasn't access to element for at least one center.
*
* @param \Chill\MainBundle\Export\ExportElementInterface $element
* @param DirectExportInterface|ExportInterface $export
*
* @return bool
*/
public function isGrantedForElement(ExportElementInterface $element, ?ExportElementInterface $export = null, ?array $centers = null)
public function isGrantedForElement(ExportElementInterface $element, \Chill\MainBundle\Export\DirectExportInterface|\Chill\MainBundle\Export\ExportInterface $export = null, ?array $centers = null)
{
if ($element instanceof ExportInterface || $element instanceof DirectExportInterface) {
$role = $element->requiredRole();
@@ -506,7 +495,7 @@ class ExportManager
//debugging
$this->logger->debug('user has no access to element', [
'method' => __METHOD__,
'type' => get_class($element),
'type' => $element::class,
'center' => $center->getName(),
'role' => $role,
]);
@@ -577,7 +566,7 @@ class ExportManager
private function handleFilters(
ExportInterface $export,
QueryBuilder $qb,
$data,
mixed $data,
array $centers
) {
$filters = $this->retrieveUsedFilters($data);
@@ -598,11 +587,9 @@ class ExportManager
}
/**
* @param mixed $data
*
* @return AggregatorInterface[]
*/
private function retrieveUsedAggregators($data)
private function retrieveUsedAggregators(mixed $data)
{
if (null === $data) {
return [];
@@ -616,11 +603,9 @@ class ExportManager
}
/**
* @param mixed $data
*
* @return string[]
*/
private function retrieveUsedAggregatorsType($data)
private function retrieveUsedAggregatorsType(mixed $data)
{
if (null === $data) {
return [];
@@ -660,7 +645,7 @@ class ExportManager
*
* @return array an array with types
*/
private function retrieveUsedFiltersType($data)
private function retrieveUsedFiltersType(mixed $data)
{
if (null === $data) {
return [];
@@ -684,11 +669,10 @@ class ExportManager
/**
* parse the data to retrieve the used filters and aggregators.
*
* @param mixed $data
*
* @return string[]
*/
private function retrieveUsedModifiers($data)
private function retrieveUsedModifiers(mixed $data)
{
if (null === $data) {
return [];

View File

@@ -56,13 +56,10 @@ class CSVFormatter implements FormatterInterface
protected $result;
protected TranslatorInterface $translator;
public function __construct(
TranslatorInterface $translator,
protected TranslatorInterface $translator,
ExportManager $manager
) {
$this->translator = $translator;
$this->exportManager = $manager;
}

View File

@@ -347,27 +347,12 @@ class SpreadSheetFormatter implements FormatterInterface
$line = $this->addContentTable($worksheet, $sortedResult, $line);
switch ($this->formatterData['format']) {
case 'ods':
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Ods');
break;
case 'xlsx':
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx');
break;
case 'csv':
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Csv');
break;
default:
// this should not happen
// throw an exception to ensure that the error is catched
throw new LogicException();
}
$writer = match ($this->formatterData['format']) {
'ods' => \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Ods'),
'xlsx' => \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx'),
'csv' => \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Csv'),
default => throw new LogicException(),
};
$writer->save($this->tempfile);
}
@@ -435,11 +420,10 @@ class SpreadSheetFormatter implements FormatterInterface
* Get the displayable result.
*
* @param string $key
* @param mixed $value
*
* @return string
*/
protected function getDisplayableResult($key, $value)
protected function getDisplayableResult($key, mixed $value)
{
if (false === $this->cacheDisplayableResultIsInitialized) {
$this->initializeCache($key);

View File

@@ -18,11 +18,8 @@ use Symfony\Contracts\Translation\TranslatorInterface;
class DateTimeHelper
{
private TranslatorInterface $translator;
public function __construct(TranslatorInterface $translator)
public function __construct(private TranslatorInterface $translator)
{
$this->translator = $translator;
}
public function getLabel($header): callable

View File

@@ -74,14 +74,6 @@ class ExportAddressHelper
'geographical_units' => ['_unit_names', '_unit_refs'],
];
private AddressRender $addressRender;
private AddressRepository $addressRepository;
private GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository;
private TranslatableStringHelperInterface $translatableStringHelper;
/**
* @var array<string, string, GeographicalUnitLayer>>|null
*/
@@ -92,16 +84,8 @@ class ExportAddressHelper
*/
private ?array $unitRefsKeysCache = [];
public function __construct(
AddressRender $addressRender,
AddressRepository $addressRepository,
GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository,
TranslatableStringHelperInterface $translatableStringHelper
) {
$this->addressRepository = $addressRepository;
$this->geographicalUnitLayerRepository = $geographicalUnitLayerRepository;
$this->translatableStringHelper = $translatableStringHelper;
$this->addressRender = $addressRender;
public function __construct(private AddressRender $addressRender, private AddressRepository $addressRepository, private GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository, private TranslatableStringHelperInterface $translatableStringHelper)
{
}
public function addSelectClauses(int $params, QueryBuilder $queryBuilder, $entityName = 'address', $prefix = 'add')
@@ -369,16 +353,11 @@ class ExportAddressHelper
$decodedValues = json_decode($value, true, 512, JSON_THROW_ON_ERROR);
switch (count($decodedValues)) {
case 0:
return '';
case 1:
return $decodedValues[0];
default:
return implode('|', $decodedValues);
}
return match (count($decodedValues)) {
0 => '',
1 => $decodedValues[0],
default => implode('|', $decodedValues),
};
};
}

View File

@@ -21,11 +21,8 @@ use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
*/
class TranslatableStringExportLabelHelper
{
private TranslatableStringHelperInterface $translatableStringHelper;
public function __construct(TranslatableStringHelperInterface $translatableStringHelper)
public function __construct(private TranslatableStringHelperInterface $translatableStringHelper)
{
$this->translatableStringHelper = $translatableStringHelper;
}
public function getLabel(string $key, array $values, string $header)

View File

@@ -18,14 +18,8 @@ use const SORT_NUMERIC;
class UserHelper
{
private UserRender $userRender;
private UserRepositoryInterface $userRepository;
public function __construct(UserRender $userRender, UserRepositoryInterface $userRepository)
public function __construct(private UserRender $userRender, private UserRepositoryInterface $userRepository)
{
$this->userRender = $userRender;
$this->userRepository = $userRepository;
}
public function getLabel($key, array $values, string $header): callable

View File

@@ -19,11 +19,8 @@ use Symfony\Component\Security\Core\Security;
final class PrivateCommentDataMapper extends AbstractType implements DataMapperInterface
{
private Security $security;
public function __construct(Security $security)
public function __construct(private Security $security)
{
$this->security = $security;
}
public function mapDataToForms($viewData, $forms)

View File

@@ -16,14 +16,8 @@ use Symfony\Component\Form\DataMapperInterface;
class ScopePickerDataMapper implements DataMapperInterface
{
/**
* @var \Chill\MainBundle\Entity\Scope
*/
private $scope;
public function __construct(?Scope $scope = null)
public function __construct(private ?Scope $scope = null)
{
$this->scope = $scope;
}
public function mapDataToForms($data, $forms)

View File

@@ -31,17 +31,11 @@ class IdToEntityDataTransformer implements DataTransformerInterface
{
private Closure $getId;
private bool $multiple = false;
private ObjectRepository $repository;
/**
* @param Closure $getId
*/
public function __construct(ObjectRepository $repository, bool $multiple = false, ?callable $getId = null)
public function __construct(private ObjectRepository $repository, private bool $multiple = false, ?callable $getId = null)
{
$this->repository = $repository;
$this->multiple = $multiple;
$this->getId = $getId ?? static fn (object $o) => $o->getId();
}

View File

@@ -17,14 +17,8 @@ class CustomizeFormEvent extends \Symfony\Component\EventDispatcher\Event
{
public const NAME = 'chill_main.customize_form';
protected FormBuilderInterface $builder;
protected string $type;
public function __construct(string $type, FormBuilderInterface $builder)
public function __construct(protected string $type, protected FormBuilderInterface $builder)
{
$this->type = $type;
$this->builder = $builder;
}
public function getBuilder(): FormBuilderInterface

View File

@@ -24,11 +24,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
final class LocationFormType extends AbstractType
{
private TranslatableStringHelper $translatableStringHelper;
public function __construct(TranslatableStringHelper $translatableStringHelper)
public function __construct(private TranslatableStringHelper $translatableStringHelper)
{
$this->translatableStringHelper = $translatableStringHelper;
}
public function buildForm(FormBuilderInterface $builder, array $options)

View File

@@ -43,18 +43,12 @@ class ComposedRoleScopeType extends AbstractType
*/
private $rolesWithoutScope = [];
/**
* @var TranslatableStringHelper
*/
private $translatableStringHelper;
public function __construct(
TranslatableStringHelper $translatableStringHelper,
private TranslatableStringHelper $translatableStringHelper,
RoleProvider $roleProvider
) {
$this->roles = $roleProvider->getRoles();
$this->rolesWithoutScope = $roleProvider->getRolesWithoutScopes();
$this->translatableStringHelper = $translatableStringHelper;
$this->roleProvider = $roleProvider;
}

View File

@@ -17,11 +17,8 @@ use Symfony\Component\Form\Exception\TransformationFailedException;
final class AddressToIdDataTransformer implements DataTransformerInterface
{
private AddressRepository $addressRepository;
public function __construct(AddressRepository $addressRepository)
public function __construct(private AddressRepository $addressRepository)
{
$this->addressRepository = $addressRepository;
}
public function reverseTransform($value)

View File

@@ -23,16 +23,8 @@ use function count;
class CenterTransformer implements DataTransformerInterface
{
private CenterRepository $centerRepository;
private bool $multiple = false;
public function __construct(
CenterRepository $centerRepository,
bool $multiple = false
) {
$this->centerRepository = $centerRepository;
$this->multiple = $multiple;
public function __construct(private CenterRepository $centerRepository, private bool $multiple = false)
{
}
public function reverseTransform($id)

View File

@@ -25,20 +25,8 @@ use function array_key_exists;
class EntityToJsonTransformer implements DataTransformerInterface
{
private DenormalizerInterface $denormalizer;
private bool $multiple;
private SerializerInterface $serializer;
private string $type;
public function __construct(DenormalizerInterface $denormalizer, SerializerInterface $serializer, bool $multiple, string $type)
public function __construct(private DenormalizerInterface $denormalizer, private SerializerInterface $serializer, private bool $multiple, private string $type)
{
$this->denormalizer = $denormalizer;
$this->serializer = $serializer;
$this->multiple = $multiple;
$this->type = $type;
}
public function reverseTransform($value)
@@ -87,25 +75,12 @@ class EntityToJsonTransformer implements DataTransformerInterface
throw new TransformationFailedException('the key "id" is missing on element');
}
switch ($this->type) {
case 'user':
$class = User::class;
break;
case 'person':
$class = Person::class;
break;
case 'thirdparty':
$class = ThirdParty::class;
break;
default:
throw new UnexpectedValueException('This type is not supported');
}
$class = match ($this->type) {
'user' => User::class,
'person' => Person::class,
'thirdparty' => ThirdParty::class,
default => throw new UnexpectedValueException('This type is not supported'),
};
return
$this->denormalizer->denormalize(

View File

@@ -17,14 +17,8 @@ use Symfony\Component\Form\DataTransformerInterface;
class MultipleObjectsToIdTransformer implements DataTransformerInterface
{
private ?string $class;
private EntityManagerInterface $em;
public function __construct(EntityManagerInterface $em, ?string $class = null)
public function __construct(private EntityManagerInterface $em, private ?string $class = null)
{
$this->em = $em;
$this->class = $class;
}
/**

View File

@@ -17,14 +17,8 @@ use Symfony\Component\Form\Exception\TransformationFailedException;
class ObjectToIdTransformer implements DataTransformerInterface
{
private ?string $class;
private EntityManagerInterface $em;
public function __construct(EntityManagerInterface $em, ?string $class = null)
public function __construct(private EntityManagerInterface $em, private ?string $class = null)
{
$this->em = $em;
$this->class = $class;
}
/**
@@ -33,10 +27,8 @@ class ObjectToIdTransformer implements DataTransformerInterface
* @param string $id
*
* @throws TransformationFailedException if object is not found.
*
* @return object|null
*/
public function reverseTransform($id)
public function reverseTransform($id): ?object
{
if (null === $id) {
return null;

View File

@@ -20,11 +20,8 @@ use function is_int;
class PostalCodeToIdTransformer implements DataTransformerInterface
{
private PostalCodeRepositoryInterface $postalCodeRepository;
public function __construct(PostalCodeRepositoryInterface $postalCodeRepository)
public function __construct(private PostalCodeRepositoryInterface $postalCodeRepository)
{
$this->postalCodeRepository = $postalCodeRepository;
}
public function reverseTransform($value)

View File

@@ -18,11 +18,8 @@ use Symfony\Component\Form\Exception\TransformationFailedException;
class ScopeTransformer implements DataTransformerInterface
{
private EntityManagerInterface $em;
public function __construct(EntityManagerInterface $em)
public function __construct(private EntityManagerInterface $em)
{
$this->em = $em;
}
public function reverseTransform($id)

View File

@@ -33,24 +33,15 @@ final class PickCenterType extends AbstractType
{
public const CENTERS_IDENTIFIERS = 'c';
private AuthorizationHelperInterface $authorizationHelper;
private ExportManager $exportManager;
private RegroupmentRepository $regroupmentRepository;
private UserInterface $user;
public function __construct(
TokenStorageInterface $tokenStorage,
ExportManager $exportManager,
RegroupmentRepository $regroupmentRepository,
AuthorizationHelperInterface $authorizationHelper
private ExportManager $exportManager,
private RegroupmentRepository $regroupmentRepository,
private AuthorizationHelperInterface $authorizationHelper
) {
$this->exportManager = $exportManager;
$this->user = $tokenStorage->getToken()->getUser();
$this->authorizationHelper = $authorizationHelper;
$this->regroupmentRepository = $regroupmentRepository;
}
public function buildForm(FormBuilderInterface $builder, array $options)

View File

@@ -27,11 +27,8 @@ use function count;
final class FilterOrderType extends \Symfony\Component\Form\AbstractType
{
private RequestStack $requestStack;
public function __construct(RequestStack $requestStack)
public function __construct(private RequestStack $requestStack)
{
$this->requestStack = $requestStack;
}
public function buildForm(FormBuilderInterface $builder, array $options)

View File

@@ -43,16 +43,8 @@ use function uniqid;
*/
final class PickAddressType extends AbstractType
{
private AddressToIdDataTransformer $addressToIdDataTransformer;
private TranslatorInterface $translator;
public function __construct(
AddressToIdDataTransformer $addressToIdDataTransformer,
TranslatorInterface $translator
) {
$this->addressToIdDataTransformer = $addressToIdDataTransformer;
$this->translator = $translator;
public function __construct(private AddressToIdDataTransformer $addressToIdDataTransformer, private TranslatorInterface $translator)
{
}
public function buildForm(FormBuilderInterface $builder, array $options)

View File

@@ -38,20 +38,8 @@ use function count;
*/
class PickCenterType extends AbstractType
{
protected AuthorizationHelperInterface $authorizationHelper;
protected CenterRepository $centerRepository;
protected Security $security;
public function __construct(
AuthorizationHelperInterface $authorizationHelper,
Security $security,
CenterRepository $centerRepository
) {
$this->authorizationHelper = $authorizationHelper;
$this->security = $security;
$this->centerRepository = $centerRepository;
public function __construct(protected AuthorizationHelperInterface $authorizationHelper, protected Security $security, protected CenterRepository $centerRepository)
{
}
/**

View File

@@ -21,11 +21,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class PickCivilityType extends AbstractType
{
private TranslatableStringHelper $translatableStringHelper;
public function __construct(TranslatableStringHelper $translatableStringHelper)
public function __construct(private TranslatableStringHelper $translatableStringHelper)
{
$this->translatableStringHelper = $translatableStringHelper;
}
public function configureOptions(OptionsResolver $resolver)

View File

@@ -19,11 +19,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class PickLocationTypeType extends AbstractType
{
private TranslatableStringHelper $translatableStringHelper;
public function __construct(TranslatableStringHelper $translatableStringHelper)
public function __construct(private TranslatableStringHelper $translatableStringHelper)
{
$this->translatableStringHelper = $translatableStringHelper;
}
public function configureOptions(OptionsResolver $resolver)

View File

@@ -21,11 +21,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class PickPostalCodeType extends AbstractType
{
private PostalCodeToIdTransformer $postalCodeToIdTransformer;
public function __construct(PostalCodeToIdTransformer $postalCodeToIdTransformer)
public function __construct(private PostalCodeToIdTransformer $postalCodeToIdTransformer)
{
$this->postalCodeToIdTransformer = $postalCodeToIdTransformer;
}
public function buildForm(FormBuilderInterface $builder, array $options)

View File

@@ -27,17 +27,8 @@ use Symfony\Component\Serializer\SerializerInterface;
*/
class PickUserDynamicType extends AbstractType
{
private DenormalizerInterface $denormalizer;
private NormalizerInterface $normalizer;
private SerializerInterface $serializer;
public function __construct(DenormalizerInterface $denormalizer, SerializerInterface $serializer, NormalizerInterface $normalizer)
public function __construct(private DenormalizerInterface $denormalizer, private SerializerInterface $serializer, private NormalizerInterface $normalizer)
{
$this->denormalizer = $denormalizer;
$this->serializer = $serializer;
$this->normalizer = $normalizer;
}
public function buildForm(FormBuilderInterface $builder, array $options)

View File

@@ -20,14 +20,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class PickUserLocationType extends AbstractType
{
private LocationRepository $locationRepository;
private TranslatableStringHelper $translatableStringHelper;
public function __construct(TranslatableStringHelper $translatableStringHelper, LocationRepository $locationRepository)
public function __construct(private TranslatableStringHelper $translatableStringHelper, private LocationRepository $locationRepository)
{
$this->translatableStringHelper = $translatableStringHelper;
$this->locationRepository = $locationRepository;
}
public function configureOptions(OptionsResolver $resolver)

View File

@@ -24,14 +24,11 @@ use Symfony\Component\Security\Core\User\UserInterface;
class PrivateCommentType extends AbstractType
{
protected PrivateCommentDataMapper $dataMapper;
protected UserInterface $user;
public function __construct(TokenStorageInterface $tokenStorage, PrivateCommentDataMapper $dataMapper)
public function __construct(TokenStorageInterface $tokenStorage, protected PrivateCommentDataMapper $dataMapper)
{
$this->user = $tokenStorage->getToken()->getUser();
$this->dataMapper = $dataMapper;
}
public function buildForm(FormBuilderInterface $builder, array $options)

View File

@@ -42,20 +42,8 @@ use function count;
*/
class ScopePickerType extends AbstractType
{
private AuthorizationHelperInterface $authorizationHelper;
private Security $security;
private TranslatableStringHelperInterface $translatableStringHelper;
public function __construct(
AuthorizationHelperInterface $authorizationHelper,
Security $security,
TranslatableStringHelperInterface $translatableStringHelper
) {
$this->authorizationHelper = $authorizationHelper;
$this->security = $security;
$this->translatableStringHelper = $translatableStringHelper;
public function __construct(private AuthorizationHelperInterface $authorizationHelper, private Security $security, private TranslatableStringHelperInterface $translatableStringHelper)
{
}
public function buildForm(FormBuilderInterface $builder, array $options)

View File

@@ -29,24 +29,8 @@ use const SORT_STRING;
*/
class Select2CountryType extends AbstractType
{
protected ParameterBagInterface $parameterBag;
protected TranslatableStringHelper $translatableStringHelper;
private ObjectManager $em;
private RequestStack $requestStack;
public function __construct(
RequestStack $requestStack,
ObjectManager $em,
TranslatableStringHelper $translatableStringHelper,
ParameterBagInterface $parameterBag
) {
$this->requestStack = $requestStack;
$this->em = $em;
$this->translatableStringHelper = $translatableStringHelper;
$this->parameterBag = $parameterBag;
public function __construct(private RequestStack $requestStack, private ObjectManager $em, protected TranslatableStringHelper $translatableStringHelper, protected ParameterBagInterface $parameterBag)
{
}
public function buildForm(FormBuilderInterface $builder, array $options)

View File

@@ -29,24 +29,8 @@ use const SORT_STRING;
*/
class Select2LanguageType extends AbstractType
{
protected ParameterBagInterface $parameterBag;
protected TranslatableStringHelper $translatableStringHelper;
private ObjectManager $em;
private RequestStack $requestStack;
public function __construct(
RequestStack $requestStack,
ObjectManager $em,
TranslatableStringHelper $translatableStringHelper,
ParameterBagInterface $parameterBag
) {
$this->requestStack = $requestStack;
$this->em = $em;
$this->translatableStringHelper = $translatableStringHelper;
$this->parameterBag = $parameterBag;
public function __construct(private RequestStack $requestStack, private ObjectManager $em, protected TranslatableStringHelper $translatableStringHelper, protected ParameterBagInterface $parameterBag)
{
}
public function buildForm(FormBuilderInterface $builder, array $options)

View File

@@ -24,13 +24,12 @@ use function in_array;
class TranslatableStringFormType extends AbstractType
{
private $availableLanguages; // The langauges availaible
// The langauges availaible
private $frameworkTranslatorFallback; // The langagues used for the translation
public function __construct(array $availableLanguages, Translator $translator)
public function __construct(private array $availableLanguages, Translator $translator)
{
$this->availableLanguages = $availableLanguages;
$this->frameworkTranslatorFallback = $translator->getFallbackLocales();
}

View File

@@ -44,24 +44,15 @@ class UserPickerType extends AbstractType
*/
protected $tokenStorage;
protected UserACLAwareRepositoryInterface $userACLAwareRepository;
protected UserRepository $userRepository;
private UserRender $userRender;
public function __construct(
AuthorizationHelper $authorizationHelper,
TokenStorageInterface $tokenStorage,
UserRepository $userRepository,
UserACLAwareRepositoryInterface $userACLAwareRepository,
UserRender $userRender
protected UserRepository $userRepository,
protected UserACLAwareRepositoryInterface $userACLAwareRepository,
private UserRender $userRender
) {
$this->authorizationHelper = $authorizationHelper;
$this->tokenStorage = $tokenStorage;
$this->userRepository = $userRepository;
$this->userACLAwareRepository = $userACLAwareRepository;
$this->userRender = $userRender;
}
public function configureOptions(OptionsResolver $resolver)

View File

@@ -35,16 +35,8 @@ use Symfony\Component\Validator\Constraints\Regex;
class UserType extends AbstractType
{
protected ParameterBagInterface $parameterBag;
private TranslatableStringHelper $translatableStringHelper;
public function __construct(
TranslatableStringHelper $translatableStringHelper,
ParameterBagInterface $parameterBag
) {
$this->translatableStringHelper = $translatableStringHelper;
$this->parameterBag = $parameterBag;
public function __construct(private TranslatableStringHelper $translatableStringHelper, protected ParameterBagInterface $parameterBag)
{
}
public function buildForm(FormBuilderInterface $builder, array $options)

View File

@@ -36,17 +36,8 @@ use function array_key_exists;
class WorkflowStepType extends AbstractType
{
private EntityWorkflowManager $entityWorkflowManager;
private Registry $registry;
private TranslatableStringHelperInterface $translatableStringHelper;
public function __construct(EntityWorkflowManager $entityWorkflowManager, Registry $registry, TranslatableStringHelperInterface $translatableStringHelper)
public function __construct(private EntityWorkflowManager $entityWorkflowManager, private Registry $registry, private TranslatableStringHelperInterface $translatableStringHelper)
{
$this->entityWorkflowManager = $entityWorkflowManager;
$this->registry = $registry;
$this->translatableStringHelper = $translatableStringHelper;
}
public function buildForm(FormBuilderInterface $builder, array $options)

View File

@@ -25,14 +25,8 @@ use Symfony\Component\Security\Core\User\UserInterface;
final class NotificationByUserCounter implements NotificationCounterInterface
{
private CacheItemPoolInterface $cacheItemPool;
private NotificationRepository $notificationRepository;
public function __construct(CacheItemPoolInterface $cacheItemPool, NotificationRepository $notificationRepository)
public function __construct(private CacheItemPoolInterface $cacheItemPool, private NotificationRepository $notificationRepository)
{
$this->cacheItemPool = $cacheItemPool;
$this->notificationRepository = $notificationRepository;
}
public function addNotification(UserInterface $u): int

View File

@@ -25,17 +25,8 @@ use Symfony\Contracts\Translation\TranslatorInterface;
class NotificationMailer
{
private LoggerInterface $logger;
private MailerInterface $mailer;
private TranslatorInterface $translator;
public function __construct(MailerInterface $mailer, LoggerInterface $logger, TranslatorInterface $translator)
public function __construct(private MailerInterface $mailer, private LoggerInterface $logger, private TranslatorInterface $translator)
{
$this->mailer = $mailer;
$this->logger = $logger;
$this->translator = $translator;
}
public function postPersistComment(NotificationComment $comment, PostPersistEventArgs $eventArgs): void

View File

@@ -19,14 +19,8 @@ use function count;
class PersistNotificationOnTerminateEventSubscriber implements EventSubscriberInterface
{
private EntityManagerInterface $em;
private NotificationPersisterInterface $persister;
public function __construct(EntityManagerInterface $em, NotificationPersisterInterface $persister)
public function __construct(private EntityManagerInterface $em, private NotificationPersisterInterface $persister)
{
$this->em = $em;
$this->persister = $persister;
}
public static function getSubscribedEvents()

View File

@@ -39,11 +39,6 @@ class Mailer
*/
private $logger;
/**
* @var array
*/
private $routeParameters;
/**
* @var RouterInterface
*/
@@ -62,6 +57,7 @@ class Mailer
* Mailer constructor.
*
* @param $routeParameters
* @param mixed[] $routeParameters
*/
public function __construct(
MailerInterface $mailer,
@@ -69,14 +65,13 @@ class Mailer
EngineInterface $twig,
RouterInterface $router,
TranslatorInterface $translator,
$routeParameters
protected $routeParameters
) {
$this->logger = $logger;
$this->twig = $twig;
$this->mailer = $mailer;
$this->router = $router;
$this->translator = $translator;
$this->routeParameters = $routeParameters;
}
/**
@@ -112,15 +107,13 @@ class Mailer
* @param array $subject Subject of the message [ 0 => $message (required), 1 => $parameters (optional), 3 => $domain (optional) ]
* @param array $bodies The bodies. An array where keys are the contentType and values the bodies
* @param callable $callback a callback to customize the message (add attachment, etc.)
* @param mixed $recipient
* @param mixed $force
*/
public function sendNotification(
$recipient,
mixed $recipient,
array $subject,
array $bodies,
?callable $callback = null,
$force = false
mixed $force = false
) {
$fromEmail = $this->routeParameters['from_email'];
$fromName = $this->routeParameters['from_name'];

View File

@@ -17,16 +17,8 @@ use Doctrine\ORM\EntityManagerInterface;
final class NotificationHandlerManager
{
private EntityManagerInterface $em;
private iterable $handlers;
public function __construct(
iterable $handlers,
EntityManagerInterface $em
) {
$this->handlers = $handlers;
$this->em = $em;
public function __construct(private iterable $handlers, private EntityManagerInterface $em)
{
}
/**

View File

@@ -24,14 +24,8 @@ class NotificationPresence
{
private array $cache = [];
private NotificationRepository $notificationRepository;
private Security $security;
public function __construct(Security $security, NotificationRepository $notificationRepository)
public function __construct(private Security $security, private NotificationRepository $notificationRepository)
{
$this->security = $security;
$this->notificationRepository = $notificationRepository;
}
public function countNotificationsForClassAndEntity(string $relatedEntityClass, int $relatedEntityId): array

View File

@@ -21,17 +21,8 @@ use Twig\Extension\RuntimeExtensionInterface;
class NotificationTwigExtensionRuntime implements RuntimeExtensionInterface
{
private FormFactoryInterface $formFactory;
private NotificationPresence $notificationPresence;
private UrlGeneratorInterface $urlGenerator;
public function __construct(FormFactoryInterface $formFactory, NotificationPresence $notificationPresence, UrlGeneratorInterface $urlGenerator)
public function __construct(private FormFactoryInterface $formFactory, private NotificationPresence $notificationPresence, private UrlGeneratorInterface $urlGenerator)
{
$this->formFactory = $formFactory;
$this->notificationPresence = $notificationPresence;
$this->urlGenerator = $urlGenerator;
}
public function counterNotificationFor(Environment $environment, string $relatedEntityClass, int $relatedEntityId, array $options = []): string

View File

@@ -48,20 +48,11 @@ class ChillPaginationTwig extends AbstractExtension
PaginatorInterface $paginator,
$template = '@ChillMain/Pagination/long.html.twig'
) {
switch ($template) {
case 'long':
$t = self::LONG_TEMPLATE;
break;
case 'short':
$t = self::SHORT_TEMPLATE;
break;
default:
$t = $template;
}
$t = match ($template) {
'long' => self::LONG_TEMPLATE,
'short' => self::SHORT_TEMPLATE,
default => $template,
};
return $env->render($t, [
'paginator' => $paginator,

View File

@@ -18,59 +18,36 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
*/
class Page implements PageInterface
{
/**
* the number of item per page.
*
*/
protected int $itemPerPage;
/**
* the number of the current page.
*
* @var int
*/
protected int $number;
/**
* The route for the current page.
*
* @var string
*/
protected string $route;
/**
* Parameters for the route to the current page.
*
* @var array
*/
protected array $routeParameters;
/**
* The number of items in the whole iteration.
*
* @var int
*/
protected int $totalItems;
/**
* @var UrlGeneratorInterface
*/
protected $urlGenerator;
public function __construct(
int $number,
int $itemPerPage,
/**
* the number of the current page.
*/
protected int $number,
/**
* the number of item per page.
*
*/
protected int $itemPerPage,
UrlGeneratorInterface $urlGenerator,
string $route,
array $routeParameters,
int $totalItems
/**
* The route for the current page.
*/
protected string $route,
/**
* Parameters for the route to the current page.
*/
protected array $routeParameters,
/**
* The number of items in the whole iteration.
*/
protected int $totalItems
) {
$this->urlGenerator = $urlGenerator;
$this->number = $number;
$this->itemPerPage = $itemPerPage;
$this->route = $route;
$this->routeParameters = $routeParameters;
$this->totalItems = $totalItems;
}
public function generateUrl(): string

View File

@@ -20,11 +20,8 @@ class PageGenerator implements Iterator
{
protected int $current = 1;
protected Paginator $paginator;
public function __construct(Paginator $paginator)
public function __construct(protected Paginator $paginator)
{
$this->paginator = $paginator;
}
public function current(): Page

View File

@@ -22,80 +22,43 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
class Paginator implements PaginatorInterface
{
/**
* The number of the current page.
*
* @var int
* @param string[] $routeParameters
*/
protected int $currentPageNumber;
/**
* the number of items on a single page.
*
* @var int
*/
protected int $itemPerPage;
/**
* the key in the GET parameter to indicate the number of item per page.
*
* @var string
*/
protected string $itemPerPageKey;
/**
* the key in the GET parameter to indicate the page number in
* generated routes.
*
* @var string
*/
protected string $pageKey;
/**
* the route of the pages.
*
* @var string
*/
protected string $route;
/**
* the parameters of the route.
*
* @var string[]
*/
protected array $routeParameters;
/**
* The number of total items.
*
* @var int
*/
protected int $totalItems;
/**
* the generator for url.
*
* @var UrlGeneratorInterface
*/
protected UrlGeneratorInterface $urlGenerator;
public function __construct(
int $totalItems,
int $itemPerPage,
int $currentPageNumber,
string $route,
array $routeParameters,
UrlGeneratorInterface $urlGenerator,
string $pageKey,
string $itemPerPageKey
/**
* The number of total items.
*/
protected int $totalItems,
/**
* the number of items on a single page.
*/
protected int $itemPerPage,
/**
* The number of the current page.
*/
protected int $currentPageNumber,
/**
* the route of the pages.
*/
protected string $route,
/**
* the parameters of the route.
*/
protected array $routeParameters,
/**
* the generator for url.
*/
protected UrlGeneratorInterface $urlGenerator,
/**
* the key in the GET parameter to indicate the page number in
* generated routes.
*/
protected string $pageKey,
/**
* the key in the GET parameter to indicate the number of item per page.
*/
protected string $itemPerPageKey
) {
$this->totalItems = $totalItems;
$this->itemPerPage = $itemPerPage;
$this->currentPageNumber = $currentPageNumber;
$this->route = $route;
$this->routeParameters = $routeParameters;
$this->urlGenerator = $urlGenerator;
$this->pageKey = $pageKey;
$this->itemPerPageKey = $itemPerPageKey;
}
public function count(): int

Some files were not shown because too many files have changed in this diff Show More