';
} else {
$retval .= gettype($arg);
}
return $retval;
}
/**
* Gets the error as string of HTML
*/
public function getDisplay(): string
{
$this->isDisplayed(true);
$context = 'primary';
$level = $this->getLevel();
if ($level === 'error') {
$context = 'danger';
}
$retval = '';
if (! $this->isUserError()) {
$retval .= '' . $this->getType() . '';
$retval .= ' in ' . $this->getFile() . '#' . $this->getLine();
$retval .= "
\n";
}
$retval .= $this->getMessage();
if (! $this->isUserError()) {
$retval .= "
\n";
$retval .= "
\n";
$retval .= "Backtrace
\n";
$retval .= "
\n";
$retval .= $this->getBacktraceDisplay();
}
$retval .= '
';
return $retval;
}
/**
* whether this error is a user error
*/
public function isUserError(): bool
{
return $this->hideLocation ||
($this->getNumber() & (E_USER_WARNING | E_USER_ERROR | E_USER_NOTICE | E_USER_DEPRECATED));
}
/**
* return short relative path to phpMyAdmin basedir
*
* prevent path disclosure in error message,
* and make users feel safe to submit error reports
*
* @param string $path path to be shorten
*
* @return string shortened path
*/
public static function relPath(string $path): string
{
$dest = @realpath($path);
/* Probably affected by open_basedir */
if ($dest === false) {
return basename($path);
}
$hereParts = explode(
DIRECTORY_SEPARATOR,
(string) realpath(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..')
);
$destParts = explode(DIRECTORY_SEPARATOR, $dest);
$result = '.';
while (implode(DIRECTORY_SEPARATOR, $destParts) != implode(DIRECTORY_SEPARATOR, $hereParts)) {
if (count($hereParts) > count($destParts)) {
array_pop($hereParts);
$result .= DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..';
} else {
array_pop($destParts);
}
}
$path = $result . str_replace(implode(DIRECTORY_SEPARATOR, $destParts), '', $dest);
return str_replace(DIRECTORY_SEPARATOR . PATH_SEPARATOR, DIRECTORY_SEPARATOR, $path);
}
}