1 | <?php |
||
31 | class Permission extends AbstractHelper |
||
32 | { |
||
33 | /** |
||
34 | * @var int |
||
35 | */ |
||
36 | protected $mid; |
||
37 | |||
38 | /** |
||
39 | * @var string |
||
40 | */ |
||
41 | protected $dirname; |
||
42 | |||
43 | /** |
||
44 | * @var \Xoops\Core\Kernel\Handlers\XoopsGroupPermHandler |
||
45 | */ |
||
46 | protected $permissionHandler; |
||
47 | |||
48 | /** |
||
49 | * Initialize parent::__construct calls this after verifying module object. |
||
50 | * |
||
51 | * @return void |
||
52 | */ |
||
53 | public function init() |
||
59 | |||
60 | /** |
||
61 | * Check if the user has permission for an item |
||
62 | * |
||
63 | * @param string $gperm_name name of the permission to test |
||
64 | * @param int $gperm_itemid id of the object to check |
||
65 | * |
||
66 | * @return bool true if user has access, false if not |
||
67 | **/ |
||
68 | public function checkPermission($gperm_name, $gperm_itemid) |
||
80 | |||
81 | /** |
||
82 | * Redirect to a url if user does not have permission for an item |
||
83 | * |
||
84 | * @param string $gperm_name name of the permission to test |
||
85 | * @param int $gperm_itemid id of the object to check |
||
86 | * @param string $url module relative url to redirect to |
||
87 | * @param int $time time in seconds to delay |
||
88 | * @param string $message message to display with redirect |
||
89 | * |
||
90 | * @return void |
||
91 | **/ |
||
92 | public function checkPermissionRedirect( |
||
112 | |||
113 | /** |
||
114 | * Get array of groups with named permission to an item |
||
115 | * |
||
116 | * @param string $gperm_name name of the permission to test |
||
117 | * @param int $gperm_itemid id of the object to check |
||
118 | * |
||
119 | * @return array groups with permission for item |
||
120 | **/ |
||
121 | public function getGroupsForItem($gperm_name, $gperm_itemid) |
||
126 | |||
127 | /** |
||
128 | * Save group permissions for an item |
||
129 | * |
||
130 | * @param string $gperm_name name of the permission to test |
||
131 | * @param int $gperm_itemid id of the object to check |
||
132 | * @param array $groups group ids to grant permission to |
||
133 | * |
||
134 | * @return bool true if no errors |
||
135 | **/ |
||
136 | public function savePermissionForItem($gperm_name, $gperm_itemid, $groups) |
||
162 | |||
163 | /** |
||
164 | * Delete all permissions for an item and a specific name or array of names |
||
165 | * |
||
166 | * @param string|string[] $gperm_name name(s) of the permission to delete |
||
167 | * @param int $gperm_itemid id of the object to check |
||
168 | * |
||
169 | * @return bool true if no errors |
||
170 | */ |
||
171 | public function deletePermissionForItem($gperm_name, $gperm_itemid) |
||
183 | |||
184 | /** |
||
185 | * Generate a \Xoops\Form\Element to select groups to grant permission |
||
186 | * to a specific gperm_name and gperm_item. Field will be preset |
||
187 | * with existing permissions. |
||
188 | * |
||
189 | * @param string $gperm_name name of the permission to test |
||
190 | * @param int $gperm_itemid id of the object to check |
||
191 | * @param string $caption caption for form field |
||
192 | * @param string $name name/id of form field |
||
193 | * @param bool $include_anon true to include anonymous group |
||
194 | * @param int $size size of list |
||
195 | * @param bool $multiple true to allow multiple selections |
||
196 | * |
||
197 | * @return SelectGroup |
||
198 | */ |
||
199 | public function getGroupSelectFormForItem( |
||
225 | |||
226 | /** |
||
227 | * Generate a default name for a Xoops\Form\SelectGroup based on |
||
228 | * module, gperm_name and gperm_itemid |
||
229 | * |
||
230 | * @param string $gperm_name name of the permission to test |
||
231 | * @param int $gperm_itemid id of the object to check |
||
232 | * |
||
233 | * @return string |
||
234 | */ |
||
235 | public function defaultFieldName($gperm_name, $gperm_itemid) |
||
243 | } |
||
244 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.