diff --git a/src/Models/Permission.php b/src/Models/Permission.php index 95df94fb..d23d15ac 100644 --- a/src/Models/Permission.php +++ b/src/Models/Permission.php @@ -86,7 +86,7 @@ public function users(): BelongsToMany * * @throws PermissionDoesNotExist */ - public static function findByName(string $name, string $guardName = null): PermissionContract + public static function findByName(string $name, ?string $guardName = null): PermissionContract { $guardName = $guardName ?? Guard::getDefaultName(static::class); $permission = static::getPermission(['name' => $name, 'guard_name' => $guardName]); @@ -104,7 +104,7 @@ public static function findByName(string $name, string $guardName = null): Permi * * @throws PermissionDoesNotExist */ - public static function findById(int|string $id, string $guardName = null): PermissionContract + public static function findById(int|string $id, ?string $guardName = null): PermissionContract { $guardName = $guardName ?? Guard::getDefaultName(static::class); $permission = static::getPermission([(new static())->getKeyName() => $id, 'guard_name' => $guardName]); @@ -121,7 +121,7 @@ public static function findById(int|string $id, string $guardName = null): Permi * * @return PermissionContract|Permission */ - public static function findOrCreate(string $name, string $guardName = null): PermissionContract + public static function findOrCreate(string $name, ?string $guardName = null): PermissionContract { $guardName = $guardName ?? Guard::getDefaultName(static::class); $permission = static::getPermission(['name' => $name, 'guard_name' => $guardName]); diff --git a/src/Models/Role.php b/src/Models/Role.php index 4fd6e782..4b2e48ff 100644 --- a/src/Models/Role.php +++ b/src/Models/Role.php @@ -95,7 +95,7 @@ public function users(): BelongsToMany * * @throws RoleDoesNotExist */ - public static function findByName(string $name, string $guardName = null): RoleContract + public static function findByName(string $name, ?string $guardName = null): RoleContract { $guardName = $guardName ?? Guard::getDefaultName(static::class); @@ -113,7 +113,7 @@ public static function findByName(string $name, string $guardName = null): RoleC * * @return RoleContract|Role */ - public static function findById(int|string $id, string $guardName = null): RoleContract + public static function findById(int|string $id, ?string $guardName = null): RoleContract { $guardName = $guardName ?? Guard::getDefaultName(static::class); @@ -131,7 +131,7 @@ public static function findById(int|string $id, string $guardName = null): RoleC * * @return RoleContract|Role */ - public static function findOrCreate(string $name, string $guardName = null): RoleContract + public static function findOrCreate(string $name, ?string $guardName = null): RoleContract { $guardName = $guardName ?? Guard::getDefaultName(static::class); @@ -176,7 +176,7 @@ protected static function findByParam(array $params = []): ?RoleContract * * @throws PermissionDoesNotExist|GuardDoesNotMatch */ - public function hasPermissionTo($permission, string $guardName = null): bool + public function hasPermissionTo($permission, ?string $guardName = null): bool { if ($this->getWildcardClass()) { return $this->hasWildcardPermission($permission, $guardName); diff --git a/src/PermissionRegistrar.php b/src/PermissionRegistrar.php index 3c3b0d7f..1300def8 100644 --- a/src/PermissionRegistrar.php +++ b/src/PermissionRegistrar.php @@ -145,7 +145,7 @@ public function forgetCachedPermissions() return $this->cache->forget($this->cacheKey); } - public function forgetWildcardPermissionIndex(Model $record = null): void + public function forgetWildcardPermissionIndex(?Model $record = null): void { if ($record) { unset($this->wildcardPermissionsIndex[get_class($record)][$record->getKey()]); diff --git a/src/Traits/HasRoles.php b/src/Traits/HasRoles.php index a8f183c0..97f87ba9 100644 --- a/src/Traits/HasRoles.php +++ b/src/Traits/HasRoles.php @@ -218,7 +218,7 @@ public function syncRoles(...$roles) * * @param string|int|array|Role|Collection|\BackedEnum $roles */ - public function hasRole($roles, string $guard = null): bool + public function hasRole($roles, ?string $guard = null): bool { $this->loadMissing('roles'); @@ -282,7 +282,7 @@ public function hasAnyRole(...$roles): bool * * @param string|array|Role|Collection|\BackedEnum $roles */ - public function hasAllRoles($roles, string $guard = null): bool + public function hasAllRoles($roles, ?string $guard = null): bool { $this->loadMissing('roles'); @@ -324,7 +324,7 @@ public function hasAllRoles($roles, string $guard = null): bool * * @param string|array|Role|Collection $roles */ - public function hasExactRoles($roles, string $guard = null): bool + public function hasExactRoles($roles, ?string $guard = null): bool { $this->loadMissing('roles');