DX: apply rector rules up to php8.0

This commit is contained in:
2023-04-15 01:05:37 +02:00
parent d8870e906f
commit dde3002100
714 changed files with 2348 additions and 9263 deletions

View File

@@ -63,25 +63,19 @@ class RollingDate
public const T_YEAR_PREVIOUS_START = 'year_previous_start';
private ?DateTimeImmutable $fixedDate;
/**
* The pivot date is the date from the rolling is computed. By default, it is "now".
*/
private DateTimeImmutable $pivotDate;
private string $roll;
/**
* @param string|self::T_* $roll
* @param DateTimeImmutable|null $pivotDate Will be "now" if null is given
* @param DateTimeImmutable|null $fixedDate Only to insert if $roll equals @see{self::T_FIXED_DATE}
*/
public function __construct(string $roll, ?DateTimeImmutable $fixedDate = null, ?DateTimeImmutable $pivotDate = null)
public function __construct(private string $roll, private ?\DateTimeImmutable $fixedDate = null, ?DateTimeImmutable $pivotDate = null)
{
$this->roll = $roll;
$this->pivotDate = $pivotDate ?? new DateTimeImmutable('now');
$this->fixedDate = $fixedDate;
}
public function getFixedDate(): ?DateTimeImmutable

View File

@@ -82,38 +82,13 @@ class RollingDateConverter implements RollingDateConverterInterface
private function toBeginOfQuarter(DateTimeImmutable $date): DateTimeImmutable
{
switch ((int) $date->format('n')) {
case 1:
case 2:
case 3:
$month = '01';
break;
case 4:
case 5:
case 6:
$month = '04';
break;
case 7:
case 8:
case 9:
$month = '07';
break;
case 10:
case 11:
case 12:
$month = '10';
break;
default:
throw new LogicException('this month is not valid: ' . $date->format('n'));
}
$month = match ((int) $date->format('n')) {
1, 2, 3 => '01',
4, 5, 6 => '04',
7, 8, 9 => '07',
10, 11, 12 => '10',
default => throw new LogicException('this month is not valid: ' . $date->format('n')),
};
return DateTimeImmutable::createFromFormat(
'Y-m-d His',