1 | <?php |
||
13 | class NestedKeyArray implements \ArrayAccess, \IteratorAggregate |
||
14 | { |
||
15 | private $array; |
||
16 | private $keySeparator; |
||
17 | |||
18 | /** |
||
19 | * @param array $array |
||
20 | * @param string $keySeparator |
||
21 | */ |
||
22 | public function __construct(array &$array, $keySeparator = '.') |
||
27 | |||
28 | /** |
||
29 | * {@inheritdoc} |
||
30 | */ |
||
31 | public function getIterator() |
||
35 | |||
36 | /** |
||
37 | * {@inheritdoc} |
||
38 | */ |
||
39 | public function offsetExists($offset) |
||
52 | |||
53 | /** |
||
54 | * {@inheritdoc} |
||
55 | */ |
||
56 | public function offsetGet($offset) |
||
67 | |||
68 | /** |
||
69 | * {@inheritdoc} |
||
70 | */ |
||
71 | public function offsetSet($offset, $value) |
||
75 | |||
76 | /** |
||
77 | * {@inheritdoc} |
||
78 | */ |
||
79 | public function offsetUnset($offset) |
||
83 | |||
84 | |||
85 | /** |
||
86 | * @return array |
||
87 | */ |
||
88 | public function toArray() |
||
92 | |||
93 | /** |
||
94 | * @param array $target |
||
95 | * @param array $offsets |
||
96 | * @param $value |
||
97 | * @return $this |
||
98 | */ |
||
99 | private function setNestedOffset(array &$target, array $offsets, $value) |
||
113 | |||
114 | /** |
||
115 | * @param array $target |
||
116 | * @param array $offsets |
||
117 | * @return $this |
||
118 | */ |
||
119 | private function unsetNestedOffset(array &$target, array $offsets) |
||
131 | } |
||
132 |
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.