Skip to content

Commit eccdf35

Browse files
committed
fix: patch up PHP 7.4 issues
1 parent cd1e317 commit eccdf35

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/Auth.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ public function middleware(string $middleware, callable $callback)
665665

666666
if ($middleware === 'is') {
667667
return app()->registerMiddleware('is', function ($role) use ($callback) {
668-
if (!$this->user() || $this->user()?->isNot($role)) {
668+
if (!$this->user() || ($this->user() && $this->user()->isNot($role))) {
669669
$callback($role);
670670
exit;
671671
}
@@ -674,7 +674,7 @@ public function middleware(string $middleware, callable $callback)
674674

675675
if ($middleware === 'isNot') {
676676
return app()->registerMiddleware('isNot', function ($role) use ($callback) {
677-
if (!$this->user() || $this->user()?->is($role)) {
677+
if (!$this->user() || ($this->user() && $this->user()->is($role))) {
678678
$callback($role);
679679
exit;
680680
}
@@ -683,7 +683,7 @@ public function middleware(string $middleware, callable $callback)
683683

684684
if ($middleware === 'can') {
685685
return app()->registerMiddleware('can', function ($role) use ($callback) {
686-
if (!$this->user() || $this->user()?->cannot($role)) {
686+
if (!$this->user() || ($this->user() && $this->user()->cannot($role))) {
687687
$callback($role);
688688
exit;
689689
}
@@ -692,7 +692,7 @@ public function middleware(string $middleware, callable $callback)
692692

693693
if ($middleware === 'cannot') {
694694
return app()->registerMiddleware('cannot', function ($role) use ($callback) {
695-
if (!$this->user() || $this->user()?->can($role)) {
695+
if (!$this->user() || ($this->user() && $this->user()->can($role))) {
696696
$callback($role);
697697
exit;
698698
}

src/Auth/UsesRoles.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function is($role): bool
8686
return count(array_intersect($role, $this->roles)) > 0;
8787
}
8888

89-
return in_array($role, haystack: $this->roles);
89+
return in_array($role, $this->roles);
9090
}
9191

9292
/**

0 commit comments

Comments
 (0)