Skip to content

Commit 0c6453b

Browse files
committed
PHP 7.4 and PHPStan tweaks
1 parent b91448e commit 0c6453b

File tree

9 files changed

+31
-64
lines changed

9 files changed

+31
-64
lines changed

src/Aggregation/Histogram.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,9 @@
99
class Histogram implements LeafAggregationInterface
1010
{
1111

12-
/**
13-
* @var string
14-
*/
15-
private $field;
16-
17-
/**
18-
* @var int
19-
*/
20-
private $interval;
12+
private string $field;
13+
14+
private int $interval;
2115

2216

2317
public function __construct(

src/Collection/AbstractCollection.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,7 @@ public function get(
4949
string $key
5050
): ?\Spameri\ElasticQuery\Entity\EntityInterface
5151
{
52-
if (isset($this->collection[$key])) {
53-
return $this->collection[$key];
54-
}
55-
56-
return NULL;
52+
return $this->collection[$key] ?? NULL;
5753
}
5854

5955

src/Mapping/Tokenizer/CharGroup.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function getType(): string
1717
public function toArray(): array
1818
{
1919
return [
20-
$this->getType()
20+
$this->getType(),
2121
];
2222
}
2323

src/Mapping/Tokenizer/Classic.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function getType(): string
1717
public function toArray(): array
1818
{
1919
return [
20-
$this->getType()
20+
$this->getType(),
2121
];
2222
}
2323

src/Query/Exists.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@
99
class Exists implements LeafQueryInterface
1010
{
1111

12-
/**
13-
* @var string
14-
*/
15-
private $field;
12+
private string $field;
1613

1714

1815
public function __construct(

src/Query/Range.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,17 @@ public function toArray(): array
9494
];
9595

9696
if ($this->gte !== NULL) {
97-
$array['range'][$this->field]['gte'] = $this->gte instanceof \DateTimeInterface ? $this->gte->format('Y-m-d H:i:s') : $this->gte;
97+
$array['range'][$this->field]['gte'] =
98+
$this->gte instanceof \DateTimeInterface
99+
? $this->gte->format('Y-m-d H:i:s')
100+
: $this->gte;
98101
}
99102

100103
if ($this->lte !== NULL) {
101-
$array['range'][$this->field]['lte'] = $this->lte instanceof \DateTimeInterface ? $this->lte->format('Y-m-d H:i:s') : $this->lte;
104+
$array['range'][$this->field]['lte'] =
105+
$this->lte instanceof \DateTimeInterface
106+
? $this->lte->format('Y-m-d H:i:s')
107+
: $this->lte;
102108
}
103109

104110
return $array;

src/Query/Term.php

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,28 @@
22

33
namespace Spameri\ElasticQuery\Query;
44

5-
65
/**
76
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-term-query.html
87
*/
98
class Term implements LeafQueryInterface
109
{
1110

12-
/**
13-
* @var string
14-
*/
15-
private $field;
11+
private string $field;
1612

1713
/**
18-
* @var string
14+
* @var string|int|bool|float
1915
*/
2016
private $query;
2117

22-
/**
23-
* @var float
24-
*/
25-
private $boost;
18+
private float $boost;
2619

2720

21+
/**
22+
* @param string|int|bool|float $query
23+
*/
2824
public function __construct(
2925
string $field
30-
, string $query
26+
, $query
3127
, float $boost = 1.0
3228
)
3329
{
@@ -45,17 +41,14 @@ public function key(): string
4541

4642
public function toArray(): array
4743
{
48-
// phpcs:ignore SlevomatCodingStandard.Variables.UselessVariable
49-
$array = [
44+
return [
5045
'term' => [
5146
$this->field => [
5247
'value' => $this->query,
5348
'boost' => $this->boost,
5449
],
5550
],
5651
];
57-
58-
return $array;
5952
}
6053

6154
}

src/Query/Terms.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,14 @@
99
class Terms implements LeafQueryInterface
1010
{
1111

12-
/**
13-
* @var string
14-
*/
15-
private $field;
12+
private string $field;
1613

1714
/**
18-
* @var array
15+
* @var array<string|int|bool|float>
1916
*/
20-
private $query;
17+
private array $query;
2118

22-
/**
23-
* @var float
24-
*/
25-
private $boost;
19+
private float $boost;
2620

2721

2822
public function __construct(

src/Query/WildCard.php

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,17 @@
22

33
namespace Spameri\ElasticQuery\Query;
44

5-
65
/**
76
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-wildcard-query.html
87
*/
98
class WildCard implements LeafQueryInterface
109
{
1110

12-
/**
13-
* @var string
14-
*/
15-
private $field;
11+
private string $field;
1612

17-
/**
18-
* @var string
19-
*/
20-
private $query;
13+
private string $query;
2114

22-
/**
23-
* @var float
24-
*/
25-
private $boost;
15+
private float $boost;
2616

2717

2818
public function __construct(
@@ -45,17 +35,14 @@ public function key(): string
4535

4636
public function toArray(): array
4737
{
48-
// phpcs:ignore SlevomatCodingStandard.Variables.UselessVariable
49-
$array = [
38+
return [
5039
'wildcard' => [
5140
$this->field => [
5241
'value' => $this->query,
5342
'boost' => $this->boost,
5443
],
5544
],
5645
];
57-
58-
return $array;
5946
}
6047

6148
}

0 commit comments

Comments
 (0)