@@ -45,110 +45,120 @@ trait NumeralTypeTrait
45
45
* Add this expression to the given expression.
46
46
*
47
47
* @param NumeralType $right
48
+ * @param bool $insertParentheses
48
49
* @return Addition
49
50
*/
50
- public function plus (NumeralType $ right ): Addition
51
+ public function plus (NumeralType $ right, bool $ insertParentheses = true ): Addition
51
52
{
52
- return new Addition ($ this , $ right );
53
+ return new Addition ($ this , $ right, $ insertParentheses );
53
54
}
54
55
55
56
/**
56
57
* Divide this expression by the given expression.
57
58
*
58
59
* @param NumeralType $right
60
+ * @param bool $insertParentheses
59
61
* @return Division
60
62
*/
61
- public function divide (NumeralType $ right ): Division
63
+ public function divide (NumeralType $ right, bool $ insertParentheses = true ): Division
62
64
{
63
- return new Division ($ this , $ right );
65
+ return new Division ($ this , $ right, $ insertParentheses );
64
66
}
65
67
66
68
/**
67
69
* Perform an exponentiation with the given expression.
68
70
*
69
71
* @param NumeralType $right
72
+ * @param bool $insertParentheses
70
73
* @return Exponentiation
71
74
*/
72
- public function exponentiate (NumeralType $ right ): Exponentiation
75
+ public function exponentiate (NumeralType $ right, bool $ insertParentheses = true ): Exponentiation
73
76
{
74
- return new Exponentiation ($ this , $ right );
77
+ return new Exponentiation ($ this , $ right, $ insertParentheses );
75
78
}
76
79
77
80
/**
78
81
* Perform a greater than comparison against the given expression.
79
82
*
80
83
* @param NumeralType $right
84
+ * @param bool $insertParentheses
81
85
* @return GreaterThan
82
86
*/
83
- public function gt (NumeralType $ right ): GreaterThan
87
+ public function gt (NumeralType $ right, bool $ insertParentheses = true ): GreaterThan
84
88
{
85
- return new GreaterThan ($ this , $ right );
89
+ return new GreaterThan ($ this , $ right, $ insertParentheses );
86
90
}
87
91
88
92
/**
89
93
* Perform a greater than or equal comparison against the given expression.
90
94
*
91
95
* @param NumeralType $right
96
+ * @param bool $insertParentheses
92
97
* @return GreaterThanOrEqual
93
98
*/
94
- public function gte (NumeralType $ right ): GreaterThanOrEqual
99
+ public function gte (NumeralType $ right, bool $ insertParentheses = true ): GreaterThanOrEqual
95
100
{
96
- return new GreaterThanOrEqual ($ this , $ right );
101
+ return new GreaterThanOrEqual ($ this , $ right, $ insertParentheses );
97
102
}
98
103
99
104
/**
100
105
* Perform a less than comparison against the given expression.
101
106
*
102
107
* @param NumeralType $right
108
+ * @param bool $insertParentheses
103
109
* @return LessThan
104
110
*/
105
- public function lt (NumeralType $ right ): LessThan
111
+ public function lt (NumeralType $ right, bool $ insertParentheses = true ): LessThan
106
112
{
107
- return new LessThan ($ this , $ right );
113
+ return new LessThan ($ this , $ right, $ insertParentheses );
108
114
}
109
115
110
116
/**
111
117
* Perform a less than or equal comparison against the given expression.
112
118
*
113
119
* @param NumeralType $right
120
+ * @param bool $insertParentheses
114
121
* @return LessThanOrEqual
115
122
*/
116
- public function lte (NumeralType $ right ): LessThanOrEqual
123
+ public function lte (NumeralType $ right, bool $ insertParentheses = true ): LessThanOrEqual
117
124
{
118
- return new LessThanOrEqual ($ this , $ right );
125
+ return new LessThanOrEqual ($ this , $ right, $ insertParentheses );
119
126
}
120
127
121
128
/**
122
129
* Perform the modulo operation with the given expression.
123
130
*
124
131
* @param NumeralType $right
132
+ * @param bool $insertParentheses
125
133
* @return Modulo
126
134
*/
127
- public function mod (NumeralType $ right ): Modulo
135
+ public function mod (NumeralType $ right, bool $ insertParentheses = true ): Modulo
128
136
{
129
- return new Modulo ($ this , $ right );
137
+ return new Modulo ($ this , $ right, $ insertParentheses );
130
138
}
131
139
132
140
/**
133
141
* Perform a multiplication with the given expression.
134
142
*
135
143
* @param NumeralType $right
144
+ * @param bool $insertParentheses
136
145
* @return Multiplication
137
146
*/
138
- public function times (NumeralType $ right ): Multiplication
147
+ public function times (NumeralType $ right, bool $ insertParentheses = true ): Multiplication
139
148
{
140
- return new Multiplication ($ this , $ right );
149
+ return new Multiplication ($ this , $ right, $ insertParentheses );
141
150
}
142
151
143
152
/**
144
153
* Subtract the given expression from this expression.
145
154
*
146
155
* @param NumeralType $right
156
+ * @param bool $insertParentheses
147
157
* @return Subtraction
148
158
*/
149
- public function minus (NumeralType $ right ): Subtraction
159
+ public function minus (NumeralType $ right, bool $ insertParentheses = true ): Subtraction
150
160
{
151
- return new Subtraction ($ this , $ right );
161
+ return new Subtraction ($ this , $ right, $ insertParentheses );
152
162
}
153
163
154
164
/**
0 commit comments