From 68dfcd4d570e7732a244d7090ac7d9e87b2a7349 Mon Sep 17 00:00:00 2001 From: Will Taylor-Jackson Date: Fri, 2 Feb 2018 15:09:44 +0000 Subject: [PATCH] fix: don't treat strings as callables --- src/DesignMyNight/Elasticsearch/QueryBuilder.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/DesignMyNight/Elasticsearch/QueryBuilder.php b/src/DesignMyNight/Elasticsearch/QueryBuilder.php index 67e23ce..6c34c33 100644 --- a/src/DesignMyNight/Elasticsearch/QueryBuilder.php +++ b/src/DesignMyNight/Elasticsearch/QueryBuilder.php @@ -138,7 +138,7 @@ public function whereNestedDoc($column, $query, $boolean = 'and'): self { $type = 'NestedDoc'; - if ( is_callable($query) ){ + if (!is_string($query) && is_callable($query)){ call_user_func($query, $query = $this->newQuery()); } @@ -192,7 +192,7 @@ public function whereWithOptions(...$args): self /** * Add a filter query by calling the required 'where' method * and capturing the added where as a filter - * + * * @param string $method * @param array $args * @return self @@ -315,11 +315,11 @@ protected function whereRelationship(string $relationshipType, string $documentT */ public function aggregation($key, $type, $args = null, $aggregations = null): self { - if ( is_callable($args) ){ + if (!is_string($args) && is_callable($args)){ call_user_func($args, $args = $this->newQuery()); } - if ( is_callable($aggregations) ){ + if (!is_string($aggregations) && is_callable($aggregations)){ call_user_func($aggregations, $aggregations = $this->newQuery()); } @@ -351,7 +351,7 @@ public function orderBy($column, $direction = 1, $options = null): self /** * Whether to include inner hits in the response - * + * * @return self */ public function withInnerHits(): self @@ -363,7 +363,7 @@ public function withInnerHits(): self /** * Get the aggregations returned from query - * + * * @return array */ public function getAggregationResults(): array