From a22793db2be32f47a0c50eb6161fe160a4383bb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sun, 2 Nov 2025 22:44:25 +0100 Subject: [PATCH] uri: Unify exception testing for modification tests (#20368) Catch any Throwable and print the exact class name. --- .../tests/rfc3986/modification/fragment_error_reserved.phpt | 6 +++--- .../tests/rfc3986/modification/fragment_error_unicode.phpt | 6 +++--- ext/uri/tests/rfc3986/modification/host_error_reserved.phpt | 6 +++--- ext/uri/tests/rfc3986/modification/path_error_reserved.phpt | 6 +++--- ext/uri/tests/rfc3986/modification/path_error_unicode.phpt | 6 +++--- .../modification/path_error_without_leading_slash.phpt | 6 +++--- ext/uri/tests/rfc3986/modification/port_error_negative.phpt | 6 +++--- .../tests/rfc3986/modification/query_error_reserved.phpt | 6 +++--- ext/uri/tests/rfc3986/modification/query_error_unicode.phpt | 6 +++--- ext/uri/tests/rfc3986/modification/scheme_error_empty.phpt | 6 +++--- .../tests/rfc3986/modification/scheme_error_encoded.phpt | 6 +++--- .../tests/rfc3986/modification/scheme_error_reserved.phpt | 6 +++--- .../tests/rfc3986/modification/userinfo_error_reserved.phpt | 6 +++--- ext/uri/tests/whatwg/modification/host_error_empty.phpt | 6 +++--- .../host_error_forbidden_host_codepoint_opaque1.phpt | 6 +++--- .../host_error_forbidden_host_codepoint_special1.phpt | 6 +++--- .../host_error_forbidden_host_codepoint_special2.phpt | 6 +++--- .../host_error_forbidden_host_codepoint_special3.phpt | 6 +++--- .../whatwg/modification/host_error_unset_existing.phpt | 6 +++--- ext/uri/tests/whatwg/modification/port_error_negative.phpt | 6 +++--- ext/uri/tests/whatwg/modification/port_error_too_large.phpt | 6 +++--- ext/uri/tests/whatwg/modification/scheme_error_empty.phpt | 6 +++--- ext/uri/tests/whatwg/modification/scheme_error_encoded.phpt | 6 +++--- ext/uri/tests/whatwg/modification/scheme_error_invalid.phpt | 6 +++--- 24 files changed, 72 insertions(+), 72 deletions(-) diff --git a/ext/uri/tests/rfc3986/modification/fragment_error_reserved.phpt b/ext/uri/tests/rfc3986/modification/fragment_error_reserved.phpt index 4b3c3dd00a9..1afde4151ac 100644 --- a/ext/uri/tests/rfc3986/modification/fragment_error_reserved.phpt +++ b/ext/uri/tests/rfc3986/modification/fragment_error_reserved.phpt @@ -9,10 +9,10 @@ $uri = Uri\Rfc3986\Uri::parse("https://example.com"); try { $uri->withFragment("#fragment"); -} catch (Uri\InvalidUriException $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ": ", $e->getMessage(), PHP_EOL; } ?> --EXPECT-- -The specified fragment is malformed +Uri\InvalidUriException: The specified fragment is malformed diff --git a/ext/uri/tests/rfc3986/modification/fragment_error_unicode.phpt b/ext/uri/tests/rfc3986/modification/fragment_error_unicode.phpt index bbb1e2ffe87..5d6cf1198c9 100644 --- a/ext/uri/tests/rfc3986/modification/fragment_error_unicode.phpt +++ b/ext/uri/tests/rfc3986/modification/fragment_error_unicode.phpt @@ -9,10 +9,10 @@ $uri = Uri\Rfc3986\Uri::parse("https://example.com"); try { $uri->withFragment("ő"); -} catch (Uri\InvalidUriException $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ": ", $e->getMessage(), PHP_EOL; } ?> --EXPECT-- -The specified fragment is malformed +Uri\InvalidUriException: The specified fragment is malformed diff --git a/ext/uri/tests/rfc3986/modification/host_error_reserved.phpt b/ext/uri/tests/rfc3986/modification/host_error_reserved.phpt index 81d60bc2e40..ca87c1a3ce2 100644 --- a/ext/uri/tests/rfc3986/modification/host_error_reserved.phpt +++ b/ext/uri/tests/rfc3986/modification/host_error_reserved.phpt @@ -9,10 +9,10 @@ $uri = Uri\Rfc3986\Uri::parse("https://example.com"); try { $uri->withHost("ex#mple.com"); -} catch (Uri\InvalidUriException $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ": ", $e->getMessage(), PHP_EOL; } ?> --EXPECT-- -The specified host is malformed +Uri\InvalidUriException: The specified host is malformed diff --git a/ext/uri/tests/rfc3986/modification/path_error_reserved.phpt b/ext/uri/tests/rfc3986/modification/path_error_reserved.phpt index 2da84e2689b..e883a7daed1 100644 --- a/ext/uri/tests/rfc3986/modification/path_error_reserved.phpt +++ b/ext/uri/tests/rfc3986/modification/path_error_reserved.phpt @@ -9,10 +9,10 @@ $uri = Uri\Rfc3986\Uri::parse("https://example.com"); try { $uri->withPath("/[foo]"); -} catch (Uri\InvalidUriException $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ": ", $e->getMessage(), PHP_EOL; } ?> --EXPECT-- -The specified path is malformed +Uri\InvalidUriException: The specified path is malformed diff --git a/ext/uri/tests/rfc3986/modification/path_error_unicode.phpt b/ext/uri/tests/rfc3986/modification/path_error_unicode.phpt index 9335132dad5..5fc836533ca 100644 --- a/ext/uri/tests/rfc3986/modification/path_error_unicode.phpt +++ b/ext/uri/tests/rfc3986/modification/path_error_unicode.phpt @@ -9,10 +9,10 @@ $uri = Uri\Rfc3986\Uri::parse("https://example.com"); try { $uri->withPath("/ő"); -} catch (Uri\InvalidUriException $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ": ", $e->getMessage(), PHP_EOL; } ?> --EXPECT-- -The specified path is malformed +Uri\InvalidUriException: The specified path is malformed diff --git a/ext/uri/tests/rfc3986/modification/path_error_without_leading_slash.phpt b/ext/uri/tests/rfc3986/modification/path_error_without_leading_slash.phpt index 476e4ec873c..b6f66bdb5e4 100644 --- a/ext/uri/tests/rfc3986/modification/path_error_without_leading_slash.phpt +++ b/ext/uri/tests/rfc3986/modification/path_error_without_leading_slash.phpt @@ -9,10 +9,10 @@ $uri = Uri\Rfc3986\Uri::parse("https://example.com"); try { $uri->withPath("foo"); -} catch (Uri\InvalidUriException $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ": ", $e->getMessage(), PHP_EOL; } ?> --EXPECT-- -The specified path is malformed +Uri\InvalidUriException: The specified path is malformed diff --git a/ext/uri/tests/rfc3986/modification/port_error_negative.phpt b/ext/uri/tests/rfc3986/modification/port_error_negative.phpt index 598475b1e18..b8a25ee7666 100644 --- a/ext/uri/tests/rfc3986/modification/port_error_negative.phpt +++ b/ext/uri/tests/rfc3986/modification/port_error_negative.phpt @@ -9,10 +9,10 @@ $uri = Uri\Rfc3986\Uri::parse("https://example.com"); try { $uri->withPort(-1); -} catch (Uri\InvalidUriException $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ": ", $e->getMessage(), PHP_EOL; } ?> --EXPECT-- -The specified port is malformed +Uri\InvalidUriException: The specified port is malformed diff --git a/ext/uri/tests/rfc3986/modification/query_error_reserved.phpt b/ext/uri/tests/rfc3986/modification/query_error_reserved.phpt index f09e867a021..d7f9745e9ef 100644 --- a/ext/uri/tests/rfc3986/modification/query_error_reserved.phpt +++ b/ext/uri/tests/rfc3986/modification/query_error_reserved.phpt @@ -9,10 +9,10 @@ $uri = Uri\Rfc3986\Uri::parse("https://example.com"); try { $uri->withQuery("#foo"); -} catch (Uri\InvalidUriException $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ": ", $e->getMessage(), PHP_EOL; } ?> --EXPECT-- -The specified query is malformed +Uri\InvalidUriException: The specified query is malformed diff --git a/ext/uri/tests/rfc3986/modification/query_error_unicode.phpt b/ext/uri/tests/rfc3986/modification/query_error_unicode.phpt index c8f51005974..964e6b36d72 100644 --- a/ext/uri/tests/rfc3986/modification/query_error_unicode.phpt +++ b/ext/uri/tests/rfc3986/modification/query_error_unicode.phpt @@ -9,10 +9,10 @@ $uri = Uri\Rfc3986\Uri::parse("https://example.com"); try { $uri->withQuery("ő"); -} catch (Uri\InvalidUriException $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ": ", $e->getMessage(), PHP_EOL; } ?> --EXPECT-- -The specified query is malformed +Uri\InvalidUriException: The specified query is malformed diff --git a/ext/uri/tests/rfc3986/modification/scheme_error_empty.phpt b/ext/uri/tests/rfc3986/modification/scheme_error_empty.phpt index 477be1d2331..94888c446f6 100644 --- a/ext/uri/tests/rfc3986/modification/scheme_error_empty.phpt +++ b/ext/uri/tests/rfc3986/modification/scheme_error_empty.phpt @@ -9,10 +9,10 @@ $uri = Uri\Rfc3986\Uri::parse("https://example.com"); try { $uri->withScheme(""); -} catch (Uri\InvalidUriException $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ": ", $e->getMessage(), PHP_EOL; } ?> --EXPECT-- -The specified scheme is malformed +Uri\InvalidUriException: The specified scheme is malformed diff --git a/ext/uri/tests/rfc3986/modification/scheme_error_encoded.phpt b/ext/uri/tests/rfc3986/modification/scheme_error_encoded.phpt index 683f46cc42a..e44e8df85ed 100644 --- a/ext/uri/tests/rfc3986/modification/scheme_error_encoded.phpt +++ b/ext/uri/tests/rfc3986/modification/scheme_error_encoded.phpt @@ -9,10 +9,10 @@ $uri = Uri\Rfc3986\Uri::parse("https://example.com"); try { $uri->withScheme("http%73"); -} catch (Uri\InvalidUriException $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ": ", $e->getMessage(), PHP_EOL; } ?> --EXPECT-- -The specified scheme is malformed +Uri\InvalidUriException: The specified scheme is malformed diff --git a/ext/uri/tests/rfc3986/modification/scheme_error_reserved.phpt b/ext/uri/tests/rfc3986/modification/scheme_error_reserved.phpt index dd3bcc02f83..7d235e56d11 100644 --- a/ext/uri/tests/rfc3986/modification/scheme_error_reserved.phpt +++ b/ext/uri/tests/rfc3986/modification/scheme_error_reserved.phpt @@ -9,10 +9,10 @@ $uri = Uri\Rfc3986\Uri::parse("https://example.com"); try { $uri->withScheme("https:"); -} catch (Uri\InvalidUriException $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ": ", $e->getMessage(), PHP_EOL; } ?> --EXPECT-- -The specified scheme is malformed +Uri\InvalidUriException: The specified scheme is malformed diff --git a/ext/uri/tests/rfc3986/modification/userinfo_error_reserved.phpt b/ext/uri/tests/rfc3986/modification/userinfo_error_reserved.phpt index a5f820b0d59..c416ea43eb7 100644 --- a/ext/uri/tests/rfc3986/modification/userinfo_error_reserved.phpt +++ b/ext/uri/tests/rfc3986/modification/userinfo_error_reserved.phpt @@ -9,10 +9,10 @@ $uri = Uri\Rfc3986\Uri::parse("https://example.com"); try { $uri->withUserInfo("us/r:password"); // us/r:password -} catch (Uri\InvalidUriException $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ": ", $e->getMessage(), PHP_EOL; } ?> --EXPECT-- -The specified userinfo is malformed +Uri\InvalidUriException: The specified userinfo is malformed diff --git a/ext/uri/tests/whatwg/modification/host_error_empty.phpt b/ext/uri/tests/whatwg/modification/host_error_empty.phpt index f9f47395786..7ce0fa9dff2 100644 --- a/ext/uri/tests/whatwg/modification/host_error_empty.phpt +++ b/ext/uri/tests/whatwg/modification/host_error_empty.phpt @@ -9,10 +9,10 @@ $url = Uri\WhatWg\Url::parse("https://example.com"); try { $url->withHost(""); -} catch (Uri\WhatWg\InvalidUrlException $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ": ", $e->getMessage(), PHP_EOL; } ?> --EXPECT-- -The specified host is malformed (HostMissing) +Uri\WhatWg\InvalidUrlException: The specified host is malformed (HostMissing) diff --git a/ext/uri/tests/whatwg/modification/host_error_forbidden_host_codepoint_opaque1.phpt b/ext/uri/tests/whatwg/modification/host_error_forbidden_host_codepoint_opaque1.phpt index 8aebc5f7057..a6ef7e6a5d5 100644 --- a/ext/uri/tests/whatwg/modification/host_error_forbidden_host_codepoint_opaque1.phpt +++ b/ext/uri/tests/whatwg/modification/host_error_forbidden_host_codepoint_opaque1.phpt @@ -9,10 +9,10 @@ $url = Uri\WhatWg\Url::parse("foo://example.com"); try { $url = $url->withHost("ex@mple.com"); -} catch (Uri\WhatWg\InvalidUrlException $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ": ", $e->getMessage(), PHP_EOL; } ?> --EXPECT-- -The specified host is malformed (HostInvalidCodePoint) +Uri\WhatWg\InvalidUrlException: The specified host is malformed (HostInvalidCodePoint) diff --git a/ext/uri/tests/whatwg/modification/host_error_forbidden_host_codepoint_special1.phpt b/ext/uri/tests/whatwg/modification/host_error_forbidden_host_codepoint_special1.phpt index a27c26381b4..d06234d949b 100644 --- a/ext/uri/tests/whatwg/modification/host_error_forbidden_host_codepoint_special1.phpt +++ b/ext/uri/tests/whatwg/modification/host_error_forbidden_host_codepoint_special1.phpt @@ -9,10 +9,10 @@ $url = Uri\WhatWg\Url::parse("https://example.com"); try { $url = $url->withHost("ex@mple.com"); -} catch (Uri\WhatWg\InvalidUrlException $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ": ", $e->getMessage(), PHP_EOL; } ?> --EXPECT-- -The specified host is malformed (DomainInvalidCodePoint) +Uri\WhatWg\InvalidUrlException: The specified host is malformed (DomainInvalidCodePoint) diff --git a/ext/uri/tests/whatwg/modification/host_error_forbidden_host_codepoint_special2.phpt b/ext/uri/tests/whatwg/modification/host_error_forbidden_host_codepoint_special2.phpt index a0626d99c51..4413802fdb9 100644 --- a/ext/uri/tests/whatwg/modification/host_error_forbidden_host_codepoint_special2.phpt +++ b/ext/uri/tests/whatwg/modification/host_error_forbidden_host_codepoint_special2.phpt @@ -9,10 +9,10 @@ $url = Uri\WhatWg\Url::parse("https://example.com"); try { $url = $url->withHost("ex:mple.com"); -} catch (Uri\WhatWg\InvalidUrlException $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ": ", $e->getMessage(), PHP_EOL; } ?> --EXPECT-- -The specified host is malformed +Uri\WhatWg\InvalidUrlException: The specified host is malformed diff --git a/ext/uri/tests/whatwg/modification/host_error_forbidden_host_codepoint_special3.phpt b/ext/uri/tests/whatwg/modification/host_error_forbidden_host_codepoint_special3.phpt index a0626d99c51..4413802fdb9 100644 --- a/ext/uri/tests/whatwg/modification/host_error_forbidden_host_codepoint_special3.phpt +++ b/ext/uri/tests/whatwg/modification/host_error_forbidden_host_codepoint_special3.phpt @@ -9,10 +9,10 @@ $url = Uri\WhatWg\Url::parse("https://example.com"); try { $url = $url->withHost("ex:mple.com"); -} catch (Uri\WhatWg\InvalidUrlException $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ": ", $e->getMessage(), PHP_EOL; } ?> --EXPECT-- -The specified host is malformed +Uri\WhatWg\InvalidUrlException: The specified host is malformed diff --git a/ext/uri/tests/whatwg/modification/host_error_unset_existing.phpt b/ext/uri/tests/whatwg/modification/host_error_unset_existing.phpt index ca5d5a0201d..627fe8d3e58 100644 --- a/ext/uri/tests/whatwg/modification/host_error_unset_existing.phpt +++ b/ext/uri/tests/whatwg/modification/host_error_unset_existing.phpt @@ -9,10 +9,10 @@ $url = Uri\WhatWg\Url::parse("https://example.com"); try { $url = $url->withHost(null); -} catch (Uri\WhatWg\InvalidUrlException $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ": ", $e->getMessage(), PHP_EOL; } ?> --EXPECT-- -The specified host is malformed (HostMissing) +Uri\WhatWg\InvalidUrlException: The specified host is malformed (HostMissing) diff --git a/ext/uri/tests/whatwg/modification/port_error_negative.phpt b/ext/uri/tests/whatwg/modification/port_error_negative.phpt index 5de87d7e760..27e29995ce3 100644 --- a/ext/uri/tests/whatwg/modification/port_error_negative.phpt +++ b/ext/uri/tests/whatwg/modification/port_error_negative.phpt @@ -9,10 +9,10 @@ $url = Uri\WhatWg\Url::parse("https://example.com"); try { $url->withPort(-1); -} catch (Uri\WhatWg\InvalidUrlException $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ": ", $e->getMessage(), PHP_EOL; } ?> --EXPECT-- -The specified port is malformed +Uri\WhatWg\InvalidUrlException: The specified port is malformed diff --git a/ext/uri/tests/whatwg/modification/port_error_too_large.phpt b/ext/uri/tests/whatwg/modification/port_error_too_large.phpt index 4060056b0a5..f530b367216 100644 --- a/ext/uri/tests/whatwg/modification/port_error_too_large.phpt +++ b/ext/uri/tests/whatwg/modification/port_error_too_large.phpt @@ -9,10 +9,10 @@ $url = Uri\WhatWg\Url::parse("https://example.com"); try { $url->withPort(65536); -} catch (Uri\WhatWg\InvalidUrlException $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ": ", $e->getMessage(), PHP_EOL; } ?> --EXPECT-- -The specified port is malformed (PortOutOfRange) +Uri\WhatWg\InvalidUrlException: The specified port is malformed (PortOutOfRange) diff --git a/ext/uri/tests/whatwg/modification/scheme_error_empty.phpt b/ext/uri/tests/whatwg/modification/scheme_error_empty.phpt index 0460fa72945..5e3525de7d9 100644 --- a/ext/uri/tests/whatwg/modification/scheme_error_empty.phpt +++ b/ext/uri/tests/whatwg/modification/scheme_error_empty.phpt @@ -9,10 +9,10 @@ $url = Uri\WhatWg\Url::parse("https://example.com"); try { $url->withScheme(""); -} catch (Uri\WhatWg\InvalidUrlException $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ": ", $e->getMessage(), PHP_EOL; } ?> --EXPECT-- -The specified scheme is malformed +Uri\WhatWg\InvalidUrlException: The specified scheme is malformed diff --git a/ext/uri/tests/whatwg/modification/scheme_error_encoded.phpt b/ext/uri/tests/whatwg/modification/scheme_error_encoded.phpt index a52dc65dadd..bda1ac497e2 100644 --- a/ext/uri/tests/whatwg/modification/scheme_error_encoded.phpt +++ b/ext/uri/tests/whatwg/modification/scheme_error_encoded.phpt @@ -9,10 +9,10 @@ $url = Uri\WhatWg\Url::parse("https://example.com"); try { $url->withScheme("http%73"); -} catch (Uri\WhatWg\InvalidUrlException $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ": ", $e->getMessage(), PHP_EOL; } ?> --EXPECT-- -The specified scheme is malformed +Uri\WhatWg\InvalidUrlException: The specified scheme is malformed diff --git a/ext/uri/tests/whatwg/modification/scheme_error_invalid.phpt b/ext/uri/tests/whatwg/modification/scheme_error_invalid.phpt index 21cd04346a3..ad98af24e4a 100644 --- a/ext/uri/tests/whatwg/modification/scheme_error_invalid.phpt +++ b/ext/uri/tests/whatwg/modification/scheme_error_invalid.phpt @@ -9,10 +9,10 @@ $url = Uri\WhatWg\Url::parse("https://example.com"); try { $url->withScheme("http?"); -} catch (Uri\WhatWg\InvalidUrlException $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ": ", $e->getMessage(), PHP_EOL; } ?> --EXPECT-- -The specified scheme is malformed +Uri\WhatWg\InvalidUrlException: The specified scheme is malformed