Skip to content

Commit

Permalink
add types
Browse files Browse the repository at this point in the history
  • Loading branch information
Nielsvanpach committed Jun 15, 2024
1 parent fb4ea49 commit e8b849f
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
return RectorConfig::configure()
->withPaths(['src'])
->withPhpSets(php81: true)
//->withPreparedSets(deadCode: true, codingStyle: true, typeDeclarations: true)
->withPreparedSets(deadCode: true, typeDeclarations: true)
->withSkip([
NullToStrictStringFuncCallArgRector::class,
ClosureToArrowFunctionRector::class,
Expand Down
2 changes: 1 addition & 1 deletion src/Countries/Benin.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,6 @@ protected function prepareHolidays(
$holidays[$prefix.$label.' - Jour '.$range] = $holiday->addDays($range - 1);
}

return array_filter($holidays, fn ($holiday) => $holiday->year == $filterYear);
return array_filter($holidays, fn ($holiday): bool => $holiday->year == $filterYear);
}
}
2 changes: 1 addition & 1 deletion src/Countries/Country.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function get(int $year, ?string $locale = null): array
}

uasort($translatedHolidays,
fn (CarbonImmutable $a, CarbonImmutable $b) => $a->timestamp <=> $b->timestamp
fn (CarbonImmutable $a, CarbonImmutable $b): int => $a->timestamp <=> $b->timestamp
);

return $translatedHolidays;
Expand Down
8 changes: 4 additions & 4 deletions src/Countries/Czechia.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ protected function allHolidays(int $year): array
];

$filteredHolidays = array_map(
static fn (array $holiday) => $holiday[0],
static fn (array $holiday): string => $holiday[0],
array_filter($holidays,
static fn (array $holiday) => $holiday[1] === true
static fn (array $holiday): bool => $holiday[1] === true
)
);

Expand All @@ -63,9 +63,9 @@ protected function variableHolidays(int $year): array
];

return array_map(
static fn (array $variableHoliday) => $variableHoliday[0],
static fn (array $variableHoliday): \Carbon\CarbonImmutable => $variableHoliday[0],
array_filter($variableHolidays,
static fn (array $variableHoliday) => $variableHoliday[1] === true
static fn (array $variableHoliday): bool => $variableHoliday[1] === true
)
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Countries/Morocco.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ private function islamicToGregorian(int $y, int $m, int $d): array
* @param float $floatNum The floating-point number to be rounded.
* @return float The rounded integer value.
*/
private function intPart($floatNum)
private function intPart(int|float $floatNum): float
{
// Check if the floating-point number is negative
if ($floatNum < -0.0000001) {
Expand Down
4 changes: 1 addition & 3 deletions src/Countries/Norway.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected function variableHolidays(int $year): array
{
$easter = $this->easter($year);

$holidays = [
return [
'Skjærtorsdag' => $easter->subDays(3),
'Langfredag' => $easter->subDays(2),
'Første påskedag' => $easter,
Expand All @@ -36,7 +36,5 @@ protected function variableHolidays(int $year): array
'Første pinsedag' => $easter->addDays(49),
'Andre pinsedag' => $easter->addDays(50),
];

return $holidays;
}
}
2 changes: 1 addition & 1 deletion src/Countries/Switzerland.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ public function regionalHolidays(int $year): array

$regionalHolidays = array_filter(
$regionallyDifferentHolidays,
fn ($key) => in_array($key, $currentRegion),
fn ($key): bool => in_array($key, $currentRegion),
ARRAY_FILTER_USE_KEY
);

Expand Down
2 changes: 1 addition & 1 deletion src/Countries/Taiwan.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected function allHolidays(int $year): array
/** @return array<string, string> */
protected function variableHolidays(int $year): array
{
return array_filter(array_map(fn ($date) => $this->lunarCalendar($date, $year), [
return array_filter(array_map(fn ($date): ?string => $this->lunarCalendar($date, $year), [
'農曆春節-正月初一' => '01-01',
'農曆春節-正月初二' => '01-02',
'農曆春節-正月初三' => '01-03',
Expand Down
2 changes: 1 addition & 1 deletion src/Holidays.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function isHoliday(CarbonInterface|string $date, Country|string|null $cou
$holidays = array_column($holidays, 'date');

$formattedHolidays = array_map(
fn (string $holiday) => CarbonImmutable::parse($holiday)->format('Y-m-d'),
fn (string $holiday): string => CarbonImmutable::parse($holiday)->format('Y-m-d'),
$holidays
);

Expand Down

0 comments on commit e8b849f

Please sign in to comment.