1 | <?php |
||
17 | class Permission { |
||
18 | use |
||
19 | CRUD_helpers, |
||
20 | Singleton; |
||
21 | |||
22 | protected $data_model = [ |
||
23 | 'id' => 'int:0', |
||
24 | 'group' => 'text', |
||
25 | 'label' => 'text' |
||
26 | ]; |
||
27 | protected $table = '[prefix]permissions'; |
||
28 | /** |
||
29 | * Array of all permissions for quick selecting |
||
30 | * @var array |
||
31 | */ |
||
32 | protected $permissions_table = []; |
||
33 | /** |
||
34 | * @var Prefix |
||
35 | */ |
||
36 | protected $cache; |
||
37 | /** |
||
38 | * Returns database index |
||
39 | * |
||
40 | * @return int |
||
41 | */ |
||
42 | protected function cdb () { |
||
48 | /** |
||
49 | * Get permission data<br> |
||
50 | * If <b>$group</b> or/and <b>$label</b> parameter is specified, <b>$id</b> is ignored. |
||
51 | * |
||
52 | * @param int|null $id |
||
53 | * @param null|string $group |
||
54 | * @param null|string $label |
||
55 | * |
||
56 | * @return array|false If only <b>$id</b> specified - result is array of permission data, in other cases result will be array of arrays of corresponding |
||
1 ignored issue
–
show
|
|||
57 | * permissions data |
||
58 | */ |
||
59 | function get ($id = null, $group = null, $label = null) { |
||
77 | /** |
||
78 | * Add permission |
||
79 | * |
||
80 | * @param string $group |
||
81 | * @param string $label |
||
82 | * |
||
83 | * @return false|int Group id or <b>false</b> on failure |
||
1 ignored issue
–
show
|
|||
84 | */ |
||
85 | function add ($group, $label) { |
||
92 | /** |
||
93 | * Set permission |
||
94 | * |
||
95 | * @param int $id |
||
96 | * @param string $group |
||
97 | * @param string $label |
||
98 | * |
||
99 | * @return bool |
||
100 | */ |
||
101 | function set ($id, $group, $label) { |
||
108 | /** |
||
109 | * Deletion of permission or array of permissions |
||
110 | * |
||
111 | * @param int|int[] $id |
||
112 | * |
||
113 | * @return bool |
||
114 | */ |
||
115 | function del ($id) { |
||
142 | /** |
||
143 | * Returns array of all permissions grouped by permissions groups |
||
144 | * |
||
145 | * @return array Format of array: ['group']['label'] = <i>permission_id</i> |
||
146 | */ |
||
147 | function get_all () { |
||
165 | /** |
||
166 | * Deletion of permission table (is used after adding, setting or deletion of permission) |
||
167 | */ |
||
168 | protected function del_all_cache () { |
||
172 | } |
||
173 |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.If the return type contains the type array, this check recommends the use of a more specific type like
String[]
orarray<String>
.