Skip to content

Commit

Permalink
Merge branch 'master' into solution
Browse files Browse the repository at this point in the history
  • Loading branch information
vjik authored Dec 24, 2024
2 parents 6e2ceb2 + 16a53fd commit b5e5ddf
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 18 deletions.
24 changes: 22 additions & 2 deletions .github/workflows/bc.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
on:
- pull_request
- push
pull_request:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- 'infection.json.dist'
- 'phpunit.xml.dist'
- 'psalm.xml'
push:
branches: ['master']
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- 'infection.json.dist'
- 'phpunit.xml.dist'
- 'psalm.xml'

name: backwards compatibility

jobs:
roave_bc_check:
uses: yiisoft/actions/.github/workflows/bc.yml@master
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
- 'psalm.xml'

push:
branches: ['master']
paths-ignore:
- 'docs/**'
- 'README.md'
Expand All @@ -24,8 +25,10 @@ name: build
jobs:
phpunit:
uses: yiisoft/actions/.github/workflows/phpunit.yml@master
secrets:
codecovToken: ${{ secrets.CODECOV_TOKEN }}
with:
os: >-
['ubuntu-latest', 'windows-latest']
php: >-
['8.0', '8.1', '8.2']
['8.0', '8.1', '8.2', '8.3']
3 changes: 2 additions & 1 deletion .github/workflows/composer-require-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
- 'psalm.xml'

push:
branches: ['master']
paths-ignore:
- 'docs/**'
- 'README.md'
Expand All @@ -30,4 +31,4 @@ jobs:
os: >-
['ubuntu-latest']
php: >-
['8.0', '8.1', '8.2']
['8.0', '8.1', '8.2', '8.3']
1 change: 1 addition & 0 deletions .github/workflows/mutation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
- 'psalm.xml'

push:
branches: ['master']
paths-ignore:
- 'docs/**'
- 'README.md'
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Yii Error Handler Change Log

## 3.3.1 under development
## 3.4.0 under development

- Enh #125: Add error code & show function arguments (@xepozz)
- Enh #130: Pass exception message instead of rendered exception to logger in `ErrorHandler` (@olegbaturin)
- Enh #133: Extract response generator from `ErrorCatcher` middleware into separate `ThrowableResponseFactory` class (@olegbaturin)

Expand Down
3 changes: 2 additions & 1 deletion src/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ public function register(): void
return true;
}

$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
$backtrace = debug_backtrace(0);

Check warning on line 137 in src/ErrorHandler.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.1-ubuntu-latest

Escaped Mutant for Mutator "DecrementInteger": --- Original +++ New @@ @@ // This error code is not included in error_reporting. return true; } - $backtrace = debug_backtrace(0); + $backtrace = debug_backtrace(-1); array_shift($backtrace); throw new ErrorException($message, $severity, $severity, $file, $line, null, $backtrace); });
array_shift($backtrace);
throw new ErrorException($message, $severity, $severity, $file, $line, null, $backtrace);
});

Expand Down
36 changes: 24 additions & 12 deletions src/Renderer/HtmlRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,22 +267,34 @@ public function renderCallStack(Throwable $t, array $trace = []): string
[],
);

$length = count($trace);
for ($i = 0; $i < $length; ++$i) {
$file = !empty($trace[$i]['file']) ? $trace[$i]['file'] : null;
$line = !empty($trace[$i]['line']) ? $trace[$i]['line'] : null;
$class = !empty($trace[$i]['class']) ? $trace[$i]['class'] : null;
$args = !empty($trace[$i]['args']) ? $trace[$i]['args'] : [];
$index = 1;
if ($t instanceof ErrorException) {
$index = 0;
}

foreach ($trace as $traceItem) {
$file = !empty($traceItem['file']) ? $traceItem['file'] : null;
$line = !empty($traceItem['line']) ? $traceItem['line'] : null;
$class = !empty($traceItem['class']) ? $traceItem['class'] : null;
$args = !empty($traceItem['args']) ? $traceItem['args'] : [];

$parameters = [];
$function = null;
if (!empty($trace[$i]['function']) && $trace[$i]['function'] !== 'unknown') {
$function = $trace[$i]['function'];
if ($class !== null && !str_contains($function, '{closure}')) {
$parameters = (new \ReflectionMethod($class, $function))->getParameters();
if (!empty($traceItem['function']) && $traceItem['function'] !== 'unknown') {
$function = $traceItem['function'];
if (!str_contains($function, '{closure}')) {
try {
if ($class !== null && class_exists($class)) {
$parameters = (new \ReflectionMethod($class, $function))->getParameters();
} elseif (function_exists($function)) {
$parameters = (new \ReflectionFunction($function))->getParameters();
}
} catch (\ReflectionException) {
// pass
}
}
}
$index = $i + 2;
$index++;

if ($this->isVendorFile($file)) {
$vendor[$index] = $this->renderCallStackItem(
Expand Down Expand Up @@ -599,7 +611,7 @@ private function groupVendorCallStackItems(array $items): array
$groupedItems[$groupIndex][$index] = $item;
}

/** @psalm-var array<int, array<int, string>> $groupedItems It's need for Psalm <=4.30 only. */
/** @psalm-var array<int, array<int, string>> $groupedItems It's needed for Psalm <=4.30 only. */

return $groupedItems;
}
Expand Down
1 change: 1 addition & 0 deletions templates/development.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
<?php else: ?>
<span><?= $exceptionClass ?></span>
<?php endif ?>
(Code #<?= $throwable->getCode() ?>)
</div>

<div class="exception-message">
Expand Down

0 comments on commit b5e5ddf

Please sign in to comment.