mirror of
https://github.com/filp/whoops.git
synced 2026-08-31 12:38:10 +00:00
Merge pull request #537 from luismulinari/psr2-fix
Fix coding standards (PSR-2)
This commit is contained in:
@@ -6,7 +6,6 @@
|
||||
|
||||
namespace Whoops\Exception;
|
||||
|
||||
|
||||
class Formatter
|
||||
{
|
||||
/**
|
||||
|
||||
@@ -286,7 +286,7 @@ class Frame implements Serializable
|
||||
|
||||
/**
|
||||
* Mark as an frame belonging to the application.
|
||||
*
|
||||
*
|
||||
* @param boolean $application
|
||||
*/
|
||||
public function setApplication($application)
|
||||
|
||||
@@ -146,7 +146,7 @@ class FrameCollection implements ArrayAccess, IteratorAggregate, Serializable, C
|
||||
*/
|
||||
public function countIsApplication()
|
||||
{
|
||||
return count(array_filter($this->frames, function(Frame $f) {
|
||||
return count(array_filter($this->frames, function (Frame $f) {
|
||||
return $f->isApplication();
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -67,7 +67,8 @@ class Inspector
|
||||
return $this->extractDocrefUrl($this->exception->getMessage())['url'];
|
||||
}
|
||||
|
||||
private function extractDocrefUrl($message) {
|
||||
private function extractDocrefUrl($message)
|
||||
{
|
||||
$docref = [
|
||||
'message' => $message,
|
||||
'url' => null,
|
||||
@@ -128,7 +129,6 @@ class Inspector
|
||||
|
||||
// Fill empty line/file info for call_user_func_array usages (PHP Bug #44428)
|
||||
foreach ($frames as $k => $frame) {
|
||||
|
||||
if (empty($frame['file'])) {
|
||||
// Default values when file and line are missing
|
||||
$file = '[internal]';
|
||||
@@ -144,7 +144,6 @@ class Inspector
|
||||
$frames[$k]['file'] = $file;
|
||||
$frames[$k]['line'] = $line;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Find latest non-error handling frame index ($i) used to remove error handling frames
|
||||
|
||||
@@ -55,23 +55,23 @@ class JsonResponseHandler extends Handler
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
if ($this->jsonApi === true) {
|
||||
$response = [
|
||||
'errors' => [
|
||||
Formatter::formatExceptionAsDataArray(
|
||||
$this->getInspector(),
|
||||
$this->addTraceToOutput()
|
||||
),
|
||||
]
|
||||
];
|
||||
} else {
|
||||
$response = [
|
||||
'error' => Formatter::formatExceptionAsDataArray(
|
||||
$this->getInspector(),
|
||||
$this->addTraceToOutput()
|
||||
),
|
||||
];
|
||||
}
|
||||
if ($this->jsonApi === true) {
|
||||
$response = [
|
||||
'errors' => [
|
||||
Formatter::formatExceptionAsDataArray(
|
||||
$this->getInspector(),
|
||||
$this->addTraceToOutput()
|
||||
),
|
||||
]
|
||||
];
|
||||
} else {
|
||||
$response = [
|
||||
'error' => Formatter::formatExceptionAsDataArray(
|
||||
$this->getInspector(),
|
||||
$this->addTraceToOutput()
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
echo json_encode($response, defined('JSON_PARTIAL_OUTPUT_ON_ERROR') ? JSON_PARTIAL_OUTPUT_ON_ERROR : 0);
|
||||
|
||||
|
||||
@@ -151,7 +151,8 @@ class PlainTextHandler extends Handler
|
||||
public function generateResponse()
|
||||
{
|
||||
$exception = $this->getException();
|
||||
return sprintf("%s: %s in file %s on line %d%s\n",
|
||||
return sprintf(
|
||||
"%s: %s in file %s on line %d%s\n",
|
||||
get_class($exception),
|
||||
$exception->getMessage(),
|
||||
$exception->getFile(),
|
||||
@@ -221,7 +222,8 @@ class PlainTextHandler extends Handler
|
||||
);
|
||||
}
|
||||
|
||||
return sprintf("\n%s",
|
||||
return sprintf(
|
||||
"\n%s",
|
||||
preg_replace('/^/m', self::VAR_DUMP_PREFIX, ob_get_clean())
|
||||
);
|
||||
}
|
||||
|
||||
@@ -491,7 +491,7 @@ class PrettyPageHandler extends Handler
|
||||
}
|
||||
|
||||
if (is_string($this->editor) && isset($this->editors[$this->editor]) && !is_callable($this->editors[$this->editor])) {
|
||||
return [
|
||||
return [
|
||||
'ajax' => false,
|
||||
'url' => $this->editors[$this->editor],
|
||||
];
|
||||
@@ -674,7 +674,8 @@ class PrettyPageHandler extends Handler
|
||||
* @param $superGlobalName string the name of the superglobal array, e.g. '_GET'
|
||||
* @param $key string the key within the superglobal
|
||||
*/
|
||||
public function blacklist($superGlobalName, $key) {
|
||||
public function blacklist($superGlobalName, $key)
|
||||
{
|
||||
$this->blacklist[$superGlobalName][] = $key;
|
||||
}
|
||||
|
||||
@@ -688,11 +689,12 @@ class PrettyPageHandler extends Handler
|
||||
* @param $superGlobalName string the name of the superglobal array, e.g. '_GET'
|
||||
* @return array $values without sensitive data
|
||||
*/
|
||||
private function masked(array $superGlobal, $superGlobalName) {
|
||||
private function masked(array $superGlobal, $superGlobalName)
|
||||
{
|
||||
$blacklisted = $this->blacklist[$superGlobalName];
|
||||
|
||||
$values = $superGlobal;
|
||||
foreach($blacklisted as $key) {
|
||||
foreach ($blacklisted as $key) {
|
||||
if (isset($superGlobal[$key])) {
|
||||
$values[$key] = str_repeat('*', strlen($superGlobal[$key]));
|
||||
}
|
||||
|
||||
@@ -33,5 +33,4 @@ class HtmlDumperOutput
|
||||
{
|
||||
$this->output = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+16
-16
@@ -9,15 +9,15 @@ namespace Whoops\Util;
|
||||
class Misc
|
||||
{
|
||||
/**
|
||||
* Can we at this point in time send HTTP headers?
|
||||
*
|
||||
* Currently this checks if we are even serving an HTTP request,
|
||||
* as opposed to running from a command line.
|
||||
*
|
||||
* If we are serving an HTTP request, we check if it's not too late.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
* Can we at this point in time send HTTP headers?
|
||||
*
|
||||
* Currently this checks if we are even serving an HTTP request,
|
||||
* as opposed to running from a command line.
|
||||
*
|
||||
* If we are serving an HTTP request, we check if it's not too late.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function canSendHeaders()
|
||||
{
|
||||
return isset($_SERVER["REQUEST_URI"]) && !headers_sent();
|
||||
@@ -40,15 +40,15 @@ class Misc
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate ErrorException code into the represented constant.
|
||||
*
|
||||
* @param int $error_code
|
||||
* @return string
|
||||
*/
|
||||
* Translate ErrorException code into the represented constant.
|
||||
*
|
||||
* @param int $error_code
|
||||
* @return string
|
||||
*/
|
||||
public static function translateErrorCode($error_code)
|
||||
{
|
||||
$constants = get_defined_constants(true);
|
||||
if (array_key_exists('Core' , $constants)) {
|
||||
if (array_key_exists('Core', $constants)) {
|
||||
foreach ($constants['Core'] as $constant => $value) {
|
||||
if (substr($constant, 0, 2) == 'E_' && $value == $error_code) {
|
||||
return $constant;
|
||||
@@ -60,7 +60,7 @@ class Misc
|
||||
|
||||
/**
|
||||
* Determine if an error level is fatal (halts execution)
|
||||
*
|
||||
*
|
||||
* @param int $level
|
||||
* @return bool
|
||||
*/
|
||||
|
||||
@@ -88,7 +88,8 @@ class TemplateHelper
|
||||
$escaped = $this->escape($raw);
|
||||
return preg_replace(
|
||||
"@([A-z]+?://([-\w\.]+[-\w])+(:\d+)?(/([\w/_\.#-]*(\?\S+)?[^\.\s])?)?)@",
|
||||
"<a href=\"$1\" target=\"_blank\">$1</a>", $escaped
|
||||
"<a href=\"$1\" target=\"_blank\">$1</a>",
|
||||
$escaped
|
||||
);
|
||||
}
|
||||
|
||||
@@ -166,7 +167,7 @@ class TemplateHelper
|
||||
// exclude verbose information (e.g. exception stack traces)
|
||||
if (class_exists('Symfony\Component\VarDumper\Caster\Caster')) {
|
||||
$cloneVar = $this->getCloner()->cloneVar($value, Caster::EXCLUDE_VERBOSE);
|
||||
// Symfony VarDumper 2.6 Caster class dont exist.
|
||||
// Symfony VarDumper 2.6 Caster class dont exist.
|
||||
} else {
|
||||
$cloneVar = $this->getCloner()->cloneVar($value);
|
||||
}
|
||||
@@ -203,7 +204,7 @@ class TemplateHelper
|
||||
|
||||
if ($numFrames > 0) {
|
||||
$html = '<ol class="linenums">';
|
||||
foreach($frame->getArgs() as $j => $frameArg) {
|
||||
foreach ($frame->getArgs() as $j => $frameArg) {
|
||||
$html .= '<li>'. $this->dump($frameArg) .'</li>';
|
||||
}
|
||||
$html .= '</ol>';
|
||||
|
||||
Reference in New Issue
Block a user