Skip to content

Commit 7acbb8a

Browse files
committed
Add regression test for #4525
Closes phpstan/phpstan#4525
1 parent 1114ccc commit 7acbb8a

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

tests/PHPStan/Rules/Properties/TypesAssignedToPropertiesRuleTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,4 +1009,9 @@ public function testBug12250(): void
10091009
$this->analyse([__DIR__ . '/data/bug-12250.php'], []);
10101010
}
10111011

1012+
public function testBug4525(): void
1013+
{
1014+
$this->analyse([__DIR__ . '/data/bug-4525.php'], []);
1015+
}
1016+
10121017
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php // lint >= 7.4
2+
3+
namespace Bug4525;
4+
5+
use SplObjectStorage;
6+
7+
class HelloWorld
8+
{
9+
/**
10+
* @var SplObjectStorage<\DateTime, \DateTimeImmutable>
11+
*/
12+
private SplObjectStorage $map;
13+
14+
public function sayHello(): void
15+
{
16+
$this->map = new SplObjectStorage();
17+
}
18+
19+
/** @phpstan-return SplObjectStorage<\DateTime, \DateTimeImmutable> */
20+
public function getMap(): SplObjectStorage
21+
{
22+
return $this->map ??= new SplObjectStorage();
23+
}
24+
}

0 commit comments

Comments
 (0)