@@ -138,6 +138,10 @@ private function transformToAscii(string $domain, int $option): array
138
138
}
139
139
140
140
$ output = idn_to_ascii ($ domain , $ option , INTL_IDNA_VARIANT_UTS46 , $ infos );
141
+ if ([] === $ infos ) {
142
+ throw new InvalidDomain (sprintf ('The host `%s` is invalid ' , $ domain ));
143
+ }
144
+
141
145
if (0 !== $ infos ['errors ' ]) {
142
146
throw new InvalidDomain (sprintf ('The host `%s` is invalid : %s ' , $ domain , self ::getIdnErrors ($ infos ['errors ' ])));
143
147
}
@@ -170,9 +174,13 @@ private function transformToAscii(string $domain, int $option): array
170
174
*/
171
175
private function idnToUnicode (string $ domain , int $ option = IDNA_DEFAULT ): string
172
176
{
173
- $ output = idn_to_utf8 ($ domain , $ option , INTL_IDNA_VARIANT_UTS46 , $ arr );
174
- if (0 !== $ arr ['errors ' ]) {
175
- throw new InvalidDomain (sprintf ('The host `%s` is invalid : %s ' , $ domain , self ::getIdnErrors ($ arr ['errors ' ])));
177
+ $ output = idn_to_utf8 ($ domain , $ option , INTL_IDNA_VARIANT_UTS46 , $ info );
178
+ if ([] === $ info ) {
179
+ throw new InvalidDomain (sprintf ('The host `%s` is invalid ' , $ domain ));
180
+ }
181
+
182
+ if (0 !== $ info ['errors ' ]) {
183
+ throw new InvalidDomain (sprintf ('The host `%s` is invalid : %s ' , $ domain , self ::getIdnErrors ($ info ['errors ' ])));
176
184
}
177
185
178
186
// @codeCoverageIgnoreStart
0 commit comments