Skip to content

Commit 90c19d4

Browse files
committed
Test clone with with __clone
1 parent ac0369a commit 90c19d4

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--TEST--
2+
Clone with supports __clone
3+
--FILE--
4+
<?php
5+
6+
class Clazz {
7+
public function __construct(
8+
public string $foo,
9+
public string $bar,
10+
) { }
11+
12+
public function __clone() {
13+
$this->foo = 'foo updated in __clone';
14+
$this->bar = 'bar updated in __clone';
15+
}
16+
}
17+
18+
$c = new Clazz('foo', 'bar');
19+
20+
var_dump(clone($c, foo: 'foo updated in clone-with'));
21+
22+
?>
23+
--EXPECTF--
24+
object(Clazz)#%d (2) {
25+
["foo"]=>
26+
string(25) "foo updated in clone-with"
27+
["bar"]=>
28+
string(22) "bar updated in __clone"
29+
}

0 commit comments

Comments
 (0)