Skip to content

Commit efb323d

Browse files
committed
refactor: migration de l'entité Vote de Ting vers Doctrine (#2383)
1 parent ceabe1d commit efb323d

13 files changed

Lines changed: 215 additions & 378 deletions

File tree

‎phpstan-baseline.php‎

Lines changed: 29 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -3368,7 +3368,7 @@
33683368
'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Event/Ticket/IndexAction.php',
33693369
];
33703370
$ignoreErrors[] = [
3371-
'message' => '#^Parameter \\#1 \\$eventId of method AppBundle\\\\Event\\\\Model\\\\Repository\\\\VoteRepository\\:\\:getVotesByEvent\\(\\) expects int, int\\|null given\\.$#',
3371+
'message' => '#^Parameter \\#1 \\$eventId of method AppBundle\\\\Event\\\\Entity\\\\Repository\\\\VoteRepository\\:\\:getVotesByEvent\\(\\) expects int, int\\|null given\\.$#',
33723372
'identifier' => 'argument.type',
33733373
'count' => 1,
33743374
'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Event/VotesListeAction.php',
@@ -4147,12 +4147,6 @@
41474147
'count' => 2,
41484148
'path' => __DIR__ . '/sources/AppBundle/Controller/Event/Event/ShowAction.php',
41494149
];
4150-
$ignoreErrors[] = [
4151-
'message' => '#^Cannot access offset \'votes\' on mixed\\.$#',
4152-
'identifier' => 'offsetAccess.nonOffsetAccessible',
4153-
'count' => 2,
4154-
'path' => __DIR__ . '/sources/AppBundle/Controller/Event/Event/ShowAction.php',
4155-
];
41564150
$ignoreErrors[] = [
41574151
'message' => '#^Cannot call method getPath\\(\\) on mixed\\.$#',
41584152
'identifier' => 'method.nonObject',
@@ -4490,38 +4484,38 @@
44904484
'path' => __DIR__ . '/sources/AppBundle/Controller/Event/Vote/IndexAction.php',
44914485
];
44924486
$ignoreErrors[] = [
4493-
'message' => '#^Parameter \\#3 \\$vote of method AppBundle\\\\Controller\\\\Event\\\\Vote\\\\VoteController\\:\\:createVoteForm\\(\\) expects AppBundle\\\\Event\\\\Model\\\\Vote, mixed given\\.$#',
4487+
'message' => '#^Parameter \\#3 \\$vote of method AppBundle\\\\Controller\\\\Event\\\\Vote\\\\VoteController\\:\\:createVoteForm\\(\\) expects AppBundle\\\\Event\\\\Entity\\\\Vote, mixed given\\.$#',
44944488
'identifier' => 'argument.type',
44954489
'count' => 1,
44964490
'path' => __DIR__ . '/sources/AppBundle/Controller/Event/Vote/IndexAction.php',
44974491
];
44984492
$ignoreErrors[] = [
4499-
'message' => '#^Cannot call method setSubmittedOn\\(\\) on mixed\\.$#',
4500-
'identifier' => 'method.nonObject',
4493+
'message' => '#^Cannot access property \\$submittedOn on mixed\\.$#',
4494+
'identifier' => 'property.nonObject',
45014495
'count' => 1,
45024496
'path' => __DIR__ . '/sources/AppBundle/Controller/Event/Vote/NewAction.php',
45034497
];
45044498
$ignoreErrors[] = [
4505-
'message' => '#^Cannot call method setTalk\\(\\) on mixed\\.$#',
4506-
'identifier' => 'method.nonObject',
4499+
'message' => '#^Cannot access property \\$talk on mixed\\.$#',
4500+
'identifier' => 'property.nonObject',
45074501
'count' => 1,
45084502
'path' => __DIR__ . '/sources/AppBundle/Controller/Event/Vote/NewAction.php',
45094503
];
45104504
$ignoreErrors[] = [
4511-
'message' => '#^Parameter \\#1 \\$user of method AppBundle\\\\Event\\\\Model\\\\Vote\\:\\:setUser\\(\\) expects int, int\\|null given\\.$#',
4505+
'message' => '#^Parameter \\#1 \\$vote of method AppBundle\\\\Event\\\\Entity\\\\Repository\\\\VoteRepository\\:\\:upsert\\(\\) expects AppBundle\\\\Event\\\\Entity\\\\Vote, mixed given\\.$#',
45124506
'identifier' => 'argument.type',
45134507
'count' => 1,
45144508
'path' => __DIR__ . '/sources/AppBundle/Controller/Event/Vote/NewAction.php',
45154509
];
45164510
$ignoreErrors[] = [
4517-
'message' => '#^Parameter \\#1 \\$vote of method AppBundle\\\\Event\\\\Model\\\\Repository\\\\VoteRepository\\:\\:upsert\\(\\) expects AppBundle\\\\Event\\\\Model\\\\Vote, mixed given\\.$#',
4511+
'message' => '#^Parameter \\#1 \\$vote of method AppBundle\\\\Notifier\\\\SlackNotifier\\:\\:notifyVote\\(\\) expects AppBundle\\\\Event\\\\Entity\\\\Vote, mixed given\\.$#',
45184512
'identifier' => 'argument.type',
45194513
'count' => 1,
45204514
'path' => __DIR__ . '/sources/AppBundle/Controller/Event/Vote/NewAction.php',
45214515
];
45224516
$ignoreErrors[] = [
4523-
'message' => '#^Parameter \\#1 \\$vote of method AppBundle\\\\Notifier\\\\SlackNotifier\\:\\:notifyVote\\(\\) expects AppBundle\\\\Event\\\\Model\\\\Vote, mixed given\\.$#',
4524-
'identifier' => 'argument.type',
4517+
'message' => '#^Property AppBundle\\\\Event\\\\Entity\\\\Vote\\:\\:\\$userId \\(int\\) does not accept int\\|null\\.$#',
4518+
'identifier' => 'assign.propertyType',
45254519
'count' => 1,
45264520
'path' => __DIR__ . '/sources/AppBundle/Controller/Event/Vote/NewAction.php',
45274521
];
@@ -5083,6 +5077,18 @@
50835077
'count' => 1,
50845078
'path' => __DIR__ . '/sources/AppBundle/Email/Mailer/Mailer.php',
50855079
];
5080+
$ignoreErrors[] = [
5081+
'message' => '#^Cannot cast mixed to int\\.$#',
5082+
'identifier' => 'cast.int',
5083+
'count' => 7,
5084+
'path' => __DIR__ . '/sources/AppBundle/Event/Entity/Repository/VoteRepository.php',
5085+
];
5086+
$ignoreErrors[] = [
5087+
'message' => '#^Parameter \\#1 \\$datetime of class DateTimeImmutable constructor expects string, mixed given\\.$#',
5088+
'identifier' => 'argument.type',
5089+
'count' => 1,
5090+
'path' => __DIR__ . '/sources/AppBundle/Event/Entity/Repository/VoteRepository.php',
5091+
];
50865092
$ignoreErrors[] = [
50875093
'message' => '#^Class AppBundle\\\\Event\\\\Form\\\\EventCFPTextType extends generic class Symfony\\\\Component\\\\Form\\\\AbstractType but does not specify its types\\: TData$#',
50885094
'identifier' => 'missingType.generics',
@@ -6895,60 +6901,6 @@
68956901
'count' => 1,
68966902
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/TicketTypeRepository.php',
68976903
];
6898-
$ignoreErrors[] = [
6899-
'message' => '#^Cannot cast mixed to int\\.$#',
6900-
'identifier' => 'cast.int',
6901-
'count' => 1,
6902-
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/VoteRepository.php',
6903-
];
6904-
$ignoreErrors[] = [
6905-
'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\Repository\\\\VoteRepository\\:\\:getNumberOfVotesByEvent\\(\\) has no return type specified\\.$#',
6906-
'identifier' => 'missingType.return',
6907-
'count' => 1,
6908-
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/VoteRepository.php',
6909-
];
6910-
$ignoreErrors[] = [
6911-
'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\Repository\\\\VoteRepository\\:\\:getVotesByEvent\\(\\) return type with generic interface CCMBenchmark\\\\Ting\\\\Repository\\\\CollectionInterface does not specify its types\\: T$#',
6912-
'identifier' => 'missingType.generics',
6913-
'count' => 1,
6914-
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/VoteRepository.php',
6915-
];
6916-
$ignoreErrors[] = [
6917-
'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\Repository\\\\VoteRepository\\:\\:getVotesByTalkWithUser\\(\\) has no return type specified\\.$#',
6918-
'identifier' => 'missingType.return',
6919-
'count' => 1,
6920-
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/VoteRepository.php',
6921-
];
6922-
$ignoreErrors[] = [
6923-
'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\Repository\\\\VoteRepository\\:\\:getVotesByTalkWithUser\\(\\) has parameter \\$talkId with no type specified\\.$#',
6924-
'identifier' => 'missingType.parameter',
6925-
'count' => 1,
6926-
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/VoteRepository.php',
6927-
];
6928-
$ignoreErrors[] = [
6929-
'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\Repository\\\\VoteRepository\\:\\:initMetadata\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#',
6930-
'identifier' => 'missingType.iterableValue',
6931-
'count' => 1,
6932-
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/VoteRepository.php',
6933-
];
6934-
$ignoreErrors[] = [
6935-
'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\Repository\\\\VoteRepository\\:\\:initMetadata\\(\\) should return M of CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata but returns CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata\\<object\\>\\.$#',
6936-
'identifier' => 'return.type',
6937-
'count' => 1,
6938-
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/VoteRepository.php',
6939-
];
6940-
$ignoreErrors[] = [
6941-
'message' => '#^Parameter \\#1 \\$databaseName of method CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata\\<object\\>\\:\\:setDatabase\\(\\) expects string, mixed given\\.$#',
6942-
'identifier' => 'argument.type',
6943-
'count' => 1,
6944-
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/VoteRepository.php',
6945-
];
6946-
$ignoreErrors[] = [
6947-
'message' => '#^Parameter \\#1 \\$submittedOn of method AppBundle\\\\Event\\\\Model\\\\Vote\\:\\:setSubmittedOn\\(\\) expects DateTime, DateTime\\|null given\\.$#',
6948-
'identifier' => 'argument.type',
6949-
'count' => 1,
6950-
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/VoteRepository.php',
6951-
];
69526904
$ignoreErrors[] = [
69536905
'message' => '#^Property AppBundle\\\\Event\\\\Model\\\\Room\\:\\:\\$name \\(string\\) does not accept mixed\\.$#',
69546906
'identifier' => 'assign.propertyType',
@@ -7021,6 +6973,12 @@
70216973
'count' => 1,
70226974
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Talk.php',
70236975
];
6976+
$ignoreErrors[] = [
6977+
'message' => '#^Property AppBundle\\\\Event\\\\Model\\\\Talk\\:\\:\\$votes has unknown class AppBundle\\\\Event\\\\Model\\\\Vote as its type\\.$#',
6978+
'identifier' => 'class.notFound',
6979+
'count' => 1,
6980+
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Talk.php',
6981+
];
70246982
$ignoreErrors[] = [
70256983
'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\Ticket\\:\\:getTags\\(\\) return type has no value type specified in iterable type array\\.$#',
70266984
'identifier' => 'missingType.iterableValue',
@@ -7039,12 +6997,6 @@
70396997
'count' => 1,
70406998
'path' => __DIR__ . '/sources/AppBundle/Event/Model/TicketType.php',
70416999
];
7042-
$ignoreErrors[] = [
7043-
'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\Vote\\:\\:getId\\(\\) should return int but returns int\\|null\\.$#',
7044-
'identifier' => 'return.type',
7045-
'count' => 1,
7046-
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Vote.php',
7047-
];
70487000
$ignoreErrors[] = [
70497001
'message' => '#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#',
70507002
'identifier' => 'foreach.nonIterable',
@@ -8737,12 +8689,6 @@
87378689
'count' => 1,
87388690
'path' => __DIR__ . '/sources/AppBundle/Slack/MessageFactory.php',
87398691
];
8740-
$ignoreErrors[] = [
8741-
'message' => '#^Cannot call method getTitle\\(\\) on AppBundle\\\\Event\\\\Model\\\\Talk\\|null\\.$#',
8742-
'identifier' => 'method.nonObject',
8743-
'count' => 2,
8744-
'path' => __DIR__ . '/sources/AppBundle/Slack/MessageFactory.php',
8745-
];
87468692
$ignoreErrors[] = [
87478693
'message' => '#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#',
87488694
'identifier' => 'foreach.nonIterable',
@@ -9585,3 +9531,4 @@
95859531
];
95869532

95879533
return ['parameters' => ['ignoreErrors' => $ignoreErrors]];
9534+

‎sources/AppBundle/Controller/Admin/Event/VotesListeAction.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace AppBundle\Controller\Admin\Event;
66

77
use AppBundle\Event\AdminEventSelection;
8-
use AppBundle\Event\Model\Repository\VoteRepository;
8+
use AppBundle\Event\Entity\Repository\VoteRepository;
99
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
1010
use Symfony\Component\HttpFoundation\Request;
1111
use Symfony\Component\HttpFoundation\Response;

‎sources/AppBundle/Controller/Event/CFP/EditAction.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use AppBundle\Event\Model\Repository\SpeakerRepository;
1313
use AppBundle\Event\Model\Repository\TalkInvitationRepository;
1414
use AppBundle\Event\Model\Repository\TalkRepository;
15-
use AppBundle\Event\Model\Repository\VoteRepository;
15+
use AppBundle\Event\Entity\Repository\VoteRepository;
1616
use AppBundle\Event\Model\Talk;
1717
use AppBundle\Event\Model\TalkInvitation;
1818
use AppBundle\Event\Talk\InvitationFormHandler;
@@ -98,7 +98,7 @@ public function __invoke(Request $request): RedirectResponse|Response
9898
'invitations' => $this->talkInvitationRepository->getPendingInvitationsByTalkId($talk->getId()),
9999
'speakers' => $this->speakerRepository->getSpeakersByTalk($talk),
100100
'invitationForm' => $invitationForm->createView(),
101-
'votes' => $this->voteRepository->getVotesByTalkWithUser($talk->getId()),
101+
'votes' => $this->voteRepository->getVotesByTalkWithUser((int) $talk->getId()),
102102
'sidebar' => $this->sidebarRenderer->render($event),
103103
]);
104104
}

‎sources/AppBundle/Controller/Event/Event/ShowAction.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
use AppBundle\Controller\Event\EventActionHelper;
88
use AppBundle\Event\Model\Repository\TalkRepository;
9-
use AppBundle\Event\Model\Repository\VoteRepository;
9+
use AppBundle\Event\Entity\Repository\VoteRepository;
1010
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
1111
use Symfony\Component\HttpFoundation\Response;
1212

‎sources/AppBundle/Controller/Event/Vote/IndexAction.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use AppBundle\Controller\Event\EventActionHelper;
88
use AppBundle\Event\Model\Repository\TalkRepository;
99
use AppBundle\Event\Model\Talk;
10-
use AppBundle\Event\Model\Vote;
10+
use AppBundle\Event\Entity\Vote;
1111
use AppBundle\Security\Authentication;
1212
use Symfony\Component\HttpFoundation\RequestStack;
1313
use Symfony\Component\HttpFoundation\Response;

‎sources/AppBundle/Controller/Event/Vote/NewAction.php‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@
55
namespace AppBundle\Controller\Event\Vote;
66

77
use AppBundle\Controller\Event\EventActionHelper;
8+
use AppBundle\Event\Entity\Vote;
9+
use AppBundle\Event\Entity\Repository\VoteRepository;
810
use AppBundle\Event\Model\GithubUser;
911
use AppBundle\Event\Model\Repository\TalkRepository;
10-
use AppBundle\Event\Model\Repository\VoteRepository;
1112
use AppBundle\Event\Model\Talk;
12-
use AppBundle\Event\Model\Vote;
1313
use AppBundle\Notifier\SlackNotifier;
1414
use AppBundle\Security\Authentication;
15-
use CCMBenchmark\Ting\Exception;
15+
use DateTime;
16+
use Doctrine\DBAL\Exception as DbalException;
17+
use Doctrine\ORM\Exception\ORMException;
1618
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
1719
use Symfony\Component\HttpFoundation\JsonResponse;
1820
use Symfony\Component\HttpFoundation\Request;
@@ -40,7 +42,7 @@ public function __invoke(Request $request, string $eventSlug, int $talkId): Json
4042
$vote = new Vote();
4143
$user = $this->authentication->getGithubUserOrNull();
4244
if ($user instanceof GithubUser) {
43-
$vote->setUser($user->getId());
45+
$vote->userId = $user->getId();
4446
}
4547

4648
$form = $this->createVoteForm($eventSlug, $talkId, $vote);
@@ -65,15 +67,15 @@ public function __invoke(Request $request, string $eventSlug, int $talkId): Json
6567
}
6668

6769
$vote = $form->getData();
68-
$vote->setSubmittedOn(new \DateTime());
70+
$vote->submittedOn = new DateTime();
6971

7072
try {
71-
$vote->setTalk($talk);
73+
$vote->talk = $talk;
7274
$this->eventDispatcher->addListener(KernelEvents::TERMINATE, function () use ($vote): void {
7375
$this->slackNotifier->notifyVote($vote);
7476
});
7577
$this->voteRepository->upsert($vote);
76-
} catch (Exception $e) {
78+
} catch (DbalException|ORMException $e) {
7779
return new JsonResponse(['errors' => [$e->getMessage()]], Response::HTTP_INTERNAL_SERVER_ERROR);
7880
}
7981

‎sources/AppBundle/Controller/Event/Vote/VoteController.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
namespace AppBundle\Controller\Event\Vote;
66

7+
use AppBundle\Event\Entity\Vote;
78
use AppBundle\Event\Form\VoteType;
8-
use AppBundle\Event\Model\Vote;
99
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
1010
use Symfony\Component\Form\FormInterface;
1111
use Symfony\Component\HttpFoundation\Request;
@@ -14,7 +14,7 @@ abstract class VoteController extends AbstractController
1414
{
1515
protected function createVoteForm(string $eventSlug, int $talkId, Vote $vote): FormInterface
1616
{
17-
$vote->setSessionId($talkId);
17+
$vote->sessionId = $talkId;
1818

1919
return $this
2020
->createFormBuilder()->create(

0 commit comments

Comments
 (0)