This repository was archived by the owner on Sep 22, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -280,11 +280,13 @@ public function toUnicodeString(): string
280280 }
281281
282282 /**
283+ * @param array<int, UrlValidationError> $softErrors
284+ *
283285 * @throws InvalidUrlException
284286 */
285- public function resolve (string $ uri ): self
287+ public function resolve (string $ uri, array & $ softErrors = [] ): self
286288 {
287- return new self ($ uri , $ this ->url ->href );
289+ return new self ($ uri , $ this ->url ->href , $ softErrors );
288290 }
289291
290292 /**
Original file line number Diff line number Diff line change @@ -233,4 +233,17 @@ public function it_return_the_same_instance_if_nothing_is_changed(): void
233233 self ::assertTrue ($ urlBis ->equals ($ url ));
234234 self ::assertSame ($ urlBis , $ url );
235235 }
236+
237+ #[Test]
238+ public function it_will_return_soft_errors_when_uri_is_resolved_with_errors (): void
239+ {
240+ $ softErrors = [];
241+ $ url = new Url ("ftp://example.com " );
242+ $ urlBis = $ url ->resolve ("//user:p%61ss@example.org/💩 " , $ softErrors );
243+
244+ self ::assertSame ('ftp://user:p%61ss@example.org/%F0%9F%92%A9 ' , $ urlBis ->toUnicodeString ());
245+ self ::assertNotEmpty ($ softErrors );
246+ self ::assertInstanceOf (UrlValidationError::class, $ softErrors [0 ]);
247+ self ::assertSame (UrlValidationErrorType::InvalidCredentials, $ softErrors [0 ]->type );
248+ }
236249}
You can’t perform that action at this time.
0 commit comments