Skip to content

Commit e76dbde

Browse files
committed
fixup! zend_builtin_functions: Add withProperties parameter to clone() function
1 parent 8b7bd62 commit e76dbde

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

Zend/tests/clone/clone_with_012.phpt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
--TEST--
2+
Clone with property hook updating readonly property
3+
--FILE--
4+
<?php
5+
6+
class Clazz {
7+
public string $foo {
8+
set {
9+
$this->foo = $value;
10+
$this->bar = 'bar updated in hook';
11+
}
12+
}
13+
14+
public public(set) readonly string $bar;
15+
}
16+
17+
$f = new Clazz();
18+
19+
var_dump(clone($f, ['foo' => 'foo updated in clone-with']));
20+
21+
try {
22+
var_dump(clone($f, ['foo' => 'foo updated in clone-with', 'bar' => 'bar updated in clone-with']));
23+
} catch (Throwable $e) {
24+
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
25+
}
26+
27+
?>
28+
--EXPECTF--
29+
object(Clazz)#%d (2) {
30+
["foo"]=>
31+
string(25) "foo updated in clone-with"
32+
["bar"]=>
33+
string(19) "bar updated in hook"
34+
}
35+
Error: Cannot modify readonly property Clazz::$bar

0 commit comments

Comments
 (0)