From 71551a8bf87cf89a7e0cb44b3eb0e4fb77d427c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dezs=C5=91=20BICZ=C3=93?= Date: Mon, 13 May 2024 18:55:10 +0000 Subject: [PATCH] Fix handling of empty response Closes https://github.com/apigee/apigee-client-php/issues/363 --- src/Controller/NonPaginatedEntityListingControllerTrait.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Controller/NonPaginatedEntityListingControllerTrait.php b/src/Controller/NonPaginatedEntityListingControllerTrait.php index 807302b5..1a14f446 100644 --- a/src/Controller/NonPaginatedEntityListingControllerTrait.php +++ b/src/Controller/NonPaginatedEntityListingControllerTrait.php @@ -23,7 +23,7 @@ /** * Trait NonPaginatedEntityListingControllerTrait. * - * @see \Apigee\Edge\Controller\NonPaginatedEntityListingControllerInterface + * @see NonPaginatedEntityListingControllerInterface */ trait NonPaginatedEntityListingControllerTrait { @@ -43,6 +43,9 @@ public function getEntities(): array $uri = $this->getBaseEndpointUri()->withQuery(http_build_query($query_params)); $response = $this->getClient()->get($uri); $responseArray = $this->responseToArray($response); + if ([] === $responseArray) { + return []; + } // Ignore entity type key from response, ex.: apiProduct. $responseArray = reset($responseArray);