Skip to content

Commit c741ad8

Browse files
committed
refactor(ReportUsingCreator): optimize error reporting logic
- Replace container usage with static method call for error reporting - Add missing use statement for ExceptionNotify facade
1 parent 98f6984 commit c741ad8

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

rector.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@
111111
// __DIR__.'/src/OutputManager.php',
112112
],
113113
StaticClosureRector::class => [
114+
__DIR__.'/src/ReportUsingCreator.php',
114115
__DIR__.'/tests',
115116
],
116117
StaticArrowFunctionRector::class => [

src/ReportUsingCreator.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
namespace Guanguans\LaravelExceptionNotify;
1414

15+
use Guanguans\LaravelExceptionNotify\Facades\ExceptionNotify;
1516
use Illuminate\Contracts\Debug\ExceptionHandler;
1617

1718
/**
@@ -24,14 +25,14 @@ class ReportUsingCreator
2425
/**
2526
* @psalm-suppress UndefinedThisPropertyFetch
2627
* @psalm-suppress InaccessibleProperty
28+
*
29+
* @noinspection StaticClosureCanBeUsedInspection
30+
* @noinspection AnonymousFunctionStaticInspection
2731
*/
2832
public function __invoke(ExceptionHandler $exceptionHandler): \Closure
2933
{
3034
return function (\Throwable $throwable) use ($exceptionHandler): void {
31-
$this->container->make(ExceptionNotifyManager::class)->reportIf(
32-
$exceptionHandler->shouldReport($throwable),
33-
$throwable
34-
);
35+
ExceptionNotify::reportIf($exceptionHandler->shouldReport($throwable), $throwable);
3536
};
3637
}
3738
}

0 commit comments

Comments
 (0)