Skip to content

Commit

Permalink
misc: remove usage of native __unserialize method during normalization
Browse files Browse the repository at this point in the history
  • Loading branch information
romm committed Aug 30, 2023
1 parent 0a8eab7 commit 710af87
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 26 deletions.
4 changes: 0 additions & 4 deletions src/Normalizer/RecursiveNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,6 @@ private function defaultObjectNormalizer(object $object): callable
return fn () => (array)$object;
}

if (method_exists($object, '__serialize')) {
return fn () => $object->__serialize();
}

return fn () => (fn () => get_object_vars($this))->call($object);
}
}
22 changes: 0 additions & 22 deletions tests/Integration/Normalizer/NormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,6 @@ public function normalize_basic_values_yields_expected_output_data_provider(): i
],
];

yield 'class with serialize method' => [
'input' => new SomeClassWithSerializeMethod(),
'output' => [
'some_string' => 'foo',
'some_integer' => 42,
],
];

yield 'date with default normalizer' => [
'input' => new DateTimeImmutable('1971-11-08'),
'expected' => '1971-11-08T00:00:00.000000+00:00',
Expand Down Expand Up @@ -321,17 +313,3 @@ final class SomeChildClass extends SomeParentClass
{
public string $stringFromChildClass = 'bar';
}

final class SomeClassWithSerializeMethod
{
public string $string = 'foo';
public int $integer = 42;

public function __serialize(): array
{
return [
'some_string' => $this->string,
'some_integer' => $this->integer,
];
}
}

0 comments on commit 710af87

Please sign in to comment.