1 | <?php |
||
23 | class AuthHelper |
||
24 | { |
||
25 | use AuthManagerAwareTrait; |
||
26 | |||
27 | /** |
||
28 | * Checks whether a user has certain role. |
||
29 | * |
||
30 | * @param $userId |
||
31 | * @param $role |
||
32 | * |
||
33 | * @return bool |
||
34 | */ |
||
35 | public function hasRole($userId, $role) |
||
45 | |||
46 | /** |
||
47 | * @param $username |
||
48 | * |
||
49 | * @return bool |
||
50 | */ |
||
51 | 2 | public function isAdmin($username) |
|
61 | |||
62 | /** |
||
63 | * @param $name |
||
64 | * |
||
65 | * @return null|\yii\rbac\Item|Permission |
||
66 | */ |
||
67 | public function getPermission($name) |
||
71 | |||
72 | /** |
||
73 | * @param $name |
||
74 | * |
||
75 | * @return null|\yii\rbac\Item|Role |
||
76 | */ |
||
77 | public function getRole($name) |
||
81 | |||
82 | /** |
||
83 | * Removes a role, permission or rule from the RBAC system. |
||
84 | * |
||
85 | * @param Role|Permission|Rule $object |
||
86 | * |
||
87 | * @return bool whether the role, permission or rule is successfully removed |
||
88 | */ |
||
89 | public function remove($object) |
||
93 | |||
94 | /** |
||
95 | * @param AbstractAuthItem $model |
||
96 | * |
||
97 | * @return array |
||
98 | */ |
||
99 | public function getUnassignedItems(AbstractAuthItem $model) |
||
113 | } |
||
114 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: