forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbug-13623.php
More file actions
24 lines (17 loc) · 842 Bytes
/
bug-13623.php
File metadata and controls
24 lines (17 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
declare(strict_types = 1);
namespace Bug13623;
use function PHPStan\Testing\assertType;
function (array $results): void {
$customers = [];
foreach ($results as $row) {
$customers[$row['customer_id']] ??= [];
$customers[$row['customer_id']]['orders'] ??= [];
$customers[$row['customer_id']]['orders'][$row['order_id']] ??= [];
$customers[$row['customer_id']]['orders'][$row['order_id']]['balance_forward'] ??= 0;
$customers[$row['customer_id']]['orders'][$row['order_id']]['new_invoice'] ??= 0;
$customers[$row['customer_id']]['orders'][$row['order_id']]['payments'] ??= 0;
$customers[$row['customer_id']]['orders'][$row['order_id']]['balance'] ??= $row['order_total'];
}
assertType("array<array{orders: non-empty-array<array{balance_forward: 0, new_invoice: 0, payments: 0, balance: mixed}>}>", $customers);
};