-
Notifications
You must be signed in to change notification settings - Fork 570
Expand file tree
/
Copy pathbug-14063.php
More file actions
76 lines (61 loc) · 1.21 KB
/
bug-14063.php
File metadata and controls
76 lines (61 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php // lint >= 8.5
declare(strict_types = 1);
namespace Bug14063;
final readonly class Obj
{
public function __construct(public string $value) {}
public function doFoo(): void
{
clone($this, ['value' => 'newVal']);
}
}
class Bar
{
public readonly string $value;
public function __construct(string $value)
{
$this->value = $value;
}
public function doFoo(): void
{
clone($this, ['value' => 'newVal']);
}
}
readonly class Baz
{
public function __construct(
public string $pub,
protected string $prot,
private string $priv,
) {}
public function doFoo(): void
{
clone($this, [
'pub' => 'newVal',
'prot' => 'newVal',
'priv' => 'newVal',
]);
}
}
// non-readonly class with promoted public readonly property
final class Qux
{
public function __construct(public readonly string $value) {}
public function doFoo(): void
{
clone($this, ['value' => 'newVal']);
}
}
$obj = new Obj('val');
$newObj = clone($obj, ['value' => 'newVal']);
$qux = new Qux('val');
$newQux = clone($qux, ['value' => 'newVal']);
$bar = new Bar('val');
$newBar = clone($bar, ['value' => 'newVal']);
function (Baz $baz): void {
clone($baz, [
'pub' => 'newVal',
'prot' => 'newVal',
'priv' => 'newVal',
]);
};