Commit d9640d76c4f for php.net

commit d9640d76c4f3ccdd12e62f32d5d7665d880c7321
Author: NickSdot <32384907+NickSdot@users.noreply.github.com>
Date:   Sat Aug 22 20:03:08 2026 +0700

    ext/simplexml: applied fixers to improve test robustness (#23030)

diff --git a/ext/simplexml/tests/012.phpt b/ext/simplexml/tests/012.phpt
index a68345d29d9..1bb9605745d 100644
--- a/ext/simplexml/tests/012.phpt
+++ b/ext/simplexml/tests/012.phpt
@@ -14,8 +14,8 @@

 try {
     $sxe[""] = "value";
-} catch (ValueError $exception) {
-    echo $exception->getMessage() . "\n";
+} catch (Throwable $exception) {
+    echo $exception::class, ': ', $exception->getMessage(), "\n";
 }

 $sxe["attr"] = "value";
@@ -28,17 +28,17 @@

 try {
     $sxe[] = "error";
-} catch (ValueError $exception) {
-    echo $exception->getMessage() . "\n";
+} catch (Throwable $exception) {
+    echo $exception::class, ': ', $exception->getMessage(), "\n";
 }

 __HALT_COMPILER();
 ?>
 ===DONE===
 --EXPECT--
-Cannot create attribute with an empty name
+ValueError: Cannot create attribute with an empty name
 <?xml version="1.0" encoding="ISO-8859-1"?>
 <foo attr="value"/>
 <?xml version="1.0" encoding="ISO-8859-1"?>
 <foo attr="new value"/>
-Cannot append to an attribute list
+ValueError: Cannot append to an attribute list
diff --git a/ext/simplexml/tests/SimpleXMLElement_addAttribute_required_attribute_name.phpt b/ext/simplexml/tests/SimpleXMLElement_addAttribute_required_attribute_name.phpt
index 65f8f7baa8b..a3b86af10ac 100644
--- a/ext/simplexml/tests/SimpleXMLElement_addAttribute_required_attribute_name.phpt
+++ b/ext/simplexml/tests/SimpleXMLElement_addAttribute_required_attribute_name.phpt
@@ -11,13 +11,13 @@

 try {
     $a->addAttribute( "", "" );
-} catch (ValueError $exception) {
-    echo $exception->getMessage() . "\n";
+} catch (Throwable $exception) {
+    echo $exception::class, ': ', $exception->getMessage(), "\n";
 }

 echo $a->asXML();
 ?>
 --EXPECT--
-SimpleXMLElement::addAttribute(): Argument #1 ($qualifiedName) must not be empty
+ValueError: SimpleXMLElement::addAttribute(): Argument #1 ($qualifiedName) must not be empty
 <?xml version="1.0"?>
 <php>testfest</php>
diff --git a/ext/simplexml/tests/SimpleXMLElement_xpath.phpt b/ext/simplexml/tests/SimpleXMLElement_xpath.phpt
index 8af58ec2a0a..3eaa4a1fccd 100644
--- a/ext/simplexml/tests/SimpleXMLElement_xpath.phpt
+++ b/ext/simplexml/tests/SimpleXMLElement_xpath.phpt
@@ -13,9 +13,9 @@
 // $xml is supposed to hold a SimpleXMLElement, but not FALSE/NULL
 try {
     var_dump($xml->xpath("BBBB"));
-} catch (Error $e) {
-    echo $e->getMessage(), "\n";
+} catch (Throwable $e) {
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 ?>
 --EXPECT--
-SimpleXMLElement is not properly initialized
+Error: SimpleXMLElement is not properly initialized
diff --git a/ext/simplexml/tests/SimpleXMLElement_xpath_4.phpt b/ext/simplexml/tests/SimpleXMLElement_xpath_4.phpt
index b111b0bfb34..e156a64dc7c 100644
--- a/ext/simplexml/tests/SimpleXMLElement_xpath_4.phpt
+++ b/ext/simplexml/tests/SimpleXMLElement_xpath_4.phpt
@@ -11,11 +11,11 @@

 try {
     simplexml_load_string("XXXXXXX^", $x, 0x6000000000000001);
-} catch (ValueError $exception) {
-    echo $exception->getMessage() . "\n";
+} catch (Throwable $exception) {
+    echo $exception::class, ': ', $exception->getMessage(), "\n";
 }

 ?>
 --EXPECTF--
 Warning: Undefined variable $x in %s on line %d
-simplexml_load_string(): Argument #3 ($options) is too large
+ValueError: simplexml_load_string(): Argument #3 ($options) is too large
diff --git a/ext/simplexml/tests/bug37076_1.phpt b/ext/simplexml/tests/bug37076_1.phpt
index ed7fecd104c..6b2428ee1c9 100644
--- a/ext/simplexml/tests/bug37076_1.phpt
+++ b/ext/simplexml/tests/bug37076_1.phpt
@@ -9,13 +9,13 @@

 try {
     $xml->{""} .= "bar";
-} catch (ValueError $exception) {
-    echo $exception->getMessage() . "\n";
+} catch (Throwable $exception) {
+    echo $exception::class, ': ', $exception->getMessage(), "\n";
 }

 print $xml->asXML();
 ?>
 --EXPECT--
-Cannot create element with an empty name
+ValueError: Cannot create element with an empty name
 <?xml version="1.0"?>
 <root><foo/></root>
diff --git a/ext/simplexml/tests/bug38406.phpt b/ext/simplexml/tests/bug38406.phpt
index 41f2df7aaf6..f56abe5b0a7 100644
--- a/ext/simplexml/tests/bug38406.phpt
+++ b/ext/simplexml/tests/bug38406.phpt
@@ -16,8 +16,8 @@

 try {
     $item->$a = new stdclass;
-} catch (TypeError $exception) {
-    echo $exception->getMessage() . "\n";
+} catch (Throwable $exception) {
+    echo $exception::class, ': ', $exception->getMessage(), "\n";
 }

 echo "Done\n";
@@ -33,5 +33,5 @@
 }

 Warning: Array to string conversion in %s on line %d
-It's not possible to assign a complex type to properties, stdClass given
+TypeError: It's not possible to assign a complex type to properties, stdClass given
 Done
diff --git a/ext/simplexml/tests/current_error.phpt b/ext/simplexml/tests/current_error.phpt
index dc22f735477..b507eb1c654 100644
--- a/ext/simplexml/tests/current_error.phpt
+++ b/ext/simplexml/tests/current_error.phpt
@@ -16,8 +16,8 @@

 try {
     $sxe->current();
-} catch (Error $exception) {
-    echo $exception->getMessage() . "\n";
+} catch (Throwable $exception) {
+    echo $exception::class, ': ', $exception->getMessage(), "\n";
 }

 for ($sxe->rewind(); $sxe->valid(); $sxe->next()) {
@@ -26,14 +26,14 @@

 try {
     $sxe->current();
-} catch (Error $exception) {
-    echo $exception->getMessage() . "\n";
+} catch (Throwable $exception) {
+    echo $exception::class, ': ', $exception->getMessage(), "\n";
 }

 ?>
 --EXPECT--
-Iterator not initialized or already consumed
+Error: Iterator not initialized or already consumed
 string(4) "elem"
 object(SimpleXMLElement)#3 (0) {
 }
-Iterator not initialized or already consumed
+Error: Iterator not initialized or already consumed
diff --git a/ext/simplexml/tests/gh12929.phpt b/ext/simplexml/tests/gh12929.phpt
index 2ae89346dba..f64bf728069 100644
--- a/ext/simplexml/tests/gh12929.phpt
+++ b/ext/simplexml/tests/gh12929.phpt
@@ -8,8 +8,8 @@
 stream_wrapper_register($scheme, "SimpleXMLIterator");
 try {
     file_get_contents($scheme . "://x");
-} catch (Error $e) {
-    echo $e->getMessage(), "\n";
+} catch (Throwable $e) {
+    echo $e::class, ': ', $e->getMessage(), "\n";
     echo $e->getPrevious()->getMessage(), "\n";
 }

@@ -17,13 +17,13 @@
 stream_wrapper_register($scheme, "SimpleXMLElement");
 try {
     file_get_contents($scheme . "://x");
-} catch (Error $e) {
-    echo $e->getMessage(), "\n";
+} catch (Throwable $e) {
+    echo $e::class, ': ', $e->getMessage(), "\n";
     echo $e->getPrevious()->getMessage(), "\n";
 }
 ?>
 --EXPECT--
-It's not possible to assign a complex type to properties, resource given
+TypeError: It's not possible to assign a complex type to properties, resource given
 SimpleXMLElement is not properly initialized
-It's not possible to assign a complex type to properties, resource given
+TypeError: It's not possible to assign a complex type to properties, resource given
 SimpleXMLElement is not properly initialized
diff --git a/ext/simplexml/tests/key_error.phpt b/ext/simplexml/tests/key_error.phpt
index 5801aec1040..e38d8f305c9 100644
--- a/ext/simplexml/tests/key_error.phpt
+++ b/ext/simplexml/tests/key_error.phpt
@@ -16,8 +16,8 @@

 try {
     $sxe->key();
-} catch (Error $exception) {
-    echo $exception->getMessage() . "\n";
+} catch (Throwable $exception) {
+    echo $exception::class, ': ', $exception->getMessage(), "\n";
 }

 for ($sxe->rewind(); $sxe->valid(); $sxe->next()) {
@@ -26,14 +26,14 @@

 try {
     $sxe->key();
-} catch (Error $exception) {
-    echo $exception->getMessage() . "\n";
+} catch (Throwable $exception) {
+    echo $exception::class, ': ', $exception->getMessage(), "\n";
 }

 ?>
 --EXPECT--
-Iterator not initialized or already consumed
+Error: Iterator not initialized or already consumed
 string(4) "elem"
 object(SimpleXMLElement)#3 (0) {
 }
-Iterator not initialized or already consumed
+Error: Iterator not initialized or already consumed
diff --git a/ext/simplexml/tests/simplexml_uninitialized.phpt b/ext/simplexml/tests/simplexml_uninitialized.phpt
index ade8b809b7a..4731f58fd41 100644
--- a/ext/simplexml/tests/simplexml_uninitialized.phpt
+++ b/ext/simplexml/tests/simplexml_uninitialized.phpt
@@ -14,46 +14,46 @@ public function __construct() {
 $sxe = new MySXE;
 try {
     var_dump($sxe->count());
-} catch (Error $e) {
-    echo $e->getMessage(), "\n";
+} catch (Throwable $e) {
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 try {
     var_dump($sxe->xpath(''));
-} catch (Error $e) {
-    echo $e->getMessage(), "\n";
+} catch (Throwable $e) {
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 try {
     var_dump($sxe->getDocNamespaces());
-} catch (Error $e) {
-    echo $e->getMessage(), "\n";
+} catch (Throwable $e) {
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 try {
     var_dump($sxe->children());
-} catch (Error $e) {
-    echo $e->getMessage(), "\n";
+} catch (Throwable $e) {
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 try {
     var_dump($sxe->attributes());
-} catch (Error $e) {
-    echo $e->getMessage(), "\n";
+} catch (Throwable $e) {
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 try {
     var_dump($sxe->registerXPathNamespace('', ''));
-} catch (Error $e) {
-    echo $e->getMessage(), "\n";
+} catch (Throwable $e) {
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 try {
     var_dump($sxe->foo);
-} catch (Error $e) {
-    echo $e->getMessage(), "\n";
+} catch (Throwable $e) {
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }

 ?>
 --EXPECT--
-SimpleXMLElement is not properly initialized
-SimpleXMLElement is not properly initialized
-SimpleXMLElement is not properly initialized
-SimpleXMLElement is not properly initialized
-SimpleXMLElement is not properly initialized
-SimpleXMLElement is not properly initialized
-SimpleXMLElement is not properly initialized
+Error: SimpleXMLElement is not properly initialized
+Error: SimpleXMLElement is not properly initialized
+Error: SimpleXMLElement is not properly initialized
+Error: SimpleXMLElement is not properly initialized
+Error: SimpleXMLElement is not properly initialized
+Error: SimpleXMLElement is not properly initialized
+Error: SimpleXMLElement is not properly initialized