From 94ce0b03ce63aab86018fb6a49b9136de6958066 Mon Sep 17 00:00:00 2001 From: Warrick Bayman Date: Thu, 4 Nov 2021 00:04:29 +0200 Subject: [PATCH] Apply fixes from StyleCI (#25) --- src/Contracts/DeadboltServiceInterface.php | 6 ++--- src/Contracts/UserInterface.php | 12 +++++++-- src/DeadboltService.php | 6 ++--- src/Drivers/ArrayDriver.php | 6 ++--- src/Exceptions/NoSuchPermissionException.php | 2 +- src/User.php | 26 ++++++++++++++------ src/UserCollection.php | 5 ++-- tests/EloquentDriver.php | 3 +-- 8 files changed, 42 insertions(+), 24 deletions(-) diff --git a/src/Contracts/DeadboltServiceInterface.php b/src/Contracts/DeadboltServiceInterface.php index d6b2bc8..6f78e70 100644 --- a/src/Contracts/DeadboltServiceInterface.php +++ b/src/Contracts/DeadboltServiceInterface.php @@ -12,14 +12,14 @@ interface DeadboltServiceInterface { /** - * @param array $config + * @param array $config */ public function __construct(array $config); /** * A user. * - * @param Model $model + * @param Model $model * @return User */ public function user(Model $model): User; @@ -35,7 +35,7 @@ public function users(...$users): UserCollection; /** * Set permissions the driver. * - * @param DriverInterface $driver + * @param DriverInterface $driver * @return DeadboltServiceInterface */ public function driver(DriverInterface $driver): DeadboltServiceInterface; diff --git a/src/Contracts/UserInterface.php b/src/Contracts/UserInterface.php index 4f08d77..df8c500 100644 --- a/src/Contracts/UserInterface.php +++ b/src/Contracts/UserInterface.php @@ -16,8 +16,9 @@ public function __construct(Model $user, array $permissions, array $config); /** * Give the specified permissions. * - * @param mixed ...$names + * @param mixed ...$names * @return UserInterface + * * @throws JsonException|NoSuchPermissionException */ public function give(...$names): UserInterface; @@ -26,6 +27,7 @@ public function give(...$names): UserInterface; * Make a super user. * * @return UserInterface + * * @throws JsonException|NoSuchPermissionException */ public function super(): UserInterface; @@ -35,6 +37,7 @@ public function super(): UserInterface; * * @param mixed ...$names * @return UserInterface + * * @throws JsonException */ public function revoke(...$names): UserInterface; @@ -49,7 +52,7 @@ public function revokeAll(): UserInterface; /** * Sync permissions with the names provided. * - * @param mixed ...$names + * @param mixed ...$names * @return UserInterface */ public function sync(...$names): UserInterface; @@ -66,6 +69,7 @@ public function save(): UserInterface; * * @param string $permission * @return bool + * * @throws JsonException */ public function has(string $permission): bool; @@ -75,6 +79,7 @@ public function has(string $permission): bool; * * @param mixed ...$permissions * @return bool + * * @throws JsonException */ public function hasAll(...$permissions): bool; @@ -84,6 +89,7 @@ public function hasAll(...$permissions): bool; * * @param mixed ...$permissions * @return bool + * * @throws JsonException */ public function hasAny(...$permissions): bool; @@ -93,6 +99,7 @@ public function hasAny(...$permissions): bool; * * @param mixed ...$permissions * @return bool + * * @throws JsonException */ public function hasNone(...$permissions): bool; @@ -101,6 +108,7 @@ public function hasNone(...$permissions): bool; * Get an array of permissions assigned to the user. * * @return array + * * @throws JsonException */ public function all(): array; diff --git a/src/DeadboltService.php b/src/DeadboltService.php index ae73fc3..5e89184 100644 --- a/src/DeadboltService.php +++ b/src/DeadboltService.php @@ -25,7 +25,7 @@ class DeadboltService implements DeadboltServiceInterface protected $driver; /** - * @param array $config + * @param array $config */ public function __construct(array $config) { @@ -41,7 +41,7 @@ public function __construct(array $config) /** * A user. * - * @param Model $model + * @param Model $model * @return User */ public function user(Model $model): User @@ -65,7 +65,7 @@ public function users(...$users): UserCollection /** * Set permissions the driver. * - * @param DriverInterface $driver + * @param DriverInterface $driver * @return DeadboltServiceInterface */ public function driver(DriverInterface $driver): DeadboltServiceInterface diff --git a/src/Drivers/ArrayDriver.php b/src/Drivers/ArrayDriver.php index 6cea2f1..d89648b 100644 --- a/src/Drivers/ArrayDriver.php +++ b/src/Drivers/ArrayDriver.php @@ -15,7 +15,7 @@ class ArrayDriver implements DriverInterface protected $config; /** - * @param array $config + * @param array $config */ public function __construct(array $config) { @@ -37,7 +37,7 @@ public function permissions(): array /** * Get the names of the permissions without descriptions. * - * @param array $permissions + * @param array $permissions * @return array */ protected function getPermissionNames(array $permissions): array @@ -54,7 +54,7 @@ protected function getPermissionNames(array $permissions): array /** * Return the permission names with the descriptions. * - * @param array $permissions + * @param array $permissions * @return array */ protected function getDescriptions(array $permissions): array diff --git a/src/Exceptions/NoSuchPermissionException.php b/src/Exceptions/NoSuchPermissionException.php index 251ed39..24cfc8d 100644 --- a/src/Exceptions/NoSuchPermissionException.php +++ b/src/Exceptions/NoSuchPermissionException.php @@ -7,7 +7,7 @@ class NoSuchPermissionException extends \Exception { /** - * @param string $permission + * @param string $permission */ public function __construct(string $permission) { diff --git a/src/User.php b/src/User.php index 5d6686b..fda1889 100644 --- a/src/User.php +++ b/src/User.php @@ -26,9 +26,9 @@ class User implements UserInterface protected $permissions; /** - * @param Model $user - * @param array $permissions - * @param array $config + * @param Model $user + * @param array $permissions + * @param array $config */ public function __construct(Model $user, array $permissions, array $config) { @@ -40,8 +40,9 @@ public function __construct(Model $user, array $permissions, array $config) /** * Give the specified permissions. * - * @param mixed ...$names + * @param mixed ...$names * @return UserInterface + * * @throws JsonException|NoSuchPermissionException */ public function give(...$names): UserInterface @@ -60,7 +61,7 @@ public function give(...$names): UserInterface /** * Merge the specified permissions with the current permissions. * - * @param array $permissions + * @param array $permissions * @return UserInterface */ protected function assignPermissions(array $permissions): UserInterface @@ -79,6 +80,7 @@ protected function permissionsAreCast(): bool * Make a super user. * * @return UserInterface + * * @throws JsonException|NoSuchPermissionException */ public function super(): UserInterface @@ -91,6 +93,7 @@ public function super(): UserInterface * * @param mixed ...$names * @return UserInterface + * * @throws JsonException */ public function revoke(...$names): UserInterface @@ -115,7 +118,7 @@ public function revokeAll(): UserInterface /** * Sync permissions with the names provided. * - * @param mixed ...$names + * @param mixed ...$names * @return UserInterface */ public function sync(...$names): UserInterface @@ -138,8 +141,9 @@ public function save(): UserInterface /** * Check if an array is defined. * - * @param string $permission + * @param string $permission * @return bool + * * @throws NoSuchPermissionException */ protected function exists(string $permission): bool @@ -154,7 +158,7 @@ protected function exists(string $permission): bool /** * Check if the given name is a permission. * - * @param string $name + * @param string $name * @return bool */ protected function isPermission(string $name): bool @@ -167,6 +171,7 @@ protected function isPermission(string $name): bool * * @param string $permission * @return bool + * * @throws JsonException */ public function has(string $permission): bool @@ -178,6 +183,7 @@ public function has(string $permission): bool * Get the permissions currently assigned to the user. * * @return array + * * @throws JsonException */ protected function userPermissions(bool $refresh = false): array @@ -195,6 +201,7 @@ protected function userPermissions(bool $refresh = false): array * * @param mixed ...$permissions * @return bool + * * @throws JsonException */ public function hasAll(...$permissions): bool @@ -215,6 +222,7 @@ public function hasAll(...$permissions): bool * * @param mixed ...$permissions * @return bool + * * @throws JsonException */ public function hasAny(...$permissions): bool @@ -235,6 +243,7 @@ public function hasAny(...$permissions): bool * * @param mixed ...$permissions * @return bool + * * @throws JsonException */ public function hasNone(...$permissions): bool @@ -246,6 +255,7 @@ public function hasNone(...$permissions): bool * Get an array of permissions assigned to the user. * * @return array + * * @throws JsonException */ public function all(): array diff --git a/src/UserCollection.php b/src/UserCollection.php index c15601a..64187ed 100644 --- a/src/UserCollection.php +++ b/src/UserCollection.php @@ -107,8 +107,9 @@ public function save(): UserCollectionInterface /** * Call the. - * @param string $name - * @param mixed|null $arguments + * + * @param string $name + * @param mixed|null $arguments * @return UserCollectionInterface */ protected function callOnEachUser(string $name, $arguments = null): UserCollectionInterface diff --git a/tests/EloquentDriver.php b/tests/EloquentDriver.php index 0f8848c..0b28029 100644 --- a/tests/EloquentDriver.php +++ b/tests/EloquentDriver.php @@ -10,8 +10,7 @@ class EloquentDriver implements DriverInterface { public function permissions(): array { - return Permission - ::select(['name', 'description']) + return Permission::select(['name', 'description']) ->pluck('description', 'name') ->toArray(); }