2
2
3
3
namespace Safe ;
4
4
5
- use DateInterval ;
6
- use DateTime ;
7
- use DateTimeInterface ;
8
- use DateTimeZone ;
9
5
use Safe \Exceptions \DatetimeException ;
10
6
11
7
/**
@@ -23,7 +19,7 @@ class DateTimeImmutable extends \DateTimeImmutable
23
19
/**
24
20
* DateTimeImmutable constructor.
25
21
* @param string $time
26
- * @param DateTimeZone|null $timezone
22
+ * @param \ DateTimeZone|null $timezone
27
23
* @throws \Exception
28
24
*/
29
25
public function __construct ($ time = 'now ' , $ timezone = null )
@@ -52,7 +48,7 @@ public function getInnerDateTime(): \DateTimeImmutable
52
48
/**
53
49
* @param string $format
54
50
* @param string $time
55
- * @param DateTimeZone|null $timezone
51
+ * @param \ DateTimeZone|null $timezone
56
52
* @throws DatetimeException
57
53
*/
58
54
public static function createFromFormat ($ format , $ time , $ timezone = null )
@@ -80,12 +76,12 @@ public function format($format): string
80
76
}
81
77
82
78
/**
83
- * @param DateTimeInterface $datetime2
79
+ * @param \ DateTimeInterface $datetime2
84
80
* @param bool $absolute
85
- * @return DateInterval
81
+ * @return \ DateInterval
86
82
* @throws DatetimeException
87
83
*/
88
- public function diff ($ datetime2 , $ absolute = false ): DateInterval
84
+ public function diff ($ datetime2 , $ absolute = false ): \ DateInterval
89
85
{
90
86
/** @var \DateInterval|false $result */
91
87
$ result = $ this ->innerDateTime ->diff ($ datetime2 , $ absolute );
@@ -178,7 +174,7 @@ public function setTimestamp($unixtimestamp): self
178
174
}
179
175
180
176
/**
181
- * @param DateTimeZone $timezone
177
+ * @param \ DateTimeZone $timezone
182
178
* @return DateTimeImmutable
183
179
* @throws DatetimeException
184
180
*/
@@ -193,7 +189,7 @@ public function setTimezone($timezone): self
193
189
}
194
190
195
191
/**
196
- * @param DateInterval $interval
192
+ * @param \ DateInterval $interval
197
193
* @return DateTimeImmutable
198
194
* @throws DatetimeException
199
195
*/
@@ -224,7 +220,7 @@ public function getOffset(): int
224
220
//overload getters to use the inner datetime immutable instead of itself
225
221
226
222
/**
227
- * @param DateInterval $interval
223
+ * @param \ DateInterval $interval
228
224
* @return DateTimeImmutable
229
225
*/
230
226
public function add ($ interval ): self
@@ -233,12 +229,14 @@ public function add($interval): self
233
229
}
234
230
235
231
/**
236
- * @param DateTime $dateTime
232
+ * @param \ DateTime $dateTime
237
233
* @return DateTimeImmutable
238
234
*/
239
235
public static function createFromMutable ($ dateTime ): self
240
236
{
241
- return self ::createFromRegular (parent ::createFromMutable ($ dateTime ));
237
+ $ date = \DateTimeImmutable::createFromMutable ($ dateTime );
238
+
239
+ return self ::createFromRegular ($ date );
242
240
}
243
241
244
242
/**
@@ -250,7 +248,7 @@ public static function __set_state($array): self
250
248
return self ::createFromRegular (parent ::__set_state ($ array ));
251
249
}
252
250
253
- public function getTimezone (): DateTimeZone
251
+ public function getTimezone (): \ DateTimeZone
254
252
{
255
253
return $ this ->innerDateTime ->getTimezone ();
256
254
}
0 commit comments