1 | <?php namespace Arcanedev\LaravelAuth\Traits; |
||
17 | trait AuthRoleTrait |
||
18 | { |
||
19 | /* ------------------------------------------------------------------------------------------------ |
||
20 | | Role CRUD Functions |
||
21 | | ------------------------------------------------------------------------------------------------ |
||
22 | */ |
||
23 | /** |
||
24 | * Attach a role to a user. |
||
25 | * |
||
26 | * @param \Arcanesoft\Contracts\Auth\Models\Role|int $role |
||
27 | * @param bool $reload |
||
28 | */ |
||
29 | 120 | public function attachRole($role, $reload = true) |
|
36 | |||
37 | /** |
||
38 | * Sync the roles by its slugs. |
||
39 | * |
||
40 | * @param array $slugs |
||
41 | * @param bool $reload |
||
42 | * |
||
43 | * @return array |
||
44 | */ |
||
45 | 16 | public function syncRoles(array $slugs, $reload = true) |
|
57 | |||
58 | /** |
||
59 | * Detach a role from a user. |
||
60 | * |
||
61 | * @param \Arcanesoft\Contracts\Auth\Models\Role|int $role |
||
62 | * @param bool $reload |
||
63 | * |
||
64 | 16 | * @return int |
|
65 | */ |
||
66 | 16 | public function detachRole($role, $reload = true) |
|
77 | |||
78 | /** |
||
79 | * Detach all roles from a user. |
||
80 | * |
||
81 | * @param bool $reload |
||
82 | * |
||
83 | 120 | * @return int |
|
84 | */ |
||
85 | 120 | public function detachAllRoles($reload = true) |
|
92 | |||
93 | /* ------------------------------------------------------------------------------------------------ |
||
94 | | Check Functions |
||
95 | | ------------------------------------------------------------------------------------------------ |
||
96 | */ |
||
97 | /** |
||
98 | * Check if user has the given role (Role Model or Id). |
||
99 | * |
||
100 | 16 | * @param mixed $id |
|
101 | * |
||
102 | 16 | * @return bool |
|
103 | */ |
||
104 | 16 | public function hasRole($id) |
|
111 | |||
112 | /** |
||
113 | * Check if has all roles. |
||
114 | * |
||
115 | 32 | * @param array $roles |
|
116 | * @param array &$failedRoles |
||
117 | 32 | * |
|
118 | 32 | * @return bool |
|
119 | 32 | */ |
|
120 | 24 | public function isAll(array $roles, array &$failedRoles = []) |
|
126 | |||
127 | /** |
||
128 | * Check if has at least one role. |
||
129 | * |
||
130 | * @param array $roles |
||
131 | * @param array &$failedRoles |
||
132 | * |
||
133 | * @return bool |
||
134 | */ |
||
135 | 48 | public function isOne(array $roles, array &$failedRoles = []) |
|
144 | |||
145 | /** |
||
146 | * Check if has a role by its slug. |
||
147 | * |
||
148 | * @param string $slug |
||
149 | * |
||
150 | * @return bool |
||
151 | */ |
||
152 | public function hasRoleSlug($slug) |
||
160 | |||
161 | /* ------------------------------------------------------------------------------------------------ |
||
162 | | Other Functions |
||
163 | | ------------------------------------------------------------------------------------------------ |
||
164 | */ |
||
165 | /** |
||
166 | * Load all roles. |
||
167 | * |
||
168 | * @param bool $load |
||
169 | * |
||
170 | * @return self |
||
171 | */ |
||
172 | protected function loadRoles($load = true) |
||
176 | } |
||
177 |
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.json
file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.json
to be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
require
orrequire-dev
section?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceof
checks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.