Skip to content

Commit 0b76a25

Browse files
committed
Discard duplicate collection name from account serialization
Signed-off-by: Christopher Ng <chrng8@gmail.com>
1 parent 019117c commit 0b76a25

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/private/Accounts/Account.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,16 @@ public function getFilteredProperties(string $scope = null, string $verified = n
104104
return $result;
105105
}
106106

107-
/** @return IAccountPropertyCollection[]|IAccountProperty[] */
107+
/** @return array<string, IAccountProperty|array<int, IAccountProperty>> */
108108
public function jsonSerialize(): array {
109-
return $this->properties;
109+
$properties = $this->properties;
110+
foreach ($properties as $propertyName => $propertyObject) {
111+
if ($propertyObject instanceof IAccountPropertyCollection) {
112+
// Override collection serialization to discard duplicate name
113+
$properties[$propertyName] = $propertyObject->jsonSerialize()[$propertyName];
114+
}
115+
}
116+
return $properties;
110117
}
111118

112119
public function getUser(): IUser {

0 commit comments

Comments
 (0)