upgraded dependencies

This commit is contained in:
RafficMohammed
2023-01-08 01:59:16 +05:30
parent 51056e3aad
commit f9ae387337
6895 changed files with 133617 additions and 178680 deletions

View File

@@ -40,6 +40,8 @@ class HtmlErrorRenderer implements ErrorRendererInterface
private $outputBuffer;
private $logger;
private static $template = 'views/error.html.php';
/**
* @param bool|callable $debug The debugging mode as a boolean or a callable that should return it
* @param string|FileLinkFormatter|null $fileLinkFormat
@@ -48,11 +50,11 @@ class HtmlErrorRenderer implements ErrorRendererInterface
public function __construct($debug = false, string $charset = null, $fileLinkFormat = null, string $projectDir = null, $outputBuffer = '', LoggerInterface $logger = null)
{
if (!\is_bool($debug) && !\is_callable($debug)) {
throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be a boolean or a callable, "%s" given.', __METHOD__, \is_object($debug) ? \get_class($debug) : \gettype($debug)));
throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be a boolean or a callable, "%s" given.', __METHOD__, \gettype($debug)));
}
if (!\is_string($outputBuffer) && !\is_callable($outputBuffer)) {
throw new \TypeError(sprintf('Argument 5 passed to "%s()" must be a string or a callable, "%s" given.', __METHOD__, \is_object($outputBuffer) ? \get_class($outputBuffer) : \gettype($outputBuffer)));
throw new \TypeError(sprintf('Argument 5 passed to "%s()" must be a string or a callable, "%s" given.', __METHOD__, \gettype($outputBuffer)));
}
$this->debug = $debug;
@@ -68,9 +70,13 @@ class HtmlErrorRenderer implements ErrorRendererInterface
*/
public function render(\Throwable $exception): FlattenException
{
$exception = FlattenException::createFromThrowable($exception, null, [
'Content-Type' => 'text/html; charset='.$this->charset,
]);
$headers = ['Content-Type' => 'text/html; charset='.$this->charset];
if (\is_bool($this->debug) ? $this->debug : ($this->debug)($exception)) {
$headers['X-Debug-Exception'] = rawurlencode($exception->getMessage());
$headers['X-Debug-Exception-File'] = rawurlencode($exception->getFile()).':'.$exception->getLine();
}
$exception = FlattenException::createFromThrowable($exception, null, $headers);
return $exception->setAsString($this->renderException($exception));
}
@@ -132,7 +138,7 @@ class HtmlErrorRenderer implements ErrorRendererInterface
$statusCode = $this->escape($exception->getStatusCode());
if (!$debug) {
return $this->include('views/error.html.php', [
return $this->include(self::$template, [
'statusText' => $statusText,
'statusCode' => $statusCode,
]);
@@ -209,7 +215,7 @@ class HtmlErrorRenderer implements ErrorRendererInterface
/**
* Returns the link for a given file/line pair.
*
* @return string|false A link or false
* @return string|false
*/
private function getFileLink(string $file, int $line)
{
@@ -256,8 +262,6 @@ class HtmlErrorRenderer implements ErrorRendererInterface
* @param string $file A file path
* @param int $line The selected line number
* @param int $srcContext The number of displayed lines around or -1 for the whole file
*
* @return string An HTML string
*/
private function fileExcerpt(string $file, int $line, int $srcContext = 3): string
{
@@ -279,7 +283,7 @@ class HtmlErrorRenderer implements ErrorRendererInterface
}
for ($i = max($line - $srcContext, 1), $max = min($line + $srcContext, \count($content)); $i <= $max; ++$i) {
$lines[] = '<li'.($i == $line ? ' class="selected"' : '').'><a class="anchor" name="line'.$i.'"></a><code>'.$this->fixCodeMarkup($content[$i - 1]).'</code></li>';
$lines[] = '<li'.($i == $line ? ' class="selected"' : '').'><code>'.$this->fixCodeMarkup($content[$i - 1]).'</code></li>';
}
return '<ol start="'.max($line - $srcContext, 1).'">'.implode("\n", $lines).'</ol>';
@@ -298,9 +302,9 @@ class HtmlErrorRenderer implements ErrorRendererInterface
}
// missing </span> tag at the end of line
$opening = strpos($line, '<span');
$closing = strpos($line, '</span>');
if (false !== $opening && (false === $closing || $closing > $opening)) {
$opening = strrpos($line, '<span');
$closing = strrpos($line, '</span>');
if (false !== $opening && (false === $closing || $closing < $opening)) {
$line .= '</span>';
}
@@ -345,8 +349,19 @@ class HtmlErrorRenderer implements ErrorRendererInterface
{
extract($context, \EXTR_SKIP);
ob_start();
include __DIR__.'/../Resources/'.$name;
include is_file(\dirname(__DIR__).'/Resources/'.$name) ? \dirname(__DIR__).'/Resources/'.$name : $name;
return trim(ob_get_clean());
}
/**
* Allows overriding the default non-debug template.
*
* @param string $template path to the custom template file to render
*/
public static function setTemplate(string $template): void
{
self::$template = $template;
}
}