Skip to content

Commit 5363e11

Browse files
Naoraygithub-actions[bot]
authored andcommitted
Fix styling
1 parent 2530dd2 commit 5363e11

File tree

4 files changed

+27
-29
lines changed

4 files changed

+27
-29
lines changed

src/Issues/Formatters/ExceptionFormatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function formatTitle(Throwable $exception, string $level): string
6565

6666
private function formatMessage(string $message): string
6767
{
68-
if (!str_contains($message, 'Stack trace:')) {
68+
if (! str_contains($message, 'Stack trace:')) {
6969
return $message;
7070
}
7171

src/Issues/Formatters/StackTraceFormatter.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ public function format(string $stackTrace, bool $collapseVendorFrames = true): s
4343
/**
4444
* Stack trace lines start with #\d. Here we pad the numbers 0-9
4545
* with a preceding zero to keep everything in line visually.
46-
*
47-
* @param string $line
48-
* @return string
4946
*/
5047
public function padStackTraceLine(string $line): string
5148
{

tests/Issues/Formatters/ExceptionFormatterTest.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,14 @@
5959

6060
test('it properly formats exception with stack trace in message', function () {
6161
// Create a custom exception class that mimics our problematic behavior
62-
$exception = new class('Error message') extends Exception {
62+
$exception = new class('Error message') extends Exception
63+
{
6364
public function __construct()
6465
{
65-
parent::__construct("The calculation amount [123.45] does not match the expected total [456.78]. in /path/to/app/Calculations/Calculator.php:49
66+
parent::__construct('The calculation amount [123.45] does not match the expected total [456.78]. in /path/to/app/Calculations/Calculator.php:49
6667
Stack trace:
6768
#0 /path/to/app/Services/PaymentService.php(83): App\\Calculations\\Calculator->calculate()
68-
#1 /vendor/framework/src/Services/TransactionService.php(247): App\\Services\\PaymentService->process()");
69+
#1 /vendor/framework/src/Services/TransactionService.php(247): App\\Services\\PaymentService->process()');
6970
}
7071
};
7172

@@ -84,10 +85,10 @@ public function __construct()
8485

8586
test('it handles exceptions with string in context', function () {
8687
// Create a generic exception string
87-
$exceptionString = "The calculation amount [123.45] does not match the expected total [456.78]. in /path/to/app/Calculations/Calculator.php:49
88+
$exceptionString = 'The calculation amount [123.45] does not match the expected total [456.78]. in /path/to/app/Calculations/Calculator.php:49
8889
Stack trace:
8990
#0 /path/to/app/Services/PaymentService.php(83): App\\Calculations\\Calculator->calculate()
90-
#1 /vendor/framework/src/Services/TransactionService.php(247): App\\Services\\PaymentService->process()";
91+
#1 /vendor/framework/src/Services/TransactionService.php(247): App\\Services\\PaymentService->process()';
9192

9293
// Create a record with a string in the exception context
9394
$record = createLogRecord('Test message', ['exception' => $exceptionString]);

tests/Issues/Formatters/StackTraceFormatterTest.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
});
5959

6060
test('it replaces base path in stack traces', function () {
61-
$formatter = new StackTraceFormatter();
61+
$formatter = new StackTraceFormatter;
6262
$basePath = base_path();
6363

6464
$stackTrace = <<<TRACE
@@ -69,44 +69,44 @@
6969

7070
// Test simplified trace (with vendor frame collapsing)
7171
expect($formatter->format($stackTrace, true))
72-
->toBe(<<<TRACE
73-
#00 /app/Services/ImageService.php(25): Spatie\\Image\\Image->loadFile()
72+
->toBe(<<<'TRACE'
73+
#00 /app/Services/ImageService.php(25): Spatie\Image\Image->loadFile()
7474
[Vendor frames]
7575
TRACE
7676
);
7777

7878
// Test full trace (without vendor frame collapsing)
7979
expect($formatter->format($stackTrace, false))
80-
->toBe(<<<TRACE
81-
#00 /app/Services/ImageService.php(25): Spatie\\Image\\Image->loadFile()
82-
#01 /vendor/laravel/framework/src/Foundation/Application.php(1235): App\\Services\\ImageService->process()
83-
#02 /artisan(13): Illuminate\\Foundation\\Application->run()
80+
->toBe(<<<'TRACE'
81+
#00 /app/Services/ImageService.php(25): Spatie\Image\Image->loadFile()
82+
#01 /vendor/laravel/framework/src/Foundation/Application.php(1235): App\Services\ImageService->process()
83+
#02 /artisan(13): Illuminate\Foundation\Application->run()
8484
TRACE
8585
);
8686
});
8787

8888
test('it handles empty base path correctly', function () {
89-
$formatter = new StackTraceFormatter();
89+
$formatter = new StackTraceFormatter;
9090

91-
$stackTrace = <<<TRACE
91+
$stackTrace = <<<'TRACE'
9292
#0 /absolute/path/to/app/Services/ImageService.php(25): someMethod()
9393
#1 /vendor/package/src/File.php(10): otherMethod()
9494
TRACE;
9595

9696
$result = $formatter->format($stackTrace, true);
9797

9898
expect($result)
99-
->toBe(<<<TRACE
99+
->toBe(<<<'TRACE'
100100
#00 /absolute/path/to/app/Services/ImageService.php(25): someMethod()
101101
[Vendor frames]
102102
TRACE
103103
);
104104
});
105105

106106
test('it preserves non-stack-trace lines', function () {
107-
$formatter = new StackTraceFormatter();
107+
$formatter = new StackTraceFormatter;
108108

109-
$stackTrace = <<<TRACE
109+
$stackTrace = <<<'TRACE'
110110
[2024-03-21 12:00:00] Error: Something went wrong
111111
#0 /app/Services/Service.php(25): someMethod()
112112
#1 /vendor/package/src/File.php(10): otherMethod()
@@ -115,7 +115,7 @@
115115
$result = $formatter->format($stackTrace, true);
116116

117117
expect($result)
118-
->toBe(<<<TRACE
118+
->toBe(<<<'TRACE'
119119
[2024-03-21 12:00:00] Error: Something went wrong
120120
#00 /app/Services/Service.php(25): someMethod()
121121
[Vendor frames]
@@ -124,7 +124,7 @@
124124
});
125125

126126
test('it recognizes artisan lines as vendor frames', function () {
127-
$formatter = new StackTraceFormatter();
127+
$formatter = new StackTraceFormatter;
128128
$basePath = base_path();
129129

130130
$stackTrace = <<<TRACE
@@ -135,27 +135,27 @@
135135

136136
// Test simplified trace (with vendor frame collapsing)
137137
expect($formatter->format($stackTrace, true))
138-
->toBe(<<<TRACE
138+
->toBe(<<<'TRACE'
139139
#00 /app/Console/Commands/ImportCommand.php(25): handle()
140140
[Vendor frames]
141141
TRACE
142142
);
143143

144144
// Test that artisan lines are preserved in full trace
145145
expect($formatter->format($stackTrace, false))
146-
->toBe(<<<TRACE
146+
->toBe(<<<'TRACE'
147147
#00 /app/Console/Commands/ImportCommand.php(25): handle()
148-
#01 /artisan(13): Illuminate\\Foundation\\Application->run()
148+
#01 /artisan(13): Illuminate\Foundation\Application->run()
149149
#02 /artisan(37): require()
150150
TRACE
151151
);
152152
});
153153

154154
test('it collapses multiple artisan lines into single vendor frame', function () {
155-
$formatter = new StackTraceFormatter();
155+
$formatter = new StackTraceFormatter;
156156

157-
$stackTrace = <<<TRACE
158-
#0 /artisan(13): Illuminate\\Foundation\\Application->run()
157+
$stackTrace = <<<'TRACE'
158+
#0 /artisan(13): Illuminate\Foundation\Application->run()
159159
#1 /vendor/laravel/framework/src/Foundation/Application.php(1235): handle()
160160
#2 /artisan(37): require()
161161
TRACE;

0 commit comments

Comments
 (0)