Merge branch 'master' into upgrade-sf5

This commit is contained in:
2024-02-12 21:50:34 +01:00
920 changed files with 6430 additions and 1914 deletions

View File

@@ -15,10 +15,14 @@ use Chill\MainBundle\CRUD\Resolver\Resolver;
use Chill\MainBundle\Pagination\PaginatorFactory;
use Chill\MainBundle\Pagination\PaginatorInterface;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Doctrine\DBAL\LockMode;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\OptimisticLockException;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\ConflictHttpException;
use Symfony\Component\Serializer\SerializerInterface;
use Symfony\Component\Validator\Validator\ValidatorInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
@@ -143,7 +147,9 @@ abstract class AbstractCRUDController extends AbstractController
return new $class();
}
protected function customizeQuery(string $action, Request $request, $query): void {}
protected function customizeQuery(string $action, Request $request, $query): void
{
}
protected function getActionConfig(string $action)
{
@@ -172,6 +178,21 @@ abstract class AbstractCRUDController extends AbstractController
if (null === $e) {
throw $this->createNotFoundException(sprintf('The object %s for id %s is not found', $this->getEntityClass(), $id));
}
if ($request->query->has('entity_version')) {
$expectedVersion = $request->query->getInt('entity_version');
try {
$manager = $this->getDoctrine()->getManagerForClass($this->getEntityClass());
if ($manager instanceof EntityManagerInterface) {
$manager->lock($e, LockMode::OPTIMISTIC, $expectedVersion);
} else {
throw new \LogicException('This manager does not allow locking.');
}
} catch (OptimisticLockException $e) {
throw new ConflictHttpException('Sorry, but someone else has already changed this entity. Please refresh the page and apply the changes again', $e);
}
}
return $e;
}

View File

@@ -137,7 +137,7 @@ class ApiController extends AbstractCRUDController
try {
$entity = $this->deserialize($action, $request, $_format, $entity);
} catch (NotEncodableValueException $e) {
throw new BadRequestHttpException('invalid json', 400, $e);
throw new BadRequestHttpException('invalid json', $e, 400);
}
$errors = $this->validate($action, $request, $_format, $entity);
@@ -155,7 +155,7 @@ class ApiController extends AbstractCRUDController
return $response;
}
$this->managerRegistry->getManager()->flush();
$this->managerRegistry->getManagerForClass($this->getEntityClass())->flush();
$response = $this->onAfterFlush($action, $request, $_format, $entity, $errors);
@@ -177,7 +177,7 @@ class ApiController extends AbstractCRUDController
public function indexApi(Request $request, string $_format)
{
return match ($request->getMethod()) {
Request::METHOD_GET, REQUEST::METHOD_HEAD => $this->indexApiAction('_index', $request, $_format),
Request::METHOD_GET, Request::METHOD_HEAD => $this->indexApiAction('_index', $request, $_format),
default => throw $this->createNotFoundException('This method is not supported'),
};
}

View File

@@ -205,7 +205,7 @@ class CRUDController extends AbstractController
/**
* Count the number of entities.
*/
protected function countEntities(string $action, Request $request, FilterOrderHelper $filterOrder = null): int
protected function countEntities(string $action, Request $request, ?FilterOrderHelper $filterOrder = null): int
{
return $this->buildQueryEntities($action, $request)
->select('COUNT(e)')
@@ -234,7 +234,7 @@ class CRUDController extends AbstractController
* It is preferable to override customizeForm instead of overriding
* this method.
*/
protected function createFormFor(string $action, mixed $entity, string $formClass = null, array $formOptions = []): FormInterface
protected function createFormFor(string $action, mixed $entity, ?string $formClass = null, array $formOptions = []): FormInterface
{
$formClass ??= $this->getFormClassFor($action);
@@ -248,9 +248,13 @@ class CRUDController extends AbstractController
/**
* Customize the form created by createFormFor.
*/
protected function customizeForm(string $action, FormInterface $form) {}
protected function customizeForm(string $action, FormInterface $form)
{
}
protected function customizeQuery(string $action, Request $request, $query): void {}
protected function customizeQuery(string $action, Request $request, $query): void
{
}
/**
* @param null $formClass
@@ -483,7 +487,7 @@ class CRUDController extends AbstractController
*
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
*/
protected function formEditAction(string $action, Request $request, mixed $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);
@@ -685,7 +689,7 @@ class CRUDController extends AbstractController
Request $request,
int $totalItems,
PaginatorInterface $paginator,
FilterOrderHelper $filterOrder = null
?FilterOrderHelper $filterOrder = null
) {
$query = $this->queryEntities($action, $request, $paginator, $filterOrder);
@@ -695,7 +699,7 @@ class CRUDController extends AbstractController
/**
* @return \Chill\MainBundle\Entity\Center[]
*/
protected function getReachableCenters(string $role, Scope $scope = null)
protected function getReachableCenters(string $role, ?Scope $scope = null)
{
return $this->getAuthorizationHelper()
->getReachableCenters($this->getUser(), $role, $scope);
@@ -869,7 +873,9 @@ class CRUDController extends AbstractController
};
}
protected function onFormValid(string $action, object $entity, FormInterface $form, Request $request) {}
protected function onFormValid(string $action, object $entity, FormInterface $form, Request $request)
{
}
protected function onPostCheckACL($action, Request $request, $entity): ?Response
{
@@ -881,36 +887,58 @@ class CRUDController extends AbstractController
return null;
}
protected function onPostFlush(string $action, $entity, FormInterface $form, Request $request) {}
protected function onPostFlush(string $action, $entity, FormInterface $form, Request $request)
{
}
/**
* method used by indexAction.
*/
protected function onPostIndexBuildQuery(string $action, Request $request, int $totalItems, PaginatorInterface $paginator, mixed $query) {}
protected function onPostIndexBuildQuery(string $action, Request $request, int $totalItems, PaginatorInterface $paginator, mixed $query)
{
}
/**
* method used by indexAction.
*/
protected function onPostIndexFetchQuery(string $action, Request $request, int $totalItems, PaginatorInterface $paginator, mixed $entities) {}
protected function onPostIndexFetchQuery(string $action, Request $request, int $totalItems, PaginatorInterface $paginator, mixed $entities)
{
}
protected function onPostPersist(string $action, $entity, FormInterface $form, Request $request) {}
protected function onPostPersist(string $action, $entity, FormInterface $form, Request $request)
{
}
protected function onPostRemove(string $action, $entity, FormInterface $form, Request $request) {}
protected function onPostRemove(string $action, $entity, FormInterface $form, Request $request)
{
}
protected function onPreDelete(string $action, Request $request) {}
protected function onPreDelete(string $action, Request $request)
{
}
protected function onPreFlush(string $action, $entity, FormInterface $form, Request $request) {}
protected function onPreFlush(string $action, $entity, FormInterface $form, Request $request)
{
}
protected function onPreIndex(string $action, Request $request) {}
protected function onPreIndex(string $action, Request $request)
{
}
/**
* method used by indexAction.
*/
protected function onPreIndexBuildQuery(string $action, Request $request, int $totalItems, PaginatorInterface $paginator) {}
protected function onPreIndexBuildQuery(string $action, Request $request, int $totalItems, PaginatorInterface $paginator)
{
}
protected function onPrePersist(string $action, $entity, FormInterface $form, Request $request) {}
protected function onPrePersist(string $action, $entity, FormInterface $form, Request $request)
{
}
protected function onPreRemove(string $action, $entity, FormInterface $form, Request $request) {}
protected function onPreRemove(string $action, $entity, FormInterface $form, Request $request)
{
}
/**
* Add ordering fields in the query build by self::queryEntities.
@@ -935,7 +963,7 @@ class CRUDController extends AbstractController
*
* @return type
*/
protected function queryEntities(string $action, Request $request, PaginatorInterface $paginator, FilterOrderHelper $filterOrder = null)
protected function queryEntities(string $action, Request $request, PaginatorInterface $paginator, ?FilterOrderHelper $filterOrder = null)
{
$query = $this->buildQueryEntities($action, $request)
->setFirstResult($paginator->getCurrentPage()->getFirstItemNumber())

View File

@@ -16,4 +16,6 @@ use Symfony\Component\Form\AbstractType;
/**
* Class CRUDDeleteEntityForm.
*/
class CRUDDeleteEntityForm extends AbstractType {}
class CRUDDeleteEntityForm extends AbstractType
{
}

View File

@@ -57,12 +57,12 @@ class ChillUserSendRenewPasswordCodeCommand extends Command
/**
* The current input interface.
*/
private ?\Symfony\Component\Console\Input\InputInterface $input = null;
private ?InputInterface $input = null;
/**
* The current output interface.
*/
private ?\Symfony\Component\Console\Output\OutputInterface $output = null;
private ?OutputInterface $output = null;
public function __construct(
LoggerInterface $logger,

View File

@@ -194,8 +194,14 @@ class LoadPostalCodesCommand extends Command
}
}
class ExistingPostalCodeException extends \Exception {}
class ExistingPostalCodeException extends \Exception
{
}
class CountryCodeNotFoundException extends \Exception {}
class CountryCodeNotFoundException extends \Exception
{
}
class PostalCodeNotValidException extends \Exception {}
class PostalCodeNotValidException extends \Exception
{
}

View File

@@ -26,7 +26,9 @@ use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
final class AddressReferenceAPIController extends ApiController
{
public function __construct(private readonly AddressReferenceRepository $addressReferenceRepository, private readonly PaginatorFactory $paginatorFactory) {}
public function __construct(private readonly AddressReferenceRepository $addressReferenceRepository, private readonly PaginatorFactory $paginatorFactory)
{
}
/**
* @Route("/api/1.0/main/address-reference/by-postal-code/{id}/search.json")

View File

@@ -23,7 +23,9 @@ use Symfony\Component\Serializer\SerializerInterface;
class AddressToReferenceMatcherController
{
public function __construct(private readonly Security $security, private readonly EntityManagerInterface $entityManager, private readonly SerializerInterface $serializer) {}
public function __construct(private readonly Security $security, private readonly EntityManagerInterface $entityManager, private readonly SerializerInterface $serializer)
{
}
/**
* @Route("/api/1.0/main/address/reference-match/{id}/set/reviewed", methods={"POST"})

View File

@@ -334,7 +334,7 @@ class ExportController extends AbstractController
* When the method is POST, the form is stored if valid, and a redirection
* is done to next step.
*/
private function exportFormStep(Request $request, DirectExportInterface|ExportInterface $export, string $alias, SavedExport $savedExport = null): Response
private function exportFormStep(Request $request, DirectExportInterface|ExportInterface $export, string $alias, ?SavedExport $savedExport = null): Response
{
$exportManager = $this->exportManager;
@@ -392,7 +392,7 @@ class ExportController extends AbstractController
* If the form is posted and valid, store the data in session and
* redirect to the next step.
*/
private function formatterFormStep(Request $request, DirectExportInterface|ExportInterface $export, string $alias, SavedExport $savedExport = null): Response
private function formatterFormStep(Request $request, DirectExportInterface|ExportInterface $export, string $alias, ?SavedExport $savedExport = null): Response
{
// check we have data from the previous step (export step)
$data = $this->session->get('export_step', null);
@@ -521,7 +521,7 @@ class ExportController extends AbstractController
*
* @return Response
*/
private function selectCentersStep(Request $request, DirectExportInterface|ExportInterface $export, $alias, SavedExport $savedExport = null)
private function selectCentersStep(Request $request, DirectExportInterface|ExportInterface $export, $alias, ?SavedExport $savedExport = null)
{
if (!$this->filterStatsByCenters) {
return $this->redirectToRoute('chill_main_export_new', [

View File

@@ -24,7 +24,9 @@ use Symfony\Component\Serializer\SerializerInterface;
class GeographicalUnitByAddressApiController
{
public function __construct(private readonly PaginatorFactory $paginatorFactory, private readonly GeographicalUnitRepositoryInterface $geographicalUnitRepository, private readonly Security $security, private readonly SerializerInterface $serializer) {}
public function __construct(private readonly PaginatorFactory $paginatorFactory, private readonly GeographicalUnitRepositoryInterface $geographicalUnitRepository, private readonly Security $security, private readonly SerializerInterface $serializer)
{
}
/**
* @Route("/api/1.0/main/geographical-unit/by-address/{id}.{_format}", requirements={"_format": "json"})

View File

@@ -13,4 +13,6 @@ namespace Chill\MainBundle\Controller;
use Chill\MainBundle\CRUD\Controller\CRUDController;
class LocationTypeController extends CRUDController {}
class LocationTypeController extends CRUDController
{
}

View File

@@ -46,5 +46,7 @@ class LoginController extends AbstractController
]);
}
public function LoginCheckAction(Request $request) {}
public function LoginCheckAction(Request $request)
{
}
}

View File

@@ -31,7 +31,9 @@ use Symfony\Component\Serializer\SerializerInterface;
*/
class NotificationApiController
{
public function __construct(private readonly EntityManagerInterface $entityManager, private readonly NotificationRepository $notificationRepository, private readonly PaginatorFactory $paginatorFactory, private readonly Security $security, private readonly SerializerInterface $serializer) {}
public function __construct(private readonly EntityManagerInterface $entityManager, private readonly NotificationRepository $notificationRepository, private readonly PaginatorFactory $paginatorFactory, private readonly Security $security, private readonly SerializerInterface $serializer)
{
}
/**
* @Route("/{id}/mark/read", name="chill_api_main_notification_mark_read", methods={"POST"})

View File

@@ -40,7 +40,9 @@ use function in_array;
*/
class NotificationController extends AbstractController
{
public function __construct(private readonly EntityManagerInterface $em, private readonly LoggerInterface $chillLogger, private readonly LoggerInterface $logger, private readonly ChillSecurity $security, private readonly NotificationRepository $notificationRepository, private readonly NotificationHandlerManager $notificationHandlerManager, private readonly PaginatorFactory $paginatorFactory, private readonly TranslatorInterface $translator, private readonly UserRepository $userRepository, private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry) {}
public function __construct(private readonly EntityManagerInterface $em, private readonly LoggerInterface $chillLogger, private readonly LoggerInterface $logger, private readonly ChillSecurity $security, private readonly NotificationRepository $notificationRepository, private readonly NotificationHandlerManager $notificationHandlerManager, private readonly PaginatorFactory $paginatorFactory, private readonly TranslatorInterface $translator, private readonly UserRepository $userRepository, private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry)
{
}
/**
* @Route("/create", name="chill_main_notification_create")

View File

@@ -21,7 +21,9 @@ use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
class PermissionApiController extends AbstractController
{
public function __construct(private readonly DenormalizerInterface $denormalizer, private readonly Security $security) {}
public function __construct(private readonly DenormalizerInterface $denormalizer, private readonly Security $security)
{
}
/**
* @Route("/api/1.0/main/permissions/info.json", methods={"POST"})

View File

@@ -47,7 +47,8 @@ final class PermissionsGroupController extends AbstractController
private readonly EntityManagerInterface $em,
private readonly PermissionsGroupRepository $permissionsGroupRepository,
private readonly RoleScopeRepository $roleScopeRepository,
) {}
) {
}
/**
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/permissionsgroup/{id}/add_link_role_scope", name="admin_permissionsgroup_add_role_scope", methods={"PUT"})
@@ -399,7 +400,7 @@ final class PermissionsGroupController extends AbstractController
* get a role scope by his parameters. The role scope is persisted if it
* doesn't exist in database.
*/
protected function getPersistentRoleScopeBy(string $role, Scope $scope = null): RoleScope
protected function getPersistentRoleScopeBy(string $role, ?Scope $scope = null): RoleScope
{
$roleScope = $this->roleScopeRepository
->findOneBy(['role' => $role, 'scope' => $scope]);

View File

@@ -26,7 +26,9 @@ use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
final class PostalCodeAPIController extends ApiController
{
public function __construct(private readonly CountryRepository $countryRepository, private readonly PostalCodeRepositoryInterface $postalCodeRepository, private readonly PaginatorFactory $paginatorFactory) {}
public function __construct(private readonly CountryRepository $countryRepository, private readonly PostalCodeRepositoryInterface $postalCodeRepository, private readonly PaginatorFactory $paginatorFactory)
{
}
/**
* @Route("/api/1.0/main/postal-code/search.json")

View File

@@ -34,7 +34,9 @@ use Symfony\Contracts\Translation\TranslatorInterface;
class SavedExportController
{
public function __construct(private readonly \Twig\Environment $templating, private readonly EntityManagerInterface $entityManager, private readonly ExportManager $exportManager, private readonly FormFactoryInterface $formFactory, private readonly SavedExportRepositoryInterface $savedExportRepository, private readonly Security $security, private readonly SessionInterface $session, private readonly TranslatorInterface $translator, private readonly UrlGeneratorInterface $urlGenerator) {}
public function __construct(private readonly \Twig\Environment $templating, private readonly EntityManagerInterface $entityManager, private readonly ExportManager $exportManager, private readonly FormFactoryInterface $formFactory, private readonly SavedExportRepositoryInterface $savedExportRepository, private readonly Security $security, private readonly SessionInterface $session, private readonly TranslatorInterface $translator, private readonly UrlGeneratorInterface $urlGenerator)
{
}
/**
* @Route("/{_locale}/exports/saved/{id}/delete", name="chill_main_export_saved_delete")

View File

@@ -32,7 +32,9 @@ use Symfony\Contracts\Translation\TranslatorInterface;
*/
class SearchController extends AbstractController
{
public function __construct(protected SearchProvider $searchProvider, protected TranslatorInterface $translator, protected PaginatorFactory $paginatorFactory, protected SearchApi $searchApi) {}
public function __construct(protected SearchProvider $searchProvider, protected TranslatorInterface $translator, protected PaginatorFactory $paginatorFactory, protected SearchApi $searchApi)
{
}
/**
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/search/advanced/{name}", name="chill_main_advanced_search")

View File

@@ -20,7 +20,9 @@ use Symfony\Component\Security\Core\Security;
class TimelineCenterController extends AbstractController
{
public function __construct(protected TimelineBuilder $timelineBuilder, protected PaginatorFactory $paginatorFactory, private readonly Security $security) {}
public function __construct(protected TimelineBuilder $timelineBuilder, protected PaginatorFactory $paginatorFactory, private readonly Security $security)
{
}
/**
* @Route("/{_locale}/center/timeline",

View File

@@ -48,7 +48,9 @@ class UserController extends CRUDController
private readonly TranslatorInterface $translator,
private readonly ChillSecurity $security,
private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry
) {}
)
{
}
/**
* @Route("/{_locale}/admin/main/user/{uid}/add_link_groupcenter",
@@ -276,7 +278,7 @@ class UserController extends CRUDController
->build();
}
protected function countEntities(string $action, Request $request, FilterOrderHelper $filterOrder = null): int
protected function countEntities(string $action, Request $request, ?FilterOrderHelper $filterOrder = null): int
{
if (!$filterOrder instanceof FilterOrderHelper) {
return parent::countEntities($action, $request, $filterOrder);
@@ -289,7 +291,7 @@ class UserController extends CRUDController
return $this->userRepository->countByUsernameOrEmail($filterOrder->getQueryString());
}
protected function createFormFor(string $action, $entity, string $formClass = null, array $formOptions = []): FormInterface
protected function createFormFor(string $action, $entity, ?string $formClass = null, array $formOptions = []): FormInterface
{
// for "new", add special config
if ('new' === $action) {
@@ -333,7 +335,7 @@ class UserController extends CRUDController
Request $request,
int $totalItems,
PaginatorInterface $paginator,
FilterOrderHelper $filterOrder = null
?FilterOrderHelper $filterOrder = null
) {
if (0 === $totalItems) {
return [];

View File

@@ -27,7 +27,8 @@ final readonly class UserExportController
private UserRepositoryInterface $userRepository,
private Security $security,
private TranslatorInterface $translator,
) {}
) {
}
/**
* @throws \League\Csv\CannotInsertRecord

View File

@@ -21,7 +21,8 @@ class UserJobScopeHistoriesController extends AbstractController
{
public function __construct(
private readonly Environment $engine,
) {}
) {
}
/**
* @Route("/{_locale}/admin/main/user/{id}/job-scope-history", name="admin_user_job_scope_history")

View File

@@ -28,7 +28,8 @@ final class UserProfileController extends AbstractController
private readonly TranslatorInterface $translator,
private readonly ChillSecurity $security,
private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry,
) {}
) {
}
/**
* User profile that allows editing of phonenumber and visualization of certain data.

View File

@@ -29,7 +29,9 @@ use Symfony\Component\Serializer\SerializerInterface;
class WorkflowApiController
{
public function __construct(private readonly EntityManagerInterface $entityManager, private readonly EntityWorkflowRepository $entityWorkflowRepository, private readonly PaginatorFactory $paginatorFactory, private readonly Security $security, private readonly SerializerInterface $serializer) {}
public function __construct(private readonly EntityManagerInterface $entityManager, private readonly EntityWorkflowRepository $entityWorkflowRepository, private readonly PaginatorFactory $paginatorFactory, private readonly Security $security, private readonly SerializerInterface $serializer)
{
}
/**
* Return a list of workflow which are waiting an action for the user.

View File

@@ -38,7 +38,9 @@ use Symfony\Contracts\Translation\TranslatorInterface;
class WorkflowController extends AbstractController
{
public function __construct(private readonly EntityWorkflowManager $entityWorkflowManager, private readonly EntityWorkflowRepository $entityWorkflowRepository, private readonly ValidatorInterface $validator, private readonly PaginatorFactory $paginatorFactory, private readonly Registry $registry, private readonly EntityManagerInterface $entityManager, private readonly TranslatorInterface $translator, private readonly ChillSecurity $security, private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry) {}
public function __construct(private readonly EntityWorkflowManager $entityWorkflowManager, private readonly EntityWorkflowRepository $entityWorkflowRepository, private readonly ValidatorInterface $validator, private readonly PaginatorFactory $paginatorFactory, private readonly Registry $registry, private readonly EntityManagerInterface $entityManager, private readonly TranslatorInterface $translator, private readonly ChillSecurity $security, private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry)
{
}
/**
* @Route("/{_locale}/main/workflow/create", name="chill_main_workflow_create")

View File

@@ -28,5 +28,5 @@ interface CronJobInterface
*
* @return array|null optionally return an array with the same data than the previous execution
*/
public function run(array $lastExecutionData): null|array;
public function run(array $lastExecutionData): array|null;
}

View File

@@ -55,9 +55,10 @@ final readonly class CronManager implements CronManagerInterface
private EntityManagerInterface $entityManager,
private iterable $jobs,
private LoggerInterface $logger
) {}
) {
}
public function run(string $forceJob = null): void
public function run(?string $forceJob = null): void
{
if (null !== $forceJob) {
$this->runForce($forceJob);

View File

@@ -16,5 +16,5 @@ interface CronManagerInterface
/**
* Execute one job, with a given priority, or the given job (identified by his key).
*/
public function run(string $forceJob = null): void;
public function run(?string $forceJob = null): void;
}

View File

@@ -26,7 +26,7 @@ class LoadAddressReferences extends AbstractFixture implements ContainerAwareInt
{
protected $faker;
private ?\Symfony\Component\DependencyInjection\ContainerInterface $container = null;
private ?ContainerInterface $container = null;
public function __construct()
{
@@ -50,7 +50,7 @@ class LoadAddressReferences extends AbstractFixture implements ContainerAwareInt
$manager->flush();
}
public function setContainer(ContainerInterface $container = null)
public function setContainer(?ContainerInterface $container = null)
{
$this->container = $container;
}

View File

@@ -23,7 +23,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
*/
class LoadCountries extends AbstractFixture implements ContainerAwareInterface, OrderedFixtureInterface
{
private ?\Symfony\Component\DependencyInjection\ContainerInterface $container = null;
private ?ContainerInterface $container = null;
public function getOrder()
{
@@ -43,7 +43,7 @@ class LoadCountries extends AbstractFixture implements ContainerAwareInterface,
$manager->flush();
}
public function setContainer(ContainerInterface $container = null)
public function setContainer(?ContainerInterface $container = null)
{
$this->container = $container;
}

View File

@@ -27,7 +27,7 @@ class LoadLanguages extends AbstractFixture implements ContainerAwareInterface,
private array $ancientToExclude = ['ang', 'egy', 'fro', 'goh', 'grc', 'la', 'non', 'peo', 'pro', 'sga',
'dum', 'enm', 'frm', 'gmh', 'mga', 'akk', 'phn', 'zxx', 'got', 'und', ];
private ?\Symfony\Component\DependencyInjection\ContainerInterface $container = null;
private ?ContainerInterface $container = null;
// The regional version of language are language with _ in the code
// This array contains regional code to not exclude
@@ -57,7 +57,7 @@ class LoadLanguages extends AbstractFixture implements ContainerAwareInterface,
$manager->flush();
}
public function setContainer(ContainerInterface $container = null)
public function setContainer(?ContainerInterface $container = null)
{
$this->container = $container;
}

View File

@@ -23,7 +23,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
*/
class LoadLocationType extends AbstractFixture implements ContainerAwareInterface, OrderedFixtureInterface
{
private ?\Symfony\Component\DependencyInjection\ContainerInterface $container = null;
private ?ContainerInterface $container = null;
public function getOrder()
{
@@ -65,7 +65,7 @@ class LoadLocationType extends AbstractFixture implements ContainerAwareInterfac
$manager->flush();
}
public function setContainer(ContainerInterface $container = null)
public function setContainer(?ContainerInterface $container = null)
{
$this->container = $container;
}

View File

@@ -53,7 +53,7 @@ class LoadUsers extends AbstractFixture implements ContainerAwareInterface, Orde
],
];
private ?\Symfony\Component\DependencyInjection\ContainerInterface $container = null;
private ?ContainerInterface $container = null;
public function getOrder()
{
@@ -92,7 +92,7 @@ class LoadUsers extends AbstractFixture implements ContainerAwareInterface, Orde
$manager->flush();
}
public function setContainer(ContainerInterface $container = null)
public function setContainer(?ContainerInterface $container = null)
{
if (null === $container) {
throw new \LogicException('$container should not be null');

View File

@@ -261,7 +261,7 @@ class ChillMainExtension extends Extension implements
'ST_X' => STX::class,
'ST_Y' => STY::class,
'GREATEST' => Greatest::class,
'LEAST' => LEAST::class,
'LEAST' => Least::class,
],
'datetime_functions' => [
'EXTRACT' => Extract::class,

View File

@@ -29,7 +29,7 @@ class Extract extends FunctionNode
{
private string $field;
private null|\Doctrine\ORM\Query\AST\Node|string $value = null;
private \Doctrine\ORM\Query\AST\Node|string|null $value = null;
// private PathExpression $value;
// private FunctionNode $value;
// private DateDiffFunction $value;

View File

@@ -18,7 +18,7 @@ use Doctrine\ORM\Query\SqlWalker;
class JsonExtract extends FunctionNode
{
private null|\Doctrine\ORM\Query\AST\Node|string $element = null;
private \Doctrine\ORM\Query\AST\Node|string|null $element = null;
private ?\Doctrine\ORM\Query\AST\ArithmeticExpression $keyToExtract = null;

View File

@@ -23,7 +23,7 @@ class ToChar extends FunctionNode
{
private ?\Doctrine\ORM\Query\AST\ArithmeticExpression $datetime = null;
private null|\Doctrine\ORM\Query\AST\Node|string $fmt = null;
private \Doctrine\ORM\Query\AST\Node|string|null $fmt = null;
public function getSql(SqlWalker $sqlWalker)
{

View File

@@ -21,7 +21,9 @@ use Symfony\Component\Security\Core\Security;
class TrackCreateUpdateSubscriber implements EventSubscriber
{
public function __construct(private readonly Security $security) {}
public function __construct(private readonly Security $security)
{
}
public function getSubscribedEvents()
{

View File

@@ -15,7 +15,9 @@ class Point implements \JsonSerializable
{
public static string $SRID = '4326';
private function __construct(private readonly ?float $lon, private readonly ?float $lat) {}
private function __construct(private readonly ?float $lon, private readonly ?float $lat)
{
}
public static function fromArrayGeoJson(array $array): self
{

View File

@@ -39,7 +39,7 @@ final class FlatHierarchyEntityHydrator extends ObjectHydrator
);
}
private function flatListGenerator(array $hashMap, object $parent = null): \Generator
private function flatListGenerator(array $hashMap, ?object $parent = null): \Generator
{
$parent = null === $parent ? null : spl_object_id($parent);
$hashMap += [$parent => []];

View File

@@ -440,7 +440,7 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
return $this->getIsNoAddress();
}
public function setAddressReference(AddressReference $addressReference = null): Address
public function setAddressReference(?AddressReference $addressReference = null): Address
{
$this->addressReference = $addressReference;
@@ -529,7 +529,7 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
*
* @return Address
*/
public function setPostcode(PostalCode $postcode = null)
public function setPostcode(?PostalCode $postcode = null)
{
$this->postcode = $postcode;
@@ -620,7 +620,7 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
return $this;
}
public function setValidTo(\DateTimeInterface $validTo = null): self
public function setValidTo(?\DateTimeInterface $validTo = null): self
{
$this->validTo = $validTo;

View File

@@ -219,7 +219,7 @@ class AddressReference
*
* @return Address
*/
public function setPostcode(PostalCode $postcode = null)
public function setPostcode(?PostalCode $postcode = null)
{
$this->postcode = $postcode;

View File

@@ -53,5 +53,6 @@ class SimpleGeographicalUnitDTO
* @Serializer\Groups({"read"})
*/
public int $layerId
) {}
) {
}
}

View File

@@ -59,7 +59,7 @@ class PostalCode implements TrackUpdateInterface, TrackCreationInterface
*
* @groups({"read"})
*/
private ?\Chill\MainBundle\Doctrine\Model\Point $center = null;
private ?Point $center = null;
/**
* @ORM\Column(type="string", length=100)
@@ -73,7 +73,7 @@ class PostalCode implements TrackUpdateInterface, TrackCreationInterface
*
* @groups({"write", "read"})
*/
private ?\Chill\MainBundle\Entity\Country $country = null;
private ?Country $country = null;
/**
* @ORM\Column(type="datetime_immutable", nullable=true, options={"default": null})
@@ -210,7 +210,7 @@ class PostalCode implements TrackUpdateInterface, TrackCreationInterface
*
* @return PostalCode
*/
public function setCountry(Country $country = null)
public function setCountry(?Country $country = null)
{
$this->country = $country;

View File

@@ -78,14 +78,14 @@ class RoleScope
return $this->scope;
}
public function setRole(string $role = null): self
public function setRole(?string $role = null): self
{
$this->role = $role;
return $this;
}
public function setScope(Scope $scope = null): self
public function setScope(?Scope $scope = null): self
{
$this->scope = $scope;

View File

@@ -198,7 +198,9 @@ class User implements UserInterface, \Stringable, PasswordAuthenticatedUserInter
return $this;
}
public function eraseCredentials() {}
public function eraseCredentials()
{
}
public function getAbsenceStart(): ?\DateTimeImmutable
{
@@ -273,7 +275,7 @@ class User implements UserInterface, \Stringable, PasswordAuthenticatedUserInter
return $this->mainLocation;
}
public function getMainScope(\DateTimeImmutable $at = null): ?Scope
public function getMainScope(?\DateTimeImmutable $at = null): ?Scope
{
$at ??= new \DateTimeImmutable('now');
@@ -322,7 +324,7 @@ class User implements UserInterface, \Stringable, PasswordAuthenticatedUserInter
return $this->salt;
}
public function getUserJob(\DateTimeImmutable $at = null): ?UserJob
public function getUserJob(?\DateTimeImmutable $at = null): ?UserJob
{
$at ??= new \DateTimeImmutable('now');

View File

@@ -26,7 +26,8 @@ final readonly class ExportFormHelper
private AuthorizationHelperForCurrentUserInterface $authorizationHelper,
private ExportManager $exportManager,
private FormFactoryInterface $formFactory,
) {}
) {
}
public function getDefaultData(string $step, DirectExportInterface|ExportInterface $export, array $options = []): array
{

View File

@@ -89,7 +89,7 @@ class ExportManager
*
* @return FilterInterface[] a \Generator that contains filters. The key is the filter's alias
*/
public function getFiltersApplyingOn(DirectExportInterface|ExportInterface $export, array $centers = null): array
public function getFiltersApplyingOn(DirectExportInterface|ExportInterface $export, ?array $centers = null): array
{
if ($export instanceof DirectExportInterface) {
return [];
@@ -116,7 +116,7 @@ class ExportManager
*
* @return array<string, AggregatorInterface> an array that contains aggregators. The key is the filter's alias
*/
public function getAggregatorsApplyingOn(DirectExportInterface|ExportInterface $export, array $centers = null): array
public function getAggregatorsApplyingOn(DirectExportInterface|ExportInterface $export, ?array $centers = null): array
{
if ($export instanceof ListInterface || $export instanceof DirectExportInterface) {
return [];
@@ -450,8 +450,8 @@ class ExportManager
*/
public function isGrantedForElement(
DirectExportInterface|ExportInterface|ModifierInterface $element,
DirectExportInterface|ExportInterface $export = null,
array $centers = null
DirectExportInterface|ExportInterface|null $export = null,
?array $centers = null
): bool {
if ($element instanceof ExportInterface || $element instanceof DirectExportInterface) {
$role = $element->requiredRole();

View File

@@ -15,7 +15,9 @@ use Symfony\Contracts\Translation\TranslatorInterface;
class DateTimeHelper
{
public function __construct(private readonly TranslatorInterface $translator) {}
public function __construct(private readonly TranslatorInterface $translator)
{
}
public function getLabel($header): callable
{

View File

@@ -79,7 +79,9 @@ class ExportAddressHelper
*/
private ?array $unitRefsKeysCache = [];
public function __construct(private readonly AddressRender $addressRender, private readonly AddressRepository $addressRepository, private readonly GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository, private readonly TranslatableStringHelperInterface $translatableStringHelper) {}
public function __construct(private readonly AddressRender $addressRender, private readonly AddressRepository $addressRepository, private readonly GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository, private readonly TranslatableStringHelperInterface $translatableStringHelper)
{
}
public function addSelectClauses(int $params, QueryBuilder $queryBuilder, $entityName = 'address', $prefix = 'add')
{

View File

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

View File

@@ -16,7 +16,9 @@ use Chill\MainBundle\Templating\Entity\UserRender;
class UserHelper
{
public function __construct(private readonly UserRender $userRender, private readonly UserRepositoryInterface $userRepository) {}
public function __construct(private readonly UserRender $userRender, private readonly UserRepositoryInterface $userRepository)
{
}
/**
* Return a callable that will transform a value into a string representing a user.
@@ -32,7 +34,7 @@ class UserHelper
*/
public function getLabel($key, array $values, string $header): callable
{
return function (null|int|string $value) use ($header) {
return function (int|string|null $value) use ($header) {
if ('_header' === $value) {
return $header;
}

View File

@@ -20,4 +20,6 @@ namespace Chill\MainBundle\Export;
*
* When used, the `ExportManager` will not handle aggregator for this class.
*/
interface ListInterface extends ExportInterface {}
interface ListInterface extends ExportInterface
{
}

View File

@@ -17,7 +17,8 @@ final readonly class SortExportElement
{
public function __construct(
private TranslatorInterface $translator,
) {}
) {
}
/**
* @param array<int|string, FilterInterface> $elements

View File

@@ -46,7 +46,7 @@ class PostalCodeChoiceLoader implements ChoiceLoaderInterface
{
return new \Symfony\Component\Form\ChoiceList\ArrayChoiceList(
$this->lazyLoadedPostalCodes,
static fn (PostalCode $pc = null) => \call_user_func($value, $pc)
static fn (?PostalCode $pc = null) => \call_user_func($value, $pc)
);
}

View File

@@ -19,7 +19,9 @@ use Symfony\Component\Security\Core\Security;
final class PrivateCommentDataMapper extends AbstractType implements DataMapperInterface
{
public function __construct(private readonly Security $security) {}
public function __construct(private readonly Security $security)
{
}
public function mapDataToForms($viewData, iterable $forms)
{

View File

@@ -16,7 +16,9 @@ use Symfony\Component\Form\DataMapperInterface;
class ScopePickerDataMapper implements DataMapperInterface
{
public function __construct(private readonly ?Scope $scope = null) {}
public function __construct(private readonly ?Scope $scope = null)
{
}
public function mapDataToForms($data, iterable $forms)
{

View File

@@ -35,7 +35,7 @@ class IdToEntityDataTransformer implements DataTransformerInterface
public function __construct(
private readonly ObjectRepository $repository,
private readonly bool $multiple = false,
callable $getId = null
?callable $getId = null
) {
$this->getId = $getId ?? static fn (object $o) => $o->getId();
}

View File

@@ -17,7 +17,9 @@ class CustomizeFormEvent extends \Symfony\Contracts\EventDispatcher\Event
{
final public const NAME = 'chill_main.customize_form';
public function __construct(protected string $type, protected FormBuilderInterface $builder) {}
public function __construct(protected string $type, protected FormBuilderInterface $builder)
{
}
public function getBuilder(): FormBuilderInterface
{

View File

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

View File

@@ -13,6 +13,7 @@ namespace Chill\MainBundle\Form\Type;
use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Entity\PermissionsGroup;
use Doctrine\ORM\EntityRepository;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
@@ -27,7 +28,13 @@ class ComposedGroupCenterType extends AbstractType
'choice_label' => static fn (PermissionsGroup $group) => $group->getName(),
])->add('center', EntityType::class, [
'class' => Center::class,
'choice_label' => static fn (Center $center) => $center->getName(),
'query_builder' => static function (EntityRepository $er) {
$qb = $er->createQueryBuilder('c');
$qb->where($qb->expr()->eq('c.isActive', 'TRUE'))
->orderBy('c.name', 'ASC');
return $qb;
},
]);
}

View File

@@ -26,7 +26,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
*/
class ComposedRoleScopeType extends AbstractType
{
private readonly \Chill\MainBundle\Security\RoleProvider $roleProvider;
private readonly RoleProvider $roleProvider;
/**
* @var string[]

View File

@@ -17,7 +17,9 @@ use Symfony\Component\Form\Exception\TransformationFailedException;
final readonly class AddressToIdDataTransformer implements DataTransformerInterface
{
public function __construct(private AddressRepository $addressRepository) {}
public function __construct(private AddressRepository $addressRepository)
{
}
public function reverseTransform($value)
{

View File

@@ -20,7 +20,9 @@ use Symfony\Component\Form\Exception\UnexpectedTypeException;
class CenterTransformer implements DataTransformerInterface
{
public function __construct(private readonly CenterRepository $centerRepository, private readonly bool $multiple = false) {}
public function __construct(private readonly CenterRepository $centerRepository, private readonly bool $multiple = false)
{
}
public function reverseTransform($id)
{

View File

@@ -22,7 +22,9 @@ use Symfony\Component\Serializer\SerializerInterface;
class EntityToJsonTransformer implements DataTransformerInterface
{
public function __construct(private readonly DenormalizerInterface $denormalizer, private readonly SerializerInterface $serializer, private readonly bool $multiple, private readonly string $type) {}
public function __construct(private readonly DenormalizerInterface $denormalizer, private readonly SerializerInterface $serializer, private readonly bool $multiple, private readonly string $type)
{
}
public function reverseTransform($value)
{

View File

@@ -17,7 +17,9 @@ use Symfony\Component\Form\DataTransformerInterface;
class MultipleObjectsToIdTransformer implements DataTransformerInterface
{
public function __construct(private readonly EntityManagerInterface $em, private readonly ?string $class = null) {}
public function __construct(private readonly EntityManagerInterface $em, private readonly ?string $class = null)
{
}
/**
* Transforms a string (id) to an object (item).

View File

@@ -17,7 +17,9 @@ use Symfony\Component\Form\Exception\TransformationFailedException;
class ObjectToIdTransformer implements DataTransformerInterface
{
public function __construct(private readonly EntityManagerInterface $em, private readonly ?string $class = null) {}
public function __construct(private readonly EntityManagerInterface $em, private readonly ?string $class = null)
{
}
/**
* Transforms a string (id) to an object.

View File

@@ -18,7 +18,9 @@ use Symfony\Component\Form\Exception\TransformationFailedException;
class PostalCodeToIdTransformer implements DataTransformerInterface
{
public function __construct(private readonly PostalCodeRepositoryInterface $postalCodeRepository) {}
public function __construct(private readonly PostalCodeRepositoryInterface $postalCodeRepository)
{
}
public function reverseTransform($value)
{

View File

@@ -18,7 +18,9 @@ use Symfony\Component\Form\Exception\TransformationFailedException;
class ScopeTransformer implements DataTransformerInterface
{
public function __construct(private readonly EntityManagerInterface $em) {}
public function __construct(private readonly EntityManagerInterface $em)
{
}
public function reverseTransform($id)
{

View File

@@ -19,7 +19,9 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class AggregatorType extends AbstractType
{
public function __construct() {}
public function __construct()
{
}
public function buildForm(FormBuilderInterface $builder, array $options)
{

View File

@@ -29,7 +29,9 @@ class ExportType extends AbstractType
final public const PICK_FORMATTER_KEY = 'pick_formatter';
public function __construct(private readonly ExportManager $exportManager, private readonly SortExportElement $sortExportElement) {}
public function __construct(private readonly ExportManager $exportManager, private readonly SortExportElement $sortExportElement)
{
}
public function buildForm(FormBuilderInterface $builder, array $options)
{

View File

@@ -22,7 +22,9 @@ class FilterType extends AbstractType
{
final public const ENABLED_FIELD = 'enabled';
public function __construct() {}
public function __construct()
{
}
public function buildForm(FormBuilderInterface $builder, array $options)
{

View File

@@ -33,7 +33,8 @@ final class PickCenterType extends AbstractType
private readonly ExportManager $exportManager,
private readonly RegroupmentRepository $regroupmentRepository,
private readonly AuthorizationHelperForCurrentUserInterface $authorizationHelper
) {}
) {
}
public function buildForm(FormBuilderInterface $builder, array $options)
{

View File

@@ -41,7 +41,9 @@ use Symfony\Contracts\Translation\TranslatorInterface;
*/
final class PickAddressType extends AbstractType
{
public function __construct(private readonly AddressToIdDataTransformer $addressToIdDataTransformer, private readonly TranslatorInterface $translator) {}
public function __construct(private readonly AddressToIdDataTransformer $addressToIdDataTransformer, private readonly TranslatorInterface $translator)
{
}
public function buildForm(FormBuilderInterface $builder, array $options)
{

View File

@@ -34,7 +34,9 @@ use function count;
*/
class PickCenterType extends AbstractType
{
public function __construct(protected AuthorizationHelperInterface $authorizationHelper, protected Security $security, protected CenterRepository $centerRepository) {}
public function __construct(protected AuthorizationHelperInterface $authorizationHelper, protected Security $security, protected CenterRepository $centerRepository)
{
}
/**
* add a data transformer if user can reach only one center.

View File

@@ -21,7 +21,9 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class PickCivilityType extends AbstractType
{
public function __construct(private readonly TranslatableStringHelper $translatableStringHelper) {}
public function __construct(private readonly TranslatableStringHelper $translatableStringHelper)
{
}
public function configureOptions(OptionsResolver $resolver)
{

View File

@@ -19,7 +19,9 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class PickLocationTypeType extends AbstractType
{
public function __construct(private readonly TranslatableStringHelper $translatableStringHelper) {}
public function __construct(private readonly TranslatableStringHelper $translatableStringHelper)
{
}
public function configureOptions(OptionsResolver $resolver)
{

View File

@@ -21,7 +21,9 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class PickPostalCodeType extends AbstractType
{
public function __construct(private readonly PostalCodeToIdTransformer $postalCodeToIdTransformer) {}
public function __construct(private readonly PostalCodeToIdTransformer $postalCodeToIdTransformer)
{
}
public function buildForm(FormBuilderInterface $builder, array $options)
{

View File

@@ -27,7 +27,9 @@ use Symfony\Component\Serializer\SerializerInterface;
*/
class PickUserDynamicType extends AbstractType
{
public function __construct(private readonly DenormalizerInterface $denormalizer, private readonly SerializerInterface $serializer, private readonly NormalizerInterface $normalizer) {}
public function __construct(private readonly DenormalizerInterface $denormalizer, private readonly SerializerInterface $serializer, private readonly NormalizerInterface $normalizer)
{
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
@@ -40,6 +42,8 @@ class PickUserDynamicType extends AbstractType
$view->vars['types'] = ['user'];
$view->vars['uniqid'] = uniqid('pick_user_dyn');
$view->vars['suggested'] = [];
$view->vars['as_id'] = true === $options['as_id'] ? '1' : '0';
$view->vars['submit_on_adding_new_entity'] = true === $options['submit_on_adding_new_entity'] ? '1' : '0';
foreach ($options['suggested'] as $user) {
$view->vars['suggested'][] = $this->normalizer->normalize($user, 'json', ['groups' => 'read']);
@@ -52,7 +56,12 @@ class PickUserDynamicType extends AbstractType
->setDefault('multiple', false)
->setAllowedTypes('multiple', ['bool'])
->setDefault('compound', false)
->setDefault('suggested', []);
->setDefault('suggested', [])
// if set to true, only the id will be set inside the content. The denormalization will not work.
->setDefault('as_id', false)
->setAllowedTypes('as_id', ['bool'])
->setDefault('submit_on_adding_new_entity', false)
->setAllowedTypes('submit_on_adding_new_entity', ['bool']);
}
public function getBlockPrefix()

View File

@@ -20,7 +20,9 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class PickUserLocationType extends AbstractType
{
public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, private readonly LocationRepository $locationRepository) {}
public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, private readonly LocationRepository $locationRepository)
{
}
public function configureOptions(OptionsResolver $resolver)
{

View File

@@ -21,7 +21,9 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class PrivateCommentType extends AbstractType
{
public function __construct(protected PrivateCommentDataMapper $dataMapper) {}
public function __construct(protected PrivateCommentDataMapper $dataMapper)
{
}
public function buildForm(FormBuilderInterface $builder, array $options)
{

View File

@@ -43,7 +43,9 @@ class ScopePickerType extends AbstractType
private readonly AuthorizationHelperInterface $authorizationHelper,
private readonly Security $security,
private readonly TranslatableStringHelperInterface $translatableStringHelper
) {}
)
{
}
public function buildForm(FormBuilderInterface $builder, array $options)
{

View File

@@ -26,7 +26,9 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
*/
class Select2CountryType extends AbstractType
{
public function __construct(private readonly RequestStack $requestStack, private readonly ObjectManager $em, protected TranslatableStringHelper $translatableStringHelper, protected ParameterBagInterface $parameterBag) {}
public function __construct(private readonly RequestStack $requestStack, private readonly ObjectManager $em, protected TranslatableStringHelper $translatableStringHelper, protected ParameterBagInterface $parameterBag)
{
}
public function buildForm(FormBuilderInterface $builder, array $options)
{

View File

@@ -26,7 +26,9 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
*/
class Select2LanguageType extends AbstractType
{
public function __construct(private readonly RequestStack $requestStack, private readonly ObjectManager $em, protected TranslatableStringHelper $translatableStringHelper, protected ParameterBagInterface $parameterBag) {}
public function __construct(private readonly RequestStack $requestStack, private readonly ObjectManager $em, protected TranslatableStringHelper $translatableStringHelper, protected ParameterBagInterface $parameterBag)
{
}
public function buildForm(FormBuilderInterface $builder, array $options)
{

View File

@@ -36,7 +36,9 @@ use Symfony\Component\Validator\Constraints\Regex;
class UserType extends AbstractType
{
public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, protected ParameterBagInterface $parameterBag) {}
public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, protected ParameterBagInterface $parameterBag)
{
}
public function buildForm(FormBuilderInterface $builder, array $options)
{

View File

@@ -34,7 +34,9 @@ use Symfony\Component\Workflow\Transition;
class WorkflowStepType extends AbstractType
{
public function __construct(private readonly EntityWorkflowManager $entityWorkflowManager, private readonly Registry $registry, private readonly TranslatableStringHelperInterface $translatableStringHelper) {}
public function __construct(private readonly EntityWorkflowManager $entityWorkflowManager, private readonly Registry $registry, private readonly TranslatableStringHelperInterface $translatableStringHelper)
{
}
public function buildForm(FormBuilderInterface $builder, array $options)
{

View File

@@ -17,13 +17,16 @@ use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Repository\NotificationRepository;
use Chill\MainBundle\Templating\UI\NotificationCounterInterface;
use Doctrine\ORM\Event\PostPersistEventArgs;
use Doctrine\ORM\Event\PostUpdateEventArgs;
use Doctrine\ORM\Event\PreFlushEventArgs;
use Psr\Cache\CacheItemPoolInterface;
use Symfony\Component\Security\Core\User\UserInterface;
final readonly class NotificationByUserCounter implements NotificationCounterInterface
{
public function __construct(private CacheItemPoolInterface $cacheItemPool, private NotificationRepository $notificationRepository) {}
public function __construct(private CacheItemPoolInterface $cacheItemPool, private NotificationRepository $notificationRepository)
{
}
public function addNotification(UserInterface $u): int
{
@@ -60,7 +63,12 @@ final readonly class NotificationByUserCounter implements NotificationCounterInt
return 'chill_main_notif_unread_by_'.$user->getId();
}
public function onEditNotificationComment(NotificationComment $notificationComment, PostPersistEventArgs $eventArgs): void
public function onPersistNotificationComment(NotificationComment $notificationComment, PostPersistEventArgs $eventArgs): void
{
$this->resetCacheForNotification($notificationComment->getNotification());
}
public function onEditNotificationComment(NotificationComment $notificationComment, PostUpdateEventArgs $eventArgs): void
{
$this->resetCacheForNotification($notificationComment->getNotification());
}

View File

@@ -24,7 +24,9 @@ use Symfony\Contracts\Translation\TranslatorInterface;
class NotificationMailer
{
public function __construct(private readonly MailerInterface $mailer, private readonly LoggerInterface $logger, private readonly TranslatorInterface $translator) {}
public function __construct(private readonly MailerInterface $mailer, private readonly LoggerInterface $logger, private readonly TranslatorInterface $translator)
{
}
public function postPersistComment(NotificationComment $comment, PostPersistEventArgs $eventArgs): void
{

View File

@@ -18,7 +18,9 @@ use Symfony\Component\HttpKernel\Event\TerminateEvent;
class PersistNotificationOnTerminateEventSubscriber implements EventSubscriberInterface
{
public function __construct(private readonly EntityManagerInterface $em, private readonly NotificationPersisterInterface $persister) {}
public function __construct(private readonly EntityManagerInterface $em, private readonly NotificationPersisterInterface $persister)
{
}
public static function getSubscribedEvents()
{

View File

@@ -11,4 +11,6 @@ declare(strict_types=1);
namespace Chill\MainBundle\Notification\Exception;
class NotificationHandlerNotFound extends \RuntimeException {}
class NotificationHandlerNotFound extends \RuntimeException
{
}

View File

@@ -34,7 +34,9 @@ class Mailer
*
* @param mixed[] $routeParameters
*/
public function __construct(private readonly MailerInterface $mailer, private readonly LoggerInterface $logger, private readonly Environment $twig, private readonly RouterInterface $router, private readonly TranslatorInterface $translator, protected $routeParameters) {}
public function __construct(private readonly MailerInterface $mailer, private readonly LoggerInterface $logger, private readonly Environment $twig, private readonly RouterInterface $router, private readonly TranslatorInterface $translator, protected $routeParameters)
{
}
/**
* @return string
@@ -72,7 +74,7 @@ class Mailer
mixed $recipient,
array $subject,
array $bodies,
callable $callback = null,
?callable $callback = null,
mixed $force = false
) {
$fromEmail = $this->routeParameters['from_email'];

View File

@@ -17,7 +17,9 @@ use Doctrine\ORM\EntityManagerInterface;
final readonly class NotificationHandlerManager
{
public function __construct(private iterable $handlers, private EntityManagerInterface $em) {}
public function __construct(private iterable $handlers, private EntityManagerInterface $em)
{
}
/**
* @throw NotificationHandlerNotFound if handler is not found

View File

@@ -23,7 +23,9 @@ class NotificationPresence
{
private array $cache = [];
public function __construct(private readonly Security $security, private readonly NotificationRepository $notificationRepository) {}
public function __construct(private readonly Security $security, private readonly NotificationRepository $notificationRepository)
{
}
/**
* @param list<array{relatedEntityClass: class-string, relatedEntityId: int}> $more

View File

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

View File

@@ -18,7 +18,9 @@ class PageGenerator implements \Iterator
{
protected int $current = 1;
public function __construct(protected Paginator $paginator) {}
public function __construct(protected Paginator $paginator)
{
}
public function current(): Page
{

View File

@@ -57,7 +57,8 @@ class Paginator implements PaginatorInterface
* the key in the GET parameter to indicate the number of item per page.
*/
protected string $itemPerPageKey
) {}
) {
}
public function count(): int
{

View File

@@ -17,7 +17,7 @@ use Symfony\Component\Routing\RouterInterface;
/**
* Create paginator instances.
*/
class PaginatorFactory
final readonly class PaginatorFactory implements PaginatorFactoryInterface
{
final public const DEFAULT_CURRENT_PAGE_KEY = 'page';
@@ -25,24 +25,22 @@ class PaginatorFactory
final public const DEFAULT_PAGE_NUMBER = 1;
/**
* @param int $itemPerPage
*/
public function __construct(
/**
* the request stack.
*/
private readonly RequestStack $requestStack,
private RequestStack $requestStack,
/**
* the router and generator for url.
*/
private readonly RouterInterface $router,
private RouterInterface $router,
/**
* the default item per page. This may be overriden by
* the request or inside the paginator.
*/
private $itemPerPage = 20
) {}
private int $itemPerPage = 20
) {
}
/**
* create a paginator instance.
@@ -50,17 +48,14 @@ class PaginatorFactory
* The default route and route parameters are the current ones. If set,
* thos route are overriden.
*
* @param int $totalItems
* @param string|null $route the specific route to use in pages
* @param array|null $routeParameters the specific route parameters to use in pages
*
* @return PaginatorInterface
*/
public function create(
$totalItems,
string $route = null,
array $routeParameters = null
) {
int $totalItems,
?string $route = null,
?array $routeParameters = null
): PaginatorInterface {
return new Paginator(
$totalItems,
$this->getCurrentItemsPerPage(),
@@ -73,7 +68,7 @@ class PaginatorFactory
);
}
public function getCurrentItemsPerPage()
public function getCurrentItemsPerPage(): int
{
return $this->requestStack
->getCurrentRequest()
@@ -81,16 +76,13 @@ class PaginatorFactory
->getInt(self::DEFAULT_ITEM_PER_NUMBER_KEY, $this->itemPerPage);
}
public function getCurrentPageFirstItemNumber()
public function getCurrentPageFirstItemNumber(): int
{
return ($this->getCurrentPageNumber() - 1) *
$this->getCurrentItemsPerPage();
}
/**
* @return int
*/
public function getCurrentPageNumber()
public function getCurrentPageNumber(): int
{
return $this->requestStack
->getCurrentRequest()
@@ -98,14 +90,14 @@ class PaginatorFactory
->getInt(self::DEFAULT_CURRENT_PAGE_KEY, self::DEFAULT_PAGE_NUMBER);
}
protected function getCurrentRoute()
private function getCurrentRoute()
{
$request = $this->requestStack->getCurrentRequest();
return $request->get('_route');
}
protected function getCurrentRouteParameters()
private function getCurrentRouteParameters()
{
return array_merge(
$this->router->getContext()->getParameters(),

View File

@@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\MainBundle\Pagination;
/**
* Create paginator instances.
*/
interface PaginatorFactoryInterface
{
/**
* create a paginator instance.
*
* The default route and route parameters are the current ones. If set,
* thos route are overriden.
*
* @param string|null $route the specific route to use in pages
* @param array|null $routeParameters the specific route parameters to use in pages
*/
public function create(int $totalItems, ?string $route = null, ?array $routeParameters = null): PaginatorInterface;
public function getCurrentItemsPerPage(): int;
public function getCurrentPageFirstItemNumber(): int;
public function getCurrentPageNumber(): int;
}

View File

@@ -22,7 +22,7 @@ use libphonenumber\PhoneNumber;
*/
interface PhoneNumberHelperInterface
{
public function format(PhoneNumber $phoneNumber = null): string;
public function format(?PhoneNumber $phoneNumber = null): string;
/**
* Get type (mobile, landline, ...) for phone number.

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