Skip to content

Commit

Permalink
Debug/Toolbar - Memory issue fix
Browse files Browse the repository at this point in the history
  • Loading branch information
najdanovicivan committed Apr 20, 2021
1 parent dfbc85a commit db3f7d3
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion system/Debug/Toolbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function run(float $startTime, float $totalTime, RequestInterface $reques
{
foreach ($items as $key => $value)
{
$varData[esc($key)] = is_string($value) ? esc($value) : '<pre>' . esc(print_r($value, true)) . '</pre>';
$varData[esc($key)] = is_string($value) ? esc($value) : '<pre>' . esc($this->processVar($value)) . '</pre>';
}
}

Expand Down Expand Up @@ -468,4 +468,34 @@ protected function format(string $data, string $format = 'html'): string

return $output;
}

/**
* Process the varable to string for display
*
* @param mixed $var Variable
*
* @return boolean|string
*/
protected function processVar($var)
{
if (is_object($var))
{
if (is_callable([$var, 'toArray']))
{
$var = $var->toArray();
}
else
{
$var = get_class($var);
}
}
if (is_array($var))
{
foreach ($var as &$aVar)
{
$aVar = $this->processVar($aVar);
}
}
return print_r($var, true);
}
}

0 comments on commit db3f7d3

Please sign in to comment.