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