From f2d8e4bc3625383d73c2af63140ed20ee7f3603b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Suwi=C5=84ski?= Date: Mon, 8 May 2023 10:27:01 +0200 Subject: [PATCH] getRawData - return empty array on non array json response --- src/GrantType/AuthorizationCode.php | 3 ++- src/GrantType/ClientCredentials.php | 3 ++- src/GrantType/PasswordCredentials.php | 3 ++- src/GrantType/RefreshToken.php | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/GrantType/AuthorizationCode.php b/src/GrantType/AuthorizationCode.php index 9c52f40..356e13e 100644 --- a/src/GrantType/AuthorizationCode.php +++ b/src/GrantType/AuthorizationCode.php @@ -66,8 +66,9 @@ public function getRawData(SignerInterface $clientCredentialsSigner, $refreshTok ); $response = $this->client->send($request); + $rawData = json_decode($response->getBody(), true); - return (array) json_decode($response->getBody(), true); + return is_array($rawData) ? $rawData : []; } /** diff --git a/src/GrantType/ClientCredentials.php b/src/GrantType/ClientCredentials.php index 0f5284b..7e92769 100644 --- a/src/GrantType/ClientCredentials.php +++ b/src/GrantType/ClientCredentials.php @@ -68,8 +68,9 @@ public function getRawData(SignerInterface $clientCredentialsSigner, $refreshTok ); $response = $this->client->send($request); + $rawData = json_decode($response->getBody(), true); - return (array) json_decode($response->getBody(), true); + return is_array($rawData) ? $rawData : []; } /** diff --git a/src/GrantType/PasswordCredentials.php b/src/GrantType/PasswordCredentials.php index 48d413d..1223872 100644 --- a/src/GrantType/PasswordCredentials.php +++ b/src/GrantType/PasswordCredentials.php @@ -66,8 +66,9 @@ public function getRawData(SignerInterface $clientCredentialsSigner, $refreshTok ); $response = $this->client->send($request); + $rawData = json_decode($response->getBody(), true); - return (array) json_decode($response->getBody(), true); + return is_array($rawData) ? $rawData : []; } /** diff --git a/src/GrantType/RefreshToken.php b/src/GrantType/RefreshToken.php index 0d19d04..5c57aaf 100644 --- a/src/GrantType/RefreshToken.php +++ b/src/GrantType/RefreshToken.php @@ -65,8 +65,9 @@ public function getRawData(SignerInterface $clientCredentialsSigner, $refreshTok ); $response = $this->client->send($request); + $rawData = json_decode($response->getBody(), true); - return (array) json_decode($response->getBody(), true); + return is_array($rawData) ? $rawData : []; } /**