These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | namespace Redaxscript\Validator; |
||
3 | |||
4 | use function array_intersect; |
||
5 | use function in_array; |
||
6 | use function json_decode; |
||
7 | |||
8 | /** |
||
9 | * children class to validate access again group |
||
10 | * |
||
11 | * @since 2.2.0 |
||
12 | * |
||
13 | * @package Redaxscript |
||
14 | * @category Validator |
||
15 | * @author Henry Ruhs |
||
16 | * @author Sven Weingartner |
||
17 | */ |
||
18 | |||
19 | class Access implements ValidatorInterface |
||
20 | { |
||
21 | /** |
||
22 | * validate the access |
||
23 | * |
||
24 | * @since 4.0.0 |
||
25 | * |
||
26 | * @param string $access access for contents and modules |
||
27 | * @param string $groups groups of the user |
||
28 | * |
||
29 | * @return bool |
||
30 | */ |
||
31 | |||
32 | 4 | public function validate(string $access = null, string $groups = null) : bool |
|
33 | { |
||
34 | 4 | $accessArray = (array)json_decode($access); |
|
35 | 4 | $groupArray = (array)json_decode($groups); |
|
36 | 4 | return !$access || in_array(1, $groupArray) || array_intersect($accessArray, $groupArray); |
|
0 ignored issues
–
show
|
|||
37 | } |
||
38 | } |
||
39 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: