diff --git a/Zend/tests/generators/clone.phpt b/Zend/tests/generators/clone.phpt
index 1e8da25136a13..748b826365cc0 100644
--- a/Zend/tests/generators/clone.phpt
+++ b/Zend/tests/generators/clone.phpt
@@ -7,12 +7,14 @@ function gen() {
yield;
}
-$gen = gen();
-clone $gen;
+
+try {
+ $gen = gen();
+ clone $gen;
+} catch (Throwable $e) {
+ echo $e::class, ": ", $e->getMessage(), PHP_EOL;
+}
?>
---EXPECTF--
-Fatal error: Uncaught Error: Trying to clone an uncloneable object of class Generator in %s:%d
-Stack trace:
-#0 {main}
- thrown in %s on line %d
+--EXPECT--
+Error: Trying to clone an uncloneable object of class Generator
diff --git a/ext/dom/tests/modern/token_list/clone.phpt b/ext/dom/tests/modern/token_list/clone.phpt
index 039551f2d43d8..e0c71e9fd7910 100644
--- a/ext/dom/tests/modern/token_list/clone.phpt
+++ b/ext/dom/tests/modern/token_list/clone.phpt
@@ -7,11 +7,12 @@ dom
$dom = DOM\XMLDocument::createFromString('');
$element = $dom->documentElement;
-clone $element->classList;
+try {
+ clone $element->classList;
+} catch (Throwable $e) {
+ echo $e::class, ": ", $e->getMessage(), PHP_EOL;
+}
?>
---EXPECTF--
-Fatal error: Uncaught Error: Trying to clone an uncloneable object of class Dom\TokenList in %s:%d
-Stack trace:
-#0 {main}
- thrown in %s on line %d
+--EXPECT--
+Error: Trying to clone an uncloneable object of class Dom\TokenList
diff --git a/ext/gd/tests/gdimage_prevent_cloning.phpt b/ext/gd/tests/gdimage_prevent_cloning.phpt
index 426f7d9c48f6c..609e6f99bbfa9 100644
--- a/ext/gd/tests/gdimage_prevent_cloning.phpt
+++ b/ext/gd/tests/gdimage_prevent_cloning.phpt
@@ -5,12 +5,13 @@ gd
--FILE--
getMessage(), PHP_EOL;
+}
?>
---EXPECTF--
-Fatal error: Uncaught Error: Trying to clone an uncloneable object of class GdImage in %s:%d
-Stack trace:
-#0 {main}
- thrown in %s on line %d
+--EXPECT--
+Error: Trying to clone an uncloneable object of class GdImage
diff --git a/ext/mysqli/tests/mysqli_driver_unclonable.phpt b/ext/mysqli/tests/mysqli_driver_unclonable.phpt
index 54b97ef36c931..7041a024f67cb 100644
--- a/ext/mysqli/tests/mysqli_driver_unclonable.phpt
+++ b/ext/mysqli/tests/mysqli_driver_unclonable.phpt
@@ -4,12 +4,14 @@ Trying to clone mysqli_driver object
mysqli
--FILE--
getMessage(), PHP_EOL;
+}
+
?>
---EXPECTF--
-Fatal error: Uncaught Error: Trying to clone an uncloneable object of class mysqli_driver in %s:%d
-Stack trace:
-#0 {main}
- thrown in %s on line %d
+--EXPECT--
+Error: Trying to clone an uncloneable object of class mysqli_driver
diff --git a/ext/mysqli/tests/mysqli_result_unclonable.phpt b/ext/mysqli/tests/mysqli_result_unclonable.phpt
index b54c39f7a170f..98770406bb713 100644
--- a/ext/mysqli/tests/mysqli_result_unclonable.phpt
+++ b/ext/mysqli/tests/mysqli_result_unclonable.phpt
@@ -17,11 +17,11 @@ require_once 'skipifconnectfailure.inc';
if (!($res = mysqli_query($link, "SELECT 'good' AS morning")))
printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- $res_clone = clone $res;
- print "done!";
+ try {
+ $res_clone = clone $res;
+ } catch (Throwable $e) {
+ echo $e::class, ": ", $e->getMessage(), PHP_EOL;
+ }
?>
---EXPECTF--
-Fatal error: Uncaught Error: Trying to clone an uncloneable object of class mysqli_result in %s:%d
-Stack trace:
-#0 {main}
- thrown in %s on line %d
+--EXPECT--
+Error: Trying to clone an uncloneable object of class mysqli_result
diff --git a/ext/mysqli/tests/mysqli_stmt_unclonable.phpt b/ext/mysqli/tests/mysqli_stmt_unclonable.phpt
index 29658bb25c669..c1e01d37e36c0 100644
--- a/ext/mysqli/tests/mysqli_stmt_unclonable.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_unclonable.phpt
@@ -17,12 +17,11 @@ require_once 'skipifconnectfailure.inc';
if (!$stmt = mysqli_stmt_init($link))
printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- /* no, still bails out */
- $stmt_clone = clone $stmt;
- print "done!";
+ try {
+ $stmt_clone = clone $stmt;
+ } catch (Throwable $e) {
+ echo $e::class, ": ", $e->getMessage(), PHP_EOL;
+ }
?>
---EXPECTF--
-Fatal error: Uncaught Error: Trying to clone an uncloneable object of class mysqli_stmt in %s:%d
-Stack trace:
-#0 {main}
- thrown in %s on line %d
+--EXPECT--
+Error: Trying to clone an uncloneable object of class mysqli_stmt
diff --git a/ext/mysqli/tests/mysqli_unclonable.phpt b/ext/mysqli/tests/mysqli_unclonable.phpt
index 0772854ed96a1..6e42171606c24 100644
--- a/ext/mysqli/tests/mysqli_unclonable.phpt
+++ b/ext/mysqli/tests/mysqli_unclonable.phpt
@@ -14,13 +14,12 @@ require_once 'skipifconnectfailure.inc';
printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
- $link_clone = clone $link;
- mysqli_close($link);
+ try {
+ $link_clone = clone $link;
+ } catch (Throwable $e) {
+ echo $e::class, ": ", $e->getMessage(), PHP_EOL;
+ }
- print "done!";
?>
---EXPECTF--
-Fatal error: Uncaught Error: Trying to clone an uncloneable object of class mysqli in %s:%d
-Stack trace:
-#0 {main}
- thrown in %s on line %d
+--EXPECT--
+Error: Trying to clone an uncloneable object of class mysqli
diff --git a/ext/pdo/tests/bug_77849.phpt b/ext/pdo/tests/bug_77849.phpt
index 6fbf56e869b70..bbb0f3e8595e2 100644
--- a/ext/pdo/tests/bug_77849.phpt
+++ b/ext/pdo/tests/bug_77849.phpt
@@ -15,10 +15,11 @@ if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.dirname(__FILE_
require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
$db = PDOTest::factory();
-$db2 = clone $db;
+try {
+ $db2 = clone $db;
+} catch (Throwable $e) {
+ echo $e::class, ": ", $e->getMessage(), PHP_EOL;
+}
?>
---EXPECTF--
-Fatal error: Uncaught Error: Trying to clone an uncloneable object of class PDO in %s
-Stack trace:
-#0 {main}
- thrown in %s on line %d
+--EXPECT--
+Error: Trying to clone an uncloneable object of class PDO
diff --git a/ext/pdo/tests/bug_77849_2.phpt b/ext/pdo/tests/bug_77849_2.phpt
index 6453a79312e2a..3e481eedb1e1a 100644
--- a/ext/pdo/tests/bug_77849_2.phpt
+++ b/ext/pdo/tests/bug_77849_2.phpt
@@ -4,13 +4,14 @@ PDO Common: Bug #77849 (inconsistent state of cloned statament object)
pdo
--FILE--
---EXPECTF--
-Fatal error: Uncaught Error: Trying to clone an uncloneable object of class PDOStatement in %s:4
-Stack trace:
-#0 {main}
- thrown in %s on line 4
+try {
+ $stmt = new PDOStatement();
+ clone $stmt;
+} catch (Throwable $e) {
+ echo $e::class, ": ", $e->getMessage(), PHP_EOL;
+}
+?>
+--EXPECT--
+Error: Trying to clone an uncloneable object of class PDOStatement
diff --git a/ext/reflection/tests/ReflectionClass_CannotClone_basic.phpt b/ext/reflection/tests/ReflectionClass_CannotClone_basic.phpt
index 58ce9c65dce0f..64d884d6ae02c 100644
--- a/ext/reflection/tests/ReflectionClass_CannotClone_basic.phpt
+++ b/ext/reflection/tests/ReflectionClass_CannotClone_basic.phpt
@@ -6,10 +6,11 @@ TestFest PHP|Tek
--FILE--
getMessage(), PHP_EOL;
+}
?>
---EXPECTF--
-Fatal error: Uncaught Error: Trying to clone an uncloneable object of class ReflectionClass in %s:%d
-Stack trace:
-#0 {main}
- thrown in %s on line %d
+--EXPECT--
+Error: Trying to clone an uncloneable object of class ReflectionClass
diff --git a/ext/reflection/tests/ReflectionClass_isCloneable_001.phpt b/ext/reflection/tests/ReflectionClass_isCloneable_001.phpt
index 0b3701f1bb610..bde3a60a1e7f9 100644
--- a/ext/reflection/tests/ReflectionClass_isCloneable_001.phpt
+++ b/ext/reflection/tests/ReflectionClass_isCloneable_001.phpt
@@ -49,10 +49,14 @@ $obj = new ReflectionClass('xmlwriter');
var_dump($obj->isCloneable());
$obj = new ReflectionObject(new XMLWriter);
var_dump($obj->isCloneable());
-$h = clone new xmlwriter;
+try {
+ $h = clone new xmlwriter;
+} catch (Throwable $e) {
+ echo $e::class, ": ", $e->getMessage(), PHP_EOL;
+}
?>
---EXPECTF--
+--EXPECT--
User class
bool(true)
bool(true)
@@ -68,8 +72,4 @@ bool(true)
Internal class - XMLWriter
bool(false)
bool(false)
-
-Fatal error: Uncaught Error: Trying to clone an uncloneable object of class XMLWriter in %s:%d
-Stack trace:
-#0 {main}
- thrown in %s on line %d
+Error: Trying to clone an uncloneable object of class XMLWriter
diff --git a/ext/xml/tests/bug78563.phpt b/ext/xml/tests/bug78563.phpt
index 4e1bb5d63bf57..dc7d5fe02dc26 100644
--- a/ext/xml/tests/bug78563.phpt
+++ b/ext/xml/tests/bug78563.phpt
@@ -5,13 +5,13 @@ xml
--FILE--
getMessage(), PHP_EOL;
+}
?>
-===DONE===
---EXPECTF--
-Fatal error: Uncaught Error: Trying to clone an uncloneable object of class XMLParser in %s:%d
-Stack trace:
-#0 {main}
- thrown in %s on line %d
+--EXPECT--
+Error: Trying to clone an uncloneable object of class XMLParser
diff --git a/ext/xmlreader/tests/bug51936.phpt b/ext/xmlreader/tests/bug51936.phpt
index 00a8134d1a45f..6014c5550a629 100644
--- a/ext/xmlreader/tests/bug51936.phpt
+++ b/ext/xmlreader/tests/bug51936.phpt
@@ -4,20 +4,19 @@ Bug #51936 (Crash with clone XMLReader)
xmlreader
--FILE--
xml("");
$xmlreader->next();
-$xmlreader2 = clone $xmlreader;
-$xmlreader2->next();
-?>
-Done
---EXPECTF--
-Test
-Fatal error: Uncaught Error: Trying to clone an uncloneable object of class XMLReader in %s:%d
-Stack trace:
-#0 {main}
- thrown in %s on line %d
+try {
+ $xmlreader2 = clone $xmlreader;
+ $xmlreader2->next();
+} catch (Throwable $e) {
+ echo $e::class, ": ", $e->getMessage(), PHP_EOL;
+}
+
+?>
+--EXPECT--
+Error: Trying to clone an uncloneable object of class XMLReader
diff --git a/tests/classes/factory_and_singleton_007.phpt b/tests/classes/factory_and_singleton_007.phpt
index 2c35090eed5e0..fc232bdb8655a 100644
--- a/tests/classes/factory_and_singleton_007.phpt
+++ b/tests/classes/factory_and_singleton_007.phpt
@@ -8,14 +8,13 @@ class test {
}
}
-$obj = new test;
-$clone = clone $obj;
-$obj = NULL;
+try {
+ $obj = new test;
+ $clone = clone $obj;
+} catch (Throwable $e) {
+ echo $e::class, ": ", $e->getMessage(), PHP_EOL;
+}
-echo "Done\n";
?>
---EXPECTF--
-Fatal error: Uncaught Error: Call to protected test::__clone() from global scope in %s:%d
-Stack trace:
-#0 {main}
- thrown in %s on line %d
+--EXPECT--
+Error: Call to protected test::__clone() from global scope
diff --git a/tests/classes/factory_and_singleton_008.phpt b/tests/classes/factory_and_singleton_008.phpt
index 2b2c0721c75e5..672c083270730 100644
--- a/tests/classes/factory_and_singleton_008.phpt
+++ b/tests/classes/factory_and_singleton_008.phpt
@@ -8,14 +8,13 @@ class test {
}
}
-$obj = new test;
-$clone = clone $obj;
-$obj = NULL;
+try {
+ $obj = new test;
+ $clone = clone $obj;
+} catch (Throwable $e) {
+ echo $e::class, ": ", $e->getMessage(), PHP_EOL;
+}
-echo "Done\n";
?>
---EXPECTF--
-Fatal error: Uncaught Error: Call to private test::__clone() from global scope in %s:%d
-Stack trace:
-#0 {main}
- thrown in %s on line %d
+--EXPECT--
+Error: Call to private test::__clone() from global scope