Expect integer in getting human readable filesize in MDErrorReporter
This commit is contained in:
parent
b87d0f5b08
commit
6326a6dacf
|
@ -54,15 +54,15 @@ final class MDErrorReporter {
|
|||
* Function human_filesize translates byte-level filesizes to human readable ones.
|
||||
* Thanks to Jeffrey Sambells http://jeffreysambells.com/2012/10/25/human-readable-filesize-php
|
||||
*
|
||||
* @param string $bytes A file size, e.g. returned from filesize().
|
||||
* @param integer $bytes A file size, e.g. returned from filesize().
|
||||
* @param integer $decimals Number of decimal digits to allow.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function human_filesize(string $bytes, int $decimals = 2):string {
|
||||
public function human_filesize(int $bytes, int $decimals = 2):string {
|
||||
|
||||
$size = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
||||
$factor = \floor((strlen($bytes) - 1) / 3);
|
||||
$factor = \floor((strlen((string)$bytes) - 1) / 3);
|
||||
return \sprintf("%.{$decimals}f", $bytes / \pow(1024, $factor)) . $size[$factor];
|
||||
|
||||
}
|
||||
|
@ -121,10 +121,10 @@ final class MDErrorReporter {
|
|||
public function getAdditionalDebuggingInfo():array {
|
||||
|
||||
$output = [
|
||||
"Current memory usage" => $this->human_filesize((string)\memory_get_usage()),
|
||||
"Peak memory usage" => $this->human_filesize((string)\memory_get_peak_usage()),
|
||||
"Current memory usage" => $this->human_filesize(\memory_get_usage()),
|
||||
"Peak memory usage" => $this->human_filesize(\memory_get_peak_usage()),
|
||||
"Included / required files" => \get_included_files(),
|
||||
# "Allowed memory usage" => $this->human_filesize((string)ini_get("memory_limit")),
|
||||
# "Allowed memory usage" => $this->human_filesize((int)ini_get("memory_limit")),
|
||||
];
|
||||
|
||||
return $output;
|
||||
|
|
Loading…
Reference in New Issue
Block a user