From be4404bac100544de4af21ede8729ecd1ba5cb66 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Simonas=20=C5=A0erlinskas?= <simonas.serlinskas@nfq.com>
Date: Tue, 11 Aug 2015 16:52:31 +0300
Subject: [PATCH] changed empty array to std class for particular queries

---
 src/Aggregation/GlobalAggregation.php        | 2 +-
 src/Aggregation/ReverseNestedAggregation.php | 6 +++---
 src/Aggregation/TopHitsAggregation.php       | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/Aggregation/GlobalAggregation.php b/src/Aggregation/GlobalAggregation.php
index 09beb1c..ac48255 100644
--- a/src/Aggregation/GlobalAggregation.php
+++ b/src/Aggregation/GlobalAggregation.php
@@ -41,6 +41,6 @@ class GlobalAggregation extends AbstractAggregation
      */
     public function getArray()
     {
-        return [];
+        return new \stdClass();
     }
 }
diff --git a/src/Aggregation/ReverseNestedAggregation.php b/src/Aggregation/ReverseNestedAggregation.php
index 7952961..58febb5 100644
--- a/src/Aggregation/ReverseNestedAggregation.php
+++ b/src/Aggregation/ReverseNestedAggregation.php
@@ -75,11 +75,11 @@ class ReverseNestedAggregation extends AbstractAggregation
             throw new \LogicException("Reverse Nested aggregation `{$this->getName()}` has no aggregations added");
         }
 
-        $data = [];
+        $output = new \stdClass();
         if ($this->getPath()) {
-            $data['path'] = $this->getPath();
+            $output['path'] = $this->getPath();
         }
 
-        return $data;
+        return $output;
     }
 }
diff --git a/src/Aggregation/TopHitsAggregation.php b/src/Aggregation/TopHitsAggregation.php
index 70a0ff1..e88e996 100644
--- a/src/Aggregation/TopHitsAggregation.php
+++ b/src/Aggregation/TopHitsAggregation.php
@@ -138,6 +138,6 @@ class TopHitsAggregation extends AbstractAggregation
 
         $output = $this->processArray($output);
 
-        return $output;
+        return empty($output) ? new \stdClass() : $output;
     }
 }
-- 
GitLab