From a99d33c72d663252d540a7b4b02ef57577c53f3d Mon Sep 17 00:00:00 2001 From: Christopher Ng Date: Tue, 8 Mar 2022 00:38:38 +0000 Subject: Discard duplicate collection name from account serialization Signed-off-by: Christopher Ng --- lib/private/Accounts/Account.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lib/private/Accounts') diff --git a/lib/private/Accounts/Account.php b/lib/private/Accounts/Account.php index 540d15cd4b9..7d36af561ce 100644 --- a/lib/private/Accounts/Account.php +++ b/lib/private/Accounts/Account.php @@ -104,9 +104,16 @@ class Account implements IAccount { return $result; } - /** @return IAccountPropertyCollection[]|IAccountProperty[] */ + /** @return array> */ public function jsonSerialize(): array { - return $this->properties; + $properties = $this->properties; + foreach ($properties as $propertyName => $propertyObject) { + if ($propertyObject instanceof IAccountPropertyCollection) { + // Override collection serialization to discard duplicate name + $properties[$propertyName] = $propertyObject->jsonSerialize()[$propertyName]; + } + } + return $properties; } public function getUser(): IUser { -- cgit v1.2.3