1 | <?php |
||
10 | class IniObject |
||
11 | { |
||
12 | private $filename; |
||
13 | |||
14 | protected $config; |
||
15 | |||
16 | private $sections; |
||
17 | |||
18 | /** |
||
19 | * IniObject constructor. |
||
20 | * |
||
21 | * @param string|null $filename |
||
22 | * @param array $data |
||
23 | * @param array $config |
||
24 | */ |
||
25 | 12 | public function __construct(?string $filename = null, array $data = [], array $config = []) |
|
42 | |||
43 | /** |
||
44 | * @param array $data |
||
45 | * @throws InvalidArgumentException |
||
46 | */ |
||
47 | 12 | private function sectionLoad(array $data): void |
|
55 | |||
56 | /** |
||
57 | * @param string $name |
||
58 | * @return Section |
||
59 | */ |
||
60 | 7 | public function getSection(string $name): Section |
|
68 | |||
69 | /** |
||
70 | * @param string $name |
||
71 | */ |
||
72 | 1 | public function removeSection(string $name): void |
|
79 | |||
80 | 2 | public function addSection(string $name, array $section): void |
|
87 | |||
88 | 1 | public function updateSection(string $name, array $section): void |
|
95 | |||
96 | /** |
||
97 | * default config |
||
98 | */ |
||
99 | 12 | private function initDefaultConfig(): void |
|
106 | |||
107 | /** |
||
108 | * @param string $filename |
||
109 | */ |
||
110 | 12 | private function setFilename(?string $filename): void |
|
114 | |||
115 | 1 | public function __toString() |
|
125 | |||
126 | /** |
||
127 | * @return array |
||
128 | */ |
||
129 | 1 | public function toArray(): array |
|
139 | |||
140 | /** |
||
141 | * @param string|null $filename |
||
142 | * @return bool |
||
143 | */ |
||
144 | 1 | public function save(string $filename = null): bool |
|
155 | } |
||
156 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.