Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/Common/Resource/AbstractResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ abstract class AbstractResource implements ResourceInterface, Serializable
*
* @return AbstractResource
*/
public function populateFromResponse(ResponseInterface $response): self
public function populateFromResponse(ResponseInterface $response)
{
if (strpos($response->getHeaderLine('Content-Type'), 'application/json') === 0) {
$json = Utils::jsonDecode($response);
Expand All @@ -61,7 +61,7 @@ public function populateFromResponse(ResponseInterface $response): self
*
* @return mixed|void
*/
public function populateFromArray(array $array): self
public function populateFromArray(array $array)
{
$aliases = $this->getAliases();

Expand Down Expand Up @@ -145,7 +145,13 @@ public function serialize(): \stdClass
$val = $this->{$name};

$fn = function ($val) {
return ($val instanceof Serializable) ? $val->serialize() : $val;
if ($val instanceof Serializable) {
return $val->serialize();
} elseif ($val instanceof \DateTimeImmutable) {
return $val->format('c');
} else {
return $val;
}
};

if (is_array($val)) {
Expand Down