Skip to content

Commit 623b2f5

Browse files
authored
Merge pull request #12 from smoench/php84
support PHP 8.4
2 parents 5c5f004 + 8a044bb commit 623b2f5

File tree

14 files changed

+37
-84
lines changed

14 files changed

+37
-84
lines changed

.github/workflows/test-application.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ jobs:
7979
strategy:
8080
fail-fast: false
8181
matrix:
82-
php-version: [ '8.1', '8.2', '8.3' ]
82+
php-version: [ '8.1', '8.2', '8.3', '8.4' ]
8383

8484
steps:
8585
- name: Checkout project
@@ -120,9 +120,9 @@ jobs:
120120
fail-fast: false
121121
matrix:
122122
include:
123-
- opensearch-version: '1.3'
123+
- opensearch-version: '1'
124124
opensearch-composer-version: '^1'
125-
- opensearch-version: '2.4'
125+
- opensearch-version: '2'
126126
opensearch-composer-version: '^2'
127127

128128
steps:

composer.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919
}
2020
],
2121
"require": {
22-
"php": "8.1.* || 8.2.* || 8.3.*",
23-
"opensearch-project/opensearch-php": "^1.0 || ^2.0"
22+
"php": "8.1.* || 8.2.* || 8.3.* || 8.4.*",
23+
"opensearch-project/opensearch-php": "^1.0 || ^2.3.1"
2424
},
2525
"require-dev": {
26-
"phpunit/phpunit": "^10.4.2",
27-
"phpstan/phpstan": "1.10.46",
28-
"phpstan/phpstan-phpunit": "1.3.15",
29-
"rector/rector": "^0.18.11",
30-
"symplify/easy-coding-standard": "^12.0.9"
26+
"phpunit/phpunit": "^10.5.40",
27+
"phpstan/phpstan": "1.12.14",
28+
"phpstan/phpstan-phpunit": "1.4.2",
29+
"rector/rector": "^1.2.10",
30+
"symplify/easy-coding-standard": "^12.5.5"
3131
},
3232
"autoload": {
3333
"psr-4": {

rector.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Rector\Set\ValueObject\SetList;
99
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector;
1010
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector;
11-
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictGetterMethodReturnTypeRector;
1211

1312
return static function (RectorConfig $rectorConfig): void {
1413
$rectorConfig->paths([
@@ -22,7 +21,6 @@
2221
$rectorConfig->rules([
2322
TypedPropertyFromAssignsRector::class,
2423
TypedPropertyFromStrictConstructorRector::class,
25-
TypedPropertyFromStrictGetterMethodReturnTypeRector::class,
2624
]);
2725

2826
$rectorConfig->sets([

src/Aggregation/Metric/ScriptedMetricAggregation.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ class ScriptedMetricAggregation extends AbstractAggregation
4646
private $reduceScript;
4747

4848
/**
49-
* ScriptedMetricAggregation constructor.
5049
* @param string $name
5150
* @param mixed $initScript
5251
* @param mixed $mapScript

src/Aggregation/Pipeline/BucketScriptAggregation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class BucketScriptAggregation extends AbstractPipelineAggregation
2424
{
2525
private ?string $script = null;
2626

27-
public function __construct(string $name, string|array|null $bucketsPath = null, string $script = null)
27+
public function __construct(string $name, string|array|null $bucketsPath = null, ?string $script = null)
2828
{
2929
parent::__construct($name, $bucketsPath);
3030
$this->setScript($script);

src/BuilderBag.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function get(string $name): BuilderInterface
8181
*
8282
* @return BuilderInterface[]
8383
*/
84-
public function all(string $type = null): array
84+
public function all(?string $type = null): array
8585
{
8686
return array_filter(
8787
$this->bag,

src/InnerHit/NestedInnerHit.php

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -35,51 +35,34 @@ class NestedInnerHit implements NamedBuilderInterface
3535

3636
/**
3737
* Inner hits container init.
38-
*
39-
* @param string $name
40-
* @param string $path
4138
*/
42-
public function __construct($name, $path, Search $search = null)
39+
public function __construct(string $name, string $path, ?Search $search = null)
4340
{
4441
$this->setName($name);
4542
$this->setPath($path);
46-
if ($search instanceof \OpenSearchDSL\Search) {
43+
if ($search instanceof Search) {
4744
$this->setSearch($search);
4845
}
4946
}
5047

51-
/**
52-
* @return string
53-
*/
54-
public function getPath()
48+
public function getPath(): string
5549
{
5650
return $this->path;
5751
}
5852

59-
/**
60-
* @param string $path
61-
*
62-
* @return $this
63-
*/
64-
public function setPath($path)
53+
public function setPath(string $path): static
6554
{
6655
$this->path = $path;
6756

6857
return $this;
6958
}
7059

71-
/**
72-
* @return Search
73-
*/
74-
public function getSearch()
60+
public function getSearch(): ?Search
7561
{
7662
return $this->search;
7763
}
7864

79-
/**
80-
* @return $this
81-
*/
82-
public function setSearch(Search $search)
65+
public function setSearch(Search $search): static
8366
{
8467
$this->search = $search;
8568

@@ -93,7 +76,7 @@ public function getType(): string
9376

9477
public function toArray(): array
9578
{
96-
$out = $this->getSearch() ? $this->getSearch()->toArray() : new stdClass();
79+
$out = $this->getSearch() instanceof \OpenSearchDSL\Search ? $this->getSearch()->toArray() : new stdClass();
9780

9881
return [
9982
$this->getPathType() => [
@@ -104,10 +87,8 @@ public function toArray(): array
10487

10588
/**
10689
* Returns 'path' for nested and 'type' for parent inner hits
107-
*
108-
* @return null|string
10990
*/
110-
private function getPathType()
91+
private function getPathType(): ?string
11192
{
11293
return match ($this->getType()) {
11394
'nested' => 'path',

src/Query/Compound/FunctionScoreQuery.php

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,8 @@ public function __construct(
4040

4141
/**
4242
* Returns the query instance.
43-
*
44-
* @return BuilderInterface object
4543
*/
46-
public function getQuery()
44+
public function getQuery(): BuilderInterface
4745
{
4846
return $this->query;
4947
}
@@ -60,7 +58,7 @@ public function addFieldValueFactorFunction(
6058
$field,
6159
$factor,
6260
$modifier = 'none',
63-
BuilderInterface $query = null,
61+
?BuilderInterface $query = null,
6462
mixed $missing = null
6563
) {
6664
$function = [
@@ -82,30 +80,24 @@ public function addFieldValueFactorFunction(
8280
/**
8381
* Modifier to apply filter to the function score function.
8482
*/
85-
private function applyFilter(array &$function, BuilderInterface $query = null)
83+
private function applyFilter(array &$function, ?BuilderInterface $query = null): void
8684
{
87-
if ($query instanceof \OpenSearchDSL\BuilderInterface) {
85+
if ($query instanceof BuilderInterface) {
8886
$function['filter'] = $query->toArray();
8987
}
9088
}
9189

9290
/**
9391
* Add decay function to function score. Weight and query are optional.
94-
*
95-
* @param string $type
96-
* @param string $field
97-
* @param int $weight
98-
*
99-
* @return $this
10092
*/
10193
public function addDecayFunction(
102-
$type,
103-
$field,
94+
string $type,
95+
string $field,
10496
array $function,
10597
array $options = [],
106-
BuilderInterface $query = null,
107-
$weight = null
108-
) {
98+
?BuilderInterface $query = null,
99+
int|float|null $weight = null
100+
): static {
109101
$function = array_filter(
110102
[
111103
$type => array_merge(
@@ -127,12 +119,8 @@ public function addDecayFunction(
127119

128120
/**
129121
* Adds function to function score without decay function. Influence search score only for specific query.
130-
*
131-
* @param float $weight
132-
*
133-
* @return $this
134122
*/
135-
public function addWeightFunction($weight, BuilderInterface $query = null)
123+
public function addWeightFunction(int|float $weight, ?BuilderInterface $query = null)
136124
{
137125
$function = [
138126
'weight' => $weight,
@@ -150,7 +138,7 @@ public function addWeightFunction($weight, BuilderInterface $query = null)
150138
*
151139
* @return $this
152140
*/
153-
public function addRandomFunction(mixed $seed = null, BuilderInterface $query = null)
141+
public function addRandomFunction(mixed $seed = null, ?BuilderInterface $query = null)
154142
{
155143
$function = [
156144
'random_score' => $seed ? [
@@ -176,7 +164,7 @@ public function addScriptScoreFunction(
176164
$source,
177165
array $params = [],
178166
array $options = [],
179-
BuilderInterface $query = null
167+
?BuilderInterface $query = null
180168
) {
181169
$function = [
182170
'script_score' => [

src/Query/Specialized/TemplateQuery.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class TemplateQuery implements BuilderInterface
3535
/**
3636
* @param array $params Parameters to insert into template
3737
*/
38-
public function __construct(string $file = null, string $inline = null, array $params = [])
38+
public function __construct(?string $file = null, ?string $inline = null, array $params = [])
3939
{
4040
$this->setFile($file);
4141
$this->setInline($inline);

src/Query/TermLevel/ExistsQuery.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
class ExistsQuery implements BuilderInterface
2424
{
2525
/**
26-
* Constructor.
27-
*
2826
* @param string $field Field value
2927
*/
3028
public function __construct(

0 commit comments

Comments
 (0)