More compact number operations

This commit is contained in:
Alexander Makarov
2015-10-10 00:41:54 +03:00
parent b65bfad44d
commit 4ecafe653c
3 changed files with 4 additions and 4 deletions

View File

@ -184,7 +184,7 @@ class CaptchaAction extends Action
$session = Yii::$app->getSession(); $session = Yii::$app->getSession();
$session->open(); $session->open();
$name = $this->getSessionKey() . 'count'; $name = $this->getSessionKey() . 'count';
$session[$name] = $session[$name] + 1; $session[$name] += 1;
if ($valid || $session[$name] > $this->testLimit && $this->testLimit > 0) { if ($valid || $session[$name] > $this->testLimit && $this->testLimit > 0) {
$this->getVerifyCode(true); $this->getVerifyCode(true);
} }

View File

@ -231,7 +231,7 @@ class BaseVarDumper
return 'function() {/* Error: unable to determine Closure source */}'; return 'function() {/* Error: unable to determine Closure source */}';
} }
$start = $start - 1; --$start;
$source = implode("\n", array_slice(file($fileName), $start, $end - $start)); $source = implode("\n", array_slice(file($fileName), $start, $end - $start));
$tokens = token_get_all('<?php ' . $source); $tokens = token_get_all('<?php ' . $source);

View File

@ -883,7 +883,7 @@ class Formatter extends Component
if ($decimals === null) { if ($decimals === null) {
$decimals = 0; $decimals = 0;
} }
$value = $value * 100; $value *= 100;
return number_format($value, $decimals, $this->decimalSeparator, $this->thousandSeparator) . '%'; return number_format($value, $decimals, $this->decimalSeparator, $this->thousandSeparator) . '%';
} }
} }
@ -1137,7 +1137,7 @@ class Formatter extends Component
if (abs($value) < $this->sizeFormatBase) { if (abs($value) < $this->sizeFormatBase) {
break; break;
} }
$value = $value / $this->sizeFormatBase; $value /= $this->sizeFormatBase;
$position++; $position++;
} while ($position < 5); } while ($position < 5);