@@ -138,6 +138,7 @@ protected function wrapCellValue(): float|int|string
138
138
return $ this ->wrapValue ($ this ->cell ->getCalculatedValue ());
139
139
}
140
140
141
+ /** @param string[] $matches */
141
142
protected function conditionCellAdjustment (array $ matches ): float |int |string
142
143
{
143
144
$ column = $ matches [6 ];
@@ -150,7 +151,7 @@ protected function conditionCellAdjustment(array $matches): float|int|string
150
151
}
151
152
152
153
if (!str_contains ($ row , '$ ' )) {
153
- $ row += $ this ->cellRow - $ this ->referenceRow ;
154
+ $ row = ( int ) $ row + $ this ->cellRow - $ this ->referenceRow ;
154
155
}
155
156
156
157
if (!empty ($ matches [4 ])) {
@@ -194,6 +195,11 @@ protected function cellConditionCheck(string $condition): string
194
195
return implode (Calculation::FORMULA_STRING_QUOTE , $ splitCondition );
195
196
}
196
197
198
+ /**
199
+ * @param mixed[] $conditions
200
+ *
201
+ * @return mixed[]
202
+ */
197
203
protected function adjustConditionsForCellReferences (array $ conditions ): array
198
204
{
199
205
return array_map (
@@ -210,7 +216,11 @@ protected function processOperatorComparison(Conditional $conditional): bool
210
216
211
217
$ operator = self ::COMPARISON_OPERATORS [$ conditional ->getOperatorType ()];
212
218
$ conditions = $ this ->adjustConditionsForCellReferences ($ conditional ->getConditions ());
213
- $ expression = sprintf ('%s%s%s ' , (string ) $ this ->wrapCellValue (), $ operator , (string ) array_pop ($ conditions ));
219
+ /** @var float|int|string */
220
+ $ temp1 = $ this ->wrapCellValue ();
221
+ /** @var scalar */
222
+ $ temp2 = array_pop ($ conditions );
223
+ $ expression = sprintf ('%s%s%s ' , (string ) $ temp1 , $ operator , (string ) $ temp2 );
214
224
215
225
return $ this ->evaluateExpression ($ expression );
216
226
}
@@ -234,7 +244,7 @@ protected function processRangeOperator(Conditional $conditional): bool
234
244
(string ) $ this ->wrapCellValue (),
235
245
self ::COMPARISON_RANGE_OPERATORS [$ conditional ->getOperatorType ()]
236
246
),
237
- ...$ conditions
247
+ ...$ conditions //* @phpstan-ignore-line
238
248
);
239
249
240
250
return $ this ->evaluateExpression ($ expression );
@@ -257,11 +267,14 @@ protected function processDuplicatesComparison(Conditional $conditional): bool
257
267
protected function processExpression (Conditional $ conditional ): bool
258
268
{
259
269
$ conditions = $ this ->adjustConditionsForCellReferences ($ conditional ->getConditions ());
270
+ /** @var string */
260
271
$ expression = array_pop ($ conditions );
272
+ /** @var float|int|string */
273
+ $ temp = $ this ->wrapCellValue ();
261
274
262
275
$ expression = (string ) preg_replace (
263
276
'/\b ' . $ this ->referenceCell . '\b/i ' ,
264
- (string ) $ this -> wrapCellValue () ,
277
+ (string ) $ temp ,
265
278
$ expression
266
279
);
267
280
0 commit comments