Skip to content

Commit 6b55f3e

Browse files
committed
#110876 fix
1 parent bdd0a5c commit 6b55f3e

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

src/Concerns/DecoratesBoolQuery.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Ensi\LaravelElasticQuery\Concerns;
44

55
use Closure;
6-
use Ensi\LaravelElasticQuery\Contracts\BoolQuery;
76
use Ensi\LaravelElasticQuery\Contracts\MatchOptions;
87
use Ensi\LaravelElasticQuery\Contracts\MultiMatchOptions;
98
use Ensi\LaravelElasticQuery\Contracts\WildcardOptions;
@@ -108,7 +107,7 @@ public function orWhereWildcard(string $field, string $query, ?WildcardOptions $
108107
return $this;
109108
}
110109

111-
public function addMustBool(): BoolQuery
110+
public function addMustBool(callable $fn): static
112111
{
113112
return $this->forwardCallTo($this->boolQuery(), __FUNCTION__, func_get_args());
114113
}

src/Contracts/BoolQuery.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ public function whereWildcard(string $field, string $query, ?WildcardOptions $op
3333

3434
public function orWhereWildcard(string $field, string $query, ?WildcardOptions $options = null): static;
3535

36-
public function addMustBool(): BoolQuery;
36+
public function addMustBool(callable $fn): static;
3737
}

src/Filtering/BoolQueryBuilder.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,13 @@ public function makeWildcard(string $field, string $query, ?WildcardOptions $opt
202202
return new Wildcard($this->absolutePath($field), $query, $options ?: new WildcardOptions());
203203
}
204204

205-
public function addMustBool(): BoolQueryBuilder
205+
public function addMustBool(callable $fn): static
206206
{
207207
$boolCriteria = static::make();
208+
$fn($boolCriteria);
208209
$this->must->add($boolCriteria);
209210

210-
return $boolCriteria;
211+
return $this;
211212
}
212213

213214
protected function addNestedCriteria(string $nested, Closure $filter, CriteriaCollection $target): static

tests/Unit/Filtering/BoolQueryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ public function testAddMustBool(): void
251251
{
252252
$builder = BoolQueryBuilder::make();
253253
$builder->where('mustName', 'value');
254-
$builder->addMustBool()->orWhereWildcard('wildcardName', 'wildcardValue')->orWhereMatch('matchName', 'matchValue');
254+
$builder->addMustBool(fn (BoolQueryBuilder $builder) => $builder->orWhereWildcard('wildcardName', 'wildcardValue')->orWhereMatch('matchName', 'matchValue'));
255255

256256
$dsl = $builder->toDSL();
257257

0 commit comments

Comments
 (0)