Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: properly bind singleton #291

Merged
merged 1 commit into from Jul 14, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/DumpRecorder/DumpRecorder.php
Expand Up @@ -26,7 +26,9 @@ public function register(): self
{
$multiDumpHandler = new MultiDumpHandler();

$this->app->singleton(MultiDumpHandler::class, $multiDumpHandler);
$this->app->singleton(MultiDumpHandler::class, function () use ($multiDumpHandler) {
return $multiDumpHandler;
});
Comment on lines -29 to +31
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't this just be ?

$this->app->instance(MultiDumpHandler::class, $multiDumpHandler);

This would be also more clearly convey the intend here. The closure factory looks redundant.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, i always forget about instance -- both should have the same effect


$previousHandler = VarDumper::setHandler(function ($var) use ($multiDumpHandler) {
$multiDumpHandler->dump($var);
Expand Down