2 namespace TYPO3\CMS\Core\Utility;
34 $theInt = (int)$theInt;
37 if ($defaultValue && !$theInt) {
38 $theInt = $defaultValue;
57 $theInt = (int)$theInt;
75 if ($var ===
'' || is_object($var) || is_array($var)) {
78 return (
string)(int)$var === (
string)$var;
92 $pattern_lnum =
'[0-9]+';
93 $pattern_dnum =
'([0-9]*[\.]' . $pattern_lnum .
')|(' . $pattern_lnum .
'[\.][0-9]*)';
94 $pattern_exp_dnum =
'[+-]?((' . $pattern_lnum .
'|' . $pattern_dnum .
')([eE][+-]?' . $pattern_lnum .
')?)';
96 if ($var ===
'' || is_object($var) || is_array($var)) {
100 $matches = preg_match(
'/^' . $pattern_exp_dnum .
'$/', $var);
101 return $matches === 1;
114 $string = preg_replace(
'/[[:space:]]*/',
'', $string);
116 $string =
'+' . $string;
117 $qm =
'\\*\\/\\+-^%';
118 $regex =
'([' . $qm .
'])([' . $qm .
']?[0-9\\.]*)';
121 preg_match_all(
'/' . $regex .
'/', $string, $reg);
126 $buffer = doubleval(current($reg[2]));
128 $regSliced = array_slice($reg[2], 1, null,
true);
129 foreach ($regSliced as $k => $v) {
132 if ($sign ==
'+' || $sign ==
'-') {
133 $Msign ==
'-' ? ($number -= $buffer) : ($number += $buffer);
141 $err =
'dividing by zero';
148 $err =
'dividing by zero';
155 $buffer = pow($buffer, $v);
159 $number = $Msign ==
'-' ? ($number -= $buffer) : ($number += $buffer);
160 return $err ?
'ERROR: ' . $err : $number;
174 $valueLenO = strcspn($string,
'(');
175 $valueLenC = strcspn($string,
')');
176 if ($valueLenC == strlen($string) || $valueLenC < $valueLenO) {
177 $value = self::calculateWithPriorityToAdditionAndSubtraction(substr($string, 0, $valueLenC));
178 $string = $value . substr($string, ($valueLenC + 1));
181 $string = substr($string, 0, $valueLenO) . self::calculateWithParentheses(substr($string, ($valueLenO + 1)));
188 }
while ($valueLenO < strlen($string));
202 $value = filter_var($value, FILTER_VALIDATE_INT, array(
204 'min_range' => $minimum,
205 'max_range' => $maximum
208 $isInRange = is_int($value);