@@ -120,7 +120,7 @@ public function modify(string $modifier): static
120120 public function setDate (int $ year , int $ month , int $ day ): static
121121 {
122122 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 ));
124124 }
125125 return parent ::setDate ($ year , $ month , $ day );
126126 }
@@ -134,7 +134,7 @@ public function setTime(int $hour, int $minute, int $second = 0, int $microsecon
134134 || $ second < 0 || $ second >= 60
135135 || $ microsecond < 0 || $ microsecond >= 1_000_000
136136 ) {
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 ));
138138 }
139139 return parent ::setTime ($ hour , $ minute , $ second , $ microsecond );
140140 }
@@ -211,7 +211,7 @@ private function handleErrors(string $value): void
211211 $ errors = self ::getLastErrors ();
212212 $ errors = array_merge ($ errors ['errors ' ] ?? [], $ errors ['warnings ' ] ?? []);
213213 if ($ errors ) {
214- trigger_error ( self ::class . ' : ' . implode (', ' , $ errors ) . " ' $ value' " , E_USER_WARNING );
214+ throw new \ Exception ( implode (', ' , $ errors ) . " ' $ value' " );
215215 }
216216 }
217217}
0 commit comments