diff --git a/.github/workflows/run-test.yml b/.github/workflows/run-test.yml index f99e55af..33f6f31f 100644 --- a/.github/workflows/run-test.yml +++ b/.github/workflows/run-test.yml @@ -25,7 +25,7 @@ jobs: key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }} - uses: shivammathur/setup-php@v2 with: - php-version: '8.2' + php-version: '8.3' extensions: apcu - name: Configure recaptcha secrets run: cp config/recaptcha_secrets.json.dist config/recaptcha_secrets.json diff --git a/.lando.yml b/.lando.yml index a1cf7fbc..66356aed 100644 --- a/.lando.yml +++ b/.lando.yml @@ -5,7 +5,7 @@ excludes: - var/cache - node_modules config: - php: '8.2' + php: '8.3' config: php: lando/php/php.ini vhosts: lando/apache/000-default.conf @@ -21,7 +21,7 @@ services: - 'apt-get update' - '/bin/bash /app/shell_provisioner/run.sh' overrides: - image: 'devwithlando/php:8.2-apache-4' + image: 'devwithlando/php:8.3-apache-4' build: context: ./lando dockerfile: Dockerfile diff --git a/composer.json b/composer.json index 88e91c32..7b95c66f 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "type": "project", "license": "proprietary", "require": { - "php": "^8.2", + "php": "^8.3", "ext-apcu": "*", "ext-ctype": "*", "ext-iconv": "*", diff --git a/composer.lock b/composer.lock index ff9c4e4e..ac51e478 100644 --- a/composer.lock +++ b/composer.lock @@ -12405,7 +12405,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": "^8.2", + "php": "^8.3", "ext-apcu": "*", "ext-ctype": "*", "ext-iconv": "*" diff --git a/config/packages/framework.yaml b/config/packages/framework.yaml index da4518f4..5355e05c 100644 --- a/config/packages/framework.yaml +++ b/config/packages/framework.yaml @@ -3,6 +3,7 @@ framework: secret: '%env(APP_SECRET)%' csrf_protection: true http_method_override: true + handle_all_throwables: true translator: { fallback: "%locale%" } default_locale: "%locale%" diff --git a/deploy.sh b/deploy.sh index d7c84501..4d898b57 100644 --- a/deploy.sh +++ b/deploy.sh @@ -67,7 +67,7 @@ chmod -R a+rwX var/log var/cache printOk printAction "Stopping FPM" -sudo systemctl stop php8.2-fpm +sudo systemctl stop php8.3-fpm printOk #printAction "Running doctrine schema update" #bin/console doctrine:schema:update --force ${Q} @@ -77,7 +77,7 @@ printAction "Activate new version" ln -sfn releases/${VERSION} current printOk printAction "Starting FPM" -sudo systemctl start php8.2-fpm +sudo systemctl start php8.3-fpm printOk printAction "Cleanup old versions, keep last 2" diff --git a/lando/Dockerfile b/lando/Dockerfile index e581c551..ce365109 100644 --- a/lando/Dockerfile +++ b/lando/Dockerfile @@ -1,4 +1,4 @@ -FROM devwithlando/php:8.2-apache-4 +FROM devwithlando/php:8.3-apache-4 RUN apt-get update -y diff --git a/src/Command/EnrichParticipantInfoCommand.php b/src/Command/EnrichParticipantInfoCommand.php index 003dc746..55089cd4 100644 --- a/src/Command/EnrichParticipantInfoCommand.php +++ b/src/Command/EnrichParticipantInfoCommand.php @@ -6,35 +6,31 @@ use Doctrine\ORM\EntityManagerInterface; use GeoIp2\Database\Reader; use GeoIp2\Exception\AddressNotFoundException; +use MaxMind\Db\Reader\InvalidDatabaseException; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class EnrichParticipantInfoCommand extends Command { - private ParticipantRepository $participantRepository; - private EntityManagerInterface $em; - private string $geoIpDbPath; - public function __construct( - ParticipantRepository $participantRepository, - EntityManagerInterface $em, - string $geoIpDbPath, + private ParticipantRepository $participantRepository, + private EntityManagerInterface $em, + private string $geoIpDbPath, ) { - $this->participantRepository = $participantRepository; - $this->em = $em; - $this->geoIpDbPath = $geoIpDbPath; - parent::__construct(); } - protected function configure() + protected function configure(): void { $this ->setName('app:enrich:participants') ->setDescription('Enrich the participant information'); } + /** + * @throws InvalidDatabaseException + */ protected function execute(InputInterface $input, OutputInterface $output): int { $batchSize = 1000; diff --git a/src/Command/GetBouncedMailsCommand.php b/src/Command/GetBouncedMailsCommand.php index 5e17ee7b..32f85848 100644 --- a/src/Command/GetBouncedMailsCommand.php +++ b/src/Command/GetBouncedMailsCommand.php @@ -9,22 +9,21 @@ class GetBouncedMailsCommand extends Command { - private BounceQuery $bounceQuery; - - public function __construct(BounceQuery $bounceQuery) + public function __construct(private readonly BounceQuery $bounceQuery) { - $this->bounceQuery = $bounceQuery; - parent::__construct(); } - protected function configure() + protected function configure(): void { $this ->setName('app:getBounced') ->setDescription('Get bounced emails'); } + /** + * @throws \Exception + */ protected function execute(InputInterface $input, OutputInterface $output): int { $bounces = $this->bounceQuery->getBounces(); diff --git a/src/Command/HashBlacklistCommand.php b/src/Command/HashBlacklistCommand.php index bb9cc1ce..9e06589e 100644 --- a/src/Command/HashBlacklistCommand.php +++ b/src/Command/HashBlacklistCommand.php @@ -11,20 +11,14 @@ class HashBlacklistCommand extends Command { - private EntityManagerInterface $em; - private HashService $hashService; - public function __construct( - EntityManagerInterface $em, - HashService $hashService, + private readonly EntityManagerInterface $em, + private readonly HashService $hashService, ) { - $this->em = $em; - $this->hashService = $hashService; - parent::__construct(); } - protected function configure() + protected function configure(): void { $this ->setName('app:hash-black-list') diff --git a/src/Command/HashOldDataCommand.php b/src/Command/HashOldDataCommand.php index ae020973..4c3fb095 100644 --- a/src/Command/HashOldDataCommand.php +++ b/src/Command/HashOldDataCommand.php @@ -5,6 +5,7 @@ use App\Entity\BlacklistEmail; use App\Entity\Participant; use App\Service\HashService; +use Doctrine\DBAL\Logging\Middleware as LoggingMiddleware; use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; @@ -13,14 +14,17 @@ class HashOldDataCommand extends Command { public function __construct( - private EntityManagerInterface $em, - private HashService $hashService, + private readonly EntityManagerInterface $em, + private readonly HashService $hashService, ) { - $em - ->getConnection() - ->getConfiguration() - ->setSQLLogger(null) - ; + $configuration = $em->getConnection()->getConfiguration(); + $middlewares = $configuration->getMiddlewares(); + + $filteredMiddlewares = array_filter($middlewares, static function ($middleware) { + return !($middleware instanceof LoggingMiddleware); + }); + + $configuration->setMiddlewares($filteredMiddlewares); parent::__construct(); } diff --git a/src/Command/ReportQueriesCommand.php b/src/Command/ReportQueriesCommand.php index 39713daa..941925e1 100644 --- a/src/Command/ReportQueriesCommand.php +++ b/src/Command/ReportQueriesCommand.php @@ -11,17 +11,12 @@ class ReportQueriesCommand extends Command { - private ReportQueriesService $reportQueriesService; - private ExportReportQueriesService $exportReportQueriesService; - - public function __construct(ReportQueriesService $reportQueriesService, ExportReportQueriesService $exportReportQueriesService) + public function __construct(private readonly ReportQueriesService $reportQueriesService, private readonly ExportReportQueriesService $exportReportQueriesService) { parent::__construct(); - $this->reportQueriesService = $reportQueriesService; - $this->exportReportQueriesService = $exportReportQueriesService; } - protected function configure() + protected function configure(): void { $this ->setName('app:report-queries') @@ -37,10 +32,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int { $year = $input->getArgument('year'); - if ('all' !== $year) { - if (false === strtotime($year)) { - $year = date('Y'); - } + if (('all' !== $year) && false === strtotime($year)) { + $year = date('Y'); } $this->exportReportQueriesService->export($this->reportQueriesService->getReportResults($year), $year); diff --git a/src/Command/SendEmptyWishlistReminderCommand.php b/src/Command/SendEmptyWishlistReminderCommand.php index 47fcb6c3..70524a6f 100644 --- a/src/Command/SendEmptyWishlistReminderCommand.php +++ b/src/Command/SendEmptyWishlistReminderCommand.php @@ -12,26 +12,16 @@ class SendEmptyWishlistReminderCommand extends Command { - private EntityManagerInterface $em; - private ParticipantMailQuery $participantMailQuery; - private WishlistMailQuery $wishlistMailQuery; - private MailerService $mailerService; - public function __construct( - EntityManagerInterface $em, - ParticipantMailQuery $participantMailQuery, - WishlistMailQuery $wishlistMailQuery, - MailerService $mailerService, + private readonly EntityManagerInterface $em, + private readonly ParticipantMailQuery $participantMailQuery, + private readonly WishlistMailQuery $wishlistMailQuery, + private readonly MailerService $mailerService, ) { - $this->em = $em; - $this->participantMailQuery = $participantMailQuery; - $this->wishlistMailQuery = $wishlistMailQuery; - $this->mailerService = $mailerService; - parent::__construct(); } - protected function configure() + protected function configure(): void { $this ->setName('app:sendWishlistReminderMails') diff --git a/src/Command/SendParticipantViewReminderCommand.php b/src/Command/SendParticipantViewReminderCommand.php index 07fb38a2..8aa89d10 100644 --- a/src/Command/SendParticipantViewReminderCommand.php +++ b/src/Command/SendParticipantViewReminderCommand.php @@ -11,23 +11,15 @@ class SendParticipantViewReminderCommand extends Command { - private EntityManagerInterface $em; - private ParticipantMailQuery $participantMailQuery; - private MailerService $mailerService; - public function __construct( - EntityManagerInterface $em, - ParticipantMailQuery $participantMailQuery, - MailerService $mailerService, + private readonly EntityManagerInterface $em, + private readonly ParticipantMailQuery $participantMailQuery, + private readonly MailerService $mailerService, ) { - $this->em = $em; - $this->participantMailQuery = $participantMailQuery; - $this->mailerService = $mailerService; - parent::__construct(); } - protected function configure() + protected function configure(): void { $this ->setName('app:sendParticipantViewReminderMails') diff --git a/src/Command/SendPartyStatusCommand.php b/src/Command/SendPartyStatusCommand.php index 647e9df5..4b1a2212 100644 --- a/src/Command/SendPartyStatusCommand.php +++ b/src/Command/SendPartyStatusCommand.php @@ -12,23 +12,15 @@ class SendPartyStatusCommand extends Command { - private EntityManagerInterface $em; - private ParticipantMailQuery $participantMailQuery; - private MailerService $mailerService; - public function __construct( - EntityManagerInterface $em, - ParticipantMailQuery $participantMailQuery, - MailerService $mailerService, + private readonly EntityManagerInterface $em, + private readonly ParticipantMailQuery $participantMailQuery, + private readonly MailerService $mailerService, ) { - $this->em = $em; - $this->participantMailQuery = $participantMailQuery; - $this->mailerService = $mailerService; - parent::__construct(); } - protected function configure() + protected function configure(): void { $this ->setName('app:sendPartyStatusMails') diff --git a/src/Command/SendWishlistUpdatedCommand.php b/src/Command/SendWishlistUpdatedCommand.php index e84a6e0c..c51a7d5d 100644 --- a/src/Command/SendWishlistUpdatedCommand.php +++ b/src/Command/SendWishlistUpdatedCommand.php @@ -12,23 +12,15 @@ class SendWishlistUpdatedCommand extends Command { - private EntityManagerInterface $em; - private ParticipantMailQuery $participantMailQuery; - private MailerService $mailerService; - public function __construct( - EntityManagerInterface $em, - ParticipantMailQuery $participantMailQuery, - MailerService $mailerService, + private readonly EntityManagerInterface $em, + private readonly ParticipantMailQuery $participantMailQuery, + private readonly MailerService $mailerService, ) { - $this->em = $em; - $this->participantMailQuery = $participantMailQuery; - $this->mailerService = $mailerService; - parent::__construct(); } - protected function configure() + protected function configure(): void { $this ->setName('app:sendWishlistUpdatedMails') diff --git a/src/DependencyInjection/Compiler/FormCompilerPass.php b/src/DependencyInjection/Compiler/FormCompilerPass.php index de148a62..725f154e 100644 --- a/src/DependencyInjection/Compiler/FormCompilerPass.php +++ b/src/DependencyInjection/Compiler/FormCompilerPass.php @@ -12,12 +12,9 @@ */ class FormCompilerPass implements CompilerPassInterface { - /** - * @var array - */ - private $templates = ['jquery']; + private array $templates = ['jquery']; - public function process(ContainerBuilder $container) + public function process(ContainerBuilder $container): void { $resources = $container->getParameter('twig.form.resources'); diff --git a/src/Form/Extension/DateTypeExtension.php b/src/Form/Extension/DateTypeExtension.php index cdbe6282..b0638f71 100644 --- a/src/Form/Extension/DateTypeExtension.php +++ b/src/Form/Extension/DateTypeExtension.php @@ -10,7 +10,7 @@ class DateTypeExtension extends AbstractTypeExtension { - public function configureOptions(OptionsResolver $resolver) + public function configureOptions(OptionsResolver $resolver): void { $resolver->setDefaults([ 'widget' => 'single_text', @@ -24,7 +24,7 @@ public function configureOptions(OptionsResolver $resolver) ]); } - public function buildView(FormView $view, FormInterface $form, array $options) + public function buildView(FormView $view, FormInterface $form, array $options): void { // Adds a custom block prefix array_splice( @@ -35,7 +35,7 @@ public function buildView(FormView $view, FormInterface $form, array $options) ); } - public function finishView(FormView $view, FormInterface $form, array $options) + public function finishView(FormView $view, FormInterface $form, array $options): void { $view->vars['type'] = 'text'; @@ -47,7 +47,7 @@ public function finishView(FormView $view, FormInterface $form, array $options) ]); } - public function getExtendedType() + public function getExtendedType(): string { return DateType::class; } diff --git a/src/Form/Type/AddParticipantType.php b/src/Form/Type/AddParticipantType.php index e53699dd..47c3a7e8 100644 --- a/src/Form/Type/AddParticipantType.php +++ b/src/Form/Type/AddParticipantType.php @@ -10,7 +10,7 @@ class AddParticipantType extends AbstractType { - public function buildForm(FormBuilderInterface $builder, array $options) + public function buildForm(FormBuilderInterface $builder, array $options): void { $builder ->add( @@ -26,7 +26,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) ; } - public function configureOptions(OptionsResolver $resolver) + public function configureOptions(OptionsResolver $resolver): void { $resolver->setDefaults([ 'data_class' => Participant::class, diff --git a/src/Form/Type/AnonymousMessageFormType.php b/src/Form/Type/AnonymousMessageFormType.php index 858e5f81..c28d67af 100644 --- a/src/Form/Type/AnonymousMessageFormType.php +++ b/src/Form/Type/AnonymousMessageFormType.php @@ -10,7 +10,7 @@ class AnonymousMessageFormType extends AbstractType { - public function buildForm(FormBuilderInterface $builder, array $options) + public function buildForm(FormBuilderInterface $builder, array $options): void { $builder ->add('message', TextareaType::class, [ diff --git a/src/Form/Type/ContactType.php b/src/Form/Type/ContactType.php index 7eb96074..2a7d8e28 100644 --- a/src/Form/Type/ContactType.php +++ b/src/Form/Type/ContactType.php @@ -15,7 +15,7 @@ class ContactType extends AbstractType { - public function buildForm(FormBuilderInterface $builder, array $options) + public function buildForm(FormBuilderInterface $builder, array $options): void { $builder ->add('subject', ChoiceType::class, [ @@ -46,7 +46,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) ; } - public function configureOptions(OptionsResolver $resolver) + public function configureOptions(OptionsResolver $resolver): void { $resolver->setDefaults([ 'data_class' => ContactSubmission::class, diff --git a/src/Form/Type/ExcludeParticipantType.php b/src/Form/Type/ExcludeParticipantType.php index 7da59faf..6e23dff3 100644 --- a/src/Form/Type/ExcludeParticipantType.php +++ b/src/Form/Type/ExcludeParticipantType.php @@ -13,7 +13,7 @@ class ExcludeParticipantType extends AbstractType { - public function buildForm(FormBuilderInterface $builder, array $options) + public function buildForm(FormBuilderInterface $builder, array $options): void { $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) { $me = $event->getData(); @@ -40,7 +40,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) }); } - public function configureOptions(OptionsResolver $resolver) + public function configureOptions(OptionsResolver $resolver): void { $resolver->setDefaults([ 'data_class' => Participant::class, diff --git a/src/Form/Type/ForgotLinkType.php b/src/Form/Type/ForgotLinkType.php index b552dcf4..d946fa53 100644 --- a/src/Form/Type/ForgotLinkType.php +++ b/src/Form/Type/ForgotLinkType.php @@ -10,7 +10,7 @@ class ForgotLinkType extends AbstractType { - public function buildForm(FormBuilderInterface $builder, array $options) + public function buildForm(FormBuilderInterface $builder, array $options): void { $builder ->add('email', EmailType::class, [ diff --git a/src/Form/Type/ParticipantType.php b/src/Form/Type/ParticipantType.php index c56758a3..c89085cb 100644 --- a/src/Form/Type/ParticipantType.php +++ b/src/Form/Type/ParticipantType.php @@ -10,7 +10,7 @@ class ParticipantType extends AbstractType { - public function buildForm(FormBuilderInterface $builder, array $options) + public function buildForm(FormBuilderInterface $builder, array $options): void { $builder ->add( @@ -26,7 +26,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) ; } - public function configureOptions(OptionsResolver $resolver) + public function configureOptions(OptionsResolver $resolver): void { $resolver->setDefaults([ 'data_class' => Participant::class, diff --git a/src/Form/Type/PartyExcludeParticipantType.php b/src/Form/Type/PartyExcludeParticipantType.php index d4469c45..6f315823 100644 --- a/src/Form/Type/PartyExcludeParticipantType.php +++ b/src/Form/Type/PartyExcludeParticipantType.php @@ -11,7 +11,7 @@ class PartyExcludeParticipantType extends AbstractType { - public function buildForm(FormBuilderInterface $builder, array $options) + public function buildForm(FormBuilderInterface $builder, array $options): void { $builder ->add( @@ -24,7 +24,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) ); } - public function configureOptions(OptionsResolver $resolver) + public function configureOptions(OptionsResolver $resolver): void { $resolver->setDefaults( [ diff --git a/src/Form/Type/PartyType.php b/src/Form/Type/PartyType.php index 13a354b0..e6cffac2 100644 --- a/src/Form/Type/PartyType.php +++ b/src/Form/Type/PartyType.php @@ -14,7 +14,7 @@ class PartyType extends AbstractType { - public function buildForm(FormBuilderInterface $builder, array $options) + public function buildForm(FormBuilderInterface $builder, array $options): void { $builder ->add('message', TextareaType::class) @@ -39,7 +39,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) ; } - public function configureOptions(OptionsResolver $resolver) + public function configureOptions(OptionsResolver $resolver): void { $resolver->setDefaults([ 'data_class' => Party::class, diff --git a/src/Form/Type/RequestReuseUrlType.php b/src/Form/Type/RequestReuseUrlType.php index b65566d9..8fd95bef 100644 --- a/src/Form/Type/RequestReuseUrlType.php +++ b/src/Form/Type/RequestReuseUrlType.php @@ -10,7 +10,7 @@ class RequestReuseUrlType extends AbstractType { - public function buildForm(FormBuilderInterface $builder, array $options) + public function buildForm(FormBuilderInterface $builder, array $options): void { $builder ->add('email', EmailType::class, [ diff --git a/src/Form/Type/SetJoinModeType.php b/src/Form/Type/SetJoinModeType.php index def6136d..59bdc4bd 100644 --- a/src/Form/Type/SetJoinModeType.php +++ b/src/Form/Type/SetJoinModeType.php @@ -10,7 +10,7 @@ class SetJoinModeType extends AbstractType { - public function buildForm(FormBuilderInterface $builder, array $options) + public function buildForm(FormBuilderInterface $builder, array $options): void { $builder ->add( @@ -26,7 +26,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) ; } - public function configureOptions(OptionsResolver $resolver) + public function configureOptions(OptionsResolver $resolver): void { $resolver->setDefaults([ 'data_class' => Party::class, diff --git a/src/Form/Type/UnsubscribeType.php b/src/Form/Type/UnsubscribeType.php index 8ddb3c48..ba6c21ca 100644 --- a/src/Form/Type/UnsubscribeType.php +++ b/src/Form/Type/UnsubscribeType.php @@ -8,7 +8,7 @@ class UnsubscribeType extends AbstractType { - public function buildForm(FormBuilderInterface $builder, array $options) + public function buildForm(FormBuilderInterface $builder, array $options): void { $builder ->add('allParties', CheckboxType::class, [ diff --git a/src/Form/Type/UpdatePartyDetailsType.php b/src/Form/Type/UpdatePartyDetailsType.php index e6d6271a..fecd07e4 100644 --- a/src/Form/Type/UpdatePartyDetailsType.php +++ b/src/Form/Type/UpdatePartyDetailsType.php @@ -12,7 +12,7 @@ class UpdatePartyDetailsType extends AbstractType { - public function buildForm(FormBuilderInterface $builder, array $options) + public function buildForm(FormBuilderInterface $builder, array $options): void { $builder ->add('eventdate', DateType::class, [ @@ -30,7 +30,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) } } - public function configureOptions(OptionsResolver $resolver) + public function configureOptions(OptionsResolver $resolver): void { $resolver->setDefaults([ 'data_class' => Party::class, diff --git a/src/Form/Type/WishlistItemType.php b/src/Form/Type/WishlistItemType.php index 2a078b1c..d9bdc0ef 100644 --- a/src/Form/Type/WishlistItemType.php +++ b/src/Form/Type/WishlistItemType.php @@ -11,14 +11,14 @@ class WishlistItemType extends AbstractType { - public function buildForm(FormBuilderInterface $builder, array $options) + public function buildForm(FormBuilderInterface $builder, array $options): void { $builder ->add('rank', HiddenType::class) ->add('description', TextType::class); } - public function configureOptions(OptionsResolver $resolver) + public function configureOptions(OptionsResolver $resolver): void { $resolver->setDefaults( [ diff --git a/src/Form/Type/WishlistType.php b/src/Form/Type/WishlistType.php index ead56e27..4533c60a 100644 --- a/src/Form/Type/WishlistType.php +++ b/src/Form/Type/WishlistType.php @@ -10,7 +10,7 @@ class WishlistType extends AbstractType { - public function buildForm(FormBuilderInterface $builder, array $options) + public function buildForm(FormBuilderInterface $builder, array $options): void { $builder->add('wishlistItems', CollectionType::class, [ @@ -20,7 +20,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) ]); } - public function configureOptions(OptionsResolver $resolver) + public function configureOptions(OptionsResolver $resolver): void { $resolver->setDefaults( [ diff --git a/src/Query/ParticipantReportQuery.php b/src/Query/ParticipantReportQuery.php index 4aa8411e..6f41b3f1 100644 --- a/src/Query/ParticipantReportQuery.php +++ b/src/Query/ParticipantReportQuery.php @@ -4,17 +4,21 @@ use Doctrine\Common\Collections\Criteria; use Doctrine\DBAL\Connection; +use Doctrine\DBAL\Exception; use Doctrine\DBAL\Query\QueryBuilder; class ParticipantReportQuery { public function __construct( - private Connection $dbal, - private PartyReportQuery $partyReportQuery, - private FeaturedYearsQuery $featuredYearsQuery, + private readonly Connection $dbal, + private readonly PartyReportQuery $partyReportQuery, + private readonly FeaturedYearsQuery $featuredYearsQuery, ) { } + /** + * @throws Exception + */ public function countConfirmedParticipantsUntilDate(\DateTime $date): array { $query = $this->dbal->createQueryBuilder() @@ -25,9 +29,12 @@ public function countConfirmedParticipantsUntilDate(\DateTime $date): array ->andWhere('e.view_date IS NOT NULL') ->setParameter('lastDay', $date->format('Y-m-d H:i:s')); - return $query->execute()->fetchAll(); + return $query->fetchAllAssociative(); } + /** + * @throws Exception + */ public function countDistinctParticipantsUntilDate(\DateTime $date): array { $query = $this->dbal->createQueryBuilder() @@ -37,9 +44,12 @@ public function countDistinctParticipantsUntilDate(\DateTime $date): array ->where('p.sent_date < :lastDay') ->setParameter('lastDay', $date->format('Y-m-d H:i:s')); - return $query->execute()->fetchAll(); + return $query->fetchAllAssociative(); } + /** + * @throws Exception + */ public function queryDataForMonthlyParticipantChart(Season $season): array { $query = $this->dbal->createQueryBuilder() @@ -53,9 +63,12 @@ public function queryDataForMonthlyParticipantChart(Season $season): array ->setParameter('firstDay', $season->getStart()->format('Y-m-d H:i:s')) ->setParameter('lastDay', $season->getEnd()->format('Y-m-d H:i:s')); - return $query->execute()->fetchAll(); + return $query->fetchAllAssociative(); } + /** + * @throws Exception + */ public function queryDataForYearlyParticipantChart(): array { $featuredYears = $this->featuredYearsQuery->getFeaturedYears(); @@ -75,7 +88,7 @@ public function queryDataForYearlyParticipantChart(): array ->setParameter('firstDay', $firstDay) ->setParameter('lastDay', $lastDay); - $chartData = $query->execute()->fetchAll(); + $chartData = $query->fetchAllAssociative(); $participant = [ 'year' => $year, @@ -88,6 +101,9 @@ public function queryDataForYearlyParticipantChart(): array return $participantChartData; } + /** + * @throws Exception + */ public function queryDataForParticipantChartUntilDate(\DateTime $date): array { $query = $this->dbal->createQueryBuilder() @@ -98,7 +114,7 @@ public function queryDataForParticipantChartUntilDate(\DateTime $date): array ->groupBy('year(p.sent_date), month(p.sent_date)') ->setParameter('lastDay', $date->format('Y-m-d H:i:s')); - $totalParticipantChartData = $query->execute()->fetchAll(); + $totalParticipantChartData = $query->fetchAllAssociative(); $accumulatedParticipantCounter = 0; @@ -110,6 +126,9 @@ public function queryDataForParticipantChartUntilDate(\DateTime $date): array return $totalParticipantChartData; } + /** + * @throws Exception + */ public function calculateAverageParticipantsPerPartyUntilDate(\DateTime $date): float { $totalParties = $this->partyReportQuery->countAllPartiesUntilDate($date); @@ -122,6 +141,9 @@ public function calculateAverageParticipantsPerPartyUntilDate(\DateTime $date): throw new NoResultException(); } + /** + * @throws Exception + */ public function countAllParticipantsUntilDate(\DateTime $date): array { $query = $this->dbal->createQueryBuilder() @@ -131,9 +153,12 @@ public function countAllParticipantsUntilDate(\DateTime $date): array ->where('p.sent_date < :lastDay') ->setParameter('lastDay', $date->format('Y-m-d H:i:s')); - return $query->execute()->fetchAll(); + return $query->fetchAllAssociative(); } + /** + * @throws Exception + */ public function calculateParticipantCountDifferenceBetweenSeasons(Season $season1, Season $season2): int { $participantCountSeason1 = $this->countParticipants($season1); @@ -147,6 +172,9 @@ public function calculateParticipantCountDifferenceBetweenSeasons(Season $season return $participantCountSeason1 - $participantCountSeason2; } + /** + * @throws Exception + */ public function countParticipants(Season $season): int { $query = $this->dbal->createQueryBuilder() @@ -158,11 +186,14 @@ public function countParticipants(Season $season): int ->setParameter('firstDay', $season->getStart()->format('Y-m-d H:i:s')) ->setParameter('lastDay', $season->getEnd()->format('Y-m-d H:i:s')); - $participantCount = $query->execute()->fetchAll(); + $participantCount = $query->fetchAllAssociative(); return (int) $participantCount[0]['participant_count']; } + /** + * @throws Exception + */ public function calculateConfirmedParticipantsCountDifferenceBetweenSeasons(Season $season1, Season $season2): mixed { $confirmedParticipantCountSeason1 = $this->countConfirmedParticipants($season1); @@ -176,6 +207,9 @@ public function calculateConfirmedParticipantsCountDifferenceBetweenSeasons(Seas return $confirmedParticipantCountSeason1[0]['confirmedParticipantCount'] - $confirmedParticipantCountSeason2[0]['confirmedParticipantCount']; } + /** + * @throws Exception + */ public function countConfirmedParticipants(Season $season): array { $query = $this->dbal->createQueryBuilder() @@ -188,9 +222,12 @@ public function countConfirmedParticipants(Season $season): array ->setParameter('firstDay', $season->getStart()->format('Y-m-d H:i:s')) ->setParameter('lastDay', $season->getEnd()->format('Y-m-d H:i:s')); - return $query->execute()->fetchAll(); + return $query->fetchAllAssociative(); } + /** + * @throws Exception + */ public function calculateDistinctParticipantCountDifferenceBetweenSeasons(Season $season1, Season $season2): mixed { $distinctParticipantCountSeason1 = $this->countDistinctParticipants($season1); @@ -204,6 +241,9 @@ public function calculateDistinctParticipantCountDifferenceBetweenSeasons(Season return $distinctParticipantCountSeason1[0]['distinctParticipantCount'] - $distinctParticipantCountSeason2[0]['distinctParticipantCount']; } + /** + * @throws Exception + */ public function countDistinctParticipants(Season $season): array { $query = $this->dbal->createQueryBuilder() @@ -215,7 +255,7 @@ public function countDistinctParticipants(Season $season): array ->setParameter('firstDay', $season->getStart()->format('Y-m-d H:i:s')) ->setParameter('lastDay', $season->getEnd()->format('Y-m-d H:i:s')); - return $query->execute()->fetchAll(); + return $query->fetchAllAssociative(); } public function calculateAverageParticipantsPerPartyBetweenSeasons(Season $season1, Season $season2): float @@ -243,6 +283,9 @@ public function calculateAverageParticipantsPerParty(Season $season): float throw new NoResultException(); } + /** + * @throws Exception + */ public function fetchMailsForExport(Season $season, bool $isAdmin): iterable { /** @var QueryBuilder $subQuery */ @@ -279,11 +322,12 @@ public function fetchMailsForExport(Season $season, bool $isAdmin): iterable ->setParameter('lastDay', $season->getEnd()->format('Y-m-d H:i:s')) ->setParameter('admin', $isAdmin ? 1 : 0); - $result = $qb->execute()->fetchAll(); - - return $result; + return $qb->fetchAllAssociative(); } + /** + * @throws Exception + */ public function fetchDataForPartyUpdateMail(string $listUrl): array { $party = $this->dbal->createQueryBuilder() @@ -315,13 +359,16 @@ public function fetchDataForPartyUpdateMail(string $listUrl): array ->setParameter('listurl', $listUrl); return [ - 'party' => $party->execute()->fetchAll(), - 'participantCount' => $participantCount->execute()->fetchAll(), - 'wishlistCount' => $wishlistCount->execute()->fetchAll(), - 'viewedCount' => $viewedCount->execute()->fetchAll(), + 'party' => $party->fetchAllAssociative(), + 'participantCount' => $participantCount->fetchAllAssociative(), + 'wishlistCount' => $wishlistCount->fetchAllAssociative(), + 'viewedCount' => $viewedCount->fetchAllAssociative(), ]; } + /** + * @throws Exception + */ public function findBuddyByParticipantId(int $participantId): array { $query = $this->dbal->createQueryBuilder() @@ -330,6 +377,6 @@ public function findBuddyByParticipantId(int $participantId): array ->where('p.assigned_participant_id = :id') ->setParameter('id', $participantId); - return $query->execute()->fetchAll(); + return $query->fetchAllAssociative(); } } diff --git a/src/Query/PartyReportQuery.php b/src/Query/PartyReportQuery.php index 78f64bfe..68f25ca7 100644 --- a/src/Query/PartyReportQuery.php +++ b/src/Query/PartyReportQuery.php @@ -3,6 +3,7 @@ namespace App\Query; use Doctrine\DBAL\Connection; +use Doctrine\DBAL\Exception; class PartyReportQuery { @@ -15,6 +16,9 @@ public function __construct(Connection $dbal, FeaturedYearsQuery $featuredYearsQ $this->featuredYearsQuery = $featuredYearsQuery; } + /** + * @throws Exception + */ public function countParties(Season $season): int { $query = $this->dbal->createQueryBuilder() @@ -25,12 +29,15 @@ public function countParties(Season $season): int ->setParameter('firstDay', $season->getStart()->format('Y-m-d H:i:s')) ->setParameter('lastDay', $season->getEnd()->format('Y-m-d H:i:s')); - $partyCount = $query->execute()->fetchAll(); + $partyCount = $query->fetchAllAssociative(); return (int) $partyCount[0]['partyCount']; } - public function countAllPartiesUntilDate(\DateTime $date) + /** + * @throws Exception + */ + public function countAllPartiesUntilDate(\DateTime $date): array { $query = $this->dbal->createQueryBuilder() ->select('count(p.id) AS partyCount') @@ -38,10 +45,13 @@ public function countAllPartiesUntilDate(\DateTime $date) ->where('p.sent_date < :lastDay') ->setParameter('lastDay', $date->format('Y-m-d H:i:s')); - return $query->execute()->fetchAll(); + return $query->fetchAllAssociative(); } - public function queryDataForMonthlyPartyChart(Season $season) + /** + * @throws Exception + */ + public function queryDataForMonthlyPartyChart(Season $season): array { $query = $this->dbal->createQueryBuilder() ->select('count(p.id) AS accumulatedPartyCountByMonth, p.sent_date AS month') @@ -53,9 +63,12 @@ public function queryDataForMonthlyPartyChart(Season $season) ->setParameter('firstDay', $season->getStart()->format('Y-m-d H:i:s')) ->setParameter('lastDay', $season->getEnd()->format('Y-m-d H:i:s')); - return $query->execute()->fetchAll(); + return $query->fetchAllAssociative(); } + /** + * @throws Exception + */ public function queryDataForYearlyPartyChart(): array { $featuredYears = $this->featuredYearsQuery->getFeaturedYears(); @@ -74,7 +87,7 @@ public function queryDataForYearlyPartyChart(): array ->setParameter('firstDay', $firstDay) ->setParameter('lastDay', $lastDay); - $chartData = $query->execute()->fetchAll(); + $chartData = $query->fetchAllAssociative(); $party = [ 'year' => $year, @@ -87,7 +100,10 @@ public function queryDataForYearlyPartyChart(): array return $partyChartData; } - public function queryDataForPartyChartUntilDate(\DateTime $date) + /** + * @throws Exception + */ + public function queryDataForPartyChartUntilDate(\DateTime $date): array { $query = $this->dbal->createQueryBuilder() ->select('count(p.id) AS totalPartyCount, p.sent_date AS month') @@ -96,7 +112,7 @@ public function queryDataForPartyChartUntilDate(\DateTime $date) ->groupBy('year(p.sent_date), month(p.sent_date)') ->setParameter('lastDay', $date->format('Y-m-d H:i:s')); - $totalPartyChartData = $query->execute()->fetchAll(); + $totalPartyChartData = $query->fetchAllAssociative(); $accumulatedPartyCounter = 0; @@ -108,7 +124,7 @@ public function queryDataForPartyChartUntilDate(\DateTime $date) return $totalPartyChartData; } - public function calculatePartyCountDifferenceBetweenSeasons(Season $season1, Season $season2) + public function calculatePartyCountDifferenceBetweenSeasons(Season $season1, Season $season2): int { $partyCountSeason1 = $this->countParties($season1); diff --git a/src/Query/WishlistMailQuery.php b/src/Query/WishlistMailQuery.php index f54ff687..69e9484a 100644 --- a/src/Query/WishlistMailQuery.php +++ b/src/Query/WishlistMailQuery.php @@ -4,6 +4,7 @@ use App\Entity\Participant; use Doctrine\DBAL\Connection; +use Doctrine\DBAL\Exception; class WishlistMailQuery { @@ -14,7 +15,10 @@ public function __construct(Connection $dbal) $this->dbal = $dbal; } - public function countWishlistItemsOfParticipant(Participant $participant) + /** + * @throws Exception + */ + public function countWishlistItemsOfParticipant(Participant $participant): array { $query = $this->dbal->createQueryBuilder() ->select('count(w.id) AS wishlistItemCount') @@ -22,6 +26,6 @@ public function countWishlistItemsOfParticipant(Participant $participant) ->where('w.participant_id = :participantId') ->setParameter('participantId', $participant->getId()); - return $query->execute()->fetchAll(); + return $query->fetchAllAssociative(); } } diff --git a/src/Query/WishlistReportQuery.php b/src/Query/WishlistReportQuery.php index 92b2d98d..89d87c4f 100644 --- a/src/Query/WishlistReportQuery.php +++ b/src/Query/WishlistReportQuery.php @@ -3,6 +3,7 @@ namespace App\Query; use Doctrine\DBAL\Connection; +use Doctrine\DBAL\Exception; class WishlistReportQuery { @@ -15,6 +16,9 @@ public function __construct(Connection $dbal, ParticipantReportQuery $participan $this->participantReportQuery = $participantReportQuery; } + /** + * @throws Exception + */ public function calculateCompletedWishlists(Season $season): float { $wishlistCount = $this->countWishlists($season); @@ -27,7 +31,10 @@ public function calculateCompletedWishlists(Season $season): float return ($wishlistCount[0]['wishlistCount'] / $participantCount) * 100; } - private function countWishlists(Season $season) + /** + * @throws Exception + */ + private function countWishlists(Season $season): array { $query = $this->dbal->createQueryBuilder() ->select('count(p.id) AS wishlistCount') @@ -39,9 +46,12 @@ private function countWishlists(Season $season) ->setParameter('firstDay', $season->getStart()->format('Y-m-d H:i:s')) ->setParameter('lastDay', $season->getEnd()->format('Y-m-d H:i:s')); - return $query->execute()->fetchAll(); + return $query->fetchAllAssociative(); } + /** + * @throws Exception + */ public function calculateCompletedWishlistsUntilDate(\DateTime $date): float { $totalWishlists = $this->countAllWishlistsUntilDate($date); @@ -54,7 +64,10 @@ public function calculateCompletedWishlistsUntilDate(\DateTime $date): float throw new NoResultException(); } - private function countAllWishlistsUntilDate(\DateTime $date) + /** + * @throws Exception + */ + private function countAllWishlistsUntilDate(\DateTime $date): array { $query = $this->dbal->createQueryBuilder() ->select('count(p.id) AS totalWishlistCount') @@ -64,9 +77,12 @@ private function countAllWishlistsUntilDate(\DateTime $date) ->andWhere('wishlist_updated_time IS NOT NULL') ->setParameter('lastDay', $date->format('Y-m-d H:i:s')); - return $query->execute()->fetchAll(); + return $query->fetchAllAssociative(); } + /** + * @throws Exception + */ public function calculateCompletedWishlistDifferenceBetweenSeasons(Season $season1, Season $season2): float { $completedWishlistsSeason1 = $this->calculateCompletedWishlists($season1); diff --git a/src/Service/ExportService.php b/src/Service/ExportService.php index 4a4779dc..6fe1c6e2 100644 --- a/src/Service/ExportService.php +++ b/src/Service/ExportService.php @@ -58,7 +58,7 @@ private function getPartyReuseBaseUrl(): string { $url = $this->router->generate( 'party_reuse', - ['listurl' => '1'], + ['listurl' => '1', '_locale' => 'en'], UrlGeneratorInterface::ABSOLUTE_URL ); diff --git a/src/Validator/ParticipantHasValidExcludesValidator.php b/src/Validator/ParticipantHasValidExcludesValidator.php index c9270c87..6dd52cde 100644 --- a/src/Validator/ParticipantHasValidExcludesValidator.php +++ b/src/Validator/ParticipantHasValidExcludesValidator.php @@ -12,7 +12,7 @@ class ParticipantHasValidExcludesValidator extends ConstraintValidator * @param Participant $participant * @param ParticipantHasValidExcludes $constraint */ - public function validate($participant, Constraint $constraint) + public function validate($participant, Constraint $constraint): void { $party = $participant->getParty(); // should be at least 2 possible participants remaining to choose from, -1 for itself diff --git a/src/Validator/ParticipantIsNotBlacklistedValidator.php b/src/Validator/ParticipantIsNotBlacklistedValidator.php index f875035f..27506126 100644 --- a/src/Validator/ParticipantIsNotBlacklistedValidator.php +++ b/src/Validator/ParticipantIsNotBlacklistedValidator.php @@ -24,7 +24,7 @@ public function __construct( /** * @param string $email */ - public function validate($email, Constraint $constraint) + public function validate($email, Constraint $constraint): void { $email = $this->hashService->hashEmail($email); $repository = $this->em->getRepository(BlacklistEmail::class);