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 | * Revoke the given permission. |
||
34 | * |
||
35 | * @param $permission |
||
36 | * |
||
37 | * @return HasPermissions |
||
38 | */ |
||
39 | public function revokePermissionTo($permission) |
||
47 | |||
48 | /** |
||
49 | * @param string|array|Permission|\Illuminate\Support\Collection $permissions |
||
50 | * |
||
51 | * @return Permission |
||
52 | */ |
||
53 | protected function getStoredPermission($permissions) |
||
65 | } |
||
66 |
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.