Update website
This commit is contained in:
parent
4413528994
commit
1d90fbf296
6865 changed files with 1091082 additions and 0 deletions
49
vendor/symfony/error-handler/ErrorRenderer/CliErrorRenderer.php
vendored
Normal file
49
vendor/symfony/error-handler/ErrorRenderer/CliErrorRenderer.php
vendored
Normal file
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\ErrorHandler\ErrorRenderer;
|
||||
|
||||
use Symfony\Component\ErrorHandler\Exception\FlattenException;
|
||||
use Symfony\Component\VarDumper\Cloner\VarCloner;
|
||||
use Symfony\Component\VarDumper\Dumper\CliDumper;
|
||||
|
||||
// Help opcache.preload discover always-needed symbols
|
||||
class_exists(CliDumper::class);
|
||||
|
||||
/**
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class CliErrorRenderer implements ErrorRendererInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function render(\Throwable $exception): FlattenException
|
||||
{
|
||||
$cloner = new VarCloner();
|
||||
$dumper = new class() extends CliDumper {
|
||||
protected function supportsColors(): bool
|
||||
{
|
||||
$outputStream = $this->outputStream;
|
||||
$this->outputStream = fopen('php://stdout', 'w');
|
||||
|
||||
try {
|
||||
return parent::supportsColors();
|
||||
} finally {
|
||||
$this->outputStream = $outputStream;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return FlattenException::createFromThrowable($exception)
|
||||
->setAsString($dumper->dump($cloner->cloneVar($exception), true));
|
||||
}
|
||||
}
|
27
vendor/symfony/error-handler/ErrorRenderer/ErrorRendererInterface.php
vendored
Normal file
27
vendor/symfony/error-handler/ErrorRenderer/ErrorRendererInterface.php
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\ErrorHandler\ErrorRenderer;
|
||||
|
||||
use Symfony\Component\ErrorHandler\Exception\FlattenException;
|
||||
|
||||
/**
|
||||
* Formats an exception to be used as response content.
|
||||
*
|
||||
* @author Yonel Ceruto <yonelceruto@gmail.com>
|
||||
*/
|
||||
interface ErrorRendererInterface
|
||||
{
|
||||
/**
|
||||
* Renders a Throwable as a FlattenException.
|
||||
*/
|
||||
public function render(\Throwable $exception): FlattenException;
|
||||
}
|
379
vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php
vendored
Normal file
379
vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php
vendored
Normal file
File diff suppressed because one or more lines are too long
92
vendor/symfony/error-handler/ErrorRenderer/SerializerErrorRenderer.php
vendored
Normal file
92
vendor/symfony/error-handler/ErrorRenderer/SerializerErrorRenderer.php
vendored
Normal file
|
@ -0,0 +1,92 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\ErrorHandler\ErrorRenderer;
|
||||
|
||||
use Symfony\Component\ErrorHandler\Exception\FlattenException;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\Serializer\Exception\NotEncodableValueException;
|
||||
use Symfony\Component\Serializer\SerializerInterface;
|
||||
|
||||
/**
|
||||
* Formats an exception using Serializer for rendering.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class SerializerErrorRenderer implements ErrorRendererInterface
|
||||
{
|
||||
private $serializer;
|
||||
private $format;
|
||||
private $fallbackErrorRenderer;
|
||||
private $debug;
|
||||
|
||||
/**
|
||||
* @param string|callable(FlattenException) $format The format as a string or a callable that should return it
|
||||
* formats not supported by Request::getMimeTypes() should be given as mime types
|
||||
* @param bool|callable $debug The debugging mode as a boolean or a callable that should return it
|
||||
*/
|
||||
public function __construct(SerializerInterface $serializer, $format, ?ErrorRendererInterface $fallbackErrorRenderer = null, $debug = false)
|
||||
{
|
||||
if (!\is_string($format) && !\is_callable($format)) {
|
||||
throw new \TypeError(sprintf('Argument 2 passed to "%s()" must be a string or a callable, "%s" given.', __METHOD__, \gettype($format)));
|
||||
}
|
||||
|
||||
if (!\is_bool($debug) && !\is_callable($debug)) {
|
||||
throw new \TypeError(sprintf('Argument 4 passed to "%s()" must be a boolean or a callable, "%s" given.', __METHOD__, \gettype($debug)));
|
||||
}
|
||||
|
||||
$this->serializer = $serializer;
|
||||
$this->format = $format;
|
||||
$this->fallbackErrorRenderer = $fallbackErrorRenderer ?? new HtmlErrorRenderer();
|
||||
$this->debug = $debug;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function render(\Throwable $exception): FlattenException
|
||||
{
|
||||
$headers = ['Vary' => 'Accept'];
|
||||
$debug = \is_bool($this->debug) ? $this->debug : ($this->debug)($exception);
|
||||
if ($debug) {
|
||||
$headers['X-Debug-Exception'] = rawurlencode(substr($exception->getMessage(), 0, 2000));
|
||||
$headers['X-Debug-Exception-File'] = rawurlencode($exception->getFile()).':'.$exception->getLine();
|
||||
}
|
||||
|
||||
$flattenException = FlattenException::createFromThrowable($exception, null, $headers);
|
||||
|
||||
try {
|
||||
$format = \is_string($this->format) ? $this->format : ($this->format)($flattenException);
|
||||
$headers['Content-Type'] = Request::getMimeTypes($format)[0] ?? $format;
|
||||
|
||||
$flattenException->setAsString($this->serializer->serialize($flattenException, $format, [
|
||||
'exception' => $exception,
|
||||
'debug' => $debug,
|
||||
]));
|
||||
} catch (NotEncodableValueException $e) {
|
||||
$flattenException = $this->fallbackErrorRenderer->render($exception);
|
||||
}
|
||||
|
||||
return $flattenException->setHeaders($flattenException->getHeaders() + $headers);
|
||||
}
|
||||
|
||||
public static function getPreferredFormat(RequestStack $requestStack): \Closure
|
||||
{
|
||||
return static function () use ($requestStack) {
|
||||
if (!$request = $requestStack->getCurrentRequest()) {
|
||||
throw new NotEncodableValueException();
|
||||
}
|
||||
|
||||
return $request->getPreferredFormat();
|
||||
};
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue