Skip to content

Commit 6094c42

Browse files
authored
Use the nullsafe operator in SessionGuard (#41561)
1 parent 82f3ccf commit 6094c42

File tree

1 file changed

+7
-33
lines changed

1 file changed

+7
-33
lines changed

src/Illuminate/Auth/SessionGuard.php

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -685,9 +685,7 @@ protected function rehashUserPassword($password, $attribute)
685685
*/
686686
public function attempting($callback)
687687
{
688-
if (isset($this->events)) {
689-
$this->events->listen(Events\Attempting::class, $callback);
690-
}
688+
$this->events?->listen(Events\Attempting::class, $callback);
691689
}
692690

693691
/**
@@ -699,11 +697,7 @@ public function attempting($callback)
699697
*/
700698
protected function fireAttemptEvent(array $credentials, $remember = false)
701699
{
702-
if (isset($this->events)) {
703-
$this->events->dispatch(new Attempting(
704-
$this->name, $credentials, $remember
705-
));
706-
}
700+
$this->events?->dispatch(new Attempting($this->name, $credentials, $remember));
707701
}
708702

709703
/**
@@ -714,11 +708,7 @@ protected function fireAttemptEvent(array $credentials, $remember = false)
714708
*/
715709
protected function fireValidatedEvent($user)
716710
{
717-
if (isset($this->events)) {
718-
$this->events->dispatch(new Validated(
719-
$this->name, $user
720-
));
721-
}
711+
$this->events?->dispatch(new Validated($this->name, $user));
722712
}
723713

724714
/**
@@ -730,11 +720,7 @@ protected function fireValidatedEvent($user)
730720
*/
731721
protected function fireLoginEvent($user, $remember = false)
732722
{
733-
if (isset($this->events)) {
734-
$this->events->dispatch(new Login(
735-
$this->name, $user, $remember
736-
));
737-
}
723+
$this->events?->dispatch(new Login($this->name, $user, $remember));
738724
}
739725

740726
/**
@@ -745,11 +731,7 @@ protected function fireLoginEvent($user, $remember = false)
745731
*/
746732
protected function fireAuthenticatedEvent($user)
747733
{
748-
if (isset($this->events)) {
749-
$this->events->dispatch(new Authenticated(
750-
$this->name, $user
751-
));
752-
}
734+
$this->events?->dispatch(new Authenticated($this->name, $user));
753735
}
754736

755737
/**
@@ -760,11 +742,7 @@ protected function fireAuthenticatedEvent($user)
760742
*/
761743
protected function fireOtherDeviceLogoutEvent($user)
762744
{
763-
if (isset($this->events)) {
764-
$this->events->dispatch(new OtherDeviceLogout(
765-
$this->name, $user
766-
));
767-
}
745+
$this->events?->dispatch(new OtherDeviceLogout($this->name, $user));
768746
}
769747

770748
/**
@@ -776,11 +754,7 @@ protected function fireOtherDeviceLogoutEvent($user)
776754
*/
777755
protected function fireFailedEvent($user, array $credentials)
778756
{
779-
if (isset($this->events)) {
780-
$this->events->dispatch(new Failed(
781-
$this->name, $user, $credentials
782-
));
783-
}
757+
$this->events?->dispatch(new Failed($this->name, $user, $credentials));
784758
}
785759

786760
/**

0 commit comments

Comments
 (0)