Commit 8551dc60f15 for php.net
commit 8551dc60f1599d103163db5558a3d2dc2cb64978
Author: NickSdot <32384907+NickSdot@users.noreply.github.com>
Date: Fri Aug 14 16:20:49 2026 +0700
ext/xml: applied fixers to improve test robustness (#23025)
diff --git a/ext/xml/tests/bug78563.phpt b/ext/xml/tests/bug78563.phpt
index dc7d5fe02dc..94dec81e792 100644
--- a/ext/xml/tests/bug78563.phpt
+++ b/ext/xml/tests/bug78563.phpt
@@ -9,7 +9,7 @@
$parser = xml_parser_create();
clone $parser;
} catch (Throwable $e) {
- echo $e::class, ": ", $e->getMessage(), PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
?>
diff --git a/ext/xml/tests/gh15868.phpt b/ext/xml/tests/gh15868.phpt
index 17ed80558d7..0e3b866574f 100644
--- a/ext/xml/tests/gh15868.phpt
+++ b/ext/xml/tests/gh15868.phpt
@@ -14,7 +14,7 @@ function ($parser, $name, $attrs) {
try {
xml_parse_into_struct($parser, "<container/>", $values, $tags);
} catch (Error $e) {
- echo $e->getMessage(), "\n";
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
$parser = xml_parser_create();
@@ -27,7 +27,7 @@ function ($parser, $name, $attrs) {
try {
xml_parse_into_struct($parser, "<container/>", $values, $tags);
} catch (Error $e) {
- echo $e->getMessage(), "\n";
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
$parser = xml_parser_create();
@@ -37,10 +37,10 @@ function ($parser, $name, $attrs) {
try {
xml_parse_into_struct($parser, "<root><![CDATA[x]]></root>", $values, $tags);
} catch (Error $e) {
- echo $e->getMessage(), "\n";
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
--EXPECT--
-stop 1
-stop 2
-stop 3
+Error: stop 1
+Error: stop 2
+Error: stop 3
diff --git a/ext/xml/tests/xml_parser_get_option_variation4.phpt b/ext/xml/tests/xml_parser_get_option_variation4.phpt
index f6d858a7e9c..4afc09c4121 100644
--- a/ext/xml/tests/xml_parser_get_option_variation4.phpt
+++ b/ext/xml/tests/xml_parser_get_option_variation4.phpt
@@ -10,9 +10,9 @@
try {
xml_parser_get_option ($xmlParser, 42);
} catch (ValueError $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
?>
--EXPECT--
-xml_parser_get_option(): Argument #2 ($option) must be a XML_OPTION_* constant
+ValueError: xml_parser_get_option(): Argument #2 ($option) must be a XML_OPTION_* constant
diff --git a/ext/xml/tests/xml_parser_set_option_errors.phpt b/ext/xml/tests/xml_parser_set_option_errors.phpt
index fbb733423d7..9e722162c3b 100644
--- a/ext/xml/tests/xml_parser_set_option_errors.phpt
+++ b/ext/xml/tests/xml_parser_set_option_errors.phpt
@@ -11,24 +11,24 @@
try {
xml_parser_set_option($xmlParser, XML_OPTION_CASE_FOLDING, []);
} catch (ValueError $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
try {
xml_parser_set_option($xmlParser, XML_OPTION_CASE_FOLDING, new stdClass());
} catch (TypeError $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
echo "Skip Whitespace\n";
try {
xml_parser_set_option($xmlParser, XML_OPTION_SKIP_WHITE, []);
} catch (ValueError $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
try {
xml_parser_set_option($xmlParser, XML_OPTION_SKIP_WHITE, new stdClass());
} catch (TypeError $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
echo "Tag Start\n";
@@ -42,17 +42,17 @@
try {
xml_parser_set_option($xmlParser, XML_OPTION_TARGET_ENCODING, 'Invalid Encoding');
} catch (ValueError $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
try {
xml_parser_set_option($xmlParser, XML_OPTION_TARGET_ENCODING, []);
} catch (ValueError $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
try {
xml_parser_set_option($xmlParser, XML_OPTION_TARGET_ENCODING, new stdClass());
} catch (Error $exception) {
- echo $exception::class, ': ', $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
?>
@@ -77,12 +77,12 @@
Warning: Object of class stdClass could not be converted to int in %s on line %d
Encodings
-xml_parser_set_option(): Argument #3 ($value) is not a supported target encoding
+ValueError: xml_parser_set_option(): Argument #3 ($value) is not a supported target encoding
Warning: xml_parser_set_option(): Argument #3 ($value) must be of type string|int|bool, array given in %s on line %d
Warning: Array to string conversion in %s on line %d
-xml_parser_set_option(): Argument #3 ($value) is not a supported target encoding
+ValueError: xml_parser_set_option(): Argument #3 ($value) is not a supported target encoding
Warning: xml_parser_set_option(): Argument #3 ($value) must be of type string|int|bool, stdClass given in %s on line %d
Error: Object of class stdClass could not be converted to string
diff --git a/ext/xml/tests/xml_parser_set_option_nonexistent_option.phpt b/ext/xml/tests/xml_parser_set_option_nonexistent_option.phpt
index d19dc9e69d5..3bed7aefd7f 100644
--- a/ext/xml/tests/xml_parser_set_option_nonexistent_option.phpt
+++ b/ext/xml/tests/xml_parser_set_option_nonexistent_option.phpt
@@ -10,9 +10,9 @@
try {
xml_parser_set_option($xmlParser, 42, 1);
} catch (ValueError $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
?>
--EXPECT--
-xml_parser_set_option(): Argument #2 ($option) must be a XML_OPTION_* constant
+ValueError: xml_parser_set_option(): Argument #2 ($option) must be a XML_OPTION_* constant