Skip to content
This repository was archived by the owner on Oct 22, 2019. It is now read-only.

Commit c2ba327

Browse files
author
Marko Kruljac
committed
changed array declaration to short syntax
1 parent b73b453 commit c2ba327

1 file changed

Lines changed: 28 additions & 28 deletions

File tree

src/Prometheus/Storage/InMemory.php

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,21 @@ public function flushMemory()
3333

3434
private function collectHistograms()
3535
{
36-
$histograms = array();
36+
$histograms = [];
3737
foreach ($this->histograms as $histogram) {
3838
$metaData = $histogram['meta'];
39-
$data = array(
39+
$data = [
4040
'name' => $metaData['name'],
4141
'help' => $metaData['help'],
4242
'type' => $metaData['type'],
4343
'labelNames' => $metaData['labelNames'],
4444
'buckets' => $metaData['buckets']
45-
);
45+
];
4646

4747
// Add the Inf bucket so we can compute it later on
4848
$data['buckets'][] = '+Inf';
4949

50-
$histogramBuckets = array();
50+
$histogramBuckets = [];
5151
foreach ($histogram['samples'] as $key => $value) {
5252
$parts = explode(':', $key);
5353
$labelValues = $parts[2];
@@ -65,38 +65,38 @@ private function collectHistograms()
6565
foreach ($data['buckets'] as $bucket) {
6666
$bucket = (string) $bucket;
6767
if (!isset($histogramBuckets[$labelValues][$bucket])) {
68-
$data['samples'][] = array(
68+
$data['samples'][] = [
6969
'name' => $metaData['name'] . '_bucket',
70-
'labelNames' => array('le'),
71-
'labelValues' => array_merge($decodedLabelValues, array($bucket)),
70+
'labelNames' => ['le'],
71+
'labelValues' => array_merge($decodedLabelValues, [$bucket]),
7272
'value' => $acc
73-
);
73+
];
7474
} else {
7575
$acc += $histogramBuckets[$labelValues][$bucket];
76-
$data['samples'][] = array(
76+
$data['samples'][] = [
7777
'name' => $metaData['name'] . '_' . 'bucket',
78-
'labelNames' => array('le'),
79-
'labelValues' => array_merge($decodedLabelValues, array($bucket)),
78+
'labelNames' => ['le'],
79+
'labelValues' => array_merge($decodedLabelValues, [$bucket]),
8080
'value' => $acc
81-
);
81+
];
8282
}
8383
}
8484

8585
// Add the count
86-
$data['samples'][] = array(
86+
$data['samples'][] = [
8787
'name' => $metaData['name'] . '_count',
88-
'labelNames' => array(),
88+
'labelNames' => [],
8989
'labelValues' => $decodedLabelValues,
9090
'value' => $acc
91-
);
91+
];
9292

9393
// Add the sum
94-
$data['samples'][] = array(
94+
$data['samples'][] = [
9595
'name' => $metaData['name'] . '_sum',
96-
'labelNames' => array(),
96+
'labelNames' => [],
9797
'labelValues' => $decodedLabelValues,
9898
'value' => $histogramBuckets[$labelValues]['sum']
99-
);
99+
];
100100

101101
}
102102
$histograms[] = new MetricFamilySamples($data);
@@ -109,21 +109,21 @@ private function internalCollect(array $metrics)
109109
$result = [];
110110
foreach ($metrics as $metric) {
111111
$metaData = $metric['meta'];
112-
$data = array(
112+
$data = [
113113
'name' => $metaData['name'],
114114
'help' => $metaData['help'],
115115
'type' => $metaData['type'],
116116
'labelNames' => $metaData['labelNames'],
117-
);
117+
];
118118
foreach ($metric['samples'] as $key => $value) {
119119
$parts = explode(':', $key);
120120
$labelValues = $parts[2];
121-
$data['samples'][] = array(
121+
$data['samples'][] = [
122122
'name' => $metaData['name'],
123-
'labelNames' => array(),
123+
'labelNames' => [],
124124
'labelValues' => json_decode($labelValues),
125125
'value' => $value
126-
);
126+
];
127127
}
128128
$this->sortSamples($data['samples']);
129129
$result[] = new MetricFamilySamples($data);
@@ -138,7 +138,7 @@ public function fetchSamples()
138138
{
139139
return array_map(
140140
function ($data) { return new Sample($data); },
141-
array_values(array_reduce(array_values($this->samples), 'array_merge', array()))
141+
array_values(array_reduce(array_values($this->samples), 'array_merge', []))
142142
);
143143
}
144144

@@ -224,12 +224,12 @@ public function updateCounter(array $data)
224224
*/
225225
private function histogramBucketValueKey(array $data, $bucket)
226226
{
227-
return implode(':', array(
227+
return implode(':', [
228228
$data['type'],
229229
$data['name'],
230230
json_encode($data['labelValues']),
231231
$bucket
232-
));
232+
]);
233233
}
234234

235235
/**
@@ -239,7 +239,7 @@ private function histogramBucketValueKey(array $data, $bucket)
239239
*/
240240
private function metaKey(array $data)
241241
{
242-
return implode(':', array($data['type'], $data['name'], 'meta'));
242+
return implode(':', [$data['type'], $data['name'], 'meta']);
243243
}
244244

245245
/**
@@ -250,7 +250,7 @@ private function metaKey(array $data)
250250
private function valueKey(array $data)
251251
{
252252
return implode(':',
253-
array($data['type'], $data['name'], json_encode($data['labelValues']), 'value'));
253+
[$data['type'], $data['name'], json_encode($data['labelValues']), 'value']);
254254
}
255255

256256
/**

0 commit comments

Comments
 (0)