Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions tests/PHPStan/Rules/Functions/ReturnTypeRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,17 @@ public function testBug12274(): void
]);
}

public function testBug9401(): void
{
$this->checkExplicitMixed = true;
$this->checkNullables = true;

$this->analyse([__DIR__ . '/data/bug-9401.php'], [
[
'Function Bug9401\foo() should return list<int<1, max>> but returns list<int<0, max>>.',
17,
],
]);
}

}
18 changes: 18 additions & 0 deletions tests/PHPStan/Rules/Functions/data/bug-9401.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php declare(strict_types = 1);

namespace Bug9401;

/**
* @param array<mixed> $foos
* @return list<positive-int>
*/
function foo(array $foos): array
{
$list = [];
foreach ($foos as $foo) {
if (is_int($foo) && $foo >= 0) {
$list[] = $foo;
}
}
return $list;
}
Loading