Upgrade to 3.5.5

This commit is contained in:
Bastian Allgeier
2021-05-11 11:55:32 +02:00
parent de3560f3d6
commit efeff45192
146 changed files with 2008 additions and 1075 deletions

View File

@@ -11,6 +11,9 @@
"role": "Developer"
}
],
"scripts": {
"test": "phpunit --testdox tests"
},
"require": {
"php": "^5.5.9 || ^7.0 || ^8.0",
"psr/log": "^1.0.1"

View File

@@ -28,7 +28,7 @@ class JsonResponseHandler extends Handler
/**
* Returns errors[[]] instead of error[] to be in compliance with the json:api spec
* @param bool $jsonApi Default is false
* @return $this
* @return static
*/
public function setJsonApi($jsonApi = false)
{
@@ -38,7 +38,7 @@ class JsonResponseHandler extends Handler
/**
* @param bool|null $returnFrames
* @return bool|$this
* @return bool|static
*/
public function addTraceToOutput($returnFrames = null)
{

View File

@@ -97,17 +97,18 @@ class PlainTextHandler extends Handler
* Set var dumper callback function.
*
* @param callable $dumper
* @return void
* @return static
*/
public function setDumper(callable $dumper)
{
$this->dumper = $dumper;
return $this;
}
/**
* Add error trace to output.
* @param bool|null $addTraceToOutput
* @return bool|$this
* @return bool|static
*/
public function addTraceToOutput($addTraceToOutput = null)
{
@@ -122,7 +123,7 @@ class PlainTextHandler extends Handler
/**
* Add previous exceptions to output.
* @param bool|null $addPreviousToOutput
* @return bool|$this
* @return bool|static
*/
public function addPreviousToOutput($addPreviousToOutput = null)
{
@@ -138,7 +139,7 @@ class PlainTextHandler extends Handler
* Add error trace function arguments to output.
* Set to True for all frame args, or integer for the n first frame args.
* @param bool|integer|null $addTraceFunctionArgsToOutput
* @return null|bool|integer
* @return static|bool|integer
*/
public function addTraceFunctionArgsToOutput($addTraceFunctionArgsToOutput = null)
{
@@ -151,6 +152,7 @@ class PlainTextHandler extends Handler
} else {
$this->addTraceFunctionArgsToOutput = $addTraceFunctionArgsToOutput;
}
return $this;
}
/**
@@ -158,10 +160,12 @@ class PlainTextHandler extends Handler
* If the limit is reached, the var_dump output is discarded.
* Prevent memory limit errors.
* @var integer
* @return static
*/
public function setTraceFunctionArgsOutputLimit($traceFunctionArgsOutputLimit)
{
$this->traceFunctionArgsOutputLimit = (integer) $traceFunctionArgsOutputLimit;
return $this;
}
/**
@@ -199,7 +203,7 @@ class PlainTextHandler extends Handler
/**
* Only output to logger.
* @param bool|null $loggerOnly
* @return null|bool
* @return static|bool
*/
public function loggerOnly($loggerOnly = null)
{
@@ -208,6 +212,7 @@ class PlainTextHandler extends Handler
}
$this->loggerOnly = (bool) $loggerOnly;
return $this;
}
/**

View File

@@ -175,6 +175,8 @@ class PrettyPageHandler extends Handler
/**
* @return int|null
*
* @throws \Exception
*/
public function handle()
{
@@ -349,11 +351,12 @@ class PrettyPageHandler extends Handler
* @param string $label
* @param array $data
*
* @return void
* @return static
*/
public function addDataTable($label, array $data)
{
$this->extraTables[$label] = $data;
return $this;
}
/**
@@ -368,7 +371,7 @@ class PrettyPageHandler extends Handler
*
* @throws InvalidArgumentException If $callback is not callable
*
* @return void
* @return static
*/
public function addDataTableCallback($label, /* callable */ $callback)
{
@@ -387,6 +390,8 @@ class PrettyPageHandler extends Handler
return [];
}
};
return $this;
}
/**
@@ -418,7 +423,7 @@ class PrettyPageHandler extends Handler
*
* @param bool|null $value
*
* @return bool|null
* @return bool|static
*/
public function handleUnconditionally($value = null)
{
@@ -427,6 +432,7 @@ class PrettyPageHandler extends Handler
}
$this->handleUnconditionally = (bool) $value;
return $this;
}
/**
@@ -447,11 +453,12 @@ class PrettyPageHandler extends Handler
* @param string $identifier
* @param string|callable $resolver
*
* @return void
* @return static
*/
public function addEditor($identifier, $resolver)
{
$this->editors[$identifier] = $resolver;
return $this;
}
/**
@@ -469,7 +476,7 @@ class PrettyPageHandler extends Handler
*
* @throws InvalidArgumentException If invalid argument identifier provided
*
* @return void
* @return static
*/
public function setEditor($editor)
{
@@ -481,6 +488,7 @@ class PrettyPageHandler extends Handler
}
$this->editor = $editor;
return $this;
}
/**
@@ -591,11 +599,12 @@ class PrettyPageHandler extends Handler
*
* @param string $title
*
* @return void
* @return static
*/
public function setPageTitle($title)
{
$this->pageTitle = (string) $title;
return $this;
}
/**
@@ -615,7 +624,7 @@ class PrettyPageHandler extends Handler
*
* @throws InvalidArgumentException If $path is not a valid directory
*
* @return void
* @return static
*/
public function addResourcePath($path)
{
@@ -626,6 +635,7 @@ class PrettyPageHandler extends Handler
}
array_unshift($this->searchPaths, $path);
return $this;
}
/**
@@ -633,11 +643,12 @@ class PrettyPageHandler extends Handler
*
* @param string|null $name
*
* @return void
* @return static
*/
public function addCustomCss($name)
{
$this->customCss = $name;
return $this;
}
/**
@@ -645,11 +656,12 @@ class PrettyPageHandler extends Handler
*
* @param string|null $name
*
* @return void
* @return static
*/
public function addCustomJs($name)
{
$this->customJs = $name;
return $this;
}
/**
@@ -718,11 +730,12 @@ class PrettyPageHandler extends Handler
*
* @param string $resourcesPath
*
* @return void
* @return static
*/
public function setResourcesPath($resourcesPath)
{
$this->addResourcePath($resourcesPath);
return $this;
}
/**
@@ -767,11 +780,12 @@ class PrettyPageHandler extends Handler
* @param string $key The key within the superglobal
* @see hideSuperglobalKey
*
* @return void
* @return static
*/
public function blacklist($superGlobalName, $key)
{
$this->blacklist[$superGlobalName][] = $key;
return $this;
}
/**
@@ -779,7 +793,7 @@ class PrettyPageHandler extends Handler
*
* @param string $superGlobalName The name of the superglobal array, e.g. '_GET'
* @param string $key The key within the superglobal
* @return void
* @return static
*/
public function hideSuperglobalKey($superGlobalName, $key)
{
@@ -789,9 +803,10 @@ class PrettyPageHandler extends Handler
/**
* Checks all values within the given superGlobal array.
*
* Blacklisted values will be replaced by a equal length string cointaining
* only '*' characters. We intentionally dont rely on $GLOBALS as it
* depends on the 'auto_globals_jit' php.ini setting.
* Blacklisted values will be replaced by a equal length string containing
* only '*' characters for string values.
* Non-string values will be replaced with a fixed asterisk count.
* We intentionally dont rely on $GLOBALS as it depends on the 'auto_globals_jit' php.ini setting.
*
* @param array $superGlobal One of the superglobal arrays
* @param string $superGlobalName The name of the superglobal array, e.g. '_GET'
@@ -805,8 +820,8 @@ class PrettyPageHandler extends Handler
$values = $superGlobal;
foreach ($blacklisted as $key) {
if (isset($superGlobal[$key]) && is_string($superGlobal[$key])) {
$values[$key] = str_repeat('*', strlen($superGlobal[$key]));
if (isset($superGlobal[$key])) {
$values[$key] = str_repeat('*', is_string($superGlobal[$key]) ? strlen($superGlobal[$key]) : 3);
}
}

View File

@@ -23,7 +23,7 @@ class XmlResponseHandler extends Handler
/**
* @param bool|null $returnFrames
* @return bool|$this
* @return bool|static
*/
public function addTraceToOutput($returnFrames = null)
{

View File

@@ -100,7 +100,7 @@ Zepto(function($) {
var clipboard = new Clipboard('.clipboard');
var showTooltip = function(elem, msg) {
elem.setAttribute('class', 'clipboard tooltipped tooltipped-s');
elem.classList.add('tooltipped', 'tooltipped-s');
elem.setAttribute('aria-label', msg);
};
@@ -117,7 +117,7 @@ Zepto(function($) {
var btn = document.querySelector('.clipboard');
btn.addEventListener('mouseleave', function(e) {
e.currentTarget.setAttribute('class', 'clipboard');
e.currentTarget.classList.remove('tooltipped', 'tooltipped-s');
e.currentTarget.removeAttribute('aria-label');
});

View File

@@ -38,6 +38,11 @@ final class Run implements RunInterface
*/
private $sendHttpCode = 500;
/**
* @var integer|false
*/
private $sendExitCode = 1;
/**
* @var HandlerInterface[]
*/
@@ -288,6 +293,31 @@ final class Run implements RunInterface
return $this->sendHttpCode = $code;
}
/**
* Should Whoops exit with a specific code on the CLI if possible?
* Whoops will exit with 1 by default, but you can specify something else.
*
* @param int $code
*
* @return int
*
* @throws InvalidArgumentException
*/
public function sendExitCode($code = null)
{
if (func_num_args() == 0) {
return $this->sendExitCode;
}
if ($code < 0 || 255 <= $code) {
throw new InvalidArgumentException(
"Invalid status code '$code', must be between 0 and 254"
);
}
return $this->sendExitCode = (int) $code;
}
/**
* Should Whoops push output directly to the client?
* If this is false, output will be returned by handleException.
@@ -380,7 +410,9 @@ final class Run implements RunInterface
// HHVM fix for https://github.com/facebook/hhvm/issues/4055
$this->system->flushOutputBuffer();
$this->system->stopExecution(1);
$this->system->stopExecution(
$this->sendExitCode()
);
}
return $output;

View File

@@ -90,6 +90,15 @@ interface RunInterface
*/
public function sendHttpCode($code = null);
/**
* Should Whoops exit with a specific code on the CLI if possible?
* Whoops will exit with 1 by default, but you can specify something else.
*
* @param int $code
* @return int
*/
public function sendExitCode($code = null);
/**
* Should Whoops push output directly to the client?
* If this is false, output will be returned by handleException

View File

@@ -124,6 +124,13 @@ class SystemFacade
*/
public function setHttpResponseCode($httpCode)
{
if (!headers_sent()) {
// Ensure that no 'location' header is present as otherwise this
// will override the HTTP code being set here, and mask the
// expected error page.
header_remove('location');
}
return http_response_code($httpCode);
}