From 07a4788a2e81505b44af3bfe22554f694adf3258 Mon Sep 17 00:00:00 2001 From: Brian Hanson Date: Thu, 11 Jun 2026 12:49:34 -0500 Subject: [PATCH 1/2] Fix return type error --- src/Support/DateTimeHelper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Support/DateTimeHelper.php b/src/Support/DateTimeHelper.php index 89685fecb19..71e349adb34 100644 --- a/src/Support/DateTimeHelper.php +++ b/src/Support/DateTimeHelper.php @@ -72,11 +72,11 @@ class DateTimeHelper * @param bool $assumeSystemTimeZone Whether it should be assumed that the value was set in the system timezone if * the timezone was not specified. If this is `false`, UTC will be assumed. * @param bool $setToSystemTimeZone Whether to set the resulting DateTime object to the system timezone. - * @return DateTime|false The DateTime object, or `false` if $object could not be converted to one + * @return DateTimeInterface|false The DateTime object, or `false` if $object could not be converted to one * * @throws Exception */ - public static function toDateTime(mixed $value, bool $assumeSystemTimeZone = false, bool $setToSystemTimeZone = true): DateTime|false + public static function toDateTime(mixed $value, bool $assumeSystemTimeZone = false, bool $setToSystemTimeZone = true): DateTimeInterface|false { if ($value instanceof DateTime) { return $value; From cc43125c0d4f69bf15f748bc4a29049826f8dcfd Mon Sep 17 00:00:00 2001 From: Brian Hanson Date: Thu, 11 Jun 2026 13:01:18 -0500 Subject: [PATCH 2/2] Fix PHPStan issue --- src/Condition/BaseDateRangeConditionRule.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Condition/BaseDateRangeConditionRule.php b/src/Condition/BaseDateRangeConditionRule.php index 11337026af0..5a683215c98 100644 --- a/src/Condition/BaseDateRangeConditionRule.php +++ b/src/Condition/BaseDateRangeConditionRule.php @@ -16,6 +16,7 @@ use CraftCms\Cms\Support\Url; use DateTimeInterface; use Exception; +use Illuminate\Support\Facades\Date; use Illuminate\Validation\Rule; use Override; @@ -379,6 +380,12 @@ protected function matchValue(?DateTimeInterface $value): bool private function _inclusiveEndDate(): DateTimeInterface { - return DateTimeHelper::toDateTime($this->_endDate)->modify('+1 day'); + $endDate = DateTimeHelper::toDateTime($this->_endDate); + + if ($endDate === false) { + throw new Exception('Invalid end date.'); + } + + return Date::instance($endDate)->modify('+1 day'); } }