1 | <?php |
||
34 | class SerializerFactory { |
||
35 | |||
36 | const OPTION_DEFAULT = 0; |
||
37 | /** @since 1.2.0 */ |
||
38 | const OPTION_OBJECTS_FOR_MAPS = 1; |
||
39 | /** |
||
40 | * Omit hashes when serializing snaks. |
||
41 | * @since 2.5.0 |
||
42 | */ |
||
43 | const OPTION_SERIALIZE_SNAKS_WITHOUT_HASH = 2; |
||
44 | |||
45 | /** |
||
46 | * @var int |
||
47 | */ |
||
48 | private $options; |
||
49 | |||
50 | /** |
||
51 | * @var Serializer |
||
52 | */ |
||
53 | private $dataValueSerializer; |
||
54 | |||
55 | /** |
||
56 | * @param Serializer $dataValueSerializer serializer for DataValue objects |
||
57 | * @param int $options set multiple with bitwise or |
||
58 | * |
||
59 | * @throws InvalidArgumentException |
||
60 | */ |
||
61 | 52 | public function __construct( Serializer $dataValueSerializer, $options = 0 ) { |
|
69 | |||
70 | /** |
||
71 | * @return bool |
||
72 | */ |
||
73 | 38 | private function shouldUseObjectsForMaps() { |
|
76 | |||
77 | /** |
||
78 | * @return bool |
||
79 | */ |
||
80 | 30 | private function shouldSerializeSnaksWithHash() { |
|
83 | |||
84 | /** |
||
85 | * @return DispatchableSerializer A serializer that can only serialize Item and Property |
||
86 | * objects, but no other entity types. In contexts with custom entity types other than items |
||
87 | * and properties this is not what you want. If in doubt, favor a custom |
||
88 | * `DispatchingSerializer` containing the exact entity serializers you need. |
||
89 | */ |
||
90 | 1 | public function newEntitySerializer() { |
|
96 | |||
97 | /** |
||
98 | * Returns a Serializer that can serialize Item objects. |
||
99 | * |
||
100 | * @since 2.1 |
||
101 | * |
||
102 | * @return Serializer |
||
103 | */ |
||
104 | 8 | public function newItemSerializer() { |
|
113 | |||
114 | /** |
||
115 | * Returns a Serializer that can serialize Property objects. |
||
116 | * |
||
117 | * @since 2.1 |
||
118 | * |
||
119 | * @return Serializer |
||
120 | */ |
||
121 | 3 | public function newPropertySerializer() { |
|
128 | |||
129 | /** |
||
130 | * Returns a Serializer that can serialize SiteLink objects. |
||
131 | * |
||
132 | * @return Serializer |
||
133 | */ |
||
134 | 12 | public function newSiteLinkSerializer() { |
|
137 | |||
138 | /** |
||
139 | * Returns a Serializer that can serialize StatementList objects. |
||
140 | * |
||
141 | * @since 1.4 |
||
142 | * |
||
143 | * @return Serializer |
||
144 | */ |
||
145 | 14 | public function newStatementListSerializer() { |
|
151 | |||
152 | /** |
||
153 | * Returns a Serializer that can serialize Statement objects. |
||
154 | * |
||
155 | * @since 1.4 |
||
156 | * |
||
157 | * @return Serializer |
||
158 | */ |
||
159 | 22 | public function newStatementSerializer() { |
|
166 | |||
167 | /** |
||
168 | * Returns a Serializer that can serialize ReferenceList objects. |
||
169 | * |
||
170 | * @return Serializer |
||
171 | */ |
||
172 | 26 | public function newReferencesSerializer() { |
|
175 | |||
176 | /** |
||
177 | * Returns a Serializer that can serialize Reference objects. |
||
178 | * |
||
179 | * @return Serializer |
||
180 | */ |
||
181 | 30 | public function newReferenceSerializer() { |
|
186 | |||
187 | /** |
||
188 | * Returns a Serializer that can serialize SnakList objects. |
||
189 | * |
||
190 | * @param bool $serializeSnaksWithHash |
||
191 | * |
||
192 | * @since 1.4 |
||
193 | * |
||
194 | * @return Serializer |
||
195 | */ |
||
196 | 36 | public function newSnakListSerializer( $serializeSnaksWithHash = true ) { |
|
202 | |||
203 | /** |
||
204 | * Returns a Serializer that can serialize Snak objects. |
||
205 | * |
||
206 | * @param bool $serializeWithHash |
||
207 | * |
||
208 | * @return Serializer |
||
209 | */ |
||
210 | 43 | public function newSnakSerializer( $serializeWithHash = true ) { |
|
213 | |||
214 | /** |
||
215 | * Returns a Serializer that can serialize TypedSnak objects. |
||
216 | * |
||
217 | * @param bool $serializeWithHash |
||
218 | * |
||
219 | * @since 1.3 |
||
220 | * |
||
221 | * @return Serializer |
||
222 | */ |
||
223 | 1 | public function newTypedSnakSerializer( $serializeWithHash = true ) { |
|
226 | |||
227 | /** |
||
228 | * Returns a Serializer that can serialize Term objects. |
||
229 | * |
||
230 | * @since 1.5 |
||
231 | * |
||
232 | * @return Serializer |
||
233 | */ |
||
234 | 12 | public function newTermSerializer() { |
|
237 | |||
238 | /** |
||
239 | * Returns a Serializer that can serialize TermList objects. |
||
240 | * |
||
241 | * @since 1.5 |
||
242 | * |
||
243 | * @return Serializer |
||
244 | */ |
||
245 | 11 | public function newTermListSerializer() { |
|
248 | |||
249 | /** |
||
250 | * Returns a Serializer that can serialize AliasGroup objects. |
||
251 | * |
||
252 | * @since 1.6 |
||
253 | * |
||
254 | * @return Serializer |
||
255 | */ |
||
256 | 12 | public function newAliasGroupSerializer() { |
|
259 | |||
260 | /** |
||
261 | * Returns a Serializer that can serialize AliasGroupList objects. |
||
262 | * |
||
263 | * @since 1.5 |
||
264 | * |
||
265 | * @return Serializer |
||
266 | */ |
||
267 | 11 | public function newAliasGroupListSerializer() { |
|
270 | |||
271 | } |
||
272 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: