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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.x] Use nullsafe operator for event dispatcher #52024

Merged
merged 1 commit into from
Jul 5, 2024

Conversation

seriquynh
Copy link
Contributor

  • Nullsafe operator for the $events property already used in Illuminate\Redis and Illuminate\Auth, so we can change other similar null check conditions as well.
  • The \Illuminate\Log\Logger::fireLogEvent method can also use nullsafe operator for $dispatcher.

if ($this->events) {
$this->events->dispatch(new PasswordResetLinkSent($user));
}
$this->events?->dispatch(new PasswordResetLinkSent($user));

Choose a reason for hiding this comment

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

$this->events is not typed hinted as an \Illuminate\Contracts\Events\Dispatcher and because of this the proper check would be:

if ($this->events instanceof \Illuminate\Contracts\Events\Dispatcher) {

But I don't expect this observation to be taken into consideration so take it as FYI only :)

@taylorotwell taylorotwell merged commit 7d9a206 into laravel:11.x Jul 5, 2024
30 checks passed
@seriquynh seriquynh deleted the nullsafe-operator branch July 5, 2024 23:11
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.

None yet

3 participants