Skip to content
New issue

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

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix docblock for Model::getEventDispatcher() #52602

Merged
merged 4 commits into from
Aug 31, 2024

Conversation

inmula
Copy link
Contributor

@inmula inmula commented Aug 29, 2024

The static::$dispatcher property may be null after using Model::unsetEventDispatcher(). The docblock for Model::getEventDispatcher and the docblock for the property itself should reflect that.

This fix avoids warnings from static analysers such as PHPstan when using the getEventDispatcher method:

Using nullsafe method call on non-nullable type Illuminate\Contracts\Events\Dispatcher. Use -> instead.

@@ -399,7 +399,7 @@ public function dispatchesEvents()
/**
* Get the event dispatcher instance.
*
* @return \Illuminate\Contracts\Events\Dispatcher
* @return ?\Illuminate\Contracts\Events\Dispatcher
Copy link
Member

Choose a reason for hiding this comment

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

We use |null everywhere instead.

@taylorotwell taylorotwell merged commit 5ac2aa9 into laravel:11.x Aug 31, 2024
17 checks passed
@inmula inmula deleted the dispatcher-nullable branch September 4, 2024 07:14
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants