Skip to content

Commit 7ec101f

Browse files
committed
Regression test
Closes phpstan/phpstan#9086
1 parent 2ab647e commit 7ec101f

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

tests/PHPStan/Analyser/NodeScopeResolverTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public function dataFileAsserts(): iterable
8686
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-5508.php');
8787
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-10254.php');
8888
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-7281.php');
89+
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-9086.php');
8990
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-2750.php');
9091
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-2850.php');
9192
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-2863.php');
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
namespace Bug9086;
4+
5+
use ArrayObject;
6+
use function PHPStan\Testing\assertType;
7+
8+
/**
9+
* @template A
10+
* @template B
11+
*
12+
* @param A $items
13+
* @param callable(A): B $ab
14+
* @return B
15+
*/
16+
function pipe(mixed $items, callable $ab): mixed
17+
{
18+
return $ab($items);
19+
}
20+
21+
/**
22+
* @return ArrayObject<string, bool>
23+
*/
24+
function getObject(): ArrayObject
25+
{
26+
return new ArrayObject;
27+
}
28+
29+
function (): void {
30+
$result = pipe(getObject(), function(ArrayObject $i) {
31+
assertType('ArrayObject<string, bool>', $i);
32+
return $i;
33+
});
34+
35+
assertType('ArrayObject<string, bool>', $result);
36+
};

0 commit comments

Comments
 (0)