Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
roxblnfk committed Mar 28, 2022
1 parent c49cc44 commit ed228c5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
17 changes: 7 additions & 10 deletions src/Exceptions/src/ConsoleHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,10 @@ public function setColorsSupport(bool $enabled = true): void

public function renderException(\Throwable $e, int $verbosity = self::VERBOSITY_BASIC): string
{
$result = '';

if ($e instanceof \Error) {
$result .= $this->renderHeader('[' . $e::class . "]\n" . $e->getMessage(), 'bg:magenta,white');
} else {
$result .= $this->renderHeader('[' . $e::class . "]\n" . $e->getMessage(), 'bg:red,white');
}
$result = $this->renderHeader(
\sprintf("[%s]\n%s", $e::class, $e->getMessage()),
$e instanceof \Error ? 'bg:magenta,white' : 'bg:red,white'
);

$result .= $this->format(
"<yellow>in</reset> <green>%s</reset><yellow>:</reset><white>%s</reset>\n",
Expand Down Expand Up @@ -92,7 +89,7 @@ private function renderHeader(string $title, string $style, int $padding = 0): s
$lines = \explode("\n", \str_replace("\r", '', $title));

$length = 0;
\array_walk($lines, function ($v) use (&$length): void {
\array_walk($lines, static function ($v) use (&$length): void {
$length = max($length, \mb_strlen($v));
});

Expand Down Expand Up @@ -123,7 +120,7 @@ private function renderTrace(\Throwable $e, Highlighter $h = null): string
$result = $this->format("\n<red>Exception Trace:</reset>\n");

foreach ($stacktrace as $trace) {
if (isset($trace['type']) && isset($trace['class'])) {
if (isset($trace['type'], $trace['class'])) {
$line = $this->format(
' <white>%s%s%s()</reset>',
$trace['class'],
Expand Down Expand Up @@ -153,7 +150,7 @@ private function renderTrace(\Throwable $e, Highlighter $h = null): string

$result .= $line . "\n";

if (!empty($h) && !empty($trace['file'])) {
if ($h !== null && !empty($trace['file'])) {
$result .= $h->highlightLines(
\file_get_contents($trace['file']),
$trace['line'],
Expand Down
10 changes: 7 additions & 3 deletions src/Exceptions/src/PlainHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ final class PlainHandler extends AbstractHandler

public function renderException(\Throwable $e, int $verbosity = self::VERBOSITY_BASIC): string
{
$result = '';
$result .= '[' . $e::class . "]\n" . $e->getMessage();
$result .= \sprintf(" in %s:%s\n", $e->getFile(), $e->getLine());
$result = \sprintf(
"[%s]\n%s in %s:%s\n",
$e::class,
$e->getMessage(),
$e->getFile(),
$e->getLine()
);

if ($verbosity >= self::VERBOSITY_DEBUG) {
$result .= $this->renderTrace($e, new Highlighter(new PlainStyle()));
Expand Down
2 changes: 1 addition & 1 deletion src/Files/src/Files.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function ensureDirectory(
}

//Directories always executable
$mode |= 0111;
$mode |= 0o111;
if (\is_dir($directory)) {
//Exists :(
return $this->setPermissions($directory, $mode);
Expand Down

0 comments on commit ed228c5

Please sign in to comment.