Skip to content

Commit 9aeda46

Browse files
committed
Regression test for #3915
1 parent 80e832a commit 9aeda46

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

tests/PHPStan/Analyser/NodeScopeResolverTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10274,6 +10274,11 @@ public function dataNeverEarlyTerminates(): array
1027410274
return $this->gatherAssertTypes(__DIR__ . '/data/early-termination-phpdoc.php');
1027510275
}
1027610276

10277+
public function dataBug3915(): array
10278+
{
10279+
return $this->gatherAssertTypes(__DIR__ . '/data/bug-3915.php');
10280+
}
10281+
1027710282
/**
1027810283
* @param string $file
1027910284
* @return array<string, mixed[]>
@@ -10443,6 +10448,7 @@ private function gatherAssertTypes(string $file): array
1044310448
* @dataProvider dataBug4016
1044410449
* @dataProvider dataPromotedProperties
1044510450
* @dataProvider dataNeverEarlyTerminates
10451+
* @dataProvider dataBug3915
1044610452
* @param string $assertType
1044710453
* @param string $file
1044810454
* @param mixed ...$args
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace Bug3915;
4+
5+
use function PHPStan\Analyser\assertType;
6+
7+
class HelloWorld
8+
{
9+
10+
public function sayHello(): void
11+
{
12+
$lengths = [0];
13+
foreach ([1] as $row) {
14+
$lengths[] = self::getInt();
15+
}
16+
assertType('array<int, int>&nonEmpty', $lengths);
17+
}
18+
19+
public static function getInt(): int
20+
{
21+
return 5;
22+
}
23+
24+
}

0 commit comments

Comments
 (0)