Skip to content

Commit

Permalink
fixed csfixer + phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
Lung committed Sep 21, 2023
1 parent 29a4e5d commit 94c37fc
Show file tree
Hide file tree
Showing 15 changed files with 30 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/Application/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public function addRoutesInto(App $app): App
})->add(CheckLeaderParticipants::class);
})->add(OpenStatusOnlyMiddleware::class);
})->add(PatrolLeadersOnlyMiddleware::class);

$app->group('/troop', function (RouteCollectorProxy $app) {
$app->post('/tieParticipantToTroopByLeader', TroopController::class . '::tieParticipantToTroopByLeader')
->setName('tie-tp-by-tl')
Expand Down
2 changes: 1 addition & 1 deletion src/Application/migrations/20230917104721_add_tie_code.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public function up(): void
$table = $this->table('participant');
$table->addColumn('tie_code', 'string', ['null' => false, 'default' => '123456',]);
$table->save();

$table->changeColumn('tie_code', 'string', ['null' => false]);
$table->save();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Event/EventType/EventType.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public function showParticipantInfoInMail(): bool

public function calculatePaymentDueDate(DateTimeImmutable $dateFrom): DateTimeImmutable
{
// TODO edit to take 14 days or day before event start date, whatever comes sooner
// TODO edit to take 14 days or day before event start date, whatever comes sooner
return $dateFrom->add(DateInterval::createFromDateString('14 days'));
}

Expand Down
10 changes: 5 additions & 5 deletions src/Event/EventType/Korbo/EventTypeKorbo.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ public function isSellingIstTicketsAllowed(): bool
return true;
}

public function calculatePaymentDueDate(DateTimeImmutable $dateFrom): DateTimeImmutable
{
// TODO remove for 2024, hotfix only
return new DateTimeImmutable('2023-09-18');
}
public function calculatePaymentDueDate(DateTimeImmutable $dateFrom): DateTimeImmutable
{
// TODO remove for 2024, hotfix only
return new DateTimeImmutable('2023-09-18');
}
}
2 changes: 1 addition & 1 deletion src/Middleware/CheckLeaderParticipants.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function process(Request $request, ResponseHandler $handler): Response

$participantId = (int)$route->getArgument('participantId');
$leader = $this->participantRepository->getParticipantFromUser($this->getUser($request));

if ($leader instanceof PatrolLeader) {
if (!$this->patrolService->patrolParticipantBelongsPatrolLeader(
$this->patrolService->getPatrolParticipant($participantId),
Expand Down
2 changes: 1 addition & 1 deletion src/Participant/Participant.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class Participant extends EntityDatetime
public const FOOD_OTHER = 'other';
public const SCARF_NO = 'no';
public const SCARF_YES = 'yes';

protected function initDefaults(): void
{
parent::initDefaults();
Expand Down
3 changes: 2 additions & 1 deletion src/Participant/ParticipantController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use kissj\Participant\Patrol\PatrolParticipant;
use kissj\Participant\Patrol\PatrolParticipantRepository;
use kissj\Participant\Troop\TroopLeader;
use kissj\Participant\Troop\TroopParticipant;
use kissj\Participant\Troop\TroopParticipantRepository;
use kissj\User\User;
use kissj\User\UserStatus;
Expand Down Expand Up @@ -91,7 +92,7 @@ public function closeRegistration(Request $request, Response $response, User $us
}

/**
* @return array<string, User|Participant|AbstractContentArbiter|PatrolParticipant[]>
* @return array<string, User|Participant|AbstractContentArbiter|PatrolParticipant[]|TroopParticipant[]>
*/
private function getTemplateData(Participant $participant): array
{
Expand Down
3 changes: 1 addition & 2 deletions src/Participant/ParticipantService.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,8 @@ private function isCloseRegistrationValidForTroopLeader(TroopLeader $troopLeader

$validityFlag = false;
}

if ($participant->user->status !== UserStatus::Closed) {

if ($participant->getUserButNotNull()->status !== UserStatus::Closed) {
$this->flashMessages->warning(
$this->translator->trans(
'flash.warning.tpNotClosed',
Expand Down
2 changes: 1 addition & 1 deletion src/Participant/Troop/TroopController.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function tieParticipantToTroopByParticipant(

return $this->redirect($request, $response, 'getDashboard');
}

$tieCode = $this->getParameterFromBody($request, 'tieCode');
$troopLeader = $this->troopLeaderRepository->findTroopLeaderFromTieCode($tieCode, $event);

Expand Down
2 changes: 1 addition & 1 deletion src/Participant/Troop/TroopLeaderRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function findTroopLeaderFromTieCode(string $tieCode, Event $event): ?Troo
'tie_code' => strtoupper($tieCode),
'role' => ParticipantRole::TroopLeader,
]);
if ($troopLeader?->user->event->id !== $event->id) {
if ($troopLeader?->getUserButNotNull()->event->id !== $event->id) {
return null;
}

Expand Down
6 changes: 4 additions & 2 deletions src/Participant/Troop/TroopParticipantRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,21 @@ public function findTroopParticipantFromTieCode(string $tieCode, Event $event):
'tie_code' => strtoupper($tieCode),
'role' => ParticipantRole::TroopParticipant,
]);
if ($troopParticipant?->user->event->id !== $event->id) {
if ($troopParticipant?->getUserButNotNull()->event->id !== $event->id) {
return null;
}

return $troopParticipant;
}

/**
* @return TroopParticipant[]
*/
public function findAllTroopParticipantsForTroopLeader(TroopLeader $troopLeader): array
{
return $this->findBy(['patrol_leader_id' => $troopLeader->id]);
}

// TODO check why?
public function getFromUser(User $user): TroopParticipant
{
return $this->getOneBy(['user' => $user]);
Expand Down
8 changes: 4 additions & 4 deletions src/Participant/Troop/TroopService.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function tieTroopParticipantToTroopLeader(

return $troopParticipant;
}

if ($troopParticipant->troopLeader?->id === $troopLeader->id) {
$this->flashMessages->warning($this->translator->trans('flash.warning.troopParticipantAlreadyTied'));

Expand All @@ -76,15 +76,15 @@ public function troopParticipantBelongsTroopLeader(
TroopParticipant $troopParticipant,
TroopLeader $troopLeader
): bool {
return $troopParticipant->troopLeader->id === $troopLeader->id;
return $troopParticipant->troopLeader?->id === $troopLeader->id;
}

public function untieTroopParticipant(int $participantId): TroopParticipant
{
$troopParticipant = $this->troopParticipantRepository->get($participantId);
$troopParticipant->troopLeader = null;
$this->troopParticipantRepository->persist($troopParticipant);
return $troopParticipant;

return $troopParticipant;
}
}
2 changes: 1 addition & 1 deletion src/Payment/PaymentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function confirmPayment(Payment $payment): Payment
if ($participant instanceof TroopLeader) {
foreach ($participant->troopParticipants as $tp) {
$this->userService->setUserPaid($tp->getUserButNotNull());

$tp->registrationCloseDate = $now;
$this->participantRepository->persist($tp);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Settings/TwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ public function getTests(): array
}),
new TwigTest('eligibleForShowTieCode', function ($participant): bool {
return (
$participant instanceof TroopLeader && $participant->user->status === UserStatus::Open
) || (
$participant instanceof TroopParticipant && $participant->troopLeader === null
);
$participant instanceof TroopLeader && $participant->getUserButNotNull()->status === UserStatus::Open
) || (
$participant instanceof TroopParticipant && $participant->troopLeader === null
);
}),
];
}
Expand Down
2 changes: 2 additions & 0 deletions tests/Unit/Payment/PaymentServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use kissj\BankPayment\FioBankPaymentService;
use kissj\FlashMessages\FlashMessagesBySession;
use kissj\Mailer\PhpMailerWrapper;
use kissj\Participant\ParticipantRepository;
use kissj\Payment\PaymentRepository;
use kissj\User\UserService;
use Monolog\Logger;
Expand All @@ -20,6 +21,7 @@ public function testGetVariableNumber(): void
\Mockery::mock(FioBankPaymentService::class),
\Mockery::mock(BankPaymentRepository::class),
\Mockery::mock(PaymentRepository::class),
\Mockery::mock(ParticipantRepository::class),
\Mockery::mock(UserService::class),
\Mockery::mock(FlashMessagesBySession::class),
\Mockery::mock(PhpMailerWrapper::class),
Expand Down

0 comments on commit 94c37fc

Please sign in to comment.