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