Commit fee455a9 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

:ambulance: fix(core) Replace pow by ** operator

PHP now has an exponentiation operator ** that can be used instead of
 the pow function.

issue #5827
Showing with 10 additions and 10 deletions
+10 -10
...@@ -1367,7 +1367,7 @@ function normalize_netmask($netmask) ...@@ -1367,7 +1367,7 @@ function normalize_netmask($netmask)
for ($i = 7; $i >= 0; $i--) { for ($i = 7; $i >= 0; $i--) {
if ($num-- > 0) { if ($num-- > 0) {
$result += pow(2, $i); $result += 2 ** $i;
} }
} }
...@@ -1418,7 +1418,7 @@ function netmask_to_bits($netmask) ...@@ -1418,7 +1418,7 @@ function netmask_to_bits($netmask)
$res += 8 - $i; $res += 8 - $i;
break; break;
} }
$start -= pow(2, $i); $start -= 2 ** $i;
} }
} }
...@@ -1499,7 +1499,7 @@ function gen_uids($rule, $attributes) ...@@ -1499,7 +1499,7 @@ function gen_uids($rule, $attributes)
$size = $m[2]; $size = $m[2];
$start = ($m[1] == ":" ? 0 : -1); $start = ($m[1] == ":" ? 0 : -1);
for ($i = $start, $p = pow(10, $size) - 1; $i < $p; $i++) { for ($i = $start, $p = (10 ** $size) - 1; $i < $p; $i++) {
if ($i == -1) { if ($i == -1) {
$number = ""; $number = "";
} else { } else {
...@@ -1523,7 +1523,7 @@ function gen_uids($rule, $attributes) ...@@ -1523,7 +1523,7 @@ function gen_uids($rule, $attributes)
while (TRUE) { while (TRUE) {
mt_srand((double)microtime() * 1000000); mt_srand((double)microtime() * 1000000);
$number = sprintf("%0".$size."d", mt_rand(0, pow(10, $size) - 1)); $number = sprintf("%0".$size."d", mt_rand(0, (10 ** $size) - 1));
$res = preg_replace('/{id#(\d+)}/', $number, $uid); $res = preg_replace('/{id#(\d+)}/', $number, $uid);
$ldap->search('(uid='.ldap_escape_f(preg_replace('/[{}]/', '', $res)).')', array('dn')); $ldap->search('(uid='.ldap_escape_f(preg_replace('/[{}]/', '', $res)).')', array('dn'));
if ($ldap->count() == 0) { if ($ldap->count() == 0) {
...@@ -1614,7 +1614,7 @@ function humanReadableSize ($bytes, $precision = 2) ...@@ -1614,7 +1614,7 @@ function humanReadableSize ($bytes, $precision = 2)
} }
$base = log($bytes) / log(1024); $base = log($bytes) / log(1024);
return sprintf($format[floor($base)], round(pow(1024, $base - floor($base)), $precision)); return sprintf($format[floor($base)], round(1024 ** ($base - floor($base)), $precision));
} }
......
...@@ -265,11 +265,11 @@ class BytesSizeAttribute extends UnitIntAttribute ...@@ -265,11 +265,11 @@ class BytesSizeAttribute extends UnitIntAttribute
function __construct ($label, $description, $ldapName, $required, $min = FALSE, $max = FALSE, $defaultValue = "", $acl = "") function __construct ($label, $description, $ldapName, $required, $min = FALSE, $max = FALSE, $defaultValue = "", $acl = "")
{ {
$units = array( $units = array(
1 => _('B'), 1 => _('B'),
pow(1024, 1) => _('KiB'), 1024 ** 1 => _('KiB'),
pow(1024, 2) => _('MiB'), 1024 ** 2 => _('MiB'),
pow(1024, 3) => _('GiB'), 1024 ** 3 => _('GiB'),
pow(1024, 4) => _('TiB'), 1024 ** 4 => _('TiB'),
); );
parent::__construct ($label, $description, $ldapName, $required, $units, $min, $max, $defaultValue, $acl); parent::__construct ($label, $description, $ldapName, $required, $units, $min, $max, $defaultValue, $acl);
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment