-
Notifications
You must be signed in to change notification settings - Fork 568
Expand file tree
/
Copy pathbug-13416.php
More file actions
61 lines (48 loc) · 1.06 KB
/
bug-13416.php
File metadata and controls
61 lines (48 loc) · 1.06 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
<?php declare(strict_types=1);
namespace Bug13416;
class MyRecord {
/** @var array<int, self> */
private static array $storage = [];
/** @phpstan-impure */
public function insert(): void {
self::$storage[] = $this;
}
/**
* @return array<int, self>
* @phpstan-impure
*/
public static function find(): array {
return self::$storage;
}
}
class AnotherRecord extends MyRecord {}
class PHPStanMinimalBug {
public function testMinimalBug(): void {
$msg1 = new MyRecord();
$msg1->insert();
assert(
count(MyRecord::find()) === 1,
'should have 1 record initially'
);
$msg2 = new MyRecord();
$msg2->insert();
assert(
count(MyRecord::find()) === 2,
'should have 2 messages after adding one'
);
}
public function testMinimalBugChildClass(): void {
$msg1 = new AnotherRecord();
$msg1->insert();
assert(
count(MyRecord::find()) === 1,
'should have 1 record initially'
);
$msg2 = new AnotherRecord();
$msg2->insert();
assert(
count(MyRecord::find()) === 2,
'should have 2 messages after adding one'
);
}
}