From 11ababf5c73af4c96ca39705dfa50e19f221c63f Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 23 Nov 2020 12:50:51 +0100 Subject: [PATCH] Fix regression introduced in #1872 (#1873) --- src/Query/Terms.php | 10 +++++----- tests/Query/TermsTest.php | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Query/Terms.php b/src/Query/Terms.php index 4e544fab16..6162ad906f 100644 --- a/src/Query/Terms.php +++ b/src/Query/Terms.php @@ -30,7 +30,7 @@ class Terms extends AbstractQuery private $lookup; /** - * @param array $terms Terms list, leave empty if building a terms-lookup query + * @param array $terms Terms list, leave empty if building a terms-lookup query */ public function __construct(string $field, array $terms = []) { @@ -45,7 +45,7 @@ public function __construct(string $field, array $terms = []) /** * Sets terms for the query. * - * @param array + * @param array */ public function setTerms(array $terms): self { @@ -57,12 +57,12 @@ public function setTerms(array $terms): self /** * Adds a single term to the list. * - * @param float|int|string $term + * @param bool|float|int|string $term */ public function addTerm($term): self { - if (!\is_string($term) && !\is_int($term) && !\is_float($term)) { - throw new \TypeError(\sprintf('Argument 1 passed to "%s()" must be of type float|int|string, %s given.', __METHOD__, \is_object($term) ? \get_class($term) : \gettype($term))); + if (!\is_scalar($term)) { + throw new \TypeError(\sprintf('Argument 1 passed to "%s()" must be a scalar, %s given.', __METHOD__, \is_object($term) ? \get_class($term) : \gettype($term))); } $this->terms[] = $term; diff --git a/tests/Query/TermsTest.php b/tests/Query/TermsTest.php index f42a99e7ba..7d6ae773bd 100644 --- a/tests/Query/TermsTest.php +++ b/tests/Query/TermsTest.php @@ -179,7 +179,7 @@ public function testVariousDataTypesViaAddTerm(): void public function testAddTermTypeError(): void { $this->expectException(\TypeError::class); - $this->expectExceptionMessage('Argument 1 passed to "Elastica\Query\Terms::addTerm()" must be of type float|int|string, stdClass given.'); + $this->expectExceptionMessage('Argument 1 passed to "Elastica\Query\Terms::addTerm()" must be a scalar, stdClass given.'); $query = new Terms('some_numeric_field'); $query->addTerm(new \stdClass());