Skip to content

Commit

Permalink
Fixes #277: Prevent accidental string matches for global functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Radiergummi committed Apr 12, 2023
1 parent 8390e21 commit ca4cdc7
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/Concerns/BuildsFluentQueries.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Matchory\Elasticsearch\Concerns;

use Closure;
use InvalidArgumentException;
use JetBrains\PhpStorm\Deprecated;
use Matchory\Elasticsearch\Classes\Search;
Expand Down Expand Up @@ -459,7 +460,7 @@ public function body(array $body = []): self
*/
public function distance($name, $value, string $distance): self
{
if (is_callable($name)) {
if ($name instanceof Closure) {
return tap($this, $name);
}

Expand Down Expand Up @@ -1085,7 +1086,7 @@ public function where(
$operator = Query::OPERATOR_EQUAL,
$value = null
): self {
if (is_callable($name)) {
if ($name instanceof Closure) {
$name($this);

return $this;
Expand Down Expand Up @@ -1209,7 +1210,7 @@ public function whereExists(string $name, bool $exists = true): self
*/
public function whereIn($name, $value = []): self
{
if (is_callable($name)) {
if ($name instanceof Closure) {
return tap($this, $name);
}

Expand All @@ -1230,7 +1231,7 @@ public function whereNot(
string $operator = Query::OPERATOR_EQUAL,
$value = null
): self {
if (is_callable($name)) {
if ($name instanceof Closure) {
return tap($this, $name);
}

Expand Down Expand Up @@ -1318,7 +1319,7 @@ public function whereNotBetween(
*/
public function whereNotIn($name, $value = []): self
{
if (is_callable($name)) {
if ($name instanceof Closure) {
return tap($this, $name);
}

Expand Down

0 comments on commit ca4cdc7

Please sign in to comment.