20
20
*/
21
21
class BinaryNode extends Node
22
22
{
23
- private static $ operators = [
23
+ private const OPERATORS = [
24
24
'~ ' => '. ' ,
25
25
'and ' => '&& ' ,
26
26
'or ' => '|| ' ,
27
27
];
28
28
29
- private static $ functions = [
29
+ private const FUNCTIONS = [
30
30
'** ' => 'pow ' ,
31
31
'.. ' => 'range ' ,
32
32
'in ' => 'in_array ' ,
@@ -57,9 +57,9 @@ public function compile(Compiler $compiler)
57
57
return ;
58
58
}
59
59
60
- if (isset (self ::$ functions [$ operator ])) {
60
+ if (isset (self ::FUNCTIONS [$ operator ])) {
61
61
$ compiler
62
- ->raw (sprintf ('%s( ' , self ::$ functions [$ operator ]))
62
+ ->raw (sprintf ('%s( ' , self ::FUNCTIONS [$ operator ]))
63
63
->compile ($ this ->nodes ['left ' ])
64
64
->raw (', ' )
65
65
->compile ($ this ->nodes ['right ' ])
@@ -69,8 +69,8 @@ public function compile(Compiler $compiler)
69
69
return ;
70
70
}
71
71
72
- if (isset (self ::$ operators [$ operator ])) {
73
- $ operator = self ::$ operators [$ operator ];
72
+ if (isset (self ::OPERATORS [$ operator ])) {
73
+ $ operator = self ::OPERATORS [$ operator ];
74
74
}
75
75
76
76
$ compiler
@@ -89,13 +89,13 @@ public function evaluate(array $functions, array $values)
89
89
$ operator = $ this ->attributes ['operator ' ];
90
90
$ left = $ this ->nodes ['left ' ]->evaluate ($ functions , $ values );
91
91
92
- if (isset (self ::$ functions [$ operator ])) {
92
+ if (isset (self ::FUNCTIONS [$ operator ])) {
93
93
$ right = $ this ->nodes ['right ' ]->evaluate ($ functions , $ values );
94
94
95
95
if ('not in ' === $ operator ) {
96
96
return !\in_array ($ left , $ right );
97
97
}
98
- $ f = self ::$ functions [$ operator ];
98
+ $ f = self ::FUNCTIONS [$ operator ];
99
99
100
100
return $ f ($ left , $ right );
101
101
}
0 commit comments