X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fsymfony%2Fdebug%2FExceptionHandler.php;fp=vendor%2Fsymfony%2Fdebug%2FExceptionHandler.php;h=97470cb6b4d01ae8e7f2bb1efe24a572407a5feb;hp=0ac644ef0eb46c32636ab678fcf33c9215c172f7;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5
diff --git a/vendor/symfony/debug/ExceptionHandler.php b/vendor/symfony/debug/ExceptionHandler.php
index 0ac644ef0..97470cb6b 100644
--- a/vendor/symfony/debug/ExceptionHandler.php
+++ b/vendor/symfony/debug/ExceptionHandler.php
@@ -11,9 +11,9 @@
namespace Symfony\Component\Debug;
-use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Debug\Exception\FlattenException;
use Symfony\Component\Debug\Exception\OutOfMemoryException;
+use Symfony\Component\HttpKernel\Debug\FileLinkFormatter;
/**
* ExceptionHandler converts an exception to a Response object.
@@ -38,14 +38,6 @@ class ExceptionHandler
public function __construct($debug = true, $charset = null, $fileLinkFormat = null)
{
- if (false !== strpos($charset, '%')) {
- @trigger_error('Providing $fileLinkFormat as second argument to '.__METHOD__.' is deprecated since version 2.8 and will be unsupported in 3.0. Please provide it as third argument, after $charset.', E_USER_DEPRECATED);
-
- // Swap $charset and $fileLinkFormat for BC reasons
- $pivot = $fileLinkFormat;
- $fileLinkFormat = $charset;
- $charset = $pivot;
- }
$this->debug = $debug;
$this->charset = $charset ?: ini_get('default_charset') ?: 'UTF-8';
$this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
@@ -80,11 +72,8 @@ class ExceptionHandler
*
* @return callable|null The previous exception handler if any
*/
- public function setHandler($handler)
+ public function setHandler(callable $handler = null)
{
- if (null !== $handler && !is_callable($handler)) {
- throw new \LogicException('The exception handler must be a valid PHP callable.');
- }
$old = $this->handler;
$this->handler = $handler;
@@ -94,14 +83,14 @@ class ExceptionHandler
/**
* Sets the format for links to source files.
*
- * @param string $format The format for links to source files
+ * @param string|FileLinkFormatter $fileLinkFormat The format for links to source files
*
* @return string The previous file link format
*/
- public function setFileLinkFormat($format)
+ public function setFileLinkFormat($fileLinkFormat)
{
$old = $this->fileLinkFormat;
- $this->fileLinkFormat = $format;
+ $this->fileLinkFormat = $fileLinkFormat;
return $old;
}
@@ -117,20 +106,36 @@ class ExceptionHandler
public function handle(\Exception $exception)
{
if (null === $this->handler || $exception instanceof OutOfMemoryException) {
- $this->failSafeHandle($exception);
+ $this->sendPhpResponse($exception);
return;
}
$caughtLength = $this->caughtLength = 0;
- ob_start(array($this, 'catchOutput'));
- $this->failSafeHandle($exception);
+ ob_start(function ($buffer) {
+ $this->caughtBuffer = $buffer;
+
+ return '';
+ });
+
+ $this->sendPhpResponse($exception);
while (null === $this->caughtBuffer && ob_end_flush()) {
// Empty loop, everything is in the condition
}
if (isset($this->caughtBuffer[0])) {
- ob_start(array($this, 'cleanOutput'));
+ ob_start(function ($buffer) {
+ if ($this->caughtLength) {
+ // use substr_replace() instead of substr() for mbstring overloading resistance
+ $cleanBuffer = substr_replace($buffer, '', 0, $this->caughtLength);
+ if (isset($cleanBuffer[0])) {
+ $buffer = $cleanBuffer;
+ }
+ }
+
+ return $buffer;
+ });
+
echo $this->caughtBuffer;
$caughtLength = ob_get_length();
}
@@ -147,33 +152,6 @@ class ExceptionHandler
}
}
- /**
- * Sends a response for the given Exception.
- *
- * If you have the Symfony HttpFoundation component installed,
- * this method will use it to create and send the response. If not,
- * it will fallback to plain PHP functions.
- *
- * @param \Exception $exception An \Exception instance
- */
- private function failSafeHandle(\Exception $exception)
- {
- if (class_exists('Symfony\Component\HttpFoundation\Response', false)
- && __CLASS__ !== get_class($this)
- && ($reflector = new \ReflectionMethod($this, 'createResponse'))
- && __CLASS__ !== $reflector->class
- ) {
- $response = $this->createResponse($exception);
- $response->sendHeaders();
- $response->sendContent();
- @trigger_error(sprintf("The %s::createResponse method is deprecated since 2.8 and won't be called anymore when handling an exception in 3.0.", $reflector->class), E_USER_DEPRECATED);
-
- return;
- }
-
- $this->sendPhpResponse($exception);
- }
-
/**
* Sends the error associated with the given Exception as a plain PHP response.
*
@@ -199,26 +177,6 @@ class ExceptionHandler
echo $this->decorate($this->getContent($exception), $this->getStylesheet($exception));
}
- /**
- * Creates the error Response associated with the given Exception.
- *
- * @param \Exception|FlattenException $exception An \Exception or FlattenException instance
- *
- * @return Response A Response instance
- *
- * @deprecated since 2.8, to be removed in 3.0.
- */
- public function createResponse($exception)
- {
- @trigger_error('The '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
-
- if (!$exception instanceof FlattenException) {
- $exception = FlattenException::create($exception);
- }
-
- return Response::create($this->getHtml($exception), $exception->getStatusCode(), $exception->getHeaders())->setCharset($this->charset);
- }
-
/**
* Gets the full HTML content associated with the given exception.
*
@@ -238,8 +196,6 @@ class ExceptionHandler
/**
* Gets the HTML content associated with the given exception.
*
- * @param FlattenException $exception A FlattenException instance
- *
* @return string The content as a string
*/
public function getContent(FlattenException $exception)
@@ -262,28 +218,30 @@ class ExceptionHandler
$class = $this->formatClass($e['class']);
$message = nl2br($this->escapeHtml($e['message']));
$content .= sprintf(<<<'EOF'
-