Aggiornato Composer
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)
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
namespace Whoops\Handler;
|
||||
|
||||
use Whoops\Exception\Inspector;
|
||||
use Whoops\Inspector\InspectorInterface;
|
||||
use Whoops\RunInterface;
|
||||
|
||||
/**
|
||||
@@ -36,7 +36,7 @@ abstract class Handler implements HandlerInterface
|
||||
private $run;
|
||||
|
||||
/**
|
||||
* @var Inspector $inspector
|
||||
* @var InspectorInterface $inspector
|
||||
*/
|
||||
private $inspector;
|
||||
|
||||
@@ -62,15 +62,15 @@ abstract class Handler implements HandlerInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Inspector $inspector
|
||||
* @param InspectorInterface $inspector
|
||||
*/
|
||||
public function setInspector(Inspector $inspector)
|
||||
public function setInspector(InspectorInterface $inspector)
|
||||
{
|
||||
$this->inspector = $inspector;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Inspector
|
||||
* @return InspectorInterface
|
||||
*/
|
||||
protected function getInspector()
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
namespace Whoops\Handler;
|
||||
|
||||
use Whoops\Exception\Inspector;
|
||||
use Whoops\Inspector\InspectorInterface;
|
||||
use Whoops\RunInterface;
|
||||
|
||||
interface HandlerInterface
|
||||
@@ -29,8 +29,8 @@ interface HandlerInterface
|
||||
public function setException($exception);
|
||||
|
||||
/**
|
||||
* @param Inspector $inspector
|
||||
* @param InspectorInterface $inspector
|
||||
* @return void
|
||||
*/
|
||||
public function setInspector(Inspector $inspector);
|
||||
public function setInspector(InspectorInterface $inspector);
|
||||
}
|
||||
|
||||
@@ -60,7 +60,8 @@ class JsonResponseHandler extends Handler
|
||||
'errors' => [
|
||||
Formatter::formatExceptionAsDataArray(
|
||||
$this->getInspector(),
|
||||
$this->addTraceToOutput()
|
||||
$this->addTraceToOutput(),
|
||||
$this->getRun()->getFrameFilters()
|
||||
),
|
||||
]
|
||||
];
|
||||
@@ -68,7 +69,8 @@ class JsonResponseHandler extends Handler
|
||||
$response = [
|
||||
'error' => Formatter::formatExceptionAsDataArray(
|
||||
$this->getInspector(),
|
||||
$this->addTraceToOutput()
|
||||
$this->addTraceToOutput(),
|
||||
$this->getRun()->getFrameFilters()
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -282,7 +282,7 @@ class PlainTextHandler extends Handler
|
||||
return '';
|
||||
}
|
||||
$inspector = $this->getInspector();
|
||||
$frames = $inspector->getFrames();
|
||||
$frames = $inspector->getFrames($this->getRun()->getFrameFilters());
|
||||
|
||||
$response = "\nStack trace:";
|
||||
|
||||
|
||||
@@ -287,6 +287,7 @@ class PrettyPageHandler extends Handler
|
||||
$vars["tables"] = array_merge($extraTables, $vars["tables"]);
|
||||
|
||||
$plainTextHandler = new PlainTextHandler();
|
||||
$plainTextHandler->setRun($this->getRun());
|
||||
$plainTextHandler->setException($this->getException());
|
||||
$plainTextHandler->setInspector($this->getInspector());
|
||||
$vars["preface"] = "<!--\n\n\n" . $this->templateHelper->escape($plainTextHandler->generateResponse()) . "\n\n\n\n\n\n\n\n\n\n\n-->";
|
||||
@@ -304,7 +305,7 @@ class PrettyPageHandler extends Handler
|
||||
*/
|
||||
protected function getExceptionFrames()
|
||||
{
|
||||
$frames = $this->getInspector()->getFrames();
|
||||
$frames = $this->getInspector()->getFrames($this->getRun()->getFrameFilters());
|
||||
|
||||
if ($this->getApplicationPaths()) {
|
||||
foreach ($frames as $frame) {
|
||||
@@ -353,7 +354,6 @@ class PrettyPageHandler extends Handler
|
||||
* will be flattened with `print_r`.
|
||||
*
|
||||
* @param string $label
|
||||
* @param array $data
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
@@ -383,7 +383,7 @@ class PrettyPageHandler extends Handler
|
||||
throw new InvalidArgumentException('Expecting callback argument to be callable');
|
||||
}
|
||||
|
||||
$this->extraTables[$label] = function (\Whoops\Exception\Inspector $inspector = null) use ($callback) {
|
||||
$this->extraTables[$label] = function (\Whoops\Inspector\InspectorInterface $inspector = null) use ($callback) {
|
||||
try {
|
||||
$result = call_user_func($callback, $inspector);
|
||||
|
||||
@@ -755,11 +755,9 @@ class PrettyPageHandler extends Handler
|
||||
/**
|
||||
* Set the application paths.
|
||||
*
|
||||
* @param array $applicationPaths
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setApplicationPaths($applicationPaths)
|
||||
public function setApplicationPaths(array $applicationPaths)
|
||||
{
|
||||
$this->applicationPaths = $applicationPaths;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,8 @@ class XmlResponseHandler extends Handler
|
||||
$response = [
|
||||
'error' => Formatter::formatExceptionAsDataArray(
|
||||
$this->getInspector(),
|
||||
$this->addTraceToOutput()
|
||||
$this->addTraceToOutput(),
|
||||
$this->getRun()->getFrameFilters()
|
||||
),
|
||||
];
|
||||
|
||||
|
||||
@@ -1,237 +1,5 @@
|
||||
/* PrismJS 1.24.1
|
||||
/* PrismJS 1.29.0
|
||||
https://prismjs.com/download.html#themes=prism-tomorrow&languages=markup+markup-templating+php&plugins=line-highlight+line-numbers */
|
||||
/**
|
||||
* prism.js tomorrow night eighties for JavaScript, CoffeeScript, CSS and HTML
|
||||
* Based on https://github.com/chriskempson/tomorrow-theme
|
||||
* @author Rose Pritchard
|
||||
*/
|
||||
|
||||
code[class*="language-"],
|
||||
pre[class*="language-"] {
|
||||
color: #ccc;
|
||||
background: none;
|
||||
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
|
||||
font-size: 1em;
|
||||
text-align: left;
|
||||
white-space: pre;
|
||||
word-spacing: normal;
|
||||
word-break: normal;
|
||||
word-wrap: normal;
|
||||
line-height: 1.5;
|
||||
|
||||
-moz-tab-size: 4;
|
||||
-o-tab-size: 4;
|
||||
tab-size: 4;
|
||||
|
||||
-webkit-hyphens: none;
|
||||
-moz-hyphens: none;
|
||||
-ms-hyphens: none;
|
||||
hyphens: none;
|
||||
|
||||
}
|
||||
|
||||
/* Code blocks */
|
||||
pre[class*="language-"] {
|
||||
padding: 1em;
|
||||
margin: .5em 0;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
:not(pre) > code[class*="language-"],
|
||||
pre[class*="language-"] {
|
||||
background: #2d2d2d;
|
||||
}
|
||||
|
||||
/* Inline code */
|
||||
:not(pre) > code[class*="language-"] {
|
||||
padding: .1em;
|
||||
border-radius: .3em;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.token.comment,
|
||||
.token.block-comment,
|
||||
.token.prolog,
|
||||
.token.doctype,
|
||||
.token.cdata {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.token.punctuation {
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
.token.tag,
|
||||
.token.attr-name,
|
||||
.token.namespace,
|
||||
.token.deleted {
|
||||
color: #e2777a;
|
||||
}
|
||||
|
||||
.token.function-name {
|
||||
color: #6196cc;
|
||||
}
|
||||
|
||||
.token.boolean,
|
||||
.token.number,
|
||||
.token.function {
|
||||
color: #f08d49;
|
||||
}
|
||||
|
||||
.token.property,
|
||||
.token.class-name,
|
||||
.token.constant,
|
||||
.token.symbol {
|
||||
color: #f8c555;
|
||||
}
|
||||
|
||||
.token.selector,
|
||||
.token.important,
|
||||
.token.atrule,
|
||||
.token.keyword,
|
||||
.token.builtin {
|
||||
color: #cc99cd;
|
||||
}
|
||||
|
||||
.token.string,
|
||||
.token.char,
|
||||
.token.attr-value,
|
||||
.token.regex,
|
||||
.token.variable {
|
||||
color: #7ec699;
|
||||
}
|
||||
|
||||
.token.operator,
|
||||
.token.entity,
|
||||
.token.url {
|
||||
color: #67cdcc;
|
||||
}
|
||||
|
||||
.token.important,
|
||||
.token.bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
.token.italic {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.token.entity {
|
||||
cursor: help;
|
||||
}
|
||||
|
||||
.token.inserted {
|
||||
color: green;
|
||||
}
|
||||
|
||||
pre[data-line] {
|
||||
position: relative;
|
||||
padding: 1em 0 1em 3em;
|
||||
}
|
||||
|
||||
.line-highlight {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
padding: inherit 0;
|
||||
margin-top: 1em; /* Same as .prism’s padding-top */
|
||||
|
||||
background: hsla(24, 20%, 50%,.08);
|
||||
background: linear-gradient(to right, hsla(24, 20%, 50%,.1) 70%, hsla(24, 20%, 50%,0));
|
||||
|
||||
pointer-events: none;
|
||||
|
||||
line-height: inherit;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
@media print {
|
||||
.line-highlight {
|
||||
/*
|
||||
* This will prevent browsers from replacing the background color with white.
|
||||
* It's necessary because the element is layered on top of the displayed code.
|
||||
*/
|
||||
-webkit-print-color-adjust: exact;
|
||||
color-adjust: exact;
|
||||
}
|
||||
}
|
||||
|
||||
.line-highlight:before,
|
||||
.line-highlight[data-end]:after {
|
||||
content: attr(data-start);
|
||||
position: absolute;
|
||||
top: .4em;
|
||||
left: .6em;
|
||||
min-width: 1em;
|
||||
padding: 0 .5em;
|
||||
background-color: hsla(24, 20%, 50%,.4);
|
||||
color: hsl(24, 20%, 95%);
|
||||
font: bold 65%/1.5 sans-serif;
|
||||
text-align: center;
|
||||
vertical-align: .3em;
|
||||
border-radius: 999px;
|
||||
text-shadow: none;
|
||||
box-shadow: 0 1px white;
|
||||
}
|
||||
|
||||
.line-highlight[data-end]:after {
|
||||
content: attr(data-end);
|
||||
top: auto;
|
||||
bottom: .4em;
|
||||
}
|
||||
|
||||
.line-numbers .line-highlight:before,
|
||||
.line-numbers .line-highlight:after {
|
||||
content: none;
|
||||
}
|
||||
|
||||
pre[id].linkable-line-numbers span.line-numbers-rows {
|
||||
pointer-events: all;
|
||||
}
|
||||
pre[id].linkable-line-numbers span.line-numbers-rows > span:before {
|
||||
cursor: pointer;
|
||||
}
|
||||
pre[id].linkable-line-numbers span.line-numbers-rows > span:hover:before {
|
||||
background-color: rgba(128, 128, 128, .2);
|
||||
}
|
||||
|
||||
pre[class*="language-"].line-numbers {
|
||||
position: relative;
|
||||
padding-left: 3.8em;
|
||||
counter-reset: linenumber;
|
||||
}
|
||||
|
||||
pre[class*="language-"].line-numbers > code {
|
||||
position: relative;
|
||||
white-space: inherit;
|
||||
}
|
||||
|
||||
.line-numbers .line-numbers-rows {
|
||||
position: absolute;
|
||||
pointer-events: none;
|
||||
top: 0;
|
||||
font-size: 100%;
|
||||
left: -3.8em;
|
||||
width: 3em; /* works for line-numbers below 1000 lines */
|
||||
letter-spacing: -1px;
|
||||
border-right: 1px solid #999;
|
||||
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
|
||||
}
|
||||
|
||||
.line-numbers-rows > span {
|
||||
display: block;
|
||||
counter-increment: linenumber;
|
||||
}
|
||||
|
||||
.line-numbers-rows > span:before {
|
||||
content: counter(linenumber);
|
||||
color: #999;
|
||||
display: block;
|
||||
padding-right: 0.8em;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
code[class*=language-],pre[class*=language-]{color:#ccc;background:0 0;font-family:Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace;font-size:1em;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}pre[class*=language-]{padding:1em;margin:.5em 0;overflow:auto}:not(pre)>code[class*=language-],pre[class*=language-]{background:#2d2d2d}:not(pre)>code[class*=language-]{padding:.1em;border-radius:.3em;white-space:normal}.token.block-comment,.token.cdata,.token.comment,.token.doctype,.token.prolog{color:#999}.token.punctuation{color:#ccc}.token.attr-name,.token.deleted,.token.namespace,.token.tag{color:#e2777a}.token.function-name{color:#6196cc}.token.boolean,.token.function,.token.number{color:#f08d49}.token.class-name,.token.constant,.token.property,.token.symbol{color:#f8c555}.token.atrule,.token.builtin,.token.important,.token.keyword,.token.selector{color:#cc99cd}.token.attr-value,.token.char,.token.regex,.token.string,.token.variable{color:#7ec699}.token.entity,.token.operator,.token.url{color:#67cdcc}.token.bold,.token.important{font-weight:700}.token.italic{font-style:italic}.token.entity{cursor:help}.token.inserted{color:green}
|
||||
pre[data-line]{position:relative;padding:1em 0 1em 3em}.line-highlight{position:absolute;left:0;right:0;padding:inherit 0;margin-top:1em;background:hsla(24,20%,50%,.08);background:linear-gradient(to right,hsla(24,20%,50%,.1) 70%,hsla(24,20%,50%,0));pointer-events:none;line-height:inherit;white-space:pre}@media print{.line-highlight{-webkit-print-color-adjust:exact;color-adjust:exact}}.line-highlight:before,.line-highlight[data-end]:after{content:attr(data-start);position:absolute;top:.4em;left:.6em;min-width:1em;padding:0 .5em;background-color:hsla(24,20%,50%,.4);color:#f4f1ef;font:bold 65%/1.5 sans-serif;text-align:center;vertical-align:.3em;border-radius:999px;text-shadow:none;box-shadow:0 1px #fff}.line-highlight[data-end]:after{content:attr(data-end);top:auto;bottom:.4em}.line-numbers .line-highlight:after,.line-numbers .line-highlight:before{content:none}pre[id].linkable-line-numbers span.line-numbers-rows{pointer-events:all}pre[id].linkable-line-numbers span.line-numbers-rows>span:before{cursor:pointer}pre[id].linkable-line-numbers span.line-numbers-rows>span:hover:before{background-color:rgba(128,128,128,.2)}
|
||||
pre[class*=language-].line-numbers{position:relative;padding-left:3.8em;counter-reset:linenumber}pre[class*=language-].line-numbers>code{position:relative;white-space:inherit}.line-numbers .line-numbers-rows{position:absolute;pointer-events:none;top:0;font-size:100%;left:-3.8em;width:3em;letter-spacing:-1px;border-right:1px solid #999;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.line-numbers-rows>span{display:block;counter-increment:linenumber}.line-numbers-rows>span:before{content:counter(linenumber);color:#999;display:block;padding-right:.8em;text-align:right}
|
||||
|
||||
@@ -290,13 +290,12 @@ header {
|
||||
border-radius: 6px;
|
||||
background-color: rgba(255, 255, 255, .05);
|
||||
}
|
||||
.frame-comment a {
|
||||
font-weight: bold;
|
||||
text-decoration: none;
|
||||
}
|
||||
.frame-comment a:hover {
|
||||
color: #4bb1b1;
|
||||
}
|
||||
|
||||
.frame-comment a {
|
||||
font-weight: bold;
|
||||
text-decoration: underline;
|
||||
color: #c6c6c6;
|
||||
}
|
||||
|
||||
.frame-comment:not(:last-child) {
|
||||
border-bottom: 1px dotted rgba(0, 0, 0, .3);
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -25,7 +25,7 @@ Zepto(function($) {
|
||||
* highlight the current line
|
||||
*/
|
||||
var renderCurrentCodeblock = function(id) {
|
||||
Prism.highlightAll();
|
||||
Prism.highlightAllUnder(document.querySelector('.frame-code-container .frame-code.active'));
|
||||
highlightCurrentLine();
|
||||
}
|
||||
|
||||
@@ -153,9 +153,6 @@ Zepto(function($) {
|
||||
}
|
||||
});
|
||||
|
||||
// Render late enough for highlightCurrentLine to be ready
|
||||
renderCurrentCodeblock();
|
||||
|
||||
// Avoid to quit the page with some protocol (e.g. IntelliJ Platform REST API)
|
||||
$ajaxEditors.on('click', function(e){
|
||||
e.preventDefault();
|
||||
@@ -185,4 +182,7 @@ Zepto(function($) {
|
||||
e.preventDefault();
|
||||
setActiveFramesTab($(this));
|
||||
});
|
||||
|
||||
// Render late enough for highlightCurrentLine to be ready
|
||||
renderCurrentCodeblock();
|
||||
});
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
?>
|
||||
<pre class="code-block line-numbers"
|
||||
data-line="<?php echo $line ?>"
|
||||
data-line-offset="<?php echo $start ?>"
|
||||
data-start="<?php echo $start ?>"
|
||||
><code class="language-php"><?php echo $tpl->escape($code) ?></code></pre>
|
||||
|
||||
|
||||
58
vendor/filp/whoops/src/Whoops/Run.php
vendored
58
vendor/filp/whoops/src/Whoops/Run.php
vendored
@@ -9,10 +9,13 @@ namespace Whoops;
|
||||
use InvalidArgumentException;
|
||||
use Throwable;
|
||||
use Whoops\Exception\ErrorException;
|
||||
use Whoops\Exception\Inspector;
|
||||
use Whoops\Handler\CallbackHandler;
|
||||
use Whoops\Handler\Handler;
|
||||
use Whoops\Handler\HandlerInterface;
|
||||
use Whoops\Inspector\CallableInspectorFactory;
|
||||
use Whoops\Inspector\InspectorFactory;
|
||||
use Whoops\Inspector\InspectorFactoryInterface;
|
||||
use Whoops\Inspector\InspectorInterface;
|
||||
use Whoops\Util\Misc;
|
||||
use Whoops\Util\SystemFacade;
|
||||
|
||||
@@ -66,9 +69,22 @@ final class Run implements RunInterface
|
||||
*/
|
||||
private $canThrowExceptions = true;
|
||||
|
||||
/**
|
||||
* The inspector factory to create inspectors.
|
||||
*
|
||||
* @var InspectorFactoryInterface
|
||||
*/
|
||||
private $inspectorFactory;
|
||||
|
||||
/**
|
||||
* @var array<callable>
|
||||
*/
|
||||
private $frameFilters = [];
|
||||
|
||||
public function __construct(SystemFacade $system = null)
|
||||
{
|
||||
$this->system = $system ?: new SystemFacade;
|
||||
$this->inspectorFactory = new InspectorFactory();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -165,6 +181,17 @@ final class Run implements RunInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFrameFilters()
|
||||
{
|
||||
return $this->frameFilters;
|
||||
}
|
||||
|
||||
public function clearFrameFilters()
|
||||
{
|
||||
$this->frameFilters = [];
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers this instance as an error handler.
|
||||
*
|
||||
@@ -179,6 +206,7 @@ final class Run implements RunInterface
|
||||
class_exists("\\Whoops\\Exception\\FrameCollection");
|
||||
class_exists("\\Whoops\\Exception\\Frame");
|
||||
class_exists("\\Whoops\\Exception\\Inspector");
|
||||
class_exists("\\Whoops\\Inspector\\InspectorFactory");
|
||||
|
||||
$this->system->setErrorHandler([$this, self::ERROR_HANDLER]);
|
||||
$this->system->setExceptionHandler([$this, self::EXCEPTION_HANDLER]);
|
||||
@@ -488,14 +516,38 @@ final class Run implements RunInterface
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param InspectorFactoryInterface $factory
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setInspectorFactory(InspectorFactoryInterface $factory)
|
||||
{
|
||||
$this->inspectorFactory = $factory;
|
||||
}
|
||||
|
||||
public function addFrameFilter($filterCallback)
|
||||
{
|
||||
if (!is_callable($filterCallback)) {
|
||||
throw new \InvalidArgumentException(sprintf(
|
||||
"A frame filter must be of type callable, %s type given.",
|
||||
gettype($filterCallback)
|
||||
));
|
||||
}
|
||||
|
||||
$this->frameFilters[] = $filterCallback;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Throwable $exception
|
||||
*
|
||||
* @return Inspector
|
||||
* @return InspectorInterface
|
||||
*/
|
||||
private function getInspector($exception)
|
||||
{
|
||||
return new Inspector($exception);
|
||||
return $this->inspectorFactory->create($exception);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
18
vendor/filp/whoops/src/Whoops/RunInterface.php
vendored
18
vendor/filp/whoops/src/Whoops/RunInterface.php
vendored
@@ -49,6 +49,16 @@ interface RunInterface
|
||||
*/
|
||||
public function clearHandlers();
|
||||
|
||||
/**
|
||||
* @return array<callable>
|
||||
*/
|
||||
public function getFrameFilters();
|
||||
|
||||
/**
|
||||
* @return Run
|
||||
*/
|
||||
public function clearFrameFilters();
|
||||
|
||||
/**
|
||||
* Registers this instance as an error handler.
|
||||
*
|
||||
@@ -137,4 +147,12 @@ interface RunInterface
|
||||
* Special case to deal with Fatal errors and the like.
|
||||
*/
|
||||
public function handleShutdown();
|
||||
|
||||
/**
|
||||
* Registers a filter callback in the frame filters stack.
|
||||
*
|
||||
* @param callable $filterCallback
|
||||
* @return \Whoops\Run
|
||||
*/
|
||||
public function addFrameFilter($filterCallback);
|
||||
}
|
||||
|
||||
@@ -232,7 +232,6 @@ class TemplateHelper
|
||||
* passed to the template.
|
||||
*
|
||||
* @param string $template
|
||||
* @param array $additionalVariables
|
||||
*/
|
||||
public function render($template, array $additionalVariables = null)
|
||||
{
|
||||
@@ -254,8 +253,6 @@ class TemplateHelper
|
||||
/**
|
||||
* Sets the variables to be passed to all templates rendered
|
||||
* by this template helper.
|
||||
*
|
||||
* @param array $variables
|
||||
*/
|
||||
public function setVariables(array $variables)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user