1 | <?php |
||
15 | class CheckHelper |
||
16 | { |
||
17 | protected static $allRules = []; |
||
18 | |||
19 | /** |
||
20 | * Check if data satisfies the condition |
||
21 | * |
||
22 | * @param mixed $data |
||
23 | * @param array $conditions |
||
24 | * @return bool |
||
25 | */ |
||
26 | public static function check($data, array $conditions) : bool |
||
44 | |||
45 | /** |
||
46 | * If array of rules is in "simple format" |
||
47 | * convert it to full format |
||
48 | * |
||
49 | * @param array $rules |
||
50 | * @return array |
||
51 | */ |
||
52 | protected static function tryPrepareSimpleRules(array $rules) : array |
||
65 | |||
66 | /** |
||
67 | * Init list of rules if not initialized |
||
68 | * |
||
69 | * @return void |
||
70 | */ |
||
71 | public static function initAllRules() : void |
||
88 | |||
89 | /** |
||
90 | * Check AND condition |
||
91 | * |
||
92 | * @param mixed $data |
||
93 | * @param array $conditions |
||
94 | * @return bool |
||
95 | */ |
||
96 | protected static function checkAnd($data, array $conditions) : bool |
||
105 | |||
106 | /** |
||
107 | * Check OR condition |
||
108 | * |
||
109 | * @param mixed $data |
||
110 | * @param array $conditions |
||
111 | * @return bool |
||
112 | */ |
||
113 | protected static function checkOr($data, array $conditions) : bool |
||
122 | |||
123 | /** |
||
124 | * Check/compare some field by rule and some value |
||
125 | * |
||
126 | * @param mixed $data |
||
127 | * @param string $staredRule |
||
128 | * @param mixed $arg1 |
||
129 | * @param mixed $arg2 |
||
130 | * @return bool |
||
131 | */ |
||
132 | protected static function checkField($data, string $staredRule, $arg1, $arg2) : bool |
||
143 | } |
||
144 |
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.