-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
DefaultProcessor.php
769 lines (664 loc) · 21.3 KB
/
DefaultProcessor.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
<?php declare(strict_types = 1);
namespace Orisai\ObjectMapper\Processing;
use Nette\Utils\Helpers;
use Orisai\Exceptions\Logic\InvalidState;
use Orisai\ObjectMapper\Args\Args;
use Orisai\ObjectMapper\Callbacks\AfterCallback;
use Orisai\ObjectMapper\Callbacks\BeforeCallback;
use Orisai\ObjectMapper\Callbacks\Callback;
use Orisai\ObjectMapper\Context\BaseFieldContext;
use Orisai\ObjectMapper\Context\FieldContext;
use Orisai\ObjectMapper\Context\MappedObjectContext;
use Orisai\ObjectMapper\Context\ProcessorCallContext;
use Orisai\ObjectMapper\Context\SkippedPropertiesContext;
use Orisai\ObjectMapper\Context\SkippedPropertyContext;
use Orisai\ObjectMapper\Context\TypeContext;
use Orisai\ObjectMapper\Exception\InvalidData;
use Orisai\ObjectMapper\Exception\ValueDoesNotMatch;
use Orisai\ObjectMapper\MappedObject;
use Orisai\ObjectMapper\Meta\MetaLoader;
use Orisai\ObjectMapper\Meta\Runtime\ClassRuntimeMeta;
use Orisai\ObjectMapper\Meta\Runtime\NodeRuntimeMeta;
use Orisai\ObjectMapper\Meta\Runtime\PropertyRuntimeMeta;
use Orisai\ObjectMapper\Meta\Runtime\RuntimeMeta;
use Orisai\ObjectMapper\Modifiers\FieldNameModifier;
use Orisai\ObjectMapper\Modifiers\SkippedModifier;
use Orisai\ObjectMapper\Rules\MappedObjectArgs;
use Orisai\ObjectMapper\Rules\MappedObjectRule;
use Orisai\ObjectMapper\Rules\RuleManager;
use Orisai\ObjectMapper\Types\MappedObjectType;
use Orisai\ObjectMapper\Types\MessageType;
use Orisai\ObjectMapper\Types\Value;
use stdClass;
use function array_diff;
use function array_key_exists;
use function array_keys;
use function array_map;
use function assert;
use function get_class;
use function implode;
use function in_array;
use function is_a;
use function is_array;
use function sprintf;
final class DefaultProcessor implements Processor
{
private MetaLoader $metaLoader;
private RuleManager $ruleManager;
private ObjectCreator $creator;
private ?TypeContext $typeContext = null;
public function __construct(MetaLoader $metaLoader, RuleManager $ruleManager, ObjectCreator $creator)
{
$this->metaLoader = $metaLoader;
$this->ruleManager = $ruleManager;
$this->creator = $creator;
}
/**
* @param mixed $data
* @throws InvalidData
*/
public function process($data, string $class, ?Options $options = null): MappedObject
{
$options ??= new Options();
$type = $this->createMappedObjectType($class);
$meta = $this->metaLoader->load($class);
$holder = $this->createHolder($class, $meta->getClass());
$mappedObjectContext = $this->createMappedObjectContext($options, $type, true);
$callContext = $this->createProcessorRunContext($class, $meta, $holder);
$processedData = $this->processData($data, $mappedObjectContext, $callContext);
$object = $holder->getInstance();
$this->fillObject($object, $processedData, $data, $mappedObjectContext, $callContext);
return $object;
}
/**
* @param mixed $data
* @param class-string<MappedObject> $class
* @return array<int|string, mixed>
* @throws InvalidData
*/
public function processWithoutMapping($data, string $class, ?Options $options = null): array
{
$options ??= new Options();
$type = $this->createMappedObjectType($class);
$meta = $this->metaLoader->load($class);
$holder = $this->createHolder($class, $meta->getClass());
$mappedObjectContext = $this->createMappedObjectContext($options, $type, false);
$callContext = $this->createProcessorRunContext($class, $meta, $holder);
return $this->processData($data, $mappedObjectContext, $callContext);
}
private function getTypeContext(): TypeContext
{
if ($this->typeContext === null) {
$this->typeContext = new TypeContext($this->metaLoader, $this->ruleManager);
}
return $this->typeContext;
}
// /////////////// //
// Base processing //
// /////////////// //
/**
* @param mixed $data
* @param ProcessorCallContext<MappedObject> $callContext
* @return array<int|string, mixed>
* @throws InvalidData
*/
private function processData(
$data,
MappedObjectContext $mappedObjectContext,
ProcessorCallContext $callContext
): array
{
$meta = $callContext->getMeta();
$classMeta = $meta->getClass();
if ($data instanceof stdClass) {
$data = (array) $data;
}
$data = $this->handleClassCallbacks(
$data,
$mappedObjectContext,
$callContext,
$classMeta,
BeforeCallback::class,
);
$data = $this->ensureDataProcessable($data, $mappedObjectContext);
$data = $this->handleFields($data, $mappedObjectContext, $callContext);
$data = $this->handleClassCallbacks(
$data,
$mappedObjectContext,
$callContext,
$classMeta,
AfterCallback::class,
);
assert(is_array($data)); // After class callbacks are forced to return array
return $data;
}
/**
* @param class-string<MappedObject> $class
*/
private function createMappedObjectType(string $class): MappedObjectType
{
return $this->ruleManager->getRule(MappedObjectRule::class)->createType(
new MappedObjectArgs($class),
$this->getTypeContext(),
);
}
private function createMappedObjectContext(
Options $options,
MappedObjectType $type,
bool $initializeObjects
): MappedObjectContext
{
return new MappedObjectContext(
$this->metaLoader,
$this->ruleManager,
$this,
$options,
$type,
$initializeObjects,
);
}
/**
* @template RC of MappedObject
* @param class-string<RC> $class
* @param ObjectHolder<RC> $holder
* @return ProcessorCallContext<RC>
*/
private function createProcessorRunContext(
string $class,
RuntimeMeta $meta,
ObjectHolder $holder
): ProcessorCallContext
{
return new ProcessorCallContext($class, $holder, $meta);
}
/**
* @param mixed $data
* @return array<mixed>
* @throws InvalidData
*/
private function ensureDataProcessable($data, MappedObjectContext $context): array
{
if (!is_array($data)) {
$type = $context->getType();
$type->markInvalid();
throw InvalidData::create($type, Value::of($data));
}
return $data;
}
/**
* @param int|string $fieldName
*/
private function fieldNameToPropertyName($fieldName, RuntimeMeta $meta): string
{
$map = $meta->getFieldsPropertiesMap();
return $map[$fieldName] ?? (string) $fieldName;
}
/**
* @return int|string
*/
private function propertyNameToFieldName(string $propertyName, PropertyRuntimeMeta $meta)
{
$fieldNameMeta = $meta->getModifier(FieldNameModifier::class);
if ($fieldNameMeta !== null) {
return $fieldNameMeta->getArgs()->name;
}
return $propertyName;
}
// /////////////////// //
// Properties / Fields //
// /////////////////// //
/**
* @param array<int|string, mixed> $data
* @param ProcessorCallContext<MappedObject> $callContext
* @return array<int|string, mixed>
* @throws InvalidData
*/
private function handleFields(
array $data,
MappedObjectContext $mappedObjectContext,
ProcessorCallContext $callContext
): array
{
$data = $this->handleSentFields($data, $mappedObjectContext, $callContext);
$data = $this->handleMissingFields($data, $mappedObjectContext, $callContext);
$type = $mappedObjectContext->getType();
if ($type->hasInvalidFields()) {
throw InvalidData::create($type, Value::none());
}
return $data;
}
/**
* @param array<int|string, mixed> $data
* @param ProcessorCallContext<MappedObject> $callContext
* @return array<int|string, mixed>
*/
private function handleSentFields(
array $data,
MappedObjectContext $mappedObjectContext,
ProcessorCallContext $callContext
): array
{
$type = $mappedObjectContext->getType();
$options = $mappedObjectContext->getOptions();
$meta = $callContext->getMeta();
$propertiesMeta = $meta->getProperties();
$propertyNames = array_keys($propertiesMeta);
foreach ($data as $fieldName => $value) {
// Skip invalid field
if ($type->isFieldInvalid($fieldName)) {
continue;
}
$propertyName = $this->fieldNameToPropertyName($fieldName, $meta);
// Unknown field
if (!isset($propertiesMeta[$propertyName])) {
// Remove field from data
unset($data[$fieldName]);
if ($options->isAllowUnknownFields()) {
continue;
}
// Add error to type
$hintedPropertyName = Helpers::getSuggestion($propertyNames, $propertyName);
$hintedFieldName = $hintedPropertyName !== null ?
$this->propertyNameToFieldName(
$hintedPropertyName,
$propertiesMeta[$hintedPropertyName],
)
: null;
$hint = ($hintedFieldName !== null ? sprintf(', did you mean `%s`?', $hintedFieldName) : '.');
$type->overwriteInvalidField(
$fieldName,
ValueDoesNotMatch::create(
new MessageType(sprintf('Field is unknown%s', $hint)),
Value::of($value),
),
);
continue;
}
$propertyMeta = $propertiesMeta[$propertyName];
$fieldContext = $this->createFieldContext($mappedObjectContext, $propertyMeta, $fieldName, $propertyName);
// Skip skipped property
if (
$mappedObjectContext->shouldMapDataToObjects()
&& $propertyMeta->getModifier(SkippedModifier::class) !== null
) {
$callContext->addSkippedProperty(
$propertyName,
new SkippedPropertyContext($fieldName, $value, false),
);
unset($data[$fieldName]);
continue;
}
// Process field value with property rules
try {
$data[$fieldName] = $this->processProperty(
$value,
$fieldContext,
$callContext,
$propertyMeta,
);
} catch (ValueDoesNotMatch | InvalidData $exception) {
$type->overwriteInvalidField($fieldName, $exception);
}
}
return $data;
}
/**
* @param array<int|string, mixed> $data
* @param ProcessorCallContext<MappedObject> $callContext
* @return array<string>
*/
private function findMissingProperties(array $data, ProcessorCallContext $callContext): array
{
$meta = $callContext->getMeta();
return array_diff(
array_keys($meta->getProperties()),
array_map(
fn ($fieldName): string => $this->fieldNameToPropertyName($fieldName, $meta),
array_keys($data),
),
);
}
/**
* @param ProcessorCallContext<MappedObject> $callContext
* @return array<string>
*/
private function getSkippedProperties(ProcessorCallContext $callContext): array
{
return array_keys($callContext->getSkippedProperties());
}
/**
* @param array<int|string, mixed> $data
* @param ProcessorCallContext<MappedObject> $callContext
* @return array<int|string, mixed>
*/
private function handleMissingFields(
array $data,
MappedObjectContext $mappedObjectContext,
ProcessorCallContext $callContext
): array
{
$type = $mappedObjectContext->getType();
$options = $mappedObjectContext->getOptions();
$initializeObjects = $mappedObjectContext->shouldMapDataToObjects();
$propertiesMeta = $callContext->getMeta()->getProperties();
$missingProperties = $this->findMissingProperties($data, $callContext);
$requiredFields = $options->getRequiredFields();
$fillDefaultValues = $initializeObjects || $options->isPrefillDefaultValues();
$skippedProperties = $this->getSkippedProperties($callContext);
foreach ($missingProperties as $missingProperty) {
// Skipped properties are not considered missing, they are just processed later
if (in_array($missingProperty, $skippedProperties, true)) {
continue;
}
$propertyMeta = $propertiesMeta[$missingProperty];
$defaultMeta = $propertyMeta->getDefault();
$missingField = $this->propertyNameToFieldName($missingProperty, $propertyMeta);
if ($requiredFields === RequiredFields::nonDefault() && $defaultMeta->hasValue()) {
// Add default value if defaults are not required and should be used
// If VOs are initialized then values are always prefilled - user can work with them in after callback,
// and they are defined by VO anyway
if ($fillDefaultValues) {
$data[$missingField] = $defaultMeta->getValue();
}
} elseif (
$requiredFields === RequiredFields::nonDefault()
&& is_a($propertyMeta->getRule()->getType(), MappedObjectRule::class, true)
) {
// Try to initialize object from empty array when no data given
// Mapped object in compound type is not supported (allOf, anyOf)
// Used only in default mode - if all or none values are required then we need differentiate whether user sent value or not
$mappedObjectArgs = $propertyMeta->getRule()->getArgs();
assert($mappedObjectArgs instanceof MappedObjectArgs);
try {
$data[$missingField] = $initializeObjects
? $this->process([], $mappedObjectArgs->type, $options)
: $this->processWithoutMapping([], $mappedObjectArgs->type, $options);
} catch (InvalidData $exception) {
$type->overwriteInvalidField(
$missingField,
InvalidData::create($exception->getType(), Value::none()),
);
}
} elseif ($requiredFields !== RequiredFields::none() && !$type->isFieldInvalid($missingField)) {
// Field is missing and have no default value, mark as invalid
$propertyRuleMeta = $propertyMeta->getRule();
$propertyRule = $this->ruleManager->getRule($propertyRuleMeta->getType());
$type->overwriteInvalidField(
$missingField,
ValueDoesNotMatch::create(
$propertyRule->createType(
$propertyRuleMeta->getArgs(),
$this->getTypeContext(),
),
Value::none(),
),
);
}
// Return skipped property separately
if (
array_key_exists($missingField, $data)
&& $mappedObjectContext->shouldMapDataToObjects()
&& $propertyMeta->getModifier(SkippedModifier::class) !== null
) {
$callContext->addSkippedProperty(
$missingProperty,
new SkippedPropertyContext($missingField, $data[$missingField], true),
);
unset($data[$missingField]);
continue;
}
}
return $data;
}
// //////////////// //
// Property / Field //
// //////////////// //
/**
* @param int|string $fieldName
*/
private function createFieldContext(
MappedObjectContext $mappedObjectContext,
PropertyRuntimeMeta $meta,
$fieldName,
string $propertyName
): FieldContext
{
$parentType = $mappedObjectContext->getType();
return new FieldContext(
$this->metaLoader,
$this->ruleManager,
$this,
$mappedObjectContext->getOptions(),
$parentType->getFields()[$fieldName],
$meta->getDefault(),
$mappedObjectContext->shouldMapDataToObjects(),
$fieldName,
$propertyName,
);
}
/**
* @param mixed $value
* @param ProcessorCallContext<MappedObject> $callContext
* @return mixed
* @throws ValueDoesNotMatch
* @throws InvalidData
*/
private function processProperty(
$value,
FieldContext $fieldContext,
ProcessorCallContext $callContext,
PropertyRuntimeMeta $meta
)
{
$value = $this->applyCallbacks($value, $fieldContext, $callContext, $meta, BeforeCallback::class);
$value = $this->processPropertyRules($value, $fieldContext, $meta);
$value = $this->applyCallbacks($value, $fieldContext, $callContext, $meta, AfterCallback::class);
return $value;
}
/**
* @param mixed $value
* @return mixed
* @throws ValueDoesNotMatch
* @throws InvalidData
*/
private function processPropertyRules($value, FieldContext $fieldContext, PropertyRuntimeMeta $meta)
{
$ruleMeta = $meta->getRule();
$rule = $this->ruleManager->getRule($ruleMeta->getType());
return $rule->processValue(
$value,
$ruleMeta->getArgs(),
$fieldContext,
);
}
// ///////// //
// Callbacks //
// ///////// //
/**
* @param mixed $data
* @param ProcessorCallContext<MappedObject> $callContext
* @param class-string<Callback<Args>> $callbackType
* @return mixed
* @throws InvalidData
*/
private function handleClassCallbacks(
$data,
MappedObjectContext $mappedObjectContext,
ProcessorCallContext $callContext,
ClassRuntimeMeta $meta,
string $callbackType
)
{
$type = $mappedObjectContext->getType();
try {
$data = $this->applyCallbacks($data, $mappedObjectContext, $callContext, $meta, $callbackType);
} catch (ValueDoesNotMatch | InvalidData $exception) {
$caughtType = $exception->getType();
// User thrown type is not the actual type from MappedObjectContext
if ($caughtType !== $type) {
$type->addError($exception);
throw InvalidData::create($type, Value::none());
}
throw InvalidData::create($type, $exception->getValue());
}
return $data;
}
/**
* @param mixed $data
* @param FieldContext|MappedObjectContext $baseFieldContext
* @param ProcessorCallContext<MappedObject> $callContext
* @param ClassRuntimeMeta|PropertyRuntimeMeta $meta
* @param class-string<Callback<Args>> $callbackType
* @return mixed
* @throws ValueDoesNotMatch
* @throws InvalidData
*/
private function applyCallbacks(
$data,
BaseFieldContext $baseFieldContext,
ProcessorCallContext $callContext,
NodeRuntimeMeta $meta,
string $callbackType
)
{
$holder = $callContext->getObjectHolder();
foreach ($meta->getCallbacks() as $callback) {
if ($callback->getType() === $callbackType) {
$data = $callbackType::invoke(
$data,
$callback->getArgs(),
$holder,
$baseFieldContext,
);
}
}
return $data;
}
// ///////////// //
// Mapped Object //
// ///////////// //
/**
* @param array<int|string, mixed> $data
* @param mixed $rawData
* @param ProcessorCallContext<MappedObject> $callContext
*/
private function fillObject(
MappedObject $object,
array $data,
$rawData,
MappedObjectContext $mappedObjectContext,
ProcessorCallContext $callContext
): void
{
$type = $mappedObjectContext->getType();
$options = $mappedObjectContext->getOptions();
$meta = $callContext->getMeta();
// Set raw data
if ($options->isFillRawValues()) {
$object->setRawValues($rawData);
}
// Reset mapped properties state
$propertiesMeta = $callContext->getMeta()->getProperties();
foreach ($propertiesMeta as $propertyName => $propertyMeta) {
unset($object->$propertyName);
}
// Set processed data
foreach ($data as $fieldName => $value) {
$propertyName = $this->fieldNameToPropertyName($fieldName, $meta);
$object->$propertyName = $value;
}
// Set skipped properties
$skippedProperties = $callContext->getSkippedProperties();
if ($skippedProperties !== []) {
$partial = new SkippedPropertiesContext($type, $options);
$object->setSkippedPropertiesContext($partial);
foreach ($skippedProperties as $propertyName => $skippedPropertyContext) {
$partial->addSkippedProperty($propertyName, $skippedPropertyContext);
}
}
}
/**
* @template H of MappedObject
* @param class-string<H> $class
* @param H|null $object
* @return ObjectHolder<H>
*/
private function createHolder(string $class, ClassRuntimeMeta $meta, ?MappedObject $object = null): ObjectHolder
{
return new ObjectHolder($this->creator, $meta, $class, $object);
}
// ////////////// //
// Late processing //
// ////////////// //
/**
* @param array<string> $properties
* @throws InvalidData
*/
public function processSkippedProperties(
array $properties,
MappedObject $object,
?Options $options = null
): void
{
$class = get_class($object);
// Object has no skipped properties
if (!$object->hasSkippedPropertiesContext()) {
throw InvalidState::create()
->withMessage(sprintf(
'Cannot initialize properties "%s" of "%s" instance because it has no skipped properties.',
implode(', ', $properties),
$class,
));
}
$skippedPropertiesContext = $object->getSkippedPropertiesContext();
$type = $skippedPropertiesContext->getType();
$options ??= $skippedPropertiesContext->getOptions();
$mappedObjectContext = $this->createMappedObjectContext($options, $type, true);
$skippedProperties = $skippedPropertiesContext->getSkippedProperties();
$meta = $this->metaLoader->load($class);
$holder = $this->createHolder($class, $meta->getClass(), $object);
$callContext = $this->createProcessorRunContext($class, $meta, $holder);
$propertiesMeta = $this->metaLoader->load($class)->getProperties();
foreach ($properties as $propertyName) {
// Property is initialized or does not exist
if (!array_key_exists($propertyName, $skippedProperties)) {
throw InvalidState::create()
->withMessage(sprintf(
'Cannot initialize property "%s" of "%s" instance because it is already initialized or does not exist.',
$propertyName,
$class,
));
}
$skippedPropertyContext = $skippedProperties[$propertyName];
$propertyMeta = $propertiesMeta[$propertyName];
$fieldName = $skippedPropertyContext->getFieldName();
$fieldContext = $this->createFieldContext($mappedObjectContext, $propertyMeta, $fieldName, $propertyName);
// Process field value with property rules
if ($skippedPropertyContext->isDefault()) {
$processed = $skippedPropertyContext->getValue();
} else {
try {
$processed = $this->processProperty(
$skippedPropertyContext->getValue(),
$fieldContext,
$callContext,
$propertyMeta,
);
} catch (ValueDoesNotMatch | InvalidData $exception) {
$type->overwriteInvalidField($fieldName, $exception);
continue;
}
}
$object->$propertyName = $processed;
$skippedPropertiesContext->removeSkippedProperty($propertyName);
}
// If any of fields is invalid, throw error
if ($type->hasInvalidFields()) {
throw InvalidData::create($type, Value::none());
}
// Object is fully initialized, remove partial context
if ($skippedPropertiesContext->getSkippedProperties() === []) {
$object->setSkippedPropertiesContext(null);
}
}
}