MemoryLimit: rewrite for PHP 7.1+

fixes #1222
This commit is contained in:
Thomas Gelf 2017-10-10 14:52:15 +02:00
parent 717669ed4a
commit c9c59b3f03
1 changed files with 10 additions and 8 deletions

View File

@ -33,9 +33,10 @@ class MemoryLimit
public static function parsePhpIniByteString($string)
{
$val = trim($string);
$last = strtoupper(substr($val, -1, 1));
switch ($last) {
if (preg_match('/^(\d+)([KMG])$/', $val, $m)) {
$val = $m[1];
switch ($m[2]) {
case 'G':
$val *= 1024;
// Intentional fall-through
@ -45,6 +46,7 @@ class MemoryLimit
case 'K':
$val *= 1024;
}
}
return intval($val);
}