Skip to content

Commit b5e5ddf

Browse files
authored
Merge branch 'master' into solution
2 parents 6e2ceb2 + 16a53fd commit b5e5ddf

File tree

8 files changed

+58
-18
lines changed

8 files changed

+58
-18
lines changed

.github/workflows/bc.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,28 @@
11
on:
2-
- pull_request
3-
- push
2+
pull_request:
3+
paths-ignore:
4+
- 'docs/**'
5+
- 'README.md'
6+
- 'CHANGELOG.md'
7+
- '.gitignore'
8+
- '.gitattributes'
9+
- 'infection.json.dist'
10+
- 'phpunit.xml.dist'
11+
- 'psalm.xml'
12+
push:
13+
branches: ['master']
14+
paths-ignore:
15+
- 'docs/**'
16+
- 'README.md'
17+
- 'CHANGELOG.md'
18+
- '.gitignore'
19+
- '.gitattributes'
20+
- 'infection.json.dist'
21+
- 'phpunit.xml.dist'
22+
- 'psalm.xml'
423

524
name: backwards compatibility
25+
626
jobs:
727
roave_bc_check:
828
uses: yiisoft/actions/.github/workflows/bc.yml@master

.github/workflows/build.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010
- 'psalm.xml'
1111

1212
push:
13+
branches: ['master']
1314
paths-ignore:
1415
- 'docs/**'
1516
- 'README.md'
@@ -24,8 +25,10 @@ name: build
2425
jobs:
2526
phpunit:
2627
uses: yiisoft/actions/.github/workflows/phpunit.yml@master
28+
secrets:
29+
codecovToken: ${{ secrets.CODECOV_TOKEN }}
2730
with:
2831
os: >-
2932
['ubuntu-latest', 'windows-latest']
3033
php: >-
31-
['8.0', '8.1', '8.2']
34+
['8.0', '8.1', '8.2', '8.3']

.github/workflows/composer-require-checker.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ on:
1111
- 'psalm.xml'
1212

1313
push:
14+
branches: ['master']
1415
paths-ignore:
1516
- 'docs/**'
1617
- 'README.md'
@@ -30,4 +31,4 @@ jobs:
3031
os: >-
3132
['ubuntu-latest']
3233
php: >-
33-
['8.0', '8.1', '8.2']
34+
['8.0', '8.1', '8.2', '8.3']

.github/workflows/mutation.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
- 'psalm.xml'
1010

1111
push:
12+
branches: ['master']
1213
paths-ignore:
1314
- 'docs/**'
1415
- 'README.md'

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Yii Error Handler Change Log
22

3-
## 3.3.1 under development
3+
## 3.4.0 under development
44

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

src/ErrorHandler.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ public function register(): void
134134
return true;
135135
}
136136

137-
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
137+
$backtrace = debug_backtrace(0);
138+
array_shift($backtrace);
138139
throw new ErrorException($message, $severity, $severity, $file, $line, null, $backtrace);
139140
});
140141

src/Renderer/HtmlRenderer.php

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -267,22 +267,34 @@ public function renderCallStack(Throwable $t, array $trace = []): string
267267
[],
268268
);
269269

270-
$length = count($trace);
271-
for ($i = 0; $i < $length; ++$i) {
272-
$file = !empty($trace[$i]['file']) ? $trace[$i]['file'] : null;
273-
$line = !empty($trace[$i]['line']) ? $trace[$i]['line'] : null;
274-
$class = !empty($trace[$i]['class']) ? $trace[$i]['class'] : null;
275-
$args = !empty($trace[$i]['args']) ? $trace[$i]['args'] : [];
270+
$index = 1;
271+
if ($t instanceof ErrorException) {
272+
$index = 0;
273+
}
274+
275+
foreach ($trace as $traceItem) {
276+
$file = !empty($traceItem['file']) ? $traceItem['file'] : null;
277+
$line = !empty($traceItem['line']) ? $traceItem['line'] : null;
278+
$class = !empty($traceItem['class']) ? $traceItem['class'] : null;
279+
$args = !empty($traceItem['args']) ? $traceItem['args'] : [];
276280

277281
$parameters = [];
278282
$function = null;
279-
if (!empty($trace[$i]['function']) && $trace[$i]['function'] !== 'unknown') {
280-
$function = $trace[$i]['function'];
281-
if ($class !== null && !str_contains($function, '{closure}')) {
282-
$parameters = (new \ReflectionMethod($class, $function))->getParameters();
283+
if (!empty($traceItem['function']) && $traceItem['function'] !== 'unknown') {
284+
$function = $traceItem['function'];
285+
if (!str_contains($function, '{closure}')) {
286+
try {
287+
if ($class !== null && class_exists($class)) {
288+
$parameters = (new \ReflectionMethod($class, $function))->getParameters();
289+
} elseif (function_exists($function)) {
290+
$parameters = (new \ReflectionFunction($function))->getParameters();
291+
}
292+
} catch (\ReflectionException) {
293+
// pass
294+
}
283295
}
284296
}
285-
$index = $i + 2;
297+
$index++;
286298

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

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

604616
return $groupedItems;
605617
}

templates/development.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
<?php else: ?>
7474
<span><?= $exceptionClass ?></span>
7575
<?php endif ?>
76+
(Code #<?= $throwable->getCode() ?>)
7677
</div>
7778

7879
<div class="exception-message">

0 commit comments

Comments
 (0)