Skip to content

Commit 9ff8d49

Browse files
committed
Create bug-13851.php
1 parent d37ad89 commit 9ff8d49

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Bug13851;
4+
5+
use function PHPStan\Testing\assertType;
6+
7+
class Transaction
8+
{
9+
public function __construct(public int $value)
10+
{
11+
}
12+
13+
public function withValue(int $value): self
14+
{
15+
return new self($value);
16+
}
17+
}
18+
19+
/**
20+
* @return array<string, non-empty-list<Transaction>>
21+
*/
22+
function getPositions(): array
23+
{
24+
return ['AAPL' => [new Transaction(50)], 'TSLA' => [new Transaction(50), new Transaction(100)]];
25+
}
26+
27+
$positions = getPositions();
28+
29+
foreach ($positions as $symbol => &$transactions) {
30+
foreach ($transactions as &$transaction) {
31+
$transaction = $transaction->withValue(60);
32+
}
33+
}
34+
35+
assertType('array<string, non-empty-list<Bug13851\Transaction>>', $positions);

0 commit comments

Comments
 (0)