Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion lib/StripeObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,8 @@ public function updateAttributes($values, $opts = null, $dirty = true, $apiMode
// This is necessary in case metadata is empty, as PHP arrays do
// not differentiate between lists and hashes, and we consider
// empty arrays to be lists.
if (('metadata' === $k) && \is_array($v)) {
// The same applies to the previous_attributes attribute.
if (('metadata' === $k || 'previous_attributes' === $k) && \is_array($v)) {
$this->_values[$k] = StripeObject::constructFrom($v, $opts, $apiMode);
} else {
$this->_values[$k] = Util\Util::convertToStripeObject($v, $opts, $apiMode);
Expand Down
12 changes: 12 additions & 0 deletions tests/Stripe/StripeObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -597,4 +597,16 @@ public function testDeserializeMetadataWithKeyNamedMetadata()
$inner = $obj->metadata;
self::assertSame('value', $inner->metadata);
}

public function testDeserializeEmptyPreviousAttributes()
{
/** @var mixed $obj */
$obj = StripeObject::constructFrom([
'data' => [
'previous_attributes' => [],
],
]);

self::assertInstanceOf(StripeObject::class, $obj->data->previous_attributes);
}
}