@@ -120,7 +120,7 @@ public function modify(string $modifier): static
120
120
public function setDate (int $ year , int $ month , int $ day ): static
121
121
{
122
122
if (!checkdate ($ month , $ day , $ year )) {
123
- trigger_error (sprintf (self ::class . ' : The date %04d-%02d-%02d is not valid. ' , $ year , $ month , $ day ), E_USER_WARNING );
123
+ throw new \ Exception (sprintf (' The date %04d-%02d-%02d is not valid. ' , $ year , $ month , $ day ));
124
124
}
125
125
return parent ::setDate ($ year , $ month , $ day );
126
126
}
@@ -134,7 +134,7 @@ public function setTime(int $hour, int $minute, int $second = 0, int $microsecon
134
134
|| $ second < 0 || $ second >= 60
135
135
|| $ microsecond < 0 || $ microsecond >= 1_000_000
136
136
) {
137
- trigger_error (sprintf (self ::class . ' : The time %02d:%02d:%08.5F is not valid. ' , $ hour , $ minute , $ second + $ microsecond / 1_000_000 ), E_USER_WARNING );
137
+ throw new \ Exception (sprintf (' The time %02d:%02d:%08.5F is not valid. ' , $ hour , $ minute , $ second + $ microsecond / 1_000_000 ));
138
138
}
139
139
return parent ::setTime ($ hour , $ minute , $ second , $ microsecond );
140
140
}
@@ -211,7 +211,7 @@ private function handleErrors(string $value): void
211
211
$ errors = self ::getLastErrors ();
212
212
$ errors = array_merge ($ errors ['errors ' ] ?? [], $ errors ['warnings ' ] ?? []);
213
213
if ($ errors ) {
214
- trigger_error ( self ::class . ' : ' . implode (', ' , $ errors ) . " ' $ value' " , E_USER_WARNING );
214
+ throw new \ Exception ( implode (', ' , $ errors ) . " ' $ value' " );
215
215
}
216
216
}
217
217
}
0 commit comments