Skip to content

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));
Copy link

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
@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.

2 participants