updated dependencies

This commit is contained in:
2019-12-10 05:37:33 +00:00
parent 525b34d28c
commit 90c6c629d3
1123 changed files with 7869 additions and 5694 deletions

View File

@@ -26,19 +26,26 @@ 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
* @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)
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__, \is_object($format) ? \get_class($format) : \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__, \is_object($debug) ? \get_class($debug) : \gettype($debug)));
}
$this->serializer = $serializer;
$this->format = $format;
$this->fallbackErrorRenderer = $fallbackErrorRenderer ?? new HtmlErrorRenderer();
$this->debug = $debug;
}
/**
@@ -51,7 +58,10 @@ class SerializerErrorRenderer implements ErrorRendererInterface
try {
$format = \is_string($this->format) ? $this->format : ($this->format)($flattenException);
return $flattenException->setAsString($this->serializer->serialize($flattenException, $format, ['exception' => $exception]));
return $flattenException->setAsString($this->serializer->serialize($flattenException, $format, [
'exception' => $exception,
'debug' => \is_bool($this->debug) ? $this->debug : ($this->debug)($exception),
]));
} catch (NotEncodableValueException $e) {
return $this->fallbackErrorRenderer->render($exception);
}