Skip to content

Commit f56840c

Browse files
committed
Pass trace as string into non-ignorable exception Error metadata
1 parent 5172ca3 commit f56840c

File tree

5 files changed

+8
-0
lines changed

5 files changed

+8
-0
lines changed

src/Analyser/Analyser.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ public function analyse(
110110
->withIdentifier('phpstan.internal')
111111
->withMetadata([
112112
InternalError::STACK_TRACE_METADATA_KEY => InternalError::prepareTrace($t),
113+
InternalError::STACK_TRACE_AS_STRING_METADATA_KEY => $t->getTraceAsString(),
113114
]);
114115
if ($internalErrorsCount >= $this->internalErrorsCountLimit) {
115116
$reachedInternalErrorsCountLimit = true;

src/Analyser/AnalyserResultFinalizer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public function finalize(AnalyserResult $analyserResult, bool $onlyFiles): Final
5050
->withIdentifier('phpstan.internal')
5151
->withMetadata([
5252
InternalError::STACK_TRACE_METADATA_KEY => InternalError::prepareTrace($e),
53+
InternalError::STACK_TRACE_AS_STRING_METADATA_KEY => $e->getTraceAsString(),
5354
]);
5455
continue;
5556
} catch (IdentifierNotFound $e) {

src/Analyser/FileAnalyser.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ public function analyseFile(
119119
->withIdentifier('phpstan.internal')
120120
->withMetadata([
121121
InternalError::STACK_TRACE_METADATA_KEY => InternalError::prepareTrace($e),
122+
InternalError::STACK_TRACE_AS_STRING_METADATA_KEY => $e->getTraceAsString(),
122123
]);
123124
continue;
124125
} catch (IdentifierNotFound $e) {
@@ -147,6 +148,7 @@ public function analyseFile(
147148
->withIdentifier('phpstan.internal')
148149
->withMetadata([
149150
InternalError::STACK_TRACE_METADATA_KEY => InternalError::prepareTrace($e),
151+
InternalError::STACK_TRACE_AS_STRING_METADATA_KEY => $e->getTraceAsString(),
150152
]);
151153
continue;
152154
} catch (IdentifierNotFound $e) {
@@ -217,6 +219,7 @@ public function analyseFile(
217219
->withIdentifier('phpstan.internal')
218220
->withMetadata([
219221
InternalError::STACK_TRACE_METADATA_KEY => InternalError::prepareTrace($e),
222+
InternalError::STACK_TRACE_AS_STRING_METADATA_KEY => $e->getTraceAsString(),
220223
]);
221224
} catch (IdentifierNotFound $e) {
222225
$fileErrors[] = (new Error(sprintf('Reflection error: %s not found.', $e->getIdentifier()->getName()), $file, null, $e, null, null, 'Learn more at https://phpstan.org/user-guide/discovering-symbols'))->withIdentifier('phpstan.reflection');

src/Analyser/InternalError.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ class InternalError implements JsonSerializable
1616

1717
public const STACK_TRACE_METADATA_KEY = 'stackTrace';
1818

19+
public const STACK_TRACE_AS_STRING_METADATA_KEY = 'stackTraceAsString';
20+
1921
/**
2022
* @param Trace $trace
2123
*/

src/PhpDoc/StubValidator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ static function (): void {
134134
->withIdentifier('phpstan.internal')
135135
->withMetadata([
136136
InternalError::STACK_TRACE_METADATA_KEY => InternalError::prepareTrace($e),
137+
InternalError::STACK_TRACE_AS_STRING_METADATA_KEY => $e->getTraceAsString(),
137138
]);
138139
}
139140
}

0 commit comments

Comments
 (0)