@@ -138,6 +138,7 @@ protected function wrapCellValue(): float|int|string
138138 return $ this ->wrapValue ($ this ->cell ->getCalculatedValue ());
139139 }
140140
141+ /** @param string[] $matches */
141142 protected function conditionCellAdjustment (array $ matches ): float |int |string
142143 {
143144 $ column = $ matches [6 ];
@@ -150,7 +151,7 @@ protected function conditionCellAdjustment(array $matches): float|int|string
150151 }
151152
152153 if (!str_contains ($ row , '$ ' )) {
153- $ row += $ this ->cellRow - $ this ->referenceRow ;
154+ $ row = ( int ) $ row + $ this ->cellRow - $ this ->referenceRow ;
154155 }
155156
156157 if (!empty ($ matches [4 ])) {
@@ -194,6 +195,11 @@ protected function cellConditionCheck(string $condition): string
194195 return implode (Calculation::FORMULA_STRING_QUOTE , $ splitCondition );
195196 }
196197
198+ /**
199+ * @param mixed[] $conditions
200+ *
201+ * @return mixed[]
202+ */
197203 protected function adjustConditionsForCellReferences (array $ conditions ): array
198204 {
199205 return array_map (
@@ -210,7 +216,11 @@ protected function processOperatorComparison(Conditional $conditional): bool
210216
211217 $ operator = self ::COMPARISON_OPERATORS [$ conditional ->getOperatorType ()];
212218 $ 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 );
214224
215225 return $ this ->evaluateExpression ($ expression );
216226 }
@@ -234,7 +244,7 @@ protected function processRangeOperator(Conditional $conditional): bool
234244 (string ) $ this ->wrapCellValue (),
235245 self ::COMPARISON_RANGE_OPERATORS [$ conditional ->getOperatorType ()]
236246 ),
237- ...$ conditions
247+ ...$ conditions //* @phpstan-ignore-line
238248 );
239249
240250 return $ this ->evaluateExpression ($ expression );
@@ -257,11 +267,14 @@ protected function processDuplicatesComparison(Conditional $conditional): bool
257267 protected function processExpression (Conditional $ conditional ): bool
258268 {
259269 $ conditions = $ this ->adjustConditionsForCellReferences ($ conditional ->getConditions ());
270+ /** @var string */
260271 $ expression = array_pop ($ conditions );
272+ /** @var float|int|string */
273+ $ temp = $ this ->wrapCellValue ();
261274
262275 $ expression = (string ) preg_replace (
263276 '/\b ' . $ this ->referenceCell . '\b/i ' ,
264- (string ) $ this -> wrapCellValue () ,
277+ (string ) $ temp ,
265278 $ expression
266279 );
267280
0 commit comments