File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed
tests/PHPStan/Rules/Methods Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -1232,4 +1232,18 @@ public function testBug1O580(): void
12321232 ]);
12331233 }
12341234
1235+ public function testBug4443 (): void
1236+ {
1237+ if (PHP_VERSION_ID < 80000 ) {
1238+ $ this ->markTestSkipped ('Test requires PHP 8.0. ' );
1239+ }
1240+
1241+ $ this ->analyse ([__DIR__ . '/data/bug-4443.php ' ], [
1242+ [
1243+ 'Method Bug4443\HelloWorld::getArray() should return array<mixed> but returns array<mixed>|null. ' ,
1244+ 22
1245+ ]
1246+ ]);
1247+ }
1248+
12351249}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Bug4443 ;
4+
5+ class HelloWorld
6+ {
7+ /** @var array<mixed> */
8+ private static ?array $ arr = null ;
9+
10+ private static function setup (): void
11+ {
12+ self ::$ arr = null ;
13+ }
14+
15+ /** @return array<mixed> */
16+ public static function getArray (): array
17+ {
18+ if (self ::$ arr === null ) {
19+ self ::$ arr = [];
20+ self ::setup ();
21+ }
22+ return self ::$ arr ;
23+ }
24+ }
25+
26+ HelloWorld::getArray ();
You can’t perform that action at this time.
0 commit comments