5
5
namespace App \Model ;
6
6
7
7
use App ;
8
+ use App \Helpers \Iter ;
9
+ use App \Helpers \Op ;
8
10
use Closure ;
9
11
use Nette ;
10
12
use Nette \Application \Application ;
11
13
use Nette \Forms \Controls \SelectBox ;
12
14
use Nette \Localization \Translator ;
13
15
14
- use const nspl \a \all ;
15
- use const nspl \a \any ;
16
-
17
- use function nspl \a \map ;
18
-
19
- use const nspl \f \id ;
20
- use const nspl \op \ge ;
21
- use const nspl \op \gt ;
22
- use const nspl \op \idnt ;
23
- use const nspl \op \int ;
24
- use const nspl \op \le ;
25
- use const nspl \op \lt ;
26
-
27
16
final class CategoryData {
28
17
use Nette \SmartObject;
29
18
@@ -40,11 +29,11 @@ final class CategoryData {
40
29
public const AGGREGATE_CONSTRAINT_REGEX = '(^\s*(?P<aggr>(sum|min|max))\((?P<key>age)\)(?P<op>[<>]?=?)(?P<val>[0-9]+)$\s*) ' ;
41
30
42
31
public const OP_LOOKUP = [
43
- '< ' => lt ,
44
- '<= ' => le ,
45
- '= ' => idnt,
46
- '>= ' => ge ,
47
- '> ' => gt ,
32
+ '< ' => [Op::class, ' lt ' ] ,
33
+ '<= ' => [Op::class, ' le ' ] ,
34
+ '= ' => [Op::class, ' idnt ' ] ,
35
+ '>= ' => [Op::class, ' ge ' ] ,
36
+ '> ' => [Op::class, ' gt ' ] ,
48
37
];
49
38
50
39
public const AGGR_LOOKUP = [
@@ -64,8 +53,8 @@ final class CategoryData {
64
53
];
65
54
66
55
public const VALUE_PARSERS = [
67
- 'age ' => int,
68
- 'gender ' => id ,
56
+ 'age ' => [Op::class, ' int ' ] ,
57
+ 'gender ' => [Op::class, ' id ' ] ,
69
58
];
70
59
71
60
public const KEY_MESSAGES = [
@@ -74,8 +63,8 @@ final class CategoryData {
74
63
];
75
64
76
65
public const QUANT_LOOKUP = [
77
- 'all ' => all,
78
- 'some ' => any,
66
+ 'all ' => [Iter::class, ' all ' ] ,
67
+ 'some ' => [Iter::class, ' any ' ] ,
79
68
];
80
69
81
70
public function __construct (
@@ -298,7 +287,7 @@ function(SelectBox $entry) use ($aggr, $keyProjection, $op, $comparedValue): boo
298
287
$ members = $ form ->getUnsafeValues (null )['persons ' ];
299
288
\assert ($ members instanceof \Iterator); // For PHPStan.
300
289
301
- return $ op ($ aggr (map ($ keyProjection , iterator_to_array ($ members ))), $ comparedValue );
290
+ return $ op ($ aggr (array_map ($ keyProjection , iterator_to_array ($ members ))), $ comparedValue );
302
291
},
303
292
$ this ->translator ->translate ($ message ),
304
293
];
0 commit comments