File tree Expand file tree Collapse file tree
tests/PHPStan/Analyser/nsrt Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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 );
You can’t perform that action at this time.
0 commit comments