Aggiornato Composer

This commit is contained in:
Paolo A
2024-05-17 12:24:19 +00:00
parent 4ac62108b5
commit ec201d75b2
2238 changed files with 38684 additions and 59785 deletions

View File

@@ -1 +0,0 @@
github: denis-sokolov

View File

@@ -1,56 +0,0 @@
name: Tests
on:
push:
pull_request:
jobs:
tests:
name: PHP ${{ matrix.php }}
runs-on: ubuntu-20.04
strategy:
matrix:
php: ['5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: none
env:
update: true
- name: Setup Problem Matchers
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Fix PHPUnit Version PHP < 7.4
uses: nick-invision/retry@v1
with:
timeout_minutes: 5
max_attempts: 5
command: composer require "phpunit/phpunit:^4.8.36 || ^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.8" --dev --no-update --no-interaction
if: "matrix.php < 7.4"
- name: Fix PHPUnit Version PHP >= 7.4
uses: nick-invision/retry@v1
with:
timeout_minutes: 5
max_attempts: 5
command: composer require "phpunit/phpunit:^9.3.3" --dev --no-update --no-interaction
if: "matrix.php >= 7.4"
- name: Install PHP Dependencies
uses: nick-invision/retry@v1
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --no-interaction --no-progress
- name: Execute PHPUnit
run: vendor/bin/phpunit

View File

@@ -1,124 +1,153 @@
# 2.14.5
# CHANGELOG
* Allow ArrayAccess on super globals
## v2.15.4
# 2.14.4
* Improve link color in comments.
* Fix PHP 5.5 support.
* Allow to use psr/log 2 or 3.
## v2.15.3
# 2.14.3
* Improve performance of the syntax highlighting (#758).
* Support PHP 8.1
## v2.15.2
# 2.14.1
* Fixed missing code highlight, which additionally led to issue with switching tabs, between application and all frames ([#747](https://github.com/filp/whoops/issues/747)).
## v2.15.1
* Fixed bug with PrettyPageHandler "*Calling `getFrameFilters` method on null*" ([#751](https://github.com/filp/whoops/pull/751)).
## v2.15.0
* Add addFrameFilter ([#749](https://github.com/filp/whoops/pull/749))
## v2.14.6
* Upgraded prismJS to version `1.29.0` due to security issue ([#741][i741]).
[i741]: https://github.com/filp/whoops/pull/741
## v2.14.5
* Allow `ArrayAccess` on super globals.
## v2.14.4
* Fix PHP `5.5` support.
* Allow to use psr/log `2` or `3`.
## v2.14.3
* Support PHP `8.1`.
## v2.14.1
* Fix syntax highlighting scrolling too far.
* Improve the way we detect xdebug linkformat.
# 2.14.0
## v2.14.0
* Switched syntax highlighting to Prism.js
* Switched syntax highlighting to Prism.js.
Avoids licensing issues with prettify, and uses a maintaned, modern project.
Avoids licensing issues with prettify, and uses a maintained, modern project.
# 2.13.0
## v2.13.0
* Add Netbeans editor
* Add Netbeans editor.
# 2.12.1
## v2.12.1
* Avoid redirecting away from an error.
# 2.12.0
## v2.12.0
* Hide non-string values in super globals when requested.
# 2.11.0
## v2.11.0
* Customize exit code
* Customize exit code.
# 2.10.0
## v2.10.0
* Better chaining on handler classes
* Better chaining on handler classes.
# 2.9.2
## v2.9.2
* Fix copy button styles
* Fix copy button styles.
# 2.9.1
## v2.9.1
* Fix xdebug function crash on PHP 8
* Fix xdebug function crash on PHP `8`.
# 2.9.0
## v2.9.0
* JsonResponseHandler includes the exception code
* `JsonResponseHandler` includes the exception code.
# 2.8.0
## v2.8.0
* Support PHP 8
* Support PHP 8.
# 2.7.3
## v2.7.3
* PrettyPageHandler functionality to hide superglobal keys has a clearer name hideSuperglobalKey
* `PrettyPageHandler` functionality to hide superglobal keys has a clearer name
(`hideSuperglobalKey`).
# 2.7.2
## v2.7.2
* PrettyPageHandler now accepts custom js files
* PrettyPageHandler templateHelper is now accessible through inheritance
* `PrettyPageHandler` now accepts custom js files.
* `PrettyPageHandler` and `templateHelper` is now accessible through inheritance.
# 2.7.1
## v2.7.1
* Fix a PHP warning in some cases with anonymous classes.
# 2.7.0
## v2.7.0
* removeFirstHandler and removeLastHandler.
* Added `removeFirstHandler` and `removeLastHandler`.
# 2.6.0
## v2.6.0
* Fix 2.4.0 pushHandler changing the order of handlers.
* Fix 2.4.0 `pushHandler` changing the order of handlers.
# 2.5.1
## v2.5.1
* Fix error messaging in a rare case.
# 2.5.0
## v2.5.0
* Automatically configure xdebug if available.
# 2.4.1
## v2.4.1
* Try harder to close all output buffers
* Try harder to close all output buffers.
# 2.4.0
## v2.4.0
* Allow to prepend and append handlers.
# 2.3.2
## v2.3.2
* Various fixes from the community.
# 2.3.1
## v2.3.1
* Prevent exception in Whoops when caught exception frame is not related to real file
* Prevent exception in Whoops when caught exception frame is not related to real file.
# 2.3.0
## v2.3.0
* Show previous exception messages.
# 2.2.0
## v2.2.0
* Support PHP 7.2
* Support PHP `7.2`.
# 2.1.0
## v2.1.0
* Add a `SystemFacade` to allow clients to override Whoops behavior.
* Show frame arguments in `PrettyPageHandler`.
* Highlight the line with the error.
* Add icons to search on Google and Stack Overflow.
# 2.0.0
## v2.0.0
Backwards compatibility breaking changes:

View File

@@ -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();

View File

@@ -31,9 +31,6 @@ class Frame implements Serializable
*/
protected $application;
/**
* @param array[]
*/
public function __construct(array $frame)
{
$this->frame = $frame;

View File

@@ -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) {

View File

@@ -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)

View File

@@ -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()
{

View File

@@ -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);
}

View File

@@ -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()
),
];
}

View File

@@ -282,7 +282,7 @@ class PlainTextHandler extends Handler
return '';
}
$inspector = $this->getInspector();
$frames = $inspector->getFrames();
$frames = $inspector->getFrames($this->getRun()->getFrameFilters());
$response = "\nStack trace:";

View File

@@ -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;
}

View File

@@ -43,7 +43,8 @@ class XmlResponseHandler extends Handler
$response = [
'error' => Formatter::formatExceptionAsDataArray(
$this->getInspector(),
$this->addTraceToOutput()
$this->addTraceToOutput(),
$this->getRun()->getFrameFilters()
),
];

View File

@@ -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 .prisms 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}

View File

@@ -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

View File

@@ -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();
});

View File

@@ -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>

View File

@@ -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);
}
/**

View File

@@ -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);
}

View File

@@ -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)
{