1 | <?php |
||
25 | class FormMetadataObject implements TypeInterface |
||
26 | { |
||
27 | /** |
||
28 | * @var array |
||
29 | */ |
||
30 | protected $metadata = []; |
||
31 | |||
32 | /** |
||
33 | * @var FormMetadata |
||
34 | */ |
||
35 | protected $object; |
||
36 | |||
37 | /** |
||
38 | * @param string $data |
||
39 | */ |
||
40 | public function __construct($data = null) |
||
52 | |||
53 | /** |
||
54 | * @param string $key |
||
55 | * @return mixed |
||
56 | * @throws EntryNotFoundException |
||
57 | */ |
||
58 | public function get($key) |
||
66 | |||
67 | /** |
||
68 | * @param string $key |
||
69 | * @return bool |
||
70 | */ |
||
71 | public function has($key) |
||
75 | |||
76 | /** |
||
77 | * @param string $key |
||
78 | * @param mixed $value |
||
79 | */ |
||
80 | public function set($key, $value) |
||
84 | |||
85 | /** |
||
86 | * @param string $key |
||
87 | */ |
||
88 | public function remove($key) |
||
94 | |||
95 | /** |
||
96 | * Persists the last changes of this instance in database. |
||
97 | */ |
||
98 | public function persist() |
||
110 | |||
111 | /** |
||
112 | * @return array |
||
113 | */ |
||
114 | public function getMetadata() |
||
118 | |||
119 | /** |
||
120 | * @param FormMetadata $metadata |
||
121 | */ |
||
122 | public function setObject(FormMetadata $metadata) |
||
130 | |||
131 | /** |
||
132 | * @return string |
||
133 | */ |
||
134 | public function __toString() |
||
138 | |||
139 | /** |
||
140 | * @see deepClone() |
||
141 | */ |
||
142 | public function __clone() |
||
146 | |||
147 | /** |
||
148 | * When the metadata is fetched from persistence, the `metadata` array can |
||
149 | * contain object instances, meaning that by default the original references |
||
150 | * to these objects are used in the clean properties, resulting in the |
||
151 | * object modification not being detected. |
||
152 | * |
||
153 | * In this function, we clone every object that is found, to solve the issue |
||
154 | * above. |
||
155 | * |
||
156 | * @param mixed $entry |
||
157 | * @param array $path |
||
158 | */ |
||
159 | protected function deepClone($entry, array $path = []) |
||
170 | } |
||
171 |
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: