Skip to content

Commit abe2dd8

Browse files
Add non regression test (#5442)
Co-authored-by: Markus Staab <maggus.staab@googlemail.com>
1 parent 0fe9f46 commit abe2dd8

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace PR5379;
6+
7+
use function PHPStan\Testing\assertType;
8+
9+
class AggregationParser
10+
{
11+
/**
12+
* @param array<string, mixed> $aggregation
13+
*/
14+
private function parseAggregation(array $aggregation)
15+
{
16+
$type = $aggregation['type'] ?? null;
17+
if (!\is_string($type) || empty($type) || is_numeric($type)) {
18+
return null;
19+
}
20+
21+
if (empty($aggregation['field']) && $type !== 'filter') {
22+
return null;
23+
}
24+
25+
$field = '';
26+
if ($type !== 'filter') {
27+
$field = self::buildFieldName();
28+
}
29+
30+
assertType('non-falsy-string', $type);
31+
}
32+
33+
private static function buildFieldName(): string
34+
{
35+
return 'field';
36+
}
37+
}

0 commit comments

Comments
 (0)