forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbug-14063.php
More file actions
39 lines (30 loc) · 702 Bytes
/
bug-14063.php
File metadata and controls
39 lines (30 loc) · 702 Bytes
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
<?php // lint >= 8.5
declare(strict_types = 1);
namespace Bug14063;
final readonly class Obj
{
public function __construct(public string $value) {}
public function withValue(string $newValue): self
{
return clone($this, ['value' => $newValue]);
}
}
readonly class Base
{
public function __construct(public string $value) {}
}
readonly class Child extends Base
{
public function withValue(string $newValue): self
{
return clone($this, ['value' => $newValue]);
}
}
$obj = new Obj('val');
$newObj = clone($obj, ['value' => 'newVal']);
function test(Obj $obj): void {
clone($obj, ['value' => 'newVal']);
}
function testBase(Base $base): void {
clone($base, ['value' => 'newVal']);
}