|
19 | 19 | /** |
20 | 20 | * Provides string formatting methods for datetime instances. |
21 | 21 | * |
22 | | - * Expects implementing classes to define static::$toStringFormat |
| 22 | + * Expects implementing classes to define static::$toStringFormat as `array|string|int`. |
| 23 | + * The widened type allows subclasses (like CakePHP I18n classes) to use |
| 24 | + * IntlDateFormatter constants while maintaining backward compatibility. |
23 | 25 | * |
24 | 26 | * @internal |
25 | 27 | */ |
@@ -54,6 +56,8 @@ public static function setToStringFormat(string $format): void |
54 | 56 | */ |
55 | 57 | public function __toString(): string |
56 | 58 | { |
| 59 | + assert(is_string(static::$toStringFormat)); |
| 60 | + |
57 | 61 | return $this->format(static::$toStringFormat); |
58 | 62 | } |
59 | 63 |
|
@@ -236,24 +240,11 @@ public function toUnixString(): string |
236 | 240 | /** |
237 | 241 | * Returns the quarter |
238 | 242 | * |
239 | | - * Deprecated 3.3.0: The $range parameter is deprecated. Use toQuarterRange() for quarter ranges. |
240 | | - * |
241 | | - * @param bool $range Range. |
242 | | - * @return array|int 1, 2, 3, or 4 quarter of year or array if $range true |
| 243 | + * @return int 1, 2, 3, or 4 quarter of year |
243 | 244 | */ |
244 | | - public function toQuarter(bool $range = false): int|array |
| 245 | + public function toQuarter(): int |
245 | 246 | { |
246 | | - $quarter = (int)ceil((int)$this->format('m') / 3); |
247 | | - if ($range === false) { |
248 | | - return $quarter; |
249 | | - } |
250 | | - |
251 | | - trigger_error( |
252 | | - 'Using toQuarter() with `$range=true` is deprecated. Use `toQuarterRange()` instead.', |
253 | | - E_USER_DEPRECATED, |
254 | | - ); |
255 | | - |
256 | | - return $this->toQuarterRange(); |
| 247 | + return (int)ceil((int)$this->format('m') / 3); |
257 | 248 | } |
258 | 249 |
|
259 | 250 | /** |
|
0 commit comments