319 if (!$notation = $this->getPolishNotation($text))
325 foreach ($notation as $item)
330 array_unshift($stack, $item[0]);
333 array_unshift($stack, $this->getVariableValue($item[0]));
335 case self::Operation:
339 $arg = array_shift($stack);
340 array_unshift($stack, [$arg]);
343 $arg2 = array_shift($stack);
344 $arg1 = array_shift($stack);
345 if (!is_array($arg1) || !isset($arg1[0]))
350 array_unshift($stack, $arg1);
353 $arg2 = array_shift($stack);
354 $arg1 = array_shift($stack);
355 array_unshift($stack, $arg1 == $arg2);
358 $arg2 = array_shift($stack);
359 $arg1 = array_shift($stack);
360 array_unshift($stack, $arg1 <= $arg2);
363 $arg2 = array_shift($stack);
364 $arg1 = array_shift($stack);
365 array_unshift($stack, $arg1 >= $arg2);
368 $arg2 = array_shift($stack);
369 $arg1 = array_shift($stack);
370 array_unshift($stack, $arg1 != $arg2);
373 $arg2 = array_shift($stack);
374 $arg1 = array_shift($stack);
375 array_unshift($stack, $arg1 < $arg2);
378 $arg2 = array_shift($stack);
379 $arg1 = array_shift($stack);
380 array_unshift($stack, $arg1 > $arg2);
383 $arg2 = \CBPHelper::stringify(array_shift($stack));
384 $arg1 = \CBPHelper::stringify(array_shift($stack));
385 array_unshift($stack, $arg1 . $arg2);
388 $arg2 = (float)($this->toSingleValue(array_shift($stack)));
389 $arg1 = (float)($this->toSingleValue(array_shift($stack)));
390 array_unshift($stack, $arg1 + $arg2);
393 $arg2 = (float)($this->toSingleValue(array_shift($stack)));
394 $arg1 = (float)($this->toSingleValue(array_shift($stack)));
395 array_unshift($stack, $arg1 - $arg2);
398 $arg = (float)array_shift($stack);
399 array_unshift($stack, $arg);
402 $arg = (float)array_shift($stack);
403 array_unshift($stack, (-$arg));
406 $arg2 = (float)($this->toSingleValue(array_shift($stack)));
407 $arg1 = (float)($this->toSingleValue(array_shift($stack)));
408 array_unshift($stack, $arg1 * $arg2);
411 $arg2 = (float)($this->toSingleValue(array_shift($stack)));
412 $arg1 = (float)($this->toSingleValue(array_shift($stack)));
419 array_unshift($stack, $arg1 / $arg2);
422 $arg2 = (float)array_shift($stack);
423 $arg1 = (float)array_shift($stack);
424 array_unshift($stack, $arg1 ** $arg2);
427 $arg = (float)array_shift($stack);
428 array_unshift($stack, $arg / 100);
431 $func = $this->functions[$item[0]][
'func'];
433 if (!empty($this->functions[$item[0]][
'args']))
435 $args = array_shift($stack);
436 $functionArgs->setArgs(is_array($args) ? $args : [$args]);
439 $val = $func($functionArgs);
441 $error = is_float($val) && (is_nan($val) || is_infinite($val));
444 $this->setError(8, $item[0]);
448 array_unshift($stack, $val);
452 if (count($stack) > 1)
459 return array_shift($stack);