Skip to content

Commit

Permalink
Merge branch 'master' into issue_50_enums
Browse files Browse the repository at this point in the history
  • Loading branch information
jrbasso authored Jul 13, 2023
2 parents 108b5a8 + ef82b51 commit 63a45fa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased]
### Added
- Support of UnitEnum and BackedEnum deserialization (PHP > 8.1)
### Fixed
- Fixed deprecated with DateTimeImmutable deserialization with PHP 8.2

## [3.0.0] - 2020-07-20
### Fixed
Expand Down
2 changes: 1 addition & 1 deletion src/JsonSerializer/JsonSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ protected function unserializeObject($value)
throw new JsonSerializerException('Unable to find class ' . $className);
}

if ($className === 'DateTime') {
if ($className === 'DateTime' || $className === 'DateTimeImmutable') {
$obj = $this->restoreUsingUnserialize($className, $value);
$this->objectMapping[$this->objectMappingIndex++] = $obj;
return $obj;
Expand Down
4 changes: 4 additions & 0 deletions tests/JsonSerializerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,10 @@ public function testSerializationOfDateTime()
$date = new \DateTime('2014-06-15 12:00:00', new \DateTimeZone('UTC'));
$obj = $this->serializer->unserialize($this->serializer->serialize($date));
$this->assertSame($date->getTimestamp(), $obj->getTimestamp());

$date = new \DateTimeImmutable('2014-06-15 12:00:00', new \DateTimeZone('UTC'));
$obj = $this->serializer->unserialize($this->serializer->serialize($date));
$this->assertSame($date->getTimestamp(), $obj->getTimestamp());
}

/**
Expand Down

0 comments on commit 63a45fa

Please sign in to comment.