chore: cgl fixes

This commit is contained in:
fromme committed 2026-09-11 19:37:00 +02:00
1 parent 5f8a586385
commit 5b133f724d
26 files changed
+87 -92

No files matched your search

@@ -43,7 +43,7 @@ class AdditionalServiceExclusionResolver
$submittedIds = array_filter(
$submittedIds,
fn(int $id) => !$this->conflicts($rules, $addedId, $id),
fn (int $id) => !$this->conflicts($rules, $addedId, $id),
);
}
-1
View File
@@ -510,5 +510,4 @@ class BpnXmlAnonymizer
return null;
}
}
+2 -2
View File
@@ -21,7 +21,7 @@ class CalendarGridBuilder
$months = [];
$base = $from->modify('first day of this month')->setTime(0, 0, 0);
for ($i = 0; $i < $count; $i++) {
for ($i = 0; $i < $count; ++$i) {
$monthStart = $base->modify("+{$i} months");
$months[] = [
'month' => $monthStart,
@@ -54,7 +54,7 @@ class CalendarGridBuilder
while ($current <= $gridEnd) {
$week = [];
for ($d = 0; $d < 7; $d++) {
for ($d = 0; $d < 7; ++$d) {
$week[] = [
'date' => $current,
'inMonth' => $current->format('Y-m') === $monthKey,
+12 -11
View File
@@ -30,6 +30,7 @@ class GroupsPriceCalculator
/**
* @param array<string, int|float> $config
*
* @return array<string, int|float>
*/
private function resolveConfig(array $config): array
@@ -47,8 +48,8 @@ class GroupsPriceCalculator
}
/**
* @param AccommodationPrice[] $prices all prices overlapping the booking window
* @param AdditionalService[] $additionalServices only the selected services
* @param AccommodationPrice[] $prices all prices overlapping the booking window
* @param AdditionalService[] $additionalServices only the selected services
*
* @return array{
* effectivePax: int,
@@ -88,7 +89,7 @@ class GroupsPriceCalculator
$prices,
$boardService?->getPrice(),
array_map(
fn(AdditionalService $s) => [
fn (AdditionalService $s) => [
'label' => $s->getLabel() ?? '',
'price' => $s->getPrice() ?? 0,
'type' => $s->getType(),
@@ -103,7 +104,7 @@ class GroupsPriceCalculator
* Same calculation but using frozen snapshot data from an AccommodationBooking entity
* instead of live catalog entities.
*
* @param AccommodationPrice[] $prices all prices overlapping the booking window
* @param AccommodationPrice[] $prices all prices overlapping the booking window
* @param list<array{label: string, price: int, type: string, originalServiceId: int|null}> $additionalServiceSnapshots
*
* @return array{
@@ -136,7 +137,7 @@ class GroupsPriceCalculator
string $currency,
): array {
$items = array_map(
fn(array $s) => [
fn (array $s) => [
'label' => $s['label'],
'price' => $s['price'],
'type' => AdditionalServiceType::tryFrom($s['type']) ?? AdditionalServiceType::Flat,
@@ -158,7 +159,7 @@ class GroupsPriceCalculator
}
/**
* @param AccommodationPrice[] $prices
* @param AccommodationPrice[] $prices
* @param list<array{label: string, price: int, type: AdditionalServiceType}> $additionalItems
*
* @return array{
@@ -193,7 +194,7 @@ class GroupsPriceCalculator
// Derive effectivePax: children 0–3 don't count, but never drop below includedPax
$firstCandidates = array_values(array_filter(
$prices,
fn(AccommodationPrice $p) => $p->getDateFrom() <= $dateFrom && $p->getDateTo() >= $dateFrom,
fn (AccommodationPrice $p) => $p->getDateFrom() <= $dateFrom && $p->getDateTo() >= $dateFrom,
));
$firstWinner = $this->priceTimelineBuilder->resolveWinner($firstCandidates);
$includedPaxFloor = $firstWinner?->getIncludedPax() ?? 1;
@@ -224,11 +225,11 @@ class GroupsPriceCalculator
$candidates = array_values(array_filter(
$prices,
fn(AccommodationPrice $p) => $p->getDateFrom() <= $segStart && $p->getDateTo() >= $segStart,
fn (AccommodationPrice $p) => $p->getDateFrom() <= $segStart && $p->getDateTo() >= $segStart,
));
$winner = $this->priceTimelineBuilder->resolveWinner($candidates) ?? $lastWinner;
if ($winner !== null) {
if (null !== $winner) {
$lastWinner = $winner;
$basePrice += ($winner->getPricePerNight() ?? 0) * $segNights;
$includedPax = $winner->getIncludedPax() ?? 0;
@@ -254,7 +255,7 @@ class GroupsPriceCalculator
// Rule 4: undersubscription surcharge (only when a paid board is selected)
$undersubscriptionSurcharge = 0;
$undersubscriptionThreshold = null;
if ($paidBoardPricePerPersonNight !== null) {
if (null !== $paidBoardPricePerPersonNight) {
$surcharge30 = (int) round(('CHF' === $currency ? $this->config['undersubscription30Chf'] : $this->config['undersubscription30Eur']) * 100);
$surcharge40 = (int) round(('CHF' === $currency ? $this->config['undersubscription40Chf'] : $this->config['undersubscription40Eur']) * 100);
@@ -269,7 +270,7 @@ class GroupsPriceCalculator
// Rule 5: board price
$boardPrice = 0;
if ($paidBoardPricePerPersonNight !== null) {
if (null !== $paidBoardPricePerPersonNight) {
$boardPrice = $paidBoardPricePerPersonNight * $effectivePax * $nights;
}
+4 -4
View File
@@ -115,10 +115,10 @@ class InsuranceManager
* participant's price - this splits the given insurances by type and evaluates
* each group against the appropriate price before merging the results back together.
*
* @param array<Insurance> $insurances Available insurances to filter
* @param ParticipantDto $participant The participant to match insurances for
* @param BookingDto $booking The booking context for additional criteria
* @param float $individualPrice The participant's individual travel price (excluding insurance)
* @param array<Insurance> $insurances Available insurances to filter
* @param ParticipantDto $participant The participant to match insurances for
* @param BookingDto $booking The booking context for additional criteria
* @param float $individualPrice The participant's individual travel price (excluding insurance)
* @param float $totalBookingPrice The total booking price across all participants (excluding insurance)
*
* @return array<Insurance> Filtered array of eligible insurances, sorted by price
+4 -7
View File
@@ -39,8 +39,7 @@ class ParticipantCardAssembler
BookingDto $bookingDto,
int $index,
?array $precomputedPrices = null,
): ParticipantCardDataDto
{
): ParticipantCardDataDto {
$participant = $bookingDto->participants[$index] ?? null;
if (null === $participant) {
@@ -142,8 +141,7 @@ class ParticipantCardAssembler
BookingDto $bookingDto,
int $index,
?array $precomputedPrices = null,
): ParticipantCardPriceDto
{
): ParticipantCardPriceDto {
// Check if canceled (only possible in edit mode when booking property is set)
$isCanceled = ($bookingDto->booking?->participantsStatus[$index] ?? null) === 'S';
@@ -189,8 +187,7 @@ class ParticipantCardAssembler
BookingDto $bookingDto,
int $index,
bool $forceStrictRequired = false,
): ParticipantCardDataDto
{
): ParticipantCardDataDto {
return $this->getCardDataWithValidationInternal(
$bookingDto,
$index,
@@ -262,7 +259,7 @@ class ParticipantCardAssembler
}
/**
* @param array<string> $validationGroups
* @param array<string> $validationGroups
* @param array<int, float>|null $precomputedPrices
*/
private function getCardDataWithValidationInternal(
-1
View File
@@ -8,7 +8,6 @@ use App\BusProNet\ApiClient;
use App\BusProNet\Model\Address;
use App\BusProNet\Model\Notification;
use App\Entity\User;
use App\Form\Model\BookingDto;
use App\Form\Model\ParticipantDto;
use App\Security\Crypt;
use Carbon\CarbonImmutable;
+1
View File
@@ -86,6 +86,7 @@ class ParticipantFormSupport
/**
* @param array<string, int> $options
*
* @return array<string, int>
*/
private function resolveOptions(array $options): array
+8 -8
View File
@@ -69,7 +69,7 @@ class PriceTimelineBuilder
$lastDefault = null;
// Step 2: walk each segment [start, end) and resolve the effective price.
for ($i = 0, $count = count($boundaries) - 1; $i < $count; $i++) {
for ($i = 0, $count = count($boundaries) - 1; $i < $count; ++$i) {
$segStart = $boundaries[$i];
$segEndNext = $boundaries[$i + 1];
@@ -81,12 +81,12 @@ class PriceTimelineBuilder
$candidates = array_filter(
$prices,
fn($p) => $p->getDateFrom() <= $segStart && $p->getDateTo() >= $segStart,
fn ($p) => $p->getDateFrom() <= $segStart && $p->getDateTo() >= $segStart,
);
$winner = $this->resolveWinner($candidates);
if ($winner === null) {
if (null === $winner) {
// Gap: reset merge state so the next winner always opens a new row.
$lastWinner = null;
$lastDefault = null;
@@ -94,8 +94,8 @@ class PriceTimelineBuilder
}
$defaultWinner = null;
if ($winner->getType() === PriceType::DISCOUNT) {
$defaults = array_filter($candidates, fn($p) => $p->getType() === null);
if (PriceType::DISCOUNT === $winner->getType()) {
$defaults = array_filter($candidates, fn ($p) => null === $p->getType());
$defaultWinner = $this->resolveWinner($defaults);
}
@@ -125,8 +125,8 @@ class PriceTimelineBuilder
includedPax: $winner->getIncludedPax(),
pricePerNight: round($winner->getPricePerNight() / 100, 2),
priceAdditionalPerson: round($winner->getPriceAdditionalPerson() / 100, 2),
defaultPricePerNight: $defaultWinner !== null ? round($defaultWinner->getPricePerNight() / 100, 2) : null,
defaultPriceAdditionalPerson: $defaultWinner !== null ? round($defaultWinner->getPriceAdditionalPerson() / 100, 2) : null,
defaultPricePerNight: null !== $defaultWinner ? round($defaultWinner->getPricePerNight() / 100, 2) : null,
defaultPriceAdditionalPerson: null !== $defaultWinner ? round($defaultWinner->getPriceAdditionalPerson() / 100, 2) : null,
currency: $currency,
type: $winner->getType()?->value,
);
@@ -150,7 +150,7 @@ class PriceTimelineBuilder
{
$winner = null;
foreach ($candidates as $candidate) {
if ($winner === null) {
if (null === $winner) {
$winner = $candidate;
continue;
}