1 | <?php |
||
7 | trait HasPermissions |
||
8 | { |
||
9 | /** |
||
10 | * Grant the given permission(s) to a role. |
||
11 | * |
||
12 | * @param string|array|Permission|\Illuminate\Support\Collection $permissions |
||
13 | * |
||
14 | * @return HasPermissions |
||
|
|||
15 | */ |
||
16 | public function givePermissionTo(...$permissions) |
||
31 | |||
32 | /** |
||
33 | * Remove all current permissions and set the given ones. |
||
34 | * |
||
35 | * @param array ...$permissions |
||
36 | */ |
||
37 | public function syncPermissions(...$permissions) |
||
49 | |||
50 | /** |
||
51 | * Revoke the given permission. |
||
52 | * |
||
53 | * @param $permission |
||
54 | * |
||
55 | * @return HasPermissions |
||
56 | */ |
||
57 | public function revokePermissionTo($permission) |
||
65 | |||
66 | /** |
||
67 | * @param string|array|Permission|\Illuminate\Support\Collection $permissions |
||
68 | * |
||
69 | * @return Permission |
||
70 | */ |
||
71 | protected function getStoredPermission($permissions) |
||
83 | } |
||
84 |
In PHP traits cannot be used for type-hinting as they do not define a well-defined structure. This is because any class that uses a trait can rename that trait’s methods.
If you would like to return an object that has a guaranteed set of methods, you could create a companion interface that lists these methods explicitly.