Skip to content

Commit ea87672

Browse files
committed
add 10686 test
1 parent a4c1d8c commit ea87672

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

tests/PHPStan/Rules/Properties/TypesAssignedToPropertiesRuleTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,11 @@ public function testGenericsInCallableInConstructor(): void
637637
$this->analyse([__DIR__ . '/data/generics-in-callable-in-constructor.php'], []);
638638
}
639639

640+
public function testBug10686(): void
641+
{
642+
$this->analyse([__DIR__ . '/data/bug-10686.php'], []);
643+
}
644+
640645
public function testBug11275(): void
641646
{
642647
if (PHP_VERSION_ID < 80000) {
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace Bug10686;
4+
5+
class Model {}
6+
7+
/**
8+
* @template T of object|array<mixed>
9+
*/
10+
class WeakAnalysingMap
11+
{
12+
/** @var list<T> */
13+
public array $values = [];
14+
}
15+
16+
class Reference
17+
{
18+
/** @var WeakAnalysingMap<Model> */
19+
private static WeakAnalysingMap $analysingTheirModelMap;
20+
21+
public function createAnalysingTheirModel(): Model
22+
{
23+
if ((self::$analysingTheirModelMap ?? null) === null) {
24+
self::$analysingTheirModelMap = new WeakAnalysingMap();
25+
}
26+
27+
$theirModel = new Model();
28+
29+
self::$analysingTheirModelMap->values[] = $theirModel;
30+
31+
return end(self::$analysingTheirModelMap->values);
32+
}
33+
}

0 commit comments

Comments
 (0)