Skip to content

Commit 48458f7

Browse files
VincentLangletondrejmirtes
authored andcommitted
Add non regression test
1 parent 304ab0d commit 48458f7

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

tests/PHPStan/Rules/Functions/ReturnTypeRuleTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,4 +357,17 @@ public function testBug12274(): void
357357
]);
358358
}
359359

360+
public function testBug9401(): void
361+
{
362+
$this->checkExplicitMixed = true;
363+
$this->checkNullables = true;
364+
365+
$this->analyse([__DIR__ . '/data/bug-9401.php'], [
366+
[
367+
'Function Bug9401\foo() should return list<int<1, max>> but returns list<int<0, max>>.',
368+
17,
369+
],
370+
]);
371+
}
372+
360373
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug9401;
4+
5+
/**
6+
* @param array<mixed> $foos
7+
* @return list<positive-int>
8+
*/
9+
function foo(array $foos): array
10+
{
11+
$list = [];
12+
foreach ($foos as $foo) {
13+
if (is_int($foo) && $foo >= 0) {
14+
$list[] = $foo;
15+
}
16+
}
17+
return $list;
18+
}

0 commit comments

Comments
 (0)