diff --git a/src/Year.php b/src/Year.php index 143ccc9..6eaf5c9 100644 --- a/src/Year.php +++ b/src/Year.php @@ -13,9 +13,7 @@ use function is_int; use function str_pad; -use function trigger_error; -use const E_USER_DEPRECATED; use const STR_PAD_LEFT; /** @@ -243,16 +241,10 @@ public function atDay(int $dayOfYear): LocalDate public function atMonth(int|Month $month): YearMonth { if (is_int($month)) { - // usually we don't use trigger_error() for deprecations, but we can't rely on @deprecated for a parameter type change; - // maybe we should revisit using trigger_error() unconditionally for deprecations in the future. - trigger_error('Passing an integer to Year::atMonth() is deprecated, pass a Month instance instead.', E_USER_DEPRECATED); - Field\MonthOfYear::check($month); - - $month = Month::from($month); } - return YearMonth::of($this->year, $month->value); + return YearMonth::of($this->year, $month); } /** diff --git a/src/YearMonth.php b/src/YearMonth.php index 1cbd2b2..989b78a 100644 --- a/src/YearMonth.php +++ b/src/YearMonth.php @@ -14,9 +14,7 @@ use function is_int; use function str_pad; -use function trigger_error; -use const E_USER_DEPRECATED; use const STR_PAD_LEFT; /** @@ -46,16 +44,12 @@ public static function of(int $year, int|Month $month): YearMonth Field\Year::check($year); if (is_int($month)) { - // usually we don't use trigger_error() for deprecations, but we can't rely on @deprecated for a parameter type change; - // maybe we should revisit using trigger_error() unconditionally for deprecations in the future. - trigger_error('Passing an integer to YearMonth::of() second argument is deprecated, pass a Month instance instead.', E_USER_DEPRECATED); - Field\MonthOfYear::check($month); - - return new YearMonth($year, $month); + } else { + $month = $month->value; } - return new YearMonth($year, $month->value); + return new YearMonth($year, $month); } /** @@ -216,10 +210,6 @@ public function withYear(int $year): YearMonth public function withMonth(int|Month $month): YearMonth { if (is_int($month)) { - // usually we don't use trigger_error() for deprecations, but we can't rely on @deprecated for a parameter type change; - // maybe we should revisit using trigger_error() unconditionally for deprecations in the future. - trigger_error('Passing an integer to YearMonth::withMonth() is deprecated, pass a Month instance instead.', E_USER_DEPRECATED); - Field\MonthOfYear::check($month); } else { $month = $month->value; diff --git a/src/YearWeek.php b/src/YearWeek.php index 2828606..2be17fc 100644 --- a/src/YearWeek.php +++ b/src/YearWeek.php @@ -13,9 +13,7 @@ use function is_int; use function str_pad; -use function trigger_error; -use const E_USER_DEPRECATED; use const STR_PAD_LEFT; /** @@ -197,17 +195,13 @@ public function withWeek(int $week): YearWeek public function atDay(DayOfWeek|int $dayOfWeek): LocalDate { if (is_int($dayOfWeek)) { - // usually we don't use trigger_error() for deprecations, but we can't rely on @deprecated for a parameter type change; - // maybe we should revisit using trigger_error() unconditionally for deprecations in the future. - trigger_error('Passing an integer to YearWeek::atDay() is deprecated, pass a DayOfWeek instance instead.', E_USER_DEPRECATED); - Field\DayOfWeek::check($dayOfWeek); - - $dayOfWeek = DayOfWeek::from($dayOfWeek); + } else { + $dayOfWeek = $dayOfWeek->value; } $correction = LocalDate::of($this->year, 1, 4)->getDayOfWeek()->value + 3; - $dayOfYear = $this->week * 7 + $dayOfWeek->value - $correction; + $dayOfYear = $this->week * 7 + $dayOfWeek - $correction; $maxDaysOfYear = Field\Year::isLeap($this->year) ? 366 : 365; if ($dayOfYear > $maxDaysOfYear) {