@@ -51,11 +51,6 @@ class ObjectMerge
51
51
self ::DOUBLE_T
52
52
);
53
53
54
- /** @var mixed */
55
- private static $ _leftContext ;
56
- /** @var mixed */
57
- private static $ _rightContext ;
58
-
59
54
/**
60
55
* @param stdClass ...$objects
61
56
* @return stdClass|null
@@ -159,7 +154,7 @@ private static function compareTypes($left, $right)
159
154
* @param bool $recurse
160
155
* @param int $opts
161
156
* @param callable $cb
162
- * @param mixed $key
157
+ * @param string|int $key
163
158
* @param array $leftValue
164
159
* @param array $rightValue
165
160
* @return array
@@ -188,6 +183,7 @@ private static function mergeArrayValues($recurse, $opts, $cb, $key, array $left
188
183
* @param bool $recurse
189
184
* @param int $opts
190
185
* @param callable $cb
186
+ * @param string|int $key
191
187
* @param stdClass $leftValue
192
188
* @param stdClass $rightValue
193
189
* @return stdClass
@@ -196,8 +192,8 @@ private static function mergeObjectValues($recurse, $opts, $cb, $key, stdClass $
196
192
{
197
193
$ out = new stdClass ();
198
194
foreach (array_merge (get_object_vars ($ leftValue ), get_object_vars ($ rightValue )) as $ k => $ v ) {
199
- $ leftDefined = isset ($ leftValue->{ $ k } );
200
- $ rightDefined = isset ($ rightValue->{ $ k } );
195
+ $ leftDefined = property_exists ($ leftValue, $ k );
196
+ $ rightDefined = property_exists ($ rightValue, $ k );
201
197
$ out ->{$ k } = self ::mergeValues (
202
198
$ recurse ,
203
199
$ opts ,
@@ -263,9 +259,6 @@ private static function mergeValues($recurse, $opts, $cb, $key, $leftValue, $rig
263
259
return $ rightValue ;
264
260
}
265
261
266
- self ::$ _leftContext = $ leftValue ;
267
- self ::$ _rightContext = $ rightValue ;
268
-
269
262
if (self ::ARRAY_T === $ leftType ) {
270
263
return self ::mergeArrayValues ($ recurse , $ opts , $ cb , $ key , $ leftValue , $ rightValue );
271
264
}
@@ -294,18 +287,13 @@ private static function doMerge($recurse, $opts, $cb, array $objects)
294
287
}
295
288
296
289
if (null === $ root ) {
297
- $ root = self :: $ _leftContext = clone $ object ;
290
+ $ root = clone $ object ;
298
291
continue ;
299
292
}
300
293
301
- self ::$ _rightContext = $ object ;
302
-
303
294
$ root = self ::mergeObjectValues ($ recurse , $ opts , $ cb , null , $ root , $ object );
304
295
}
305
296
306
- self ::$ _leftContext = null ;
307
- self ::$ _rightContext = null ;
308
-
309
297
return $ root ;
310
298
}
311
299
}
0 commit comments