Upgrade to 3.9.3
This commit is contained in:
@@ -6,16 +6,19 @@
|
||||
|
||||
namespace Whoops\Exception;
|
||||
|
||||
use Whoops\Inspector\InspectorInterface;
|
||||
|
||||
class Formatter
|
||||
{
|
||||
/**
|
||||
* Returns all basic information about the exception in a simple array
|
||||
* for further convertion to other languages
|
||||
* @param Inspector $inspector
|
||||
* @param bool $shouldAddTrace
|
||||
* @param InspectorInterface $inspector
|
||||
* @param bool $shouldAddTrace
|
||||
* @param array<callable> $frameFilters
|
||||
* @return array
|
||||
*/
|
||||
public static function formatExceptionAsDataArray(Inspector $inspector, $shouldAddTrace)
|
||||
public static function formatExceptionAsDataArray(InspectorInterface $inspector, $shouldAddTrace, array $frameFilters = [])
|
||||
{
|
||||
$exception = $inspector->getException();
|
||||
$response = [
|
||||
@@ -27,7 +30,7 @@ class Formatter
|
||||
];
|
||||
|
||||
if ($shouldAddTrace) {
|
||||
$frames = $inspector->getFrames();
|
||||
$frames = $inspector->getFrames($frameFilters);
|
||||
$frameData = [];
|
||||
|
||||
foreach ($frames as $frame) {
|
||||
@@ -47,7 +50,7 @@ class Formatter
|
||||
return $response;
|
||||
}
|
||||
|
||||
public static function formatExceptionPlain(Inspector $inspector)
|
||||
public static function formatExceptionPlain(InspectorInterface $inspector)
|
||||
{
|
||||
$message = $inspector->getException()->getMessage();
|
||||
$frames = $inspector->getFrames();
|
||||
|
@@ -31,9 +31,6 @@ class Frame implements Serializable
|
||||
*/
|
||||
protected $application;
|
||||
|
||||
/**
|
||||
* @param array[]
|
||||
*/
|
||||
public function __construct(array $frame)
|
||||
{
|
||||
$this->frame = $frame;
|
||||
|
@@ -25,9 +25,6 @@ class FrameCollection implements ArrayAccess, IteratorAggregate, Serializable, C
|
||||
*/
|
||||
private $frames;
|
||||
|
||||
/**
|
||||
* @param array $frames
|
||||
*/
|
||||
public function __construct(array $frames)
|
||||
{
|
||||
$this->frames = array_map(function ($frame) {
|
||||
|
@@ -6,9 +6,11 @@
|
||||
|
||||
namespace Whoops\Exception;
|
||||
|
||||
use Whoops\Inspector\InspectorFactory;
|
||||
use Whoops\Inspector\InspectorInterface;
|
||||
use Whoops\Util\Misc;
|
||||
|
||||
class Inspector
|
||||
class Inspector implements InspectorInterface
|
||||
{
|
||||
/**
|
||||
* @var \Throwable
|
||||
@@ -31,11 +33,18 @@ class Inspector
|
||||
private $previousExceptions;
|
||||
|
||||
/**
|
||||
* @param \Throwable $exception The exception to inspect
|
||||
* @var \Whoops\Inspector\InspectorFactoryInterface|null
|
||||
*/
|
||||
public function __construct($exception)
|
||||
protected $inspectorFactory;
|
||||
|
||||
/**
|
||||
* @param \Throwable $exception The exception to inspect
|
||||
* @param \Whoops\Inspector\InspectorFactoryInterface $factory
|
||||
*/
|
||||
public function __construct($exception, $factory = null)
|
||||
{
|
||||
$this->exception = $exception;
|
||||
$this->inspectorFactory = $factory ?: new InspectorFactory();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,7 +146,7 @@ class Inspector
|
||||
$previousException = $this->exception->getPrevious();
|
||||
|
||||
if ($previousException) {
|
||||
$this->previousExceptionInspector = new Inspector($previousException);
|
||||
$this->previousExceptionInspector = $this->inspectorFactory->create($previousException);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,9 +176,12 @@ class Inspector
|
||||
/**
|
||||
* Returns an iterator for the inspected exception's
|
||||
* frames.
|
||||
*
|
||||
* @param array<callable> $frameFilters
|
||||
*
|
||||
* @return \Whoops\Exception\FrameCollection
|
||||
*/
|
||||
public function getFrames()
|
||||
public function getFrames(array $frameFilters = [])
|
||||
{
|
||||
if ($this->frames === null) {
|
||||
$frames = $this->getTrace($this->exception);
|
||||
@@ -225,6 +237,13 @@ class Inspector
|
||||
$newFrames->prependFrames($outerFrames->topDiff($newFrames));
|
||||
$this->frames = $newFrames;
|
||||
}
|
||||
|
||||
// Apply frame filters callbacks on the frames stack
|
||||
if (!empty($frameFilters)) {
|
||||
foreach ($frameFilters as $filterCallback) {
|
||||
$this->frames->filter($filterCallback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->frames;
|
||||
@@ -301,7 +320,6 @@ class Inspector
|
||||
* Determine if the frame can be used to fill in previous frame's missing info
|
||||
* happens for call_user_func and call_user_func_array usages (PHP Bug #44428)
|
||||
*
|
||||
* @param array $frame
|
||||
* @return bool
|
||||
*/
|
||||
protected function isValidNextFrame(array $frame)
|
||||
|
Reference in New Issue
Block a user