-
-
Notifications
You must be signed in to change notification settings - Fork 938
Closed
Labels
Milestone
Description
Bug report
+--------------------------------------------------------------+
| Line | test.php |
+--------------------------------------------------------------+
| 23 | Unreachable statement - code above always terminates. |
+--------------------------------------------------------------+
Code snippet that reproduces the problem
➡️ https://phpstan.org/r/053b9b77-618e-4af2-8105-c2a572945565
<?php declare(strict_types = 1);
$fun = function (): array {
return [
['group_id' => 'a', 'user_id' => 'id1'],
['group_id' => 'a', 'user_id' => 'id2'],
['group_id' => 'a', 'user_id' => 'id3'],
['group_id' => 'b', 'user_id' => 'id4'],
['group_id' => 'b', 'user_id' => 'id5'],
['group_id' => 'b', 'user_id' => 'id6'],
];
};
$orders = $fun();
$result = [];
foreach ($orders as $order) {
// no error trigger with this statement
// if (isset($result[$order['group_id']])) {
if (isset($result[$order['group_id']]['users'])) {
$result[$order['group_id']]['users'][] = $order['user_id'];
continue;
}
$result[$order['group_id']] = [
'users' => [
$order['user_id'],
],
];
}Expected output
[OK] No errors
Reactions are currently unavailable