We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a58629a commit ac04bf5Copy full SHA for ac04bf5
Zend/tests/clone_initializer/clone_initializer_error11.phpt
@@ -0,0 +1,38 @@
1
+--TEST--
2
+Test that the destructor of the cloned object is run
3
+--FILE--
4
+<?php
5
+
6
+class Foo
7
+{
8
+ public function __construct(
9
+ public readonly int $bar
10
+ ) {}
11
12
+ public function __destruct()
13
+ {
14
+ echo "Destruct $this->bar\n";
15
+ }
16
17
+ public function with()
18
19
+ return clone $this with {
20
+ "bar" => 1,
21
+ "bar" => 2,
22
+ };
23
24
+}
25
26
+$foo = new Foo(0);
27
28
+try {
29
+ $foo->with();
30
+} catch (Error $e) {
31
+ echo $e->getMessage() . "\n";
32
33
34
+?>
35
+--EXPECTF--
36
+Destruct 1
37
+Cannot modify readonly property Foo::$bar
38
+Destruct 0
0 commit comments