|
5 | 5 | namespace PhpMyAdmin; |
6 | 6 |
|
7 | 7 | use ArrayObject; |
8 | | -use PhpMyAdmin\Query\Utilities; |
9 | 8 |
|
10 | 9 | use function in_array; |
11 | 10 |
|
12 | 11 | /** @extends ArrayObject<int, string> */ |
13 | 12 | abstract class ListAbstract extends ArrayObject |
14 | 13 | { |
15 | | - /** @var mixed empty item */ |
16 | | - protected mixed $itemEmpty = ''; |
17 | | - |
18 | 14 | /** |
19 | | - * defines what is an empty item (0, '', false or null) |
20 | | - * |
21 | | - * @return mixed an empty item |
22 | | - */ |
23 | | - public function getEmpty(): mixed |
24 | | - { |
25 | | - return $this->itemEmpty; |
26 | | - } |
27 | | - |
28 | | - /** |
29 | | - * checks if the given db names exists in the current list, if there is |
| 15 | + * Checks if the given strings exists in the current list, if there is |
30 | 16 | * missing at least one item it returns false otherwise true |
31 | | - * |
32 | | - * @param mixed[] ...$params params |
33 | 17 | */ |
34 | | - public function exists(...$params): bool |
| 18 | + public function exists(string ...$params): bool |
35 | 19 | { |
36 | | - $this_elements = $this->getArrayCopy(); |
37 | | - foreach ($params as $result) { |
38 | | - if (! in_array($result, $this_elements)) { |
| 20 | + $elements = $this->getArrayCopy(); |
| 21 | + foreach ($params as $param) { |
| 22 | + if (! in_array($param, $elements, true)) { |
39 | 23 | return false; |
40 | 24 | } |
41 | 25 | } |
42 | 26 |
|
43 | 27 | return true; |
44 | 28 | } |
45 | 29 |
|
46 | | - /** @return array<int, array<string, bool|string>> */ |
47 | | - public function getList(): array |
48 | | - { |
49 | | - $selected = $this->getDefault(); |
50 | | - |
51 | | - $list = []; |
52 | | - foreach ($this as $eachItem) { |
53 | | - if (Utilities::isSystemSchema($eachItem)) { |
54 | | - continue; |
55 | | - } |
56 | | - |
57 | | - $list[] = [ |
58 | | - 'name' => $eachItem, |
59 | | - 'is_selected' => $selected === $eachItem, |
60 | | - ]; |
61 | | - } |
62 | | - |
63 | | - return $list; |
64 | | - } |
65 | | - |
66 | 30 | /** |
67 | | - * returns default item |
68 | | - * |
69 | | - * @return string default item |
| 31 | + * Returns default item |
70 | 32 | */ |
71 | 33 | public function getDefault(): string |
72 | 34 | { |
73 | | - return $this->getEmpty(); |
| 35 | + return ''; |
74 | 36 | } |
75 | 37 |
|
76 | 38 | /** |
|
0 commit comments