From 32a94ff790adf31c3058d72a3e4d75634d01b8b2 Mon Sep 17 00:00:00 2001 From: Niels Vanpachtenbeke <10651054+Nielsvanpach@users.noreply.github.com> Date: Thu, 1 Feb 2024 10:45:07 +0100 Subject: [PATCH] fixes for Sweden --- phpstan-baseline.neon | 5 +++++ src/Countries/Sweden.php | 11 +++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index ec51df55b..b253bace3 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -25,6 +25,11 @@ parameters: count: 1 path: src/Countries/Country.php + - + message: "#^Cannot call method startOfDay\\(\\) on Carbon\\\\CarbonImmutable\\|false\\.$#" + count: 2 + path: src/Countries/Sweden.php + - message: "#^Cannot call method setTimeStamp\\(\\) on DateTime\\|false\\.$#" count: 1 diff --git a/src/Countries/Sweden.php b/src/Countries/Sweden.php index dc4a5b888..e16eae6eb 100644 --- a/src/Countries/Sweden.php +++ b/src/Countries/Sweden.php @@ -3,6 +3,7 @@ namespace Spatie\Holidays\Countries; use Carbon\CarbonImmutable; +use Carbon\CarbonInterface; class Sweden extends Country { @@ -28,18 +29,16 @@ protected function variableHolidays(int $year): array { $easter = $this->easter($year); - /** @var CarbonImmutable $midsummerDay */ - $midsummerDay = CarbonImmutable::createFromFormat('Y-m-d', "{$year}-06-20"); + $midsummerDay = CarbonImmutable::createFromFormat('Y-m-d', "{$year}-06-20")->startOfDay(); if (! $midsummerDay->isSaturday()) { - $midsummerDay = $midsummerDay->next(CarbonImmutable::SATURDAY); + $midsummerDay = $midsummerDay->next(CarbonInterface::SATURDAY); } - /** @var CarbonImmutable $halloween */ - $halloween = CarbonImmutable::createFromFormat('Y-m-d', "{$year}-10-31"); + $halloween = CarbonImmutable::createFromFormat('Y-m-d', "{$year}-10-31")->startOfDay(); if (! $halloween->isSaturday()) { - $halloween = $halloween->next(CarbonImmutable::SATURDAY); + $halloween = $halloween->next(CarbonInterface::SATURDAY); } return [