Skip to content

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.

* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants