Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
164 changes: 4 additions & 160 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -2953,48 +2953,12 @@
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Event/PricesAddAction.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#1 \\$dateEnd of method AppBundle\\\\Event\\\\Model\\\\TicketEventType\\:\\:setDateEnd\\(\\) expects DateTime, DateTime\\|null given\\.$#',
'identifier' => 'argument.type',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Event/PricesAddAction.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#1 \\$dateStart of method AppBundle\\\\Event\\\\Model\\\\TicketEventType\\:\\:setDateStart\\(\\) expects DateTime, DateTime\\|null given\\.$#',
'identifier' => 'argument.type',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Event/PricesAddAction.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#1 \\$eventId of method AppBundle\\\\Event\\\\Model\\\\TicketEventType\\:\\:setEventId\\(\\) expects int, int\\|null given\\.$#',
'identifier' => 'argument.type',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Event/PricesAddAction.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#1 \\$message of class Symfony\\\\Component\\\\Form\\\\FormError constructor expects string, string\\|Stringable given\\.$#',
'identifier' => 'argument.type',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Event/PricesAddAction.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method getId\\(\\) on AppBundle\\\\Event\\\\Model\\\\TicketType\\|null\\.$#',
'identifier' => 'method.nonObject',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Event/PricesEditAction.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method setTicketType\\(\\) on AppBundle\\\\Event\\\\Model\\\\TicketEventType\\|null\\.$#',
'identifier' => 'method.nonObject',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Event/PricesEditAction.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#1 \\$ticketEventType of method AppBundle\\\\Event\\\\Model\\\\Repository\\\\TicketEventTypeRepository\\:\\:update\\(\\) expects AppBundle\\\\Event\\\\Model\\\\TicketEventType, AppBundle\\\\Event\\\\Model\\\\TicketEventType\\|null given\\.$#',
'identifier' => 'argument.type',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Event/PricesEditAction.php',
];
$ignoreErrors[] = [
'message' => '#^Method AppBundle\\\\Controller\\\\Admin\\\\Event\\\\RedirectEventFromSessionListener\\:\\:__construct\\(\\) has parameter \\$controllersWithEventSelector with no value type specified in iterable type array\\.$#',
'identifier' => 'missingType.iterableValue',
Expand Down Expand Up @@ -4603,18 +4567,6 @@
'count' => 6,
'path' => __DIR__ . '/sources/AppBundle/Controller/Event/Ticket/TicketAction.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method getIsRestrictedToMembers\\(\\) on AppBundle\\\\Event\\\\Model\\\\TicketType\\|null\\.$#',
'identifier' => 'method.nonObject',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Controller/Event/Ticket/TicketAction.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method getTicketType\\(\\) on AppBundle\\\\Event\\\\Model\\\\TicketEventType\\|null\\.$#',
'identifier' => 'method.nonObject',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Controller/Event/Ticket/TicketAction.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method getTickets\\(\\) on mixed\\.$#',
'identifier' => 'method.nonObject',
Expand Down Expand Up @@ -5551,30 +5503,12 @@
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Form/TicketSpecialPriceType.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method format\\(\\) on DateTime\\|null\\.$#',
'identifier' => 'method.nonObject',
'count' => 2,
'path' => __DIR__ . '/sources/AppBundle/Event/Form/TicketType.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method getIsRestrictedToCfpSubmitter\\(\\) on AppBundle\\\\Event\\\\Model\\\\TicketType\\|null\\.$#',
'identifier' => 'method.nonObject',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Form/TicketType.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method getIsRestrictedToMembers\\(\\) on AppBundle\\\\Event\\\\Model\\\\TicketType\\|null\\.$#',
'identifier' => 'method.nonObject',
'count' => 2,
'path' => __DIR__ . '/sources/AppBundle/Event/Form/TicketType.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method getPrettyName\\(\\) on AppBundle\\\\Event\\\\Model\\\\TicketType\\|null\\.$#',
'identifier' => 'method.nonObject',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Form/TicketType.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method getTransportInformationEnabled\\(\\) on AppBundle\\\\Event\\\\Model\\\\Event\\|null\\.$#',
'identifier' => 'method.nonObject',
Expand All @@ -5588,7 +5522,7 @@
'path' => __DIR__ . '/sources/AppBundle/Event/Form/TicketType.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#1 \\$event of method AppBundle\\\\Event\\\\Model\\\\Repository\\\\TicketEventTypeRepository\\:\\:getTicketsByEvent\\(\\) expects AppBundle\\\\Event\\\\Model\\\\Event, AppBundle\\\\Event\\\\Model\\\\Event\\|null given\\.$#',
'message' => '#^Parameter \\#1 \\$event of method AppBundle\\\\Event\\\\Entity\\\\Repository\\\\TicketEventTypeRepository\\:\\:getTicketsByEvent\\(\\) expects AppBundle\\\\Event\\\\Model\\\\Event, AppBundle\\\\Event\\\\Model\\\\Event\\|null given\\.$#',
'identifier' => 'argument.type',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Form/TicketType.php',
Expand Down Expand Up @@ -5920,19 +5854,7 @@
$ignoreErrors[] = [
'message' => '#^Cannot call method format\\(\\) on DateTime\\|null\\.$#',
'identifier' => 'method.nonObject',
'count' => 13,
'path' => __DIR__ . '/sources/AppBundle/Event/JsonLd.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method getPrettyName\\(\\) on AppBundle\\\\Event\\\\Model\\\\TicketType\\|null\\.$#',
'identifier' => 'method.nonObject',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/JsonLd.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method getTechnicalName\\(\\) on AppBundle\\\\Event\\\\Model\\\\TicketType\\|null\\.$#',
'identifier' => 'method.nonObject',
'count' => 1,
'count' => 11,
'path' => __DIR__ . '/sources/AppBundle/Event/JsonLd.php',
];
$ignoreErrors[] = [
Expand Down Expand Up @@ -6433,12 +6355,6 @@
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/GithubUserRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method getPrice\\(\\) on AppBundle\\\\Event\\\\Model\\\\TicketEventType\\|null\\.$#',
'identifier' => 'method.nonObject',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/InvoiceRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\Repository\\\\InvoiceRepository\\:\\:getByEventId\\(\\) return type with generic interface CCMBenchmark\\\\Ting\\\\Repository\\\\CollectionInterface does not specify its types\\: T$#',
'identifier' => 'missingType.generics',
Expand Down Expand Up @@ -6932,58 +6848,10 @@
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/TalkToSpeakersRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method format\\(\\) on DateTime\\|null\\.$#',
'identifier' => 'method.nonObject',
'count' => 2,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/TicketEventTypeRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method getIsRestrictedToMembers\\(\\) on AppBundle\\\\Event\\\\Model\\\\TicketType\\|null\\.$#',
'identifier' => 'method.nonObject',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/TicketEventTypeRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\Repository\\\\TicketEventTypeRepository\\:\\:doesEventHasRestrictedToMembersTickets\\(\\) has parameter \\$datesFilter with no type specified\\.$#',
'identifier' => 'missingType.parameter',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/TicketEventTypeRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\Repository\\\\TicketEventTypeRepository\\:\\:getTicketsByEvent\\(\\) return type with generic interface CCMBenchmark\\\\Ting\\\\Repository\\\\CollectionInterface does not specify its types\\: T$#',
'identifier' => 'missingType.generics',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/TicketEventTypeRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\Repository\\\\TicketEventTypeRepository\\:\\:initMetadata\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#',
'identifier' => 'missingType.iterableValue',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/TicketEventTypeRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\Repository\\\\TicketEventTypeRepository\\:\\:initMetadata\\(\\) should return M of CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata but returns CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata\\<object\\>\\.$#',
'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\Repository\\\\TicketEventTypeHydrationRepository\\:\\:initMetadata\\(\\) should return M of CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata but returns CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata\\<object\\>\\.$#',
'identifier' => 'return.type',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/TicketEventTypeRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\Repository\\\\TicketEventTypeRepository\\:\\:update\\(\\) has no return type specified\\.$#',
'identifier' => 'missingType.return',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/TicketEventTypeRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#1 \\$databaseName of method CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata\\<object\\>\\:\\:setDatabase\\(\\) expects string, mixed given\\.$#',
'identifier' => 'argument.type',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/TicketEventTypeRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#3 \\$datesFilter of method AppBundle\\\\Event\\\\Model\\\\Repository\\\\TicketEventTypeRepository\\:\\:getTicketsByEvent\\(\\) expects int\\|null, mixed given\\.$#',
'identifier' => 'argument.type',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/TicketEventTypeRepository.php',
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/TicketEventTypeHydrationRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Binary operation "\\." between \'@\' and mixed results in an error\\.$#',
Expand Down Expand Up @@ -7759,12 +7627,6 @@
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Ticket/SponsorTokenMail.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method getPrettyName\\(\\) on AppBundle\\\\Event\\\\Model\\\\TicketType\\|null\\.$#',
'identifier' => 'method.nonObject',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Ticket/TicketOffers.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#4 \\$availableTickets of class AppBundle\\\\Event\\\\Model\\\\TicketOffer constructor expects int, int\\|null given\\.$#',
'identifier' => 'argument.type',
Expand All @@ -7783,24 +7645,6 @@
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Ticket/TicketTypeAvailability.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method getDay\\(\\) on AppBundle\\\\Event\\\\Model\\\\TicketType\\|null\\.$#',
'identifier' => 'method.nonObject',
'count' => 2,
'path' => __DIR__ . '/sources/AppBundle/Event/Ticket/TicketTypeAvailability.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method getDays\\(\\) on AppBundle\\\\Event\\\\Model\\\\TicketType\\|null\\.$#',
'identifier' => 'method.nonObject',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Ticket/TicketTypeAvailability.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method getTechnicalName\\(\\) on AppBundle\\\\Event\\\\Model\\\\TicketType\\|null\\.$#',
'identifier' => 'method.nonObject',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Ticket/TicketTypeAvailability.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#',
'identifier' => 'argument.type',
Expand Down
2 changes: 1 addition & 1 deletion sources/AppBundle/Association/Form/TicketEventType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace AppBundle\Association\Form;

use AppBundle\Event\Model\TicketEventType as ModelTicketEventType;
use AppBundle\Event\Entity\TicketEventType as ModelTicketEventType;
use AppBundle\Event\Model\TicketType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace AppBundle\Controller\Admin\Event;

use AppBundle\Event\AdminEventSelection;
use AppBundle\Event\Model\Repository\TicketEventTypeRepository;
use AppBundle\Event\Entity\Repository\TicketEventTypeRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;

Expand Down
29 changes: 12 additions & 17 deletions sources/AppBundle/Controller/Admin/Event/PricesAddAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,19 @@

use AppBundle\Association\Form\TicketEventType;
use AppBundle\Event\AdminEventSelection;
use AppBundle\Event\Model\Repository\TicketEventTypeRepository;
use AppBundle\Event\Entity\Repository\TicketEventTypeRepository;
use AppBundle\Event\Entity\TicketEventType as ModelTicketEventType;
use AppBundle\Event\Model\Repository\TicketTypeRepository;
use AppBundle\Event\Model\TicketEventType as ModelTicketEventType;
use AppBundle\Validator\Constraints\UniqueEntity;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\FormError;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Validator\Validator\ValidatorInterface;

class PricesAddAction extends AbstractController
{
public function __construct(
private readonly TicketTypeRepository $ticketTypeRepository,
private readonly TicketEventTypeRepository $ticketEventTypeRepository,
private readonly ValidatorInterface $validator,
) {}

public function __invoke(Request $request, AdminEventSelection $eventSelection): Response
Expand All @@ -30,9 +27,9 @@ public function __invoke(Request $request, AdminEventSelection $eventSelection):
$event = $eventSelection->event;

$ticketEventType = new ModelTicketEventType();
$ticketEventType->setEventId($event->getId());
$ticketEventType->setDateStart($event->getDateStart());
$ticketEventType->setDateEnd($event->getDateEnd());
$ticketEventType->eventId = (int) $event->getId();
$ticketEventType->dateStart = $event->getDateStart() ?? new \DateTime();
$ticketEventType->dateEnd = $event->getDateEnd() ?? new \DateTime();

$ticketTypes = $this->ticketTypeRepository->getAll();
$form = $this->createForm(TicketEventType::class, $ticketEventType, [
Expand All @@ -42,17 +39,15 @@ public function __invoke(Request $request, AdminEventSelection $eventSelection):

$form->handleRequest($request);
if ($form->isSubmitted()) {
$ticketEventType->setTicketTypeId($ticketEventType->getTicketType()->getId());
$ticketEventType->ticketTypeId = $ticketEventType->ticketType->getId();

$violations = $this->validator->validate($ticketEventType, [
new UniqueEntity(
['ticketTypeId', 'eventId'],
$this->ticketEventTypeRepository,
'Ce type de ticket existe déjà pour cet évènement.',
),
// Vérification maison d'unicité : la clé primaire est composée de (ticketTypeId, eventId)
$existant = $this->ticketEventTypeRepository->findOneBy([
'eventId' => $ticketEventType->eventId,
'ticketTypeId' => $ticketEventType->ticketTypeId,
]);
foreach ($violations as $violation) {
$form->get('ticketType')->addError(new FormError($violation->getMessage()));
if ($existant !== null) {
$form->get('ticketType')->addError(new FormError('Ce type de ticket existe déjà pour cet évènement.'));
}

if ($form->isValid()) {
Expand Down
16 changes: 10 additions & 6 deletions sources/AppBundle/Controller/Admin/Event/PricesEditAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
use AppBundle\Association\Form\TicketEventType;
use AppBundle\Controller\Event\EventActionHelper;
use AppBundle\Event\Form\EventSelectType;
use AppBundle\Event\Model\Repository\TicketEventTypeRepository;
use AppBundle\Event\Entity\Repository\TicketEventTypeRepository;
use AppBundle\Event\Model\Repository\TicketTypeRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

class PricesEditAction extends AbstractController
{
Expand All @@ -28,11 +29,14 @@ public function __invoke(Request $request, int $event, int $id): Response
$event = $this->eventActionHelper->getEventById($event);
$ticketType = $this->ticketTypeRepository->get($id);

$ticketEventType = $this->ticketEventTypeRepository->get([
'id_event' => $event->getId(),
'id_tarif' => $ticketType->getId(),
$ticketEventType = $this->ticketEventTypeRepository->find([
'eventId' => $event->getId(),
'ticketTypeId' => $ticketType->getId(),
]);
$ticketEventType->setTicketType($ticketType);
if ($ticketEventType === null) {
throw new NotFoundHttpException();
}
$ticketEventType->ticketType = $ticketType;

$ticketTypes = $this->ticketTypeRepository->getAll();
$form = $this->createForm(TicketEventType::class, $ticketEventType, [
Expand All @@ -44,7 +48,7 @@ public function __invoke(Request $request, int $event, int $id): Response

$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$this->ticketEventTypeRepository->update($ticketEventType);
$this->ticketEventTypeRepository->save($ticketEventType);

$this->addFlash('notice', 'Le tarif a été modifié');

Expand Down
6 changes: 3 additions & 3 deletions sources/AppBundle/Controller/Admin/HomeAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use AppBundle\Event\Model\Event;
use AppBundle\Event\Model\Repository\EventRepository;
use AppBundle\Event\Model\Repository\EventStatsRepository;
use AppBundle\Event\Model\Repository\TicketEventTypeRepository;
use AppBundle\Event\Entity\Repository\TicketEventTypeRepository;
use AppBundle\AssembleeGenerale\Entity\Repository\PresenceRepository;
use AppBundle\Security\Authentication;
use AppBundle\Veille\Entity\Repository\NewsletterInscriptionRepository;
Expand Down Expand Up @@ -69,8 +69,8 @@ public function __invoke(): Response

$montantTotal = 0;
foreach ($this->ticketEventTypeRepository->getTicketsByEvent($event, false) as $ticketEventType) {
if (array_key_exists($ticketEventType->getTicketTypeId(), $stats->ticketType->paying)) {
$montantTotal += $stats->ticketType->paying[$ticketEventType->getTicketTypeId()] * $ticketEventType->getPrice();
if (array_key_exists($ticketEventType->ticketTypeId, $stats->ticketType->paying)) {
$montantTotal += $stats->ticketType->paying[$ticketEventType->ticketTypeId] * ($ticketEventType->price ?? 0.0);
}
}

Expand Down
Loading
Loading