Skip to content

Commit

Permalink
Fix regression introduced in #1872 (#1873)
Browse files Browse the repository at this point in the history
  • Loading branch information
romainneutron committed Nov 23, 2020
1 parent a323450 commit 11ababf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/Query/Terms.php
Expand Up @@ -30,7 +30,7 @@ class Terms extends AbstractQuery
private $lookup;

/**
* @param array<float|int|string> $terms Terms list, leave empty if building a terms-lookup query
* @param array<bool|float|int|string> $terms Terms list, leave empty if building a terms-lookup query
*/
public function __construct(string $field, array $terms = [])
{
Expand All @@ -45,7 +45,7 @@ public function __construct(string $field, array $terms = [])
/**
* Sets terms for the query.
*
* @param array<float|int|string>
* @param array<bool|float|int|string>
*/
public function setTerms(array $terms): self
{
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/Query/TermsTest.php
Expand Up @@ -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());
Expand Down

0 comments on commit 11ababf

Please sign in to comment.