Skip to content

Commit a9abab4

Browse files
fix: update source and tests for Elasticsearch 9 compatibility
- Wrap native ES9 client calls in Index::delete(), Index::create(), Pipeline::deletePipeline(), and Reindex::run() with try/catch to convert ClientResponseException/ServerResponseException into Elastica ResponseException - Fix test assertions for ES9 breaking changes: document_parsing_exception, removed boost mapping param, removed Common query (replaced with BoolQuery should clauses + minimum_should_match), from/to range params replaced with gte/lte, _id fielddata disabled, reindex 409 conflict behavior, allowlist/whitelist regex, coordinate deltas, percentile tolerance, percentile keys returned as floats, sort by seq field - Restore cosmetic-only files from opensearch baseline and apply minimal CS Fixer 3.94.2 formatting - Disable non-ES9 cosmetic CS rules in .php-cs-fixer.dist.php Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent c27c602 commit a9abab4

139 files changed

Lines changed: 785 additions & 506 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: PHP Upgrade Rector Proposals
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
PHP_TARGET_VERSION:
7+
required: true
8+
type: string
9+
description: 'Target PHP version (e.g. 8.4)'
10+
default: '8.4'
11+
12+
jobs:
13+
rector-php-upgrade:
14+
uses: BrandEmbassy/github-actions/.github/workflows/php-upgrade-rector-proposals.yml@master
15+
with:
16+
PHP_TARGET_VERSION: ${{ inputs.PHP_TARGET_VERSION }}
17+
RECTOR_PATHS: 'src tests'
18+
secrets:
19+
COMPOSER_TOKEN: ${{ secrets.COMPOSER_TOKEN }}

.php-cs-fixer.dist.php

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,44 @@
1616
'is_null' => true,
1717
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
1818
'native_constant_invocation' => true,
19-
'native_function_invocation' => [
20-
'include' => ['@all'],
21-
],
19+
'native_function_invocation' => false,
2220
'no_alias_functions' => true,
2321
'no_useless_else' => true,
2422
'nullable_type_declaration_for_default_null_value' => true,
2523
'ordered_imports' => true,
2624
'php_unit_dedicate_assert' => ['target' => 'newest'],
2725
'php_unit_test_class_requires_covers' => false,
28-
'phpdoc_order' => true,
26+
'phpdoc_order' => false,
2927
'phpdoc_types_order' => ['null_adjustment' => 'always_last'],
3028
'static_lambda' => true,
3129
'ternary_to_null_coalescing' => true,
3230
'visibility_required' => ['elements' => ['property', 'method', 'const']],
31+
'phpdoc_no_useless_inheritdoc' => false,
32+
'no_superfluous_phpdoc_tags' => false,
33+
'global_namespace_import' => false,
34+
'trailing_comma_in_multiline' => false,
35+
'fully_qualified_strict_types' => false,
36+
'phpdoc_separation' => false,
37+
'new_with_parentheses' => false,
38+
'escape_implicit_backslashes' => false,
39+
'declare_strict_types' => false,
40+
'no_unneeded_control_parentheses' => false,
41+
'string_implicit_backslashes' => false,
42+
'phpdoc_no_alias_tag' => ['replacements' => ['type' => 'var', 'link' => 'see']],
43+
'yoda_style' => false,
44+
'curly_braces_position' => false,
45+
'braces_position' => false,
46+
'no_extra_blank_lines' => false,
47+
'blank_line_after_opening_tag' => false,
48+
'cast_spaces' => false,
49+
'native_constant_invocation' => false,
50+
'single_line_throw' => false,
51+
'declare_parentheses' => false,
52+
'class_attributes_separation' => false,
53+
'linebreak_after_opening_tag' => false,
54+
'declare_equal_normalize' => false,
55+
'blank_line_between_import_groups' => false,
56+
'single_quote' => false,
57+
'ordered_class_elements' => false,
3358
])
3459
;

phpstan-baseline.neon

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ parameters:
9090
count: 1
9191
path: tests/DocumentTest.php
9292

93+
-
94+
message: "#^Unreachable statement \\- code above always terminates\\.$#"
95+
count: 2
96+
path: tests/Multi/SearchTest.php
97+
9398
-
9499
message: "#^Call to an undefined method ReflectionType\\:\\:getName\\(\\)\\.$#"
95100
count: 2

src/Aggregation/AbstractAggregation.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ public function addAggregation(AbstractAggregation $aggregation): self
7979
* Add metadata to the aggregation.
8080
*
8181
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/agg-metadata.html
82-
* @see AbstractAggregation::getMeta()
83-
* @see AbstractAggregation::clearMeta()
82+
* @see \Elastica\Aggregation\AbstractAggregation::getMeta()
83+
* @see \Elastica\Aggregation\AbstractAggregation::clearMeta()
8484
*
8585
* @param array $meta Metadata to be attached to the aggregation
8686
*
@@ -101,8 +101,8 @@ public function setMeta(array $meta): self
101101
* Retrieve the currently configured metadata for the aggregation.
102102
*
103103
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/agg-metadata.html
104-
* @see AbstractAggregation::setMeta()
105-
* @see AbstractAggregation::clearMeta()
104+
* @see \Elastica\Aggregation\AbstractAggregation::setMeta()
105+
* @see \Elastica\Aggregation\AbstractAggregation::clearMeta()
106106
*/
107107
public function getMeta(): ?array
108108
{
@@ -113,8 +113,8 @@ public function getMeta(): ?array
113113
* Clears any previously set metadata for this aggregation.
114114
*
115115
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/agg-metadata.html
116-
* @see AbstractAggregation::setMeta()
117-
* @see AbstractAggregation::getMeta()
116+
* @see \Elastica\Aggregation\AbstractAggregation::setMeta()
117+
* @see \Elastica\Aggregation\AbstractAggregation::getMeta()
118118
*
119119
* @return $this
120120
*/

src/Aggregation/AbstractSimpleAggregation.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ public function setScript($script): self
3030
return $this->setParam('script', $script);
3131
}
3232

33+
/**
34+
* {@inheritdoc}
35+
*/
3336
public function toArray(): array
3437
{
3538
if (!$this->hasParam('field') && !$this->hasParam('script')) {

src/Aggregation/ReverseNested.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ public function setPath(string $path): self
3232
return $this->setParam('path', $path);
3333
}
3434

35+
/**
36+
* {@inheritdoc}
37+
*/
3538
public function toArray(): array
3639
{
3740
$array = parent::toArray();

src/Aggregation/ScriptedMetric.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function __construct(
2121
?string $initScript = null,
2222
?string $mapScript = null,
2323
?string $combineScript = null,
24-
?string $reduceScript = null,
24+
?string $reduceScript = null
2525
) {
2626
parent::__construct($name);
2727
if ($initScript) {

src/Aggregation/Traits/MissingTrait.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ trait MissingTrait
77
/**
88
* Defines how documents that are missing a value should be treated.
99
*
10+
* @param mixed $missing
11+
*
1012
* @return $this
1113
*/
1214
public function setMissing($missing): self

src/Aggregation/WeightedAvg.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class WeightedAvg extends AbstractAggregation
1414
/**
1515
* Set the value for this aggregation.
1616
*
17-
* @param mixed|null $missing
17+
* @param mixed $missing
1818
*
1919
* @return $this
2020
*/
@@ -50,7 +50,7 @@ public function setValueScript(string $script)
5050
/**
5151
* Set the weight for this aggregation.
5252
*
53-
* @param mixed|null $missing
53+
* @param mixed $missing
5454
*
5555
* @return $this
5656
*/
@@ -98,6 +98,8 @@ public function setFormat($format)
9898
/**
9999
* Set the value_type for this aggregation.
100100
*
101+
* @param mixed $valueType
102+
*
101103
* @return $this
102104
*/
103105
public function setValueType($valueType)

src/Bulk/Action.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Elastica\Bulk;
44

5+
use Closure;
56
use Elastica\Bulk;
67
use Elastica\Index;
78
use Elastica\JSON;
@@ -40,7 +41,7 @@ class Action
4041

4142
protected int $apiVersion;
4243

43-
protected \Closure $documentTypeResolver;
44+
protected Closure $documentTypeResolver;
4445

4546
public function __construct(string $opType = self::OP_TYPE_INDEX, array $metadata = [], array $source = [])
4647
{
@@ -73,11 +74,18 @@ public function __toString(): string
7374
return $string;
7475
}
7576

77+
/**
78+
* @return int
79+
*/
7680
public function getApiVersion(): int
7781
{
7882
return $this->apiVersion;
7983
}
8084

85+
86+
/**
87+
* @param int $apiVersion
88+
*/
8189
public function setApiVersion(int $apiVersion): void
8290
{
8391
$this->apiVersion = $apiVersion;

0 commit comments

Comments
 (0)