[php-src] master: ext/xml: applied fixers to improve test robustness (#23025)

From: Date: Fri, 14 Aug 2026 09:20:52 +0000
Subject: [php-src] master: ext/xml: applied fixers to improve test robustness (#23025)
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-140719@lists.php.net to get a copy of this message
Author: NickSdot (NickSdot) Committer: GitHub (web-flow) Pusher: LamentXU123 Date: 2026-08-14T17:20:49+08:00 Commit: https://github.com/php/php-src/commit/8551dc60f1599d103163db5558a3d2dc2cb64978 Raw diff: https://github.com/php/php-src/commit/8551dc60f1599d103163db5558a3d2dc2cb64978.diff ext/xml: applied fixers to improve test robustness (#23025) Changed paths: M ext/xml/tests/bug78563.phpt M ext/xml/tests/gh15868.phpt M ext/xml/tests/xml_parser_get_option_variation4.phpt M ext/xml/tests/xml_parser_set_option_errors.phpt M ext/xml/tests/xml_parser_set_option_nonexistent_option.phpt Diff: diff --git a/ext/xml/tests/bug78563.phpt b/ext/xml/tests/bug78563.phpt index dc7d5fe02dc2..94dec81e792c 100644 --- a/ext/xml/tests/bug78563.phpt +++ b/ext/xml/tests/bug78563.phpt @@ -9,7 +9,7 @@ try { $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 17ed80558d78..0e3b866574f6 100644 --- a/ext/xml/tests/gh15868.phpt +++ b/ext/xml/tests/gh15868.phpt @@ -14,7 +14,7 @@ xml_set_element_handler($parser, 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 @@ xml_set_element_handler($parser, 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 @@ xml_set_character_data_handler($parser, function() { 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 f6d858a7e9c0..4afc09c41219 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 @@ $xmlParser = xml_parser_create(); 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 fbb733423d77..9e722162c3bc 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 @@ echo "Case folding\n"; 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 @@ echo "Encodings\n"; 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: xml_parser_set_option(): Argument #3 ($value) must be of type string|in 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 d19dc9e69d5c..3bed7aefd7f6 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 @@ $xmlParser = xml_parser_create(); 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

« previous php.cvs (#140719) next »