diff --git a/src/Aggregation/AbstractAggregation.php b/src/Aggregation/AbstractAggregation.php index a2dd13195f7db0ffb949658001704b53c6f59ca0..d83de8255fe153eca4d4523a238be6e8f0eaa810 100644 --- a/src/Aggregation/AbstractAggregation.php +++ b/src/Aggregation/AbstractAggregation.php @@ -41,7 +41,7 @@ abstract class AbstractAggregation implements NamedBuilderInterface /** * @return array|\stdClass */ - abstract public function getArray(): array; + abstract public function getArray(): array|\stdClass; /** * Inner aggregations container init. @@ -122,11 +122,11 @@ abstract class AbstractAggregation implements NamedBuilderInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { $array = $this->getArray(); $result = [ - $this->getType() => $this->processArray($array), + $this->getType() => is_array($array) ? $this->processArray($array) : $array, ]; if ($this->supportsNesting()) { diff --git a/src/Aggregation/Bucketing/AdjacencyMatrixAggregation.php b/src/Aggregation/Bucketing/AdjacencyMatrixAggregation.php index 9bbcdc8d614c664e45c4dc988b520a543db0cbbc..606c3cce6c03851d3cb248f8ddc495af73644261 100644 --- a/src/Aggregation/Bucketing/AdjacencyMatrixAggregation.php +++ b/src/Aggregation/Bucketing/AdjacencyMatrixAggregation.php @@ -61,7 +61,7 @@ class AdjacencyMatrixAggregation extends AbstractAggregation /** * {@inheritdoc} */ - public function getArray(): array + public function getArray(): array|\stdClass { return $this->filters; } diff --git a/src/Aggregation/Bucketing/AutoDateHistogramAggregation.php b/src/Aggregation/Bucketing/AutoDateHistogramAggregation.php index 7e97b0de4677afbc9134b1e83c680bd536a0588e..45a30b69b34cd9806df855a1d5c079e2754a5de5 100644 --- a/src/Aggregation/Bucketing/AutoDateHistogramAggregation.php +++ b/src/Aggregation/Bucketing/AutoDateHistogramAggregation.php @@ -50,7 +50,7 @@ class AutoDateHistogramAggregation extends AbstractAggregation /** * {@inheritdoc} */ - public function getArray(): array + public function getArray(): array|\stdClass { return array_filter( [ diff --git a/src/Aggregation/Bucketing/ChildrenAggregation.php b/src/Aggregation/Bucketing/ChildrenAggregation.php index f81a192f1cedb41f2e59f4bebf190de30544a0b6..c36203ec1d51bca46b7c5a352ee04b45b59c9749 100644 --- a/src/Aggregation/Bucketing/ChildrenAggregation.php +++ b/src/Aggregation/Bucketing/ChildrenAggregation.php @@ -55,7 +55,7 @@ class ChildrenAggregation extends AbstractAggregation /** * {@inheritdoc} */ - public function getArray(): array + public function getArray(): array|\stdClass { if (count($this->getAggregations()) == 0) { throw new \LogicException(sprintf('Children aggregation `%s` has no aggregations added', $this->getName())); diff --git a/src/Aggregation/Bucketing/CompositeAggregation.php b/src/Aggregation/Bucketing/CompositeAggregation.php index 01d58b0983da3400ecfedf860e64624a4c115bec..ad4df1aff8c8d21964393cb780ebd5755bcc0627 100644 --- a/src/Aggregation/Bucketing/CompositeAggregation.php +++ b/src/Aggregation/Bucketing/CompositeAggregation.php @@ -63,7 +63,7 @@ class CompositeAggregation extends AbstractAggregation /** * {@inheritdoc} */ - public function getArray(): array + public function getArray(): array|\stdClass { $array = [ 'sources' => $this->sources, diff --git a/src/Aggregation/Bucketing/DateHistogramAggregation.php b/src/Aggregation/Bucketing/DateHistogramAggregation.php index abea7fc847727026cb309337154c5f4080c9039a..f78f3ebd01adda1a93cf57a9d8b074e8b031782d 100644 --- a/src/Aggregation/Bucketing/DateHistogramAggregation.php +++ b/src/Aggregation/Bucketing/DateHistogramAggregation.php @@ -68,7 +68,7 @@ class DateHistogramAggregation extends AbstractAggregation /** * {@inheritdoc} */ - public function getArray(): array + public function getArray(): array|\stdClass { if (!$this->getField() || !$this->getInterval()) { throw new \LogicException('Date histogram aggregation must have field and interval set.'); diff --git a/src/Aggregation/Bucketing/DateRangeAggregation.php b/src/Aggregation/Bucketing/DateRangeAggregation.php index 9197a9c7c9c2850fa2261067f9bb9820f1be7495..77829f17a209cd745b854d0db0fe2092b839d19b 100644 --- a/src/Aggregation/Bucketing/DateRangeAggregation.php +++ b/src/Aggregation/Bucketing/DateRangeAggregation.php @@ -98,7 +98,7 @@ class DateRangeAggregation extends AbstractAggregation /** * {@inheritdoc} */ - public function getArray(): array + public function getArray(): array|\stdClass { if ($this->getField() && $this->getFormat() && !empty($this->ranges)) { return [ diff --git a/src/Aggregation/Bucketing/DiversifiedSamplerAggregation.php b/src/Aggregation/Bucketing/DiversifiedSamplerAggregation.php index b00793c4114b7d003c89e09408f9316fda9b57a8..461c16556f7eb0a1beefbefd53e0c184bdb63100 100644 --- a/src/Aggregation/Bucketing/DiversifiedSamplerAggregation.php +++ b/src/Aggregation/Bucketing/DiversifiedSamplerAggregation.php @@ -73,7 +73,7 @@ class DiversifiedSamplerAggregation extends AbstractAggregation /** * @inheritdoc */ - public function getArray(): array + public function getArray(): array|\stdClass { return array_filter( [ diff --git a/src/Aggregation/Bucketing/FilterAggregation.php b/src/Aggregation/Bucketing/FilterAggregation.php index dff3d33b9bc545ece1296e08d07bb959686e494b..d5f936c2cb1a11ef6a48b611e26692108455eef2 100644 --- a/src/Aggregation/Bucketing/FilterAggregation.php +++ b/src/Aggregation/Bucketing/FilterAggregation.php @@ -67,7 +67,7 @@ class FilterAggregation extends AbstractAggregation /** * {@inheritdoc} */ - public function getArray(): array + public function getArray(): array|\stdClass { if (!$this->filter) { throw new \LogicException(sprintf('Filter aggregation `%s` has no filter added', $this->getName())); diff --git a/src/Aggregation/Bucketing/FiltersAggregation.php b/src/Aggregation/Bucketing/FiltersAggregation.php index ead56bbabe90a533f21aa3c3d2f2b6e5b34b3803..72fee2279c0b4c7e049b7453c539c78633e7f21c 100644 --- a/src/Aggregation/Bucketing/FiltersAggregation.php +++ b/src/Aggregation/Bucketing/FiltersAggregation.php @@ -78,7 +78,7 @@ class FiltersAggregation extends AbstractAggregation /** * {@inheritdoc} */ - public function getArray(): array + public function getArray(): array|\stdClass { return $this->filters; } diff --git a/src/Aggregation/Bucketing/GeoDistanceAggregation.php b/src/Aggregation/Bucketing/GeoDistanceAggregation.php index f9857d8dc9a98ade0e3861fe44b2b841e5f1b75e..7432a5e0600694abaac009757af655c35fc93315 100644 --- a/src/Aggregation/Bucketing/GeoDistanceAggregation.php +++ b/src/Aggregation/Bucketing/GeoDistanceAggregation.php @@ -122,7 +122,7 @@ class GeoDistanceAggregation extends AbstractAggregation /** * {@inheritdoc} */ - public function getArray(): array + public function getArray(): array|\stdClass { $data = []; diff --git a/src/Aggregation/Bucketing/GeoHashGridAggregation.php b/src/Aggregation/Bucketing/GeoHashGridAggregation.php index 4199342409ff88090c3a5fbb7ad1e22899309dc0..675ee62a73183ccb77e55148643e0b93f1a02a1f 100644 --- a/src/Aggregation/Bucketing/GeoHashGridAggregation.php +++ b/src/Aggregation/Bucketing/GeoHashGridAggregation.php @@ -120,7 +120,7 @@ class GeoHashGridAggregation extends AbstractAggregation /** * {@inheritdoc} */ - public function getArray(): array + public function getArray(): array|\stdClass { $data = []; diff --git a/src/Aggregation/Bucketing/GlobalAggregation.php b/src/Aggregation/Bucketing/GlobalAggregation.php index 4e4fac3fd1d12d394dc09f835df6051cad476e0b..92f92210f48fa17002d93946587d114d06c1a638 100644 --- a/src/Aggregation/Bucketing/GlobalAggregation.php +++ b/src/Aggregation/Bucketing/GlobalAggregation.php @@ -42,8 +42,8 @@ class GlobalAggregation extends AbstractAggregation /** * {@inheritdoc} */ - public function getArray(): array + public function getArray(): array|\stdClass { - return []; + return new \stdClass(); } } diff --git a/src/Aggregation/Bucketing/HistogramAggregation.php b/src/Aggregation/Bucketing/HistogramAggregation.php index eb842377b2170dc65206b3fa4a62e631671cba05..2f27e3955b2000ddb5d2c8c31990dd8e09318fe8 100644 --- a/src/Aggregation/Bucketing/HistogramAggregation.php +++ b/src/Aggregation/Bucketing/HistogramAggregation.php @@ -218,7 +218,7 @@ class HistogramAggregation extends AbstractAggregation /** * {@inheritdoc} */ - public function getArray(): array + public function getArray(): array|\stdClass { $out = array_filter( [ diff --git a/src/Aggregation/Bucketing/Ipv4RangeAggregation.php b/src/Aggregation/Bucketing/Ipv4RangeAggregation.php index 7538896ebabc3f7347cc75f32f6e2d7ec1ffe66a..066e82d8e1c4c5e2f46c34846c0c42d206b750f6 100644 --- a/src/Aggregation/Bucketing/Ipv4RangeAggregation.php +++ b/src/Aggregation/Bucketing/Ipv4RangeAggregation.php @@ -83,7 +83,7 @@ class Ipv4RangeAggregation extends AbstractAggregation /** * {@inheritdoc} */ - public function getArray(): array + public function getArray(): array|\stdClass { if ($this->getField() && !empty($this->ranges)) { return [ diff --git a/src/Aggregation/Bucketing/MissingAggregation.php b/src/Aggregation/Bucketing/MissingAggregation.php index c3eb5cc3293fbf3401deef9f1c99077e2caef0e7..01af957123b6830fbcba3ca43ee5d740a56fa885 100644 --- a/src/Aggregation/Bucketing/MissingAggregation.php +++ b/src/Aggregation/Bucketing/MissingAggregation.php @@ -36,7 +36,7 @@ class MissingAggregation extends AbstractAggregation /** * {@inheritdoc} */ - public function getArray(): array + public function getArray(): array|\stdClass { if ($this->getField()) { return ['field' => $this->getField()]; diff --git a/src/Aggregation/Bucketing/NestedAggregation.php b/src/Aggregation/Bucketing/NestedAggregation.php index e54ea12dd45cf2de4ef77316388ca161a5b3cb5f..fc47fe66c7dd4e4fbd4ed3b9f6280261b7869fac 100644 --- a/src/Aggregation/Bucketing/NestedAggregation.php +++ b/src/Aggregation/Bucketing/NestedAggregation.php @@ -74,7 +74,7 @@ class NestedAggregation extends AbstractAggregation /** * {@inheritdoc} */ - public function getArray(): array + public function getArray(): array|\stdClass { return ['path' => $this->getPath()]; } diff --git a/src/Aggregation/Bucketing/RangeAggregation.php b/src/Aggregation/Bucketing/RangeAggregation.php index 12aaf419eede405bbc9bcc0fe97f09d824373975..a1c87d3667175b1971c1c788885bf248ecd4ef1f 100644 --- a/src/Aggregation/Bucketing/RangeAggregation.php +++ b/src/Aggregation/Bucketing/RangeAggregation.php @@ -112,7 +112,7 @@ class RangeAggregation extends AbstractAggregation /** * {@inheritdoc} */ - public function getArray(): array + public function getArray(): array|\stdClass { $data = [ 'keyed' => $this->keyed, diff --git a/src/Aggregation/Bucketing/ReverseNestedAggregation.php b/src/Aggregation/Bucketing/ReverseNestedAggregation.php index c14b0e8ee44e5e846a591d99724b32d1bb426390..bc66b4848ab4f632b6197dddb32cb08667c499bc 100644 --- a/src/Aggregation/Bucketing/ReverseNestedAggregation.php +++ b/src/Aggregation/Bucketing/ReverseNestedAggregation.php @@ -68,9 +68,9 @@ class ReverseNestedAggregation extends AbstractAggregation /** * {@inheritdoc} */ - public function getArray(): array + public function getArray(): array|\stdClass { - $output = []; + $output = new \stdClass(); if ($this->getPath()) { $output = ['path' => $this->getPath()]; } diff --git a/src/Aggregation/Bucketing/SamplerAggregation.php b/src/Aggregation/Bucketing/SamplerAggregation.php index 3bdc031990b938a03daf616520914d177295dca6..73bf0c5902567632fb097fa2e150121fe9072d4b 100644 --- a/src/Aggregation/Bucketing/SamplerAggregation.php +++ b/src/Aggregation/Bucketing/SamplerAggregation.php @@ -75,7 +75,7 @@ class SamplerAggregation extends AbstractAggregation /** * {@inheritdoc} */ - public function getArray(): array + public function getArray(): array|\stdClass { return array_filter( [ diff --git a/src/Aggregation/Bucketing/TermsAggregation.php b/src/Aggregation/Bucketing/TermsAggregation.php index 7ada67203b5244a0933d8326641af20d6b924f57..d6b6335053a0a8357b8e2142aafc803a36056a83 100644 --- a/src/Aggregation/Bucketing/TermsAggregation.php +++ b/src/Aggregation/Bucketing/TermsAggregation.php @@ -51,7 +51,7 @@ class TermsAggregation extends AbstractAggregation /** * {@inheritdoc} */ - public function getArray(): array + public function getArray(): array|\stdClass { return array_filter( [ diff --git a/src/Aggregation/Matrix/MatrixStatsAggregation.php b/src/Aggregation/Matrix/MatrixStatsAggregation.php index f9cf983ab342d42871bd3aa1d556e419f5f1ec0f..648df482fc8c9063d22a063188dedaf74576d187 100644 --- a/src/Aggregation/Matrix/MatrixStatsAggregation.php +++ b/src/Aggregation/Matrix/MatrixStatsAggregation.php @@ -92,7 +92,7 @@ class MatrixStatsAggregation extends AbstractAggregation return 'matrix_stats'; } - public function getArray(): array + public function getArray(): array|\stdClass { $out = []; if ($this->getField()) { diff --git a/src/Aggregation/Metric/CardinalityAggregation.php b/src/Aggregation/Metric/CardinalityAggregation.php index 51486d5e47c1e4117525a6d1f791c480a7104d74..ab6706f83b92d6627723e86b955d275def0a06b3 100644 --- a/src/Aggregation/Metric/CardinalityAggregation.php +++ b/src/Aggregation/Metric/CardinalityAggregation.php @@ -38,7 +38,7 @@ class CardinalityAggregation extends AbstractAggregation /** * {@inheritdoc} */ - public function getArray(): array + public function getArray(): array|\stdClass { $out = array_filter( [ diff --git a/src/Aggregation/Metric/ExtendedStatsAggregation.php b/src/Aggregation/Metric/ExtendedStatsAggregation.php index 5fdcb9c14a957ff4983c6d2324539a94f0e0861c..b807a97f9ce848d90cdc29ac24fce0440bed0a05 100644 --- a/src/Aggregation/Metric/ExtendedStatsAggregation.php +++ b/src/Aggregation/Metric/ExtendedStatsAggregation.php @@ -78,7 +78,7 @@ class ExtendedStatsAggregation extends AbstractAggregation /** * {@inheritdoc} */ - public function getArray(): array + public function getArray(): array|\stdClass { return array_filter( [ diff --git a/src/Aggregation/Metric/GeoBoundsAggregation.php b/src/Aggregation/Metric/GeoBoundsAggregation.php index 13c35039abd4a424ef87258fa2645ed9d55ccc2b..3d363aea5f519bb9710cde20f785da8db75b70d4 100644 --- a/src/Aggregation/Metric/GeoBoundsAggregation.php +++ b/src/Aggregation/Metric/GeoBoundsAggregation.php @@ -54,7 +54,7 @@ class GeoBoundsAggregation extends AbstractAggregation /** * {@inheritdoc} */ - public function getArray(): array + public function getArray(): array|\stdClass { $data = []; if ($this->getField()) { diff --git a/src/Aggregation/Metric/GeoCentroidAggregation.php b/src/Aggregation/Metric/GeoCentroidAggregation.php index 3b0529a585f3977f9d36ece092e692af83792c1a..33d090c40e9d225e4171de481af3317cca05aee1 100644 --- a/src/Aggregation/Metric/GeoCentroidAggregation.php +++ b/src/Aggregation/Metric/GeoCentroidAggregation.php @@ -36,7 +36,7 @@ class GeoCentroidAggregation extends AbstractAggregation /** * {@inheritdoc} */ - public function getArray(): array + public function getArray(): array|\stdClass { $data = []; if ($this->getField()) { diff --git a/src/Aggregation/Metric/PercentileRanksAggregation.php b/src/Aggregation/Metric/PercentileRanksAggregation.php index 2f7969f48fffb3e657a25fac15bafe00e662d828..0631d67ed49e7e9db004d3925019873766c85f06 100644 --- a/src/Aggregation/Metric/PercentileRanksAggregation.php +++ b/src/Aggregation/Metric/PercentileRanksAggregation.php @@ -105,7 +105,7 @@ class PercentileRanksAggregation extends AbstractAggregation /** * {@inheritdoc} */ - public function getArray(): array + public function getArray(): array|\stdClass { $out = array_filter( [ diff --git a/src/Aggregation/Metric/PercentilesAggregation.php b/src/Aggregation/Metric/PercentilesAggregation.php index 385ef4bfe6ceaafd37dec5d9df55aacf8ebb2488..ede8b5e2fbe4e2e9ad842cbad51a96f0dfa3a693 100644 --- a/src/Aggregation/Metric/PercentilesAggregation.php +++ b/src/Aggregation/Metric/PercentilesAggregation.php @@ -105,7 +105,7 @@ class PercentilesAggregation extends AbstractAggregation /** * {@inheritdoc} */ - public function getArray(): array + public function getArray(): array|\stdClass { $out = array_filter( [ diff --git a/src/Aggregation/Metric/ScriptedMetricAggregation.php b/src/Aggregation/Metric/ScriptedMetricAggregation.php index 903c6e9efdc1f6312cad3417b7ae733d3b6acd7c..653dfce187587797c71ff0eaa3d810d406707258 100644 --- a/src/Aggregation/Metric/ScriptedMetricAggregation.php +++ b/src/Aggregation/Metric/ScriptedMetricAggregation.php @@ -151,7 +151,7 @@ class ScriptedMetricAggregation extends AbstractAggregation /** * {@inheritdoc} */ - public function getArray(): array + public function getArray(): array|\stdClass { return array_filter( [ diff --git a/src/Aggregation/Metric/StatsAggregation.php b/src/Aggregation/Metric/StatsAggregation.php index 111c64813b2dce7be398c5248c2760494b7facb8..776e927685bdfde2185130e45814bb770c15f783 100644 --- a/src/Aggregation/Metric/StatsAggregation.php +++ b/src/Aggregation/Metric/StatsAggregation.php @@ -47,7 +47,7 @@ class StatsAggregation extends AbstractAggregation /** * {@inheritdoc} */ - public function getArray(): array + public function getArray(): array|\stdClass { $out = []; if ($this->getField()) { diff --git a/src/Aggregation/Metric/TopHitsAggregation.php b/src/Aggregation/Metric/TopHitsAggregation.php index d81ee3d9d4f70cc88a3b5978fbe6be88e5fb3c31..aed69bce0adcae6eac92f42f2de5868dec959165 100644 --- a/src/Aggregation/Metric/TopHitsAggregation.php +++ b/src/Aggregation/Metric/TopHitsAggregation.php @@ -117,7 +117,7 @@ class TopHitsAggregation extends AbstractAggregation /** * {@inheritdoc} */ - public function getArray(): array + public function getArray(): array|\stdClass { $sortsOutput = null; $addedSorts = array_filter($this->getSorts()); @@ -136,6 +136,6 @@ class TopHitsAggregation extends AbstractAggregation static fn($val): bool => $val || is_array($val) || ($val || is_numeric($val)) ); - return empty($output) ? [] : $output; + return empty($output) ? new \stdClass() : $output; } } diff --git a/src/Aggregation/Pipeline/AbstractPipelineAggregation.php b/src/Aggregation/Pipeline/AbstractPipelineAggregation.php index b797d0f1e5ad990e50e64ebe6911adcaff7dff5a..c701bac27cfedfb08ba2585d1614ea447632ca07 100644 --- a/src/Aggregation/Pipeline/AbstractPipelineAggregation.php +++ b/src/Aggregation/Pipeline/AbstractPipelineAggregation.php @@ -47,7 +47,7 @@ abstract class AbstractPipelineAggregation extends AbstractAggregation /** * {@inheritdoc} */ - public function getArray(): array + public function getArray(): array|\stdClass { return ['buckets_path' => $this->getBucketsPath()]; } diff --git a/src/Aggregation/Pipeline/BucketScriptAggregation.php b/src/Aggregation/Pipeline/BucketScriptAggregation.php index a39d77554a85cdc03cd188087885e5e395335792..8cc36fad5ec37bb8711425182b7b86aad2a1a621 100644 --- a/src/Aggregation/Pipeline/BucketScriptAggregation.php +++ b/src/Aggregation/Pipeline/BucketScriptAggregation.php @@ -52,7 +52,7 @@ class BucketScriptAggregation extends AbstractPipelineAggregation /** * {@inheritdoc} */ - public function getArray(): array + public function getArray(): array|\stdClass { if (!$this->getScript()) { throw new \LogicException( diff --git a/src/Aggregation/Pipeline/BucketSortAggregation.php b/src/Aggregation/Pipeline/BucketSortAggregation.php index 3c09af15dca59cca13785d163f6510acd594a51f..f6f06a801b17a893422bf197c432a0ed55aa9f3d 100644 --- a/src/Aggregation/Pipeline/BucketSortAggregation.php +++ b/src/Aggregation/Pipeline/BucketSortAggregation.php @@ -68,7 +68,7 @@ class BucketSortAggregation extends AbstractPipelineAggregation /** * {@inheritdoc} */ - public function getArray(): array + public function getArray(): array|\stdClass { return array_filter( [ diff --git a/src/Aggregation/Pipeline/PercentilesBucketAggregation.php b/src/Aggregation/Pipeline/PercentilesBucketAggregation.php index 83d7c434a14ff52d6c644a5bb7c882574664ca06..f6b4f9bf610b175606d8744846fd94c2acf079a9 100644 --- a/src/Aggregation/Pipeline/PercentilesBucketAggregation.php +++ b/src/Aggregation/Pipeline/PercentilesBucketAggregation.php @@ -49,7 +49,7 @@ class PercentilesBucketAggregation extends AbstractPipelineAggregation /** * {@inheritdoc} */ - public function getArray(): array + public function getArray(): array|\stdClass { $data = ['buckets_path' => $this->getBucketsPath()]; diff --git a/src/BuilderBag.php b/src/BuilderBag.php index cdb6ea1a296ee1c9a8e8e02455726d3d6ad9ed4a..3a23a45379a53e9217b1eec2318dfe4c3953311d 100644 --- a/src/BuilderBag.php +++ b/src/BuilderBag.php @@ -106,7 +106,7 @@ class BuilderBag /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { $output = []; foreach ($this->all() as $builder) { diff --git a/src/BuilderInterface.php b/src/BuilderInterface.php index f57e0a0eab31415c8baa8137d7e3b756bb923942..7e45aa74d75230a6da1412e7a011e040ed86c004 100644 --- a/src/BuilderInterface.php +++ b/src/BuilderInterface.php @@ -21,7 +21,7 @@ interface BuilderInterface * * @return array */ - public function toArray(): array; + public function toArray(): array|\stdClass; /** * Returns element type. diff --git a/src/Highlight/Highlight.php b/src/Highlight/Highlight.php index 8bc04c62eea06043410dac95f9499d490e246cb1..adb74be5e5a7f53ff0c0d1e756ad770072577350 100644 --- a/src/Highlight/Highlight.php +++ b/src/Highlight/Highlight.php @@ -58,7 +58,7 @@ class Highlight implements BuilderInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { $output = []; @@ -69,7 +69,7 @@ class Highlight implements BuilderInterface $output = $this->processArray($output); foreach ($this->fields as $field => $params) { - $output['fields'][$field] = count($params) ? $params : []; + $output['fields'][$field] = count($params) ? $params : new \stdClass(); } return $output; diff --git a/src/InnerHit/NestedInnerHit.php b/src/InnerHit/NestedInnerHit.php index 649ebad6a8cd847dc647e81cf3270702e6dc0214..467fdf63c67c3601ea981962d968eb7b967fa3fa 100644 --- a/src/InnerHit/NestedInnerHit.php +++ b/src/InnerHit/NestedInnerHit.php @@ -77,9 +77,9 @@ class NestedInnerHit implements NamedBuilderInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { - $out = $this->getSearch() ? $this->getSearch()->toArray() : []; + $out = $this->getSearch() ? $this->getSearch()->toArray() : new \stdClass(); return [ $this->getPathType() => [ diff --git a/src/Query/Compound/BoolQuery.php b/src/Query/Compound/BoolQuery.php index 3bb46a41becfd6a0a8c302710ac502ba11270324..f4647b9d78212e42d5fca4ae8205681f4f49ffd2 100644 --- a/src/Query/Compound/BoolQuery.php +++ b/src/Query/Compound/BoolQuery.php @@ -95,7 +95,7 @@ class BoolQuery implements BuilderInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { if (count($this->container) === 1 && isset($this->container[self::MUST]) && count($this->container[self::MUST]) === 1) { @@ -116,7 +116,7 @@ class BoolQuery implements BuilderInterface $output = $this->processArray($output); if (empty($output)) { - $output = []; + $output = new \stdClass(); } return [$this->getType() => $output]; diff --git a/src/Query/Compound/BoostingQuery.php b/src/Query/Compound/BoostingQuery.php index 0df5fd298ad3e824407b1b69f83ddf7fb7fe5d8f..46830f9e02ad3aa491b6d3d87735ad39d0b6d69b 100644 --- a/src/Query/Compound/BoostingQuery.php +++ b/src/Query/Compound/BoostingQuery.php @@ -38,7 +38,7 @@ class BoostingQuery implements BuilderInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { $query = [ 'positive' => $this->positive->toArray(), diff --git a/src/Query/Compound/ConstantScoreQuery.php b/src/Query/Compound/ConstantScoreQuery.php index c1a19dae31b21d0f9a026e3ed8ee5d265b57841e..dd1d3728dd18e203fc9c0ef719569c6108563972 100644 --- a/src/Query/Compound/ConstantScoreQuery.php +++ b/src/Query/Compound/ConstantScoreQuery.php @@ -39,7 +39,7 @@ class ConstantScoreQuery implements BuilderInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { $query = [ 'filter' => $this->query->toArray(), diff --git a/src/Query/Compound/DisMaxQuery.php b/src/Query/Compound/DisMaxQuery.php index 4bde4c45f8bd33ccfc1cf82f6b5dda6403e4661c..bc00c14e841531b84a354de7db6f341f69ead589 100644 --- a/src/Query/Compound/DisMaxQuery.php +++ b/src/Query/Compound/DisMaxQuery.php @@ -60,7 +60,7 @@ class DisMaxQuery implements BuilderInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { $query = []; foreach ($this->queries as $type) { diff --git a/src/Query/Compound/FunctionScoreQuery.php b/src/Query/Compound/FunctionScoreQuery.php index 323beb68d3653bea1f1b07b61b69d9d10ea4ec44..bdd93c55da54fa1a8df39010c64065fc58fc0cd6 100644 --- a/src/Query/Compound/FunctionScoreQuery.php +++ b/src/Query/Compound/FunctionScoreQuery.php @@ -149,7 +149,7 @@ class FunctionScoreQuery implements BuilderInterface public function addRandomFunction(mixed $seed = null, BuilderInterface $query = null) { $function = [ - 'random_score' => $seed ? ['seed' => $seed] : [], + 'random_score' => $seed ? ['seed' => $seed] : new \stdClass(), ]; $this->applyFilter($function, $query); @@ -210,7 +210,7 @@ class FunctionScoreQuery implements BuilderInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { $query = [ 'query' => $this->query->toArray(), diff --git a/src/Query/FullText/CommonTermsQuery.php b/src/Query/FullText/CommonTermsQuery.php index 66c19c97ad2096a440d60096b35db4fe94df8e78..5b365cfd145ac673b26f30b21e1f57cc21644d37 100644 --- a/src/Query/FullText/CommonTermsQuery.php +++ b/src/Query/FullText/CommonTermsQuery.php @@ -43,7 +43,7 @@ class CommonTermsQuery implements BuilderInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { $query = [ 'query' => $this->query, diff --git a/src/Query/FullText/MatchQuery.php b/src/Query/FullText/MatchQuery.php index 7f5398ac4d4aac8bd325b0bc63c8dc39b00e928a..e8dd8ee73c26e24a0c03ec33612f795e18f0b413 100644 --- a/src/Query/FullText/MatchQuery.php +++ b/src/Query/FullText/MatchQuery.php @@ -43,7 +43,7 @@ class MatchQuery implements BuilderInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { $query = [ 'query' => $this->query, diff --git a/src/Query/FullText/MultiMatchQuery.php b/src/Query/FullText/MultiMatchQuery.php index 89ee785f2abce8d1e7a3e6334fa7d43b95634ac1..c6f538f17b816ebbe390e93ebfd5d988d9942134 100644 --- a/src/Query/FullText/MultiMatchQuery.php +++ b/src/Query/FullText/MultiMatchQuery.php @@ -45,7 +45,7 @@ class MultiMatchQuery implements BuilderInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { $query = [ 'query' => $this->query, diff --git a/src/Query/FullText/QueryStringQuery.php b/src/Query/FullText/QueryStringQuery.php index 9b90f021e3e4fe1c8a14b34f3b1c3c7c50579df0..cfbf323780d0b04443f520091fc430543ebb3a58 100644 --- a/src/Query/FullText/QueryStringQuery.php +++ b/src/Query/FullText/QueryStringQuery.php @@ -42,7 +42,7 @@ class QueryStringQuery implements BuilderInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { $query = [ 'query' => $this->query, diff --git a/src/Query/FullText/SimpleQueryStringQuery.php b/src/Query/FullText/SimpleQueryStringQuery.php index efee2cd81fe3883aaf270f2da80daae3d77ca6b1..8d48f35efb61ba2678be18fb0357abef5f5760e6 100644 --- a/src/Query/FullText/SimpleQueryStringQuery.php +++ b/src/Query/FullText/SimpleQueryStringQuery.php @@ -42,7 +42,7 @@ class SimpleQueryStringQuery implements BuilderInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { $query = [ 'query' => $this->query, diff --git a/src/Query/Geo/GeoBoundingBoxQuery.php b/src/Query/Geo/GeoBoundingBoxQuery.php index e2db2fce90d4c8d0bb6d59b4af2010bedc7e74e7..a5f85a13517c7d1b5b52cb0918a52e52232ba1c2 100644 --- a/src/Query/Geo/GeoBoundingBoxQuery.php +++ b/src/Query/Geo/GeoBoundingBoxQuery.php @@ -43,7 +43,7 @@ class GeoBoundingBoxQuery implements BuilderInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { return [ $this->getType() => $this->processArray([$this->field => $this->points()]) diff --git a/src/Query/Geo/GeoDistanceQuery.php b/src/Query/Geo/GeoDistanceQuery.php index df60072f52fd23d89c6d521924b63f612ab620af..8156b54ee023440285179c91a53db0871299c251 100644 --- a/src/Query/Geo/GeoDistanceQuery.php +++ b/src/Query/Geo/GeoDistanceQuery.php @@ -43,7 +43,7 @@ class GeoDistanceQuery implements BuilderInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { $query = [ 'distance' => $this->distance, diff --git a/src/Query/Geo/GeoPolygonQuery.php b/src/Query/Geo/GeoPolygonQuery.php index 656154dd29792241127fdd0a6d8b8334dcee0a8a..27eeab7414ea205afdf92026e04468b16692ca05 100644 --- a/src/Query/Geo/GeoPolygonQuery.php +++ b/src/Query/Geo/GeoPolygonQuery.php @@ -42,7 +42,7 @@ class GeoPolygonQuery implements BuilderInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { $query = [$this->field => ['points' => $this->points]]; $output = $this->processArray($query); diff --git a/src/Query/Geo/GeoShapeQuery.php b/src/Query/Geo/GeoShapeQuery.php index 029b2339514cffccdcff95edbd9dc015414ca498..212cc4aeb80b00f2ce9dd7ee0db864336f54367e 100644 --- a/src/Query/Geo/GeoShapeQuery.php +++ b/src/Query/Geo/GeoShapeQuery.php @@ -124,7 +124,7 @@ class GeoShapeQuery implements BuilderInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { $output = $this->processArray($this->fields); diff --git a/src/Query/Joining/HasChildQuery.php b/src/Query/Joining/HasChildQuery.php index 809d59ae75707759318f2fc61dc69ffa90c58b54..c3f364aa55abfbd2f657bc8407f44fc6168e0a64 100644 --- a/src/Query/Joining/HasChildQuery.php +++ b/src/Query/Joining/HasChildQuery.php @@ -42,7 +42,7 @@ class HasChildQuery implements BuilderInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { $query = [ 'type' => $this->type, diff --git a/src/Query/Joining/HasParentQuery.php b/src/Query/Joining/HasParentQuery.php index 37fe5e1433bb6cae27a90b14700564659b3eac5b..55efeb81621e8fd6d96cd6a9c73cacaef3f61967 100644 --- a/src/Query/Joining/HasParentQuery.php +++ b/src/Query/Joining/HasParentQuery.php @@ -42,7 +42,7 @@ class HasParentQuery implements BuilderInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { $query = [ 'parent_type' => $this->parentType, diff --git a/src/Query/Joining/NestedQuery.php b/src/Query/Joining/NestedQuery.php index c77958ca0c4ce01f7d7968f6ca0d14170ff3f765..3147ec1a7008851976efa54dd18ea8ed8e9d1ddc 100644 --- a/src/Query/Joining/NestedQuery.php +++ b/src/Query/Joining/NestedQuery.php @@ -42,7 +42,7 @@ class NestedQuery implements BuilderInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { return [ $this->getType() => $this->processArray( diff --git a/src/Query/Joining/ParentIdQuery.php b/src/Query/Joining/ParentIdQuery.php index 8c2be24bb450c9af9f86a7a675f38b274e1aac0d..3b1426ebdea8e3327163cda5c9b46c4628bd3f8b 100644 --- a/src/Query/Joining/ParentIdQuery.php +++ b/src/Query/Joining/ParentIdQuery.php @@ -31,7 +31,7 @@ class ParentIdQuery implements BuilderInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { $query = [ 'id' => $this->parentId, diff --git a/src/Query/MatchAllQuery.php b/src/Query/MatchAllQuery.php index 0a727aba1aa804005677ea7367355287d37b1bab..870c190695d75c86061b54d6d000fda233274236 100644 --- a/src/Query/MatchAllQuery.php +++ b/src/Query/MatchAllQuery.php @@ -42,9 +42,9 @@ class MatchAllQuery implements BuilderInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { $params = $this->getParameters(); - return [$this->getType() => !empty($params) ? $params : []]; + return [$this->getType() => !empty($params) ? $params : new \stdClass()]; } } diff --git a/src/Query/Span/FieldMaskingSpanQuery.php b/src/Query/Span/FieldMaskingSpanQuery.php index 9cd641fc0c39e2275d3bc2e894335801a72907d9..e14b237249405d48dc97cddd00f60f257ff7da32 100644 --- a/src/Query/Span/FieldMaskingSpanQuery.php +++ b/src/Query/Span/FieldMaskingSpanQuery.php @@ -82,7 +82,7 @@ class FieldMaskingSpanQuery implements SpanQueryInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { $output = [ 'query' => $this->getQuery()->toArray(), diff --git a/src/Query/Span/SpanContainingQuery.php b/src/Query/Span/SpanContainingQuery.php index ed23bd0efe2b60f5e311aa5ad466f4ba76f06b53..ec269481f5777877b6189be37922049d5125ef36 100644 --- a/src/Query/Span/SpanContainingQuery.php +++ b/src/Query/Span/SpanContainingQuery.php @@ -79,7 +79,7 @@ class SpanContainingQuery implements SpanQueryInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { $output = [ 'little' => $this->getLittle()->toArray(), diff --git a/src/Query/Span/SpanFirstQuery.php b/src/Query/Span/SpanFirstQuery.php index 61e33df268e9ff23f643da4b6729c1d087fdd9d2..ca0c896e268ce37ee6a31c3e5fbb82c1d10f008a 100644 --- a/src/Query/Span/SpanFirstQuery.php +++ b/src/Query/Span/SpanFirstQuery.php @@ -43,7 +43,7 @@ class SpanFirstQuery implements SpanQueryInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { $query = []; $query['match'] = $this->query->toArray(); diff --git a/src/Query/Span/SpanMultiTermQuery.php b/src/Query/Span/SpanMultiTermQuery.php index ac021692daddcf66c1a8dfba10fe6818113757a9..5fbb4b44ce4621f044e02d9e3076d9237dd5a53f 100644 --- a/src/Query/Span/SpanMultiTermQuery.php +++ b/src/Query/Span/SpanMultiTermQuery.php @@ -44,7 +44,7 @@ class SpanMultiTermQuery implements SpanQueryInterface * * @throws \InvalidArgumentException */ - public function toArray(): array + public function toArray(): array|\stdClass { $query = []; $query['match'] = $this->query->toArray(); diff --git a/src/Query/Span/SpanNearQuery.php b/src/Query/Span/SpanNearQuery.php index b0392ac6d3023af1e654bef7b475ccd49807d9f6..24a6b079f30b6c6673103f8ebb24536be67089df 100644 --- a/src/Query/Span/SpanNearQuery.php +++ b/src/Query/Span/SpanNearQuery.php @@ -54,7 +54,7 @@ class SpanNearQuery extends SpanOrQuery implements SpanQueryInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { $query = []; foreach ($this->getQueries() as $type) { diff --git a/src/Query/Span/SpanNotQuery.php b/src/Query/Span/SpanNotQuery.php index 2929b6ae096bc732882d65d3961502ea0a4d13c5..80b847491ab6acfb2d7fdc342b29166f6084275c 100644 --- a/src/Query/Span/SpanNotQuery.php +++ b/src/Query/Span/SpanNotQuery.php @@ -38,7 +38,7 @@ class SpanNotQuery implements SpanQueryInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { $query = [ 'include' => $this->include->toArray(), diff --git a/src/Query/Span/SpanOrQuery.php b/src/Query/Span/SpanOrQuery.php index 3ff25aaf1a22ab266c71705fe14eab53eaede885..296cab23a9adfc0d138245f803bcaa485ddf987f 100644 --- a/src/Query/Span/SpanOrQuery.php +++ b/src/Query/Span/SpanOrQuery.php @@ -64,7 +64,7 @@ class SpanOrQuery implements SpanQueryInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { $query = []; foreach ($this->queries as $type) { diff --git a/src/Query/Specialized/MoreLikeThisQuery.php b/src/Query/Specialized/MoreLikeThisQuery.php index 90d5d1907749d7f9daae5299b0604eaebafb05f7..914c862e873d39483778622bb707835f2b31cfad 100644 --- a/src/Query/Specialized/MoreLikeThisQuery.php +++ b/src/Query/Specialized/MoreLikeThisQuery.php @@ -42,7 +42,7 @@ class MoreLikeThisQuery implements BuilderInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { $query = []; diff --git a/src/Query/Specialized/ScriptQuery.php b/src/Query/Specialized/ScriptQuery.php index ce166d331d4f4a89fa548ad58c10b3bdb92d5062..3dd1a3ff5c3a7bdf25a99b09f27ba1f102f88f32 100644 --- a/src/Query/Specialized/ScriptQuery.php +++ b/src/Query/Specialized/ScriptQuery.php @@ -43,7 +43,7 @@ class ScriptQuery implements BuilderInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { $query = ['inline' => $this->script]; $output = $this->processArray($query); diff --git a/src/Query/Specialized/TemplateQuery.php b/src/Query/Specialized/TemplateQuery.php index de5c96e6175968500e709d58fe8606ddd21b6c2a..c5ffba28f69b66053d0de19e029d73697a56cf39 100644 --- a/src/Query/Specialized/TemplateQuery.php +++ b/src/Query/Specialized/TemplateQuery.php @@ -121,7 +121,7 @@ class TemplateQuery implements BuilderInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { $output = array_filter( [ diff --git a/src/Query/TermLevel/ExistsQuery.php b/src/Query/TermLevel/ExistsQuery.php index 49a5d3230d428398fe8693dd8861b2a2621e521d..74953ce1da02ee4fe8549fa38382b443563cd51e 100644 --- a/src/Query/TermLevel/ExistsQuery.php +++ b/src/Query/TermLevel/ExistsQuery.php @@ -38,7 +38,7 @@ class ExistsQuery implements BuilderInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { return [ $this->getType() => [ diff --git a/src/Query/TermLevel/FuzzyQuery.php b/src/Query/TermLevel/FuzzyQuery.php index 418c919155b6447efb8e2c18ab3b7f4dee3eb455..2638a0dd81560c8d1636867cdcefd242e7513c9c 100644 --- a/src/Query/TermLevel/FuzzyQuery.php +++ b/src/Query/TermLevel/FuzzyQuery.php @@ -43,7 +43,7 @@ class FuzzyQuery implements BuilderInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { $query = [ 'value' => $this->value, diff --git a/src/Query/TermLevel/IdsQuery.php b/src/Query/TermLevel/IdsQuery.php index 749066bef6001ab60a5c1a06fbca0f464fdf0cde..4a173c86eefe08b3333bc6e9dca5329d080409b0 100644 --- a/src/Query/TermLevel/IdsQuery.php +++ b/src/Query/TermLevel/IdsQuery.php @@ -39,7 +39,7 @@ class IdsQuery implements BuilderInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { $query = [ 'values' => $this->values, diff --git a/src/Query/TermLevel/PrefixQuery.php b/src/Query/TermLevel/PrefixQuery.php index 5b0a20bf7939b4f823d5cde4b8bb73610eab7549..f1648d85678d8bec9bc1a683983a16ada379721f 100644 --- a/src/Query/TermLevel/PrefixQuery.php +++ b/src/Query/TermLevel/PrefixQuery.php @@ -44,7 +44,7 @@ class PrefixQuery implements BuilderInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { $query = [ 'value' => $this->value, diff --git a/src/Query/TermLevel/RangeQuery.php b/src/Query/TermLevel/RangeQuery.php index 338224bc696b7fd871e8eada2c0371047c4dcc79..4cca3f1db7546db7e3175fe4b6aca83bd1eec232 100644 --- a/src/Query/TermLevel/RangeQuery.php +++ b/src/Query/TermLevel/RangeQuery.php @@ -61,7 +61,7 @@ class RangeQuery implements BuilderInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { $output = [ $this->field => $this->getParameters(), diff --git a/src/Query/TermLevel/RegexpQuery.php b/src/Query/TermLevel/RegexpQuery.php index 5ffde9e5fe5f54cd189666c44b92c1edd1dfb90b..a4aa518a6ec975e3a76f84c8c69ce3867123b2aa 100644 --- a/src/Query/TermLevel/RegexpQuery.php +++ b/src/Query/TermLevel/RegexpQuery.php @@ -43,7 +43,7 @@ class RegexpQuery implements BuilderInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { $query = [ 'value' => $this->regexpValue, diff --git a/src/Query/TermLevel/TermQuery.php b/src/Query/TermLevel/TermQuery.php index 73afffac95b2ed1361cbc391ef410d675fc460ff..3b5766d713142b8bfd864b34b4c1d779be9c140a 100644 --- a/src/Query/TermLevel/TermQuery.php +++ b/src/Query/TermLevel/TermQuery.php @@ -39,7 +39,7 @@ class TermQuery implements BuilderInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { $query = $this->processArray(); diff --git a/src/Query/TermLevel/TermsQuery.php b/src/Query/TermLevel/TermsQuery.php index 22697010addaf3ee1cb0b8a9c506d342d7fb9b2a..be2da6d3cdfd9207d845e258c263eb71c0829f50 100644 --- a/src/Query/TermLevel/TermsQuery.php +++ b/src/Query/TermLevel/TermsQuery.php @@ -46,7 +46,7 @@ class TermsQuery implements BuilderInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { $query = [ $this->field => $this->terms, diff --git a/src/Query/TermLevel/TermsSetQuery.php b/src/Query/TermLevel/TermsSetQuery.php index d15595ceb339a0d2a606c00474fcaa884e4caf2d..a644f1395f78e800015e5fcd288a00637534855f 100644 --- a/src/Query/TermLevel/TermsSetQuery.php +++ b/src/Query/TermLevel/TermsSetQuery.php @@ -51,7 +51,7 @@ class TermsSetQuery implements BuilderInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { $query = [ 'terms' => $this->terms, diff --git a/src/Query/TermLevel/TypeQuery.php b/src/Query/TermLevel/TypeQuery.php index 533be8f282fcad808caf806629dd94c37adabf38..5f42816eee8d407d5b83f0dd21573e0b5895e87c 100644 --- a/src/Query/TermLevel/TypeQuery.php +++ b/src/Query/TermLevel/TypeQuery.php @@ -40,7 +40,7 @@ class TypeQuery implements BuilderInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { return [ $this->getType() => [ diff --git a/src/Query/TermLevel/WildcardQuery.php b/src/Query/TermLevel/WildcardQuery.php index 901dfb0822b3ed455e77c8decceca34c9a127130..19dbbccb21f515f2cb1dff4801d29d78a13fe7e7 100644 --- a/src/Query/TermLevel/WildcardQuery.php +++ b/src/Query/TermLevel/WildcardQuery.php @@ -43,7 +43,7 @@ class WildcardQuery implements BuilderInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { $query = [ 'value' => $this->value, diff --git a/src/Search.php b/src/Search.php index 0d21cbf7f2d4eb883445a6b086c3cc7754ac4adc..e9e99a4a10d33bfb4775e7d097a58f4121b3a5c0 100644 --- a/src/Search.php +++ b/src/Search.php @@ -724,7 +724,7 @@ class Search /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { $output = array_filter(static::$serializer->normalize($this->endpoints)); diff --git a/src/Sort/FieldSort.php b/src/Sort/FieldSort.php index fe7c1d5f31b18a70cd3840a65cbfffed18d075c8..6d343c7b43b9ed3dc4e1f9e60ac97851fc7b777c 100644 --- a/src/Sort/FieldSort.php +++ b/src/Sort/FieldSort.php @@ -83,7 +83,7 @@ class FieldSort implements BuilderInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { if ($this->order) { $this->addParameter('order', $this->order); @@ -94,7 +94,7 @@ class FieldSort implements BuilderInterface } return [ - $this->field => $this->getParameters() ?: [], + $this->field => $this->getParameters() ?: new \stdClass(), ]; } } diff --git a/src/Sort/NestedSort.php b/src/Sort/NestedSort.php index 355ece621699aeb62b733373c768dcf66467bbbb..d61c6405a53d393891b51beea715a9bd1ee0de00 100644 --- a/src/Sort/NestedSort.php +++ b/src/Sort/NestedSort.php @@ -48,7 +48,7 @@ class NestedSort implements BuilderInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { $output = [ 'path' => $this->path, diff --git a/src/Suggest/Suggest.php b/src/Suggest/Suggest.php index 95fa710e726f9dc99b76787dea44f2bceb919858..2054496e98d2b3f361a4c597c65db3df9e8cdd9a 100644 --- a/src/Suggest/Suggest.php +++ b/src/Suggest/Suggest.php @@ -86,7 +86,7 @@ class Suggest implements NamedBuilderInterface /** * {@inheritdoc} */ - public function toArray(): array + public function toArray(): array|\stdClass { return [ $this->getName() => [ diff --git a/tests/Unit/Aggregation/Bucketing/GlobalAggregationTest.php b/tests/Unit/Aggregation/Bucketing/GlobalAggregationTest.php index 107c2ea5c3b57871ca3431faca5bf8004893c4e1..6ab648b27454590ad7de77edfa62f743d232d59f 100644 --- a/tests/Unit/Aggregation/Bucketing/GlobalAggregationTest.php +++ b/tests/Unit/Aggregation/Bucketing/GlobalAggregationTest.php @@ -28,7 +28,7 @@ class GlobalAggregationTest extends TestCase $aggregation = new GlobalAggregation('test_agg'); $result = [ - 'global' => [], + 'global' => new \stdClass(), ]; $out[] = [ @@ -42,7 +42,7 @@ class GlobalAggregationTest extends TestCase $aggregation->addAggregation($aggregation2); $result = [ - 'global' => [], + 'global' => new \stdClass(), 'aggregations' => [ $aggregation2->getName() => $aggregation2->toArray(), ], diff --git a/tests/Unit/Aggregation/Bucketing/ReverseNestedAggregationTest.php b/tests/Unit/Aggregation/Bucketing/ReverseNestedAggregationTest.php index 62d711d2fd6e329587e6d0e096efa2b9623b85c0..3e2873942af287d36e94f49bdf59fa3ddaa5f7b8 100644 --- a/tests/Unit/Aggregation/Bucketing/ReverseNestedAggregationTest.php +++ b/tests/Unit/Aggregation/Bucketing/ReverseNestedAggregationTest.php @@ -49,7 +49,7 @@ class ReverseNestedAggregationTest extends TestCase $aggregation->addAggregation($termAggregation); $expectedResult = [ - 'reverse_nested' => [], + 'reverse_nested' => new \stdClass(), 'aggregations' => [ $termAggregation->getName() => $termAggregation->toArray(), ], diff --git a/tests/Unit/Highlight/HighlightTest.php b/tests/Unit/Highlight/HighlightTest.php index c4761d8a719870e5ba5bef024d32c5fd28777b5e..da6df7ef685edb940f40b64d3ad21d516afc6091 100644 --- a/tests/Unit/Highlight/HighlightTest.php +++ b/tests/Unit/Highlight/HighlightTest.php @@ -99,7 +99,7 @@ class HighlightTest extends TestCase $result = $highlight->toArray(); $expectedResult = [ 'fields' => [ - 'ok' => [], + 'ok' => new \stdClass(), ], '_source' => [ 'include' => [ diff --git a/tests/Unit/InnerHit/NestedInnerHitTest.php b/tests/Unit/InnerHit/NestedInnerHitTest.php index cbddec82e34fc84afc05b1f6a7548f9398180ae8..94dc3e2ea3378445eb0b7a41c112359a5712b8f7 100644 --- a/tests/Unit/InnerHit/NestedInnerHitTest.php +++ b/tests/Unit/InnerHit/NestedInnerHitTest.php @@ -38,7 +38,7 @@ class NestedInnerHitTest extends TestCase $emptyInnerHit, [ 'path' => [ - 'foo' => [], + 'foo' => new \stdClass(), ], ], ]; diff --git a/tests/Unit/Query/Compound/BoolQueryTest.php b/tests/Unit/Query/Compound/BoolQueryTest.php index 708f016945530c529218a973882b63de77eea1b7..169196df1d67330dbc99bdb8cf76ef297a6af475 100644 --- a/tests/Unit/Query/Compound/BoolQueryTest.php +++ b/tests/Unit/Query/Compound/BoolQueryTest.php @@ -136,7 +136,7 @@ class BoolQueryTest extends TestCase { $bool = new BoolQuery(); - $this->assertEquals(['bool' => []], $bool->toArray()); + $this->assertEquals(['bool' => new \stdClass()], $bool->toArray()); } /** diff --git a/tests/Unit/Query/Compound/FunctionScoreQueryTest.php b/tests/Unit/Query/Compound/FunctionScoreQueryTest.php index 8270a4110eb0239277d2d929c8814af549838f0f..e95b196860ea86174ceaedfe0b726ea728426e6b 100644 --- a/tests/Unit/Query/Compound/FunctionScoreQueryTest.php +++ b/tests/Unit/Query/Compound/FunctionScoreQueryTest.php @@ -36,7 +36,7 @@ class FunctionScoreQueryTest extends TestCase 'query' => [], 'functions' => [ [ - 'random_score' => [], + 'random_score' => new \stdClass(), ], ], ], diff --git a/tests/Unit/Query/MatchAllQueryTest.php b/tests/Unit/Query/MatchAllQueryTest.php index a1e040e5a8459091de0b978219fb1c24cde87f5d..240f85d7f1e259d9cc25e206f2b3ee550822f6c0 100644 --- a/tests/Unit/Query/MatchAllQueryTest.php +++ b/tests/Unit/Query/MatchAllQueryTest.php @@ -22,7 +22,7 @@ class MatchAllQueryTest extends TestCase public function testToArrayWhenThereAreNoParams(): void { $query = new MatchAllQuery(); - $this->assertEquals(['match_all' => []], $query->toArray()); + $this->assertEquals(['match_all' => new \stdClass()], $query->toArray()); } /**