Skip to content

Commit 831abfc

Browse files
committed
feat: redine types as items and lists and fix assign.propertyType
1 parent ec2700b commit 831abfc

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

phpstan.neon.dist

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,5 @@ parameters:
88
- src
99
- tests
1010
ignoreErrors:
11-
- identifier: 'assign.propertyType'
12-
path: src/DataCollector/DoctrineDataCollector.php
1311
- identifier: 'class.notFound'
1412
path: src/DependencyInjection/Configuration.php

src/DataCollector/DoctrineDataCollector.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
* }>>,
4747
* entityCounts: array<string, array<class-string, int>>
4848
* }
49-
* @phpstan-type GroupedQueriesType = array<string, list<array{
49+
* @phpstan-type GroupedQueryItemType = array{
5050
* executionMS: float,
5151
* explainable: bool,
5252
* sql: string,
@@ -56,7 +56,8 @@
5656
* count: int,
5757
* index: int,
5858
* executionPercent?: float
59-
* }>>
59+
* }
60+
* @phpstan-type GroupedQueriesType = array<string, array<int, GroupedQueryItemType>>
6061
* @psalm-property DataType $data
6162
*/
6263
class DoctrineDataCollector extends BaseCollector
@@ -285,10 +286,11 @@ public function getGroupedQueries(): array
285286
foreach ($queries as $i => $query) {
286287
$key = $query['sql'];
287288
if (! isset($connectionGroupedQueries[$key])) {
288-
$connectionGroupedQueries[$key] = $query;
289-
$connectionGroupedQueries[$key]['executionMS'] = 0;
290-
$connectionGroupedQueries[$key]['count'] = 0;
291-
$connectionGroupedQueries[$key]['index'] = $i; // "Explain query" relies on query index in 'queries'.
289+
$connectionGroupedQueries[$key] = array_merge($query, [
290+
'executionMS' => 0,
291+
'count' => 0,
292+
'index' => $i, // "Explain query" relies on query index in 'queries'.
293+
]);
292294
}
293295

294296
$connectionGroupedQueries[$key]['executionMS'] += $query['executionMS'];
@@ -303,7 +305,9 @@ public function getGroupedQueries(): array
303305

304306
return $a['executionMS'] < $b['executionMS'] ? 1 : -1;
305307
});
306-
$this->groupedQueries[$connection] = $connectionGroupedQueries;
308+
$sortedQueries = $connectionGroupedQueries;
309+
/** @var array<int, GroupedQueryItemType> $sortedQueries */
310+
$this->groupedQueries[$connection] = $sortedQueries;
307311
}
308312

309313
foreach ($this->groupedQueries as $connection => $queries) {

0 commit comments

Comments
 (0)