From cbc602aeb76074f292a42a37ef1316a008cbda33 Mon Sep 17 00:00:00 2001 From: Oleg Zhulnev Date: Mon, 25 Mar 2024 10:04:42 +0300 Subject: [PATCH] =?UTF-8?q?Enable=20declare=5Fstrict=5Ftypes=20option=20an?= =?UTF-8?q?d=20apply=20@PHP80Migration=20set=20with=E2=80=A6=20(#2190)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add strict types to Aggregation namespace * Add strict types to Query namespace * Add strict types to other namespace * Add strict types to root namespace * Fix test and cast document ID to string * Add strict types in tests * Fix tests * apply rules to all files --- .php-cs-fixer.dist.php | 5 ++++- src/AbstractUpdateAction.php | 2 ++ src/Aggregation/AbstractAggregation.php | 2 ++ src/Aggregation/AbstractSimpleAggregation.php | 2 ++ src/Aggregation/AbstractTermsAggregation.php | 2 ++ src/Aggregation/AdjacencyMatrix.php | 2 ++ src/Aggregation/AutoDateHistogram.php | 2 ++ src/Aggregation/Avg.php | 2 ++ src/Aggregation/AvgBucket.php | 2 ++ src/Aggregation/BucketScript.php | 2 ++ src/Aggregation/BucketSelector.php | 2 ++ src/Aggregation/Cardinality.php | 2 ++ src/Aggregation/Children.php | 2 ++ src/Aggregation/Composite.php | 2 ++ src/Aggregation/CumulativeSum.php | 2 ++ src/Aggregation/DateHistogram.php | 2 ++ src/Aggregation/DateRange.php | 2 ++ src/Aggregation/Derivative.php | 2 ++ src/Aggregation/DiversifiedSampler.php | 2 ++ src/Aggregation/ExtendedStats.php | 2 ++ src/Aggregation/ExtendedStatsBucket.php | 2 ++ src/Aggregation/Filter.php | 2 ++ src/Aggregation/Filters.php | 2 ++ src/Aggregation/GapPolicyInterface.php | 2 ++ src/Aggregation/GeoBounds.php | 2 ++ src/Aggregation/GeoCentroid.php | 2 ++ src/Aggregation/GeoDistance.php | 2 ++ src/Aggregation/GeohashGrid.php | 4 +++- src/Aggregation/GeotileGridAggregation.php | 2 ++ src/Aggregation/GlobalAggregation.php | 2 ++ src/Aggregation/Histogram.php | 2 ++ src/Aggregation/IpRange.php | 2 ++ src/Aggregation/Max.php | 2 ++ src/Aggregation/Min.php | 2 ++ src/Aggregation/Missing.php | 2 ++ src/Aggregation/Nested.php | 2 ++ src/Aggregation/NormalizeAggregation.php | 2 ++ src/Aggregation/ParentAggregation.php | 2 ++ src/Aggregation/Percentiles.php | 2 ++ src/Aggregation/PercentilesBucket.php | 2 ++ src/Aggregation/Range.php | 2 ++ src/Aggregation/ReverseNested.php | 2 ++ src/Aggregation/Sampler.php | 2 ++ src/Aggregation/ScriptedMetric.php | 2 ++ src/Aggregation/SerialDiff.php | 2 ++ src/Aggregation/SignificantTerms.php | 2 ++ src/Aggregation/Stats.php | 2 ++ src/Aggregation/StatsBucket.php | 2 ++ src/Aggregation/Sum.php | 2 ++ src/Aggregation/SumBucket.php | 2 ++ src/Aggregation/Terms.php | 2 ++ src/Aggregation/TopHits.php | 2 ++ src/Aggregation/Traits/BucketsPathTrait.php | 2 ++ src/Aggregation/Traits/GapPolicyTrait.php | 2 ++ src/Aggregation/Traits/KeyedTrait.php | 2 ++ src/Aggregation/Traits/MissingTrait.php | 2 ++ src/Aggregation/Traits/ShardSizeTrait.php | 2 ++ src/Aggregation/ValueCount.php | 2 ++ src/Aggregation/WeightedAvg.php | 2 ++ src/ArrayableInterface.php | 2 ++ src/Bulk.php | 2 ++ src/Bulk/Action.php | 2 ++ src/Bulk/Action/AbstractDocument.php | 2 ++ src/Bulk/Action/CreateDocument.php | 2 ++ src/Bulk/Action/DeleteDocument.php | 2 ++ src/Bulk/Action/IndexDocument.php | 2 ++ src/Bulk/Action/UpdateDocument.php | 2 ++ src/Bulk/Response.php | 2 ++ src/Bulk/ResponseSet.php | 2 ++ src/Client.php | 2 ++ src/ClientConfiguration.php | 2 ++ src/Cluster.php | 2 ++ src/Cluster/Health.php | 2 ++ src/Cluster/Health/Index.php | 2 ++ src/Cluster/Health/Shard.php | 2 ++ src/Cluster/Settings.php | 4 +++- src/Collapse.php | 2 ++ src/Collapse/InnerHits.php | 2 ++ src/Document.php | 2 ++ src/Exception/Bulk/Response/ActionException.php | 2 ++ src/Exception/Bulk/ResponseException.php | 2 ++ src/Exception/BulkException.php | 2 ++ src/Exception/ClientException.php | 2 ++ src/Exception/DeprecatedException.php | 2 ++ src/Exception/ExceptionInterface.php | 2 ++ src/Exception/InvalidException.php | 2 ++ src/Exception/NotFoundException.php | 2 ++ src/Exception/NotImplementedException.php | 2 ++ src/Exception/QueryBuilderException.php | 2 ++ src/Exception/RequestEntityTooLargeException.php | 2 ++ src/Exception/RuntimeException.php | 2 ++ src/Index.php | 4 +++- src/Index/Recovery.php | 2 ++ src/Index/Settings.php | 8 +++++--- src/Index/Stats.php | 2 ++ src/IndexTemplate.php | 2 ++ src/JSON.php | 2 ++ src/Mapping.php | 2 ++ src/Multi/MultiBuilder.php | 2 ++ src/Multi/MultiBuilderInterface.php | 2 ++ src/Multi/ResultSet.php | 2 ++ src/Multi/Search.php | 2 ++ src/NameableInterface.php | 2 ++ src/Node.php | 2 ++ src/Node/Info.php | 2 ++ src/Node/Stats.php | 2 ++ src/Param.php | 2 ++ src/Pipeline.php | 2 ++ src/PointInTime.php | 2 ++ src/Processor/AbstractProcessor.php | 2 ++ src/Processor/AppendProcessor.php | 2 ++ src/Processor/AttachmentProcessor.php | 2 ++ src/Processor/BytesProcessor.php | 2 ++ src/Processor/ConvertProcessor.php | 2 ++ src/Processor/DateIndexNameProcessor.php | 2 ++ src/Processor/DateProcessor.php | 2 ++ src/Processor/DotExpanderProcessor.php | 2 ++ src/Processor/FailProcessor.php | 2 ++ src/Processor/ForeachProcessor.php | 4 +++- src/Processor/JoinProcessor.php | 2 ++ src/Processor/JsonProcessor.php | 2 ++ src/Processor/KvProcessor.php | 2 ++ src/Processor/LowercaseProcessor.php | 2 ++ src/Processor/RemoveProcessor.php | 2 ++ src/Processor/RenameProcessor.php | 2 ++ src/Processor/SetProcessor.php | 2 ++ src/Processor/SortProcessor.php | 2 ++ src/Processor/SplitProcessor.php | 2 ++ src/Processor/Traits/FieldTrait.php | 2 ++ src/Processor/Traits/IgnoreFailureTrait.php | 2 ++ src/Processor/Traits/IgnoreMissingTrait.php | 2 ++ src/Processor/Traits/TargetFieldTrait.php | 2 ++ src/Processor/TrimProcessor.php | 2 ++ src/Processor/UppercaseProcessor.php | 2 ++ src/Query.php | 2 ++ src/Query/AbstractGeoDistance.php | 2 ++ src/Query/AbstractGeoShape.php | 2 ++ src/Query/AbstractQuery.php | 2 ++ src/Query/AbstractSpanQuery.php | 2 ++ src/Query/BoolQuery.php | 2 ++ src/Query/Boosting.php | 2 ++ src/Query/CombinedFields.php | 2 ++ src/Query/ConstantScore.php | 2 ++ src/Query/DisMax.php | 2 ++ src/Query/DistanceFeature.php | 2 ++ src/Query/Exists.php | 2 ++ src/Query/FunctionScore.php | 2 ++ src/Query/Fuzzy.php | 2 ++ src/Query/GeoBoundingBox.php | 2 ++ src/Query/GeoDistance.php | 2 ++ src/Query/GeoPolygon.php | 2 ++ src/Query/GeoShapePreIndexed.php | 2 ++ src/Query/GeoShapeProvided.php | 2 ++ src/Query/HasChild.php | 2 ++ src/Query/HasParent.php | 2 ++ src/Query/Ids.php | 2 ++ src/Query/InnerHits.php | 2 ++ src/Query/Limit.php | 2 ++ src/Query/MatchAll.php | 2 ++ src/Query/MatchNone.php | 2 ++ src/Query/MatchPhrase.php | 2 ++ src/Query/MatchPhrasePrefix.php | 2 ++ src/Query/MatchQuery.php | 2 ++ src/Query/MoreLikeThis.php | 2 ++ src/Query/MultiMatch.php | 2 ++ src/Query/Nested.php | 2 ++ src/Query/ParentId.php | 2 ++ src/Query/Percolate.php | 2 ++ src/Query/Prefix.php | 2 ++ src/Query/QueryString.php | 2 ++ src/Query/Range.php | 2 ++ src/Query/Regexp.php | 2 ++ src/Query/Script.php | 2 ++ src/Query/Simple.php | 2 ++ src/Query/SimpleQueryString.php | 2 ++ src/Query/SpanContaining.php | 2 ++ src/Query/SpanFirst.php | 2 ++ src/Query/SpanMulti.php | 2 ++ src/Query/SpanNear.php | 2 ++ src/Query/SpanNot.php | 2 ++ src/Query/SpanOr.php | 2 ++ src/Query/SpanTerm.php | 2 ++ src/Query/SpanWithin.php | 2 ++ src/Query/Term.php | 2 ++ src/Query/Terms.php | 4 +++- src/Query/TermsSet.php | 4 +++- src/Query/Wildcard.php | 2 ++ src/QueryBuilder.php | 2 ++ src/QueryBuilder/DSL.php | 2 ++ src/QueryBuilder/DSL/Aggregation.php | 2 ++ src/QueryBuilder/DSL/Collapse.php | 2 ++ src/QueryBuilder/DSL/Query.php | 4 +++- src/QueryBuilder/DSL/Suggest.php | 2 ++ src/QueryBuilder/Facade.php | 2 ++ src/QueryBuilder/Version.php | 2 ++ src/QueryBuilder/Version/Latest.php | 2 ++ src/QueryBuilder/Version/Version700.php | 2 ++ src/Reindex.php | 2 ++ src/Request.php | 2 ++ src/Rescore/AbstractRescore.php | 2 ++ src/Rescore/Query.php | 2 ++ src/Response.php | 2 ++ src/ResponseConverter.php | 4 +++- src/Result.php | 2 ++ src/ResultSet.php | 2 ++ src/ResultSet/BuilderInterface.php | 2 ++ src/ResultSet/ChainProcessor.php | 2 ++ src/ResultSet/DefaultBuilder.php | 2 ++ src/ResultSet/ProcessingBuilder.php | 2 ++ src/ResultSet/ProcessorInterface.php | 2 ++ src/Script/AbstractScript.php | 2 ++ src/Script/Script.php | 2 ++ src/Script/ScriptFields.php | 2 ++ src/Script/ScriptId.php | 2 ++ src/Scroll.php | 2 ++ src/Search.php | 2 ++ src/SearchableInterface.php | 2 ++ src/Snapshot.php | 2 ++ src/Status.php | 6 +++--- src/Suggest.php | 2 ++ src/Suggest/AbstractSuggest.php | 2 ++ .../AbstractCandidateGenerator.php | 2 ++ .../CandidateGenerator/DirectGenerator.php | 2 ++ src/Suggest/Completion.php | 2 ++ src/Suggest/Phrase.php | 2 ++ src/Suggest/Term.php | 2 ++ src/Task.php | 2 ++ src/Util.php | 6 ++++-- .../AbstractSimpleAggregationTest.php | 2 ++ tests/Aggregation/AdjacencyMatrixTest.php | 2 ++ tests/Aggregation/AggregationMetadataTest.php | 2 ++ tests/Aggregation/AutoDateHistogramTest.php | 2 ++ tests/Aggregation/AvgBucketTest.php | 2 ++ tests/Aggregation/AvgTest.php | 2 ++ tests/Aggregation/BaseAggregationTest.php | 2 ++ tests/Aggregation/BucketScriptTest.php | 2 ++ tests/Aggregation/BucketSelectorTest.php | 2 ++ tests/Aggregation/CardinalityTest.php | 2 ++ tests/Aggregation/ChildrenTest.php | 2 ++ tests/Aggregation/CompositeTest.php | 2 ++ tests/Aggregation/CumulativeSumTest.php | 2 ++ tests/Aggregation/DateHistogramTest.php | 2 ++ tests/Aggregation/DateRangeTest.php | 4 +++- tests/Aggregation/DerivativeTest.php | 2 ++ tests/Aggregation/DiversifiedSamplerTest.php | 2 ++ tests/Aggregation/ExtendedStatsBucketTest.php | 2 ++ tests/Aggregation/ExtendedStatsTest.php | 2 ++ tests/Aggregation/FilterTest.php | 2 ++ tests/Aggregation/FiltersTest.php | 2 ++ tests/Aggregation/GeoBoundsTest.php | 2 ++ tests/Aggregation/GeoCentroidTest.php | 2 ++ tests/Aggregation/GeoDistanceTest.php | 2 ++ tests/Aggregation/GeohashGridTest.php | 2 ++ tests/Aggregation/GeotileGridAggregationTest.php | 2 ++ tests/Aggregation/GlobalAggregationTest.php | 2 ++ tests/Aggregation/HistogramTest.php | 2 ++ tests/Aggregation/IpRangeTest.php | 2 ++ tests/Aggregation/MaxTest.php | 2 ++ tests/Aggregation/MinTest.php | 2 ++ tests/Aggregation/MissingTest.php | 2 ++ tests/Aggregation/NestedTest.php | 2 ++ tests/Aggregation/NormalizeAggregationTest.php | 2 ++ tests/Aggregation/ParentAggregationTest.php | 2 ++ tests/Aggregation/PercentilesBucketTest.php | 2 ++ tests/Aggregation/PercentilesTest.php | 2 ++ tests/Aggregation/RangeTest.php | 2 ++ tests/Aggregation/ReverseNestedTest.php | 2 ++ tests/Aggregation/SamplerTest.php | 2 ++ tests/Aggregation/ScriptTest.php | 2 ++ tests/Aggregation/ScriptedMetricTest.php | 2 ++ tests/Aggregation/SerialDiffTest.php | 2 ++ tests/Aggregation/SignificantTermsTest.php | 2 ++ tests/Aggregation/StatsBucketTest.php | 2 ++ tests/Aggregation/StatsTest.php | 2 ++ tests/Aggregation/SumBucketTest.php | 2 ++ tests/Aggregation/SumTest.php | 2 ++ tests/Aggregation/TermsTest.php | 2 ++ tests/Aggregation/TopHitsTest.php | 2 ++ tests/Aggregation/ValueCountTest.php | 2 ++ tests/Aggregation/WeightedAvgTest.php | 2 ++ tests/Base.php | 10 ++++++---- tests/BasePipeline.php | 2 ++ tests/Bulk/Action/AbstractDocumentTest.php | 2 ++ tests/Bulk/Action/UpdateDocumentTest.php | 14 ++++++++------ tests/Bulk/ActionTest.php | 2 ++ tests/Bulk/ResponseSetTest.php | 2 ++ tests/BulkTest.php | 16 +++++++++------- tests/ClientConfigurationTest.php | 2 ++ tests/ClientFunctionalTest.php | 4 +++- tests/ClientTest.php | 2 ++ tests/Cluster/Health/IndexTest.php | 2 ++ tests/Cluster/Health/ShardTest.php | 2 ++ tests/Cluster/HealthTest.php | 2 ++ tests/Cluster/SettingsTest.php | 4 +++- tests/ClusterTest.php | 2 ++ tests/Collapse/CollapseTest.php | 2 ++ tests/DeprecatedClassBase.php | 2 ++ tests/DocumentTest.php | 2 ++ tests/ExampleTest.php | 2 ++ tests/Exception/AbstractExceptionTest.php | 2 ++ .../Bulk/Response/ActionExceptionTest.php | 2 ++ tests/Exception/Bulk/ResponseExceptionTest.php | 2 ++ tests/Exception/BulkExceptionTest.php | 2 ++ tests/Exception/ClientExceptionTest.php | 2 ++ tests/Exception/InvalidExceptionTest.php | 2 ++ tests/Exception/NotFoundExceptionTest.php | 2 ++ tests/Exception/NotImplementedExceptionTest.php | 2 ++ tests/Exception/QueryBuilderExceptionTest.php | 2 ++ tests/Exception/RuntimeExceptionTest.php | 2 ++ tests/Index/RecoveryTest.php | 2 ++ tests/Index/SettingsTest.php | 12 +++++------- tests/Index/StatsTest.php | 2 ++ tests/IndexTemplateTest.php | 10 +++++----- tests/IndexTest.php | 2 ++ tests/JSONTest.php | 2 ++ tests/MappingTest.php | 2 ++ tests/Multi/MultiBuilderTest.php | 2 ++ tests/Multi/SearchTest.php | 2 ++ tests/Node/InfoTest.php | 2 ++ tests/NodeTest.php | 2 ++ tests/ParamTest.php | 2 ++ tests/PipelineTest.php | 10 +++++----- tests/PointInTimeTest.php | 2 ++ tests/Processor/AppendProcessorTest.php | 2 ++ tests/Processor/AttachmentProcessorTest.php | 2 ++ tests/Processor/BytesProcessorTest.php | 2 ++ tests/Processor/ConvertProcessorTest.php | 2 ++ tests/Processor/DateIndexNameProcessorTest.php | 2 ++ tests/Processor/DateProcessorTest.php | 2 ++ tests/Processor/DotExpanderProcessorTest.php | 2 ++ tests/Processor/FailProcessorTest.php | 2 ++ tests/Processor/ForeachProcessorTest.php | 2 ++ tests/Processor/JoinProcessorTest.php | 2 ++ tests/Processor/JsonProcessorTest.php | 2 ++ tests/Processor/KvProcessorTest.php | 2 ++ tests/Processor/LowercaseProcessorTest.php | 2 ++ tests/Processor/RemoveProcessorTest.php | 2 ++ tests/Processor/RenameProcessorTest.php | 2 ++ tests/Processor/SetProcessorTest.php | 2 ++ tests/Processor/SortProcessorTest.php | 2 ++ tests/Processor/SplitProcessorTest.php | 2 ++ tests/Processor/TrimProcessorTest.php | 2 ++ tests/Processor/UppercaseProcessorTest.php | 2 ++ tests/Query/BoolQueryTest.php | 2 ++ tests/Query/BoostingTest.php | 2 ++ tests/Query/CombinedFieldsQueryTest.php | 12 +++++++----- tests/Query/ConstantScoreTest.php | 2 ++ tests/Query/DisMaxTest.php | 2 ++ tests/Query/DistanceFeatureTest.php | 2 ++ tests/Query/EscapeStringTest.php | 2 ++ tests/Query/ExistsTest.php | 2 ++ tests/Query/FunctionScoreTest.php | 2 ++ tests/Query/FuzzyTest.php | 2 ++ tests/Query/GeoBoundingBoxTest.php | 2 ++ tests/Query/GeoDistanceTest.php | 2 ++ tests/Query/GeoPolygonTest.php | 2 ++ tests/Query/GeoShapePreIndexedTest.php | 2 ++ tests/Query/GeoShapeProvidedTest.php | 2 ++ tests/Query/HasChildTest.php | 2 ++ tests/Query/HasParentTest.php | 2 ++ tests/Query/HighlightTest.php | 2 ++ tests/Query/IdsTest.php | 2 ++ tests/Query/InnerHitsTest.php | 2 ++ tests/Query/LimitTest.php | 2 ++ tests/Query/MatchAllTest.php | 2 ++ tests/Query/MatchNoneTest.php | 2 ++ tests/Query/MatchPhrasePrefixTest.php | 2 ++ tests/Query/MatchPhraseTest.php | 2 ++ tests/Query/MatchQueryTest.php | 2 ++ tests/Query/MoreLikeThisTest.php | 2 ++ tests/Query/MultiMatchTest.php | 12 +++++++----- tests/Query/NestedTest.php | 2 ++ tests/Query/ParentIdTest.php | 2 ++ tests/Query/PercolateTest.php | 2 ++ tests/Query/PostFilterTest.php | 2 ++ tests/Query/PrefixTest.php | 2 ++ tests/Query/QueryStringTest.php | 10 +++++----- tests/Query/RangeTest.php | 2 ++ tests/Query/RegexpTest.php | 2 ++ tests/Query/RescoreTest.php | 2 ++ tests/Query/ScriptTest.php | 2 ++ tests/Query/SimpleQueryStringTest.php | 2 ++ tests/Query/SimpleTest.php | 2 ++ tests/Query/SpanContainingTest.php | 2 ++ tests/Query/SpanFirstTest.php | 2 ++ tests/Query/SpanMultiTest.php | 2 ++ tests/Query/SpanNearTest.php | 2 ++ tests/Query/SpanNotTest.php | 2 ++ tests/Query/SpanOrTest.php | 2 ++ tests/Query/SpanTermTest.php | 2 ++ tests/Query/SpanWithinTest.php | 2 ++ tests/Query/TermTest.php | 2 ++ tests/Query/TermsSetTest.php | 2 ++ tests/Query/TermsTest.php | 2 ++ tests/Query/WildcardTest.php | 2 ++ tests/QueryBuilder/DSL/AbstractDSLTest.php | 4 +++- tests/QueryBuilder/DSL/AggregationTest.php | 2 ++ tests/QueryBuilder/DSL/CollapseTest.php | 2 ++ tests/QueryBuilder/DSL/QueryTest.php | 2 ++ tests/QueryBuilder/DSL/SuggestTest.php | 2 ++ tests/QueryBuilder/VersionTest.php | 10 ++++++---- tests/QueryBuilderTest.php | 2 ++ tests/QueryTest.php | 2 ++ tests/ReindexTest.php | 2 ++ tests/ResponseFunctionalTest.php | 2 ++ tests/ResponseTest.php | 2 ++ tests/ResultSet/BuilderTest.php | 2 ++ tests/ResultSet/ChainProcessorTest.php | 2 ++ tests/ResultSet/ProcessingBuilderTest.php | 2 ++ tests/ResultSetTest.php | 2 ++ tests/ResultTest.php | 2 ++ tests/Script/ScriptFieldsTest.php | 2 ++ tests/Script/ScriptIdTest.php | 2 ++ tests/Script/ScriptTest.php | 2 ++ tests/ScrollTest.php | 2 ++ tests/SearchTest.php | 10 +++++----- tests/SnapshotTest.php | 2 ++ tests/StatusTest.php | 6 +++--- tests/Suggest/CompletionTest.php | 2 ++ tests/Suggest/PhraseTest.php | 2 ++ tests/Suggest/TermTest.php | 2 ++ tests/SuggestTest.php | 2 ++ tests/TaskTest.php | 2 ++ tests/UtilTest.php | 2 ++ tests/bootstrap.php | 2 ++ 425 files changed, 917 insertions(+), 82 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index c612e7edd8..6c604d3a32 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -1,5 +1,7 @@ in(__DIR__.'/src') ->in(__DIR__.'/tests') @@ -8,7 +10,8 @@ return (new PhpCsFixer\Config()) ->setFinder($finder) ->setRules([ - '@PHP71Migration' => true, + '@PHP80Migration' => true, + '@PHP80Migration:risky' => true, '@PhpCsFixer' => true, '@PHPUnit75Migration:risky' => true, '@PSR2' => true, diff --git a/src/AbstractUpdateAction.php b/src/AbstractUpdateAction.php index 6ddbf84163..508f63df84 100644 --- a/src/AbstractUpdateAction.php +++ b/src/AbstractUpdateAction.php @@ -1,5 +1,7 @@ setParam('precision', $precision); diff --git a/src/Aggregation/GeotileGridAggregation.php b/src/Aggregation/GeotileGridAggregation.php index aa41687313..aa2b6ec2cc 100644 --- a/src/Aggregation/GeotileGridAggregation.php +++ b/src/Aggregation/GeotileGridAggregation.php @@ -1,5 +1,7 @@ getName()); + $doc = new Document((string) $id, $data, $this->getName()); $doc->setVersionParams($result); return $doc; diff --git a/src/Index/Recovery.php b/src/Index/Recovery.php index 3869c3fc72..2aaa0e221a 100644 --- a/src/Index/Recovery.php +++ b/src/Index/Recovery.php @@ -1,5 +1,7 @@ get('number_of_replicas') ?? self::DEFAULT_NUMBER_OF_REPLICAS; + return (int) ($this->get('number_of_replicas') ?? self::DEFAULT_NUMBER_OF_REPLICAS); } /** @@ -195,7 +197,7 @@ public function getNumberOfReplicas(): int */ public function getNumberOfShards(): int { - return $this->get('number_of_shards') ?? self::DEFAULT_NUMBER_OF_SHARDS; + return (int) ($this->get('number_of_shards') ?? self::DEFAULT_NUMBER_OF_SHARDS); } /** diff --git a/src/Index/Stats.php b/src/Index/Stats.php index e986500355..93269b5703 100644 --- a/src/Index/Stats.php +++ b/src/Index/Stats.php @@ -1,5 +1,7 @@ setRawProcessor($processor); } else { - throw new \TypeError(\sprintf('Argument 2 passed to %s::__construct() must be of type %s|array, %s given.', self::class, AbstractProcessor::class, \is_object($processor) ? \get_class($processor) : \gettype($processor))); + throw new \TypeError(\sprintf('Argument 2 passed to %s::__construct() must be of type %s|array, %s given.', self::class, AbstractProcessor::class, \is_object($processor) ? $processor::class : \gettype($processor))); } } diff --git a/src/Processor/JoinProcessor.php b/src/Processor/JoinProcessor.php index d3d786b3fa..52ddcf6b1d 100644 --- a/src/Processor/JoinProcessor.php +++ b/src/Processor/JoinProcessor.php @@ -1,5 +1,7 @@ getParam($this->field); diff --git a/src/Query/TermsSet.php b/src/Query/TermsSet.php index ab52d42db0..68032be1ce 100644 --- a/src/Query/TermsSet.php +++ b/src/Query/TermsSet.php @@ -1,5 +1,7 @@ setMinimumShouldMatchScript($minimumShouldMatch); } else { - throw new \TypeError(\sprintf('Argument 3 passed to "%s()" must be of type %s|string, %s given.', __METHOD__, AbstractScript::class, \is_object($minimumShouldMatch) ? \get_class($minimumShouldMatch) : \gettype($minimumShouldMatch))); + throw new \TypeError(\sprintf('Argument 3 passed to "%s()" must be of type %s|string, %s given.', __METHOD__, AbstractScript::class, \is_object($minimumShouldMatch) ? $minimumShouldMatch::class : \gettype($minimumShouldMatch))); } } diff --git a/src/Query/Wildcard.php b/src/Query/Wildcard.php index 1bc20e13d9..e62f4180b2 100644 --- a/src/Query/Wildcard.php +++ b/src/Query/Wildcard.php @@ -1,5 +1,7 @@ asString(), $response->getStatusCode()); } - return new Response($response->getBody(), $response->getStatusCode()); + return new Response((string) $response->getBody(), $response->getStatusCode()); } } diff --git a/src/Result.php b/src/Result.php index a411723e3a..511e8c990f 100644 --- a/src/Result.php +++ b/src/Result.php @@ -1,5 +1,7 @@ getData(); - return \array_map(static function ($name): string { - return (string) $name; - }, \array_keys($data['indices'])); + return \array_map(static fn ($name): string => (string) $name, \array_keys($data['indices'])); } /** diff --git a/src/Suggest.php b/src/Suggest.php index dfe604b84b..1fa1536d9d 100644 --- a/src/Suggest.php +++ b/src/Suggest.php @@ -1,5 +1,7 @@ '%2F' - return false !== \strpos(\strtoupper($requestUri), '%2F'); + return \str_contains(\strtoupper($requestUri), '%2F'); } /** @@ -64,7 +66,7 @@ public static function escapeDateMath($requestUri) $escapedUriSegment = \str_replace(static::$dateMathSymbols, static::$escapedDateMathSymbols, $uriSegment); // '\\{' and '\\}' should not be escaped - if (false !== \strpos($uriSegment, '\\\\')) { + if (\str_contains($uriSegment, '\\\\')) { $escapedUriSegment = \str_replace(['\\\\%7B', '\\\\%7D'], ['\\\\{', '\\\\}'], $escapedUriSegment); } diff --git a/tests/Aggregation/AbstractSimpleAggregationTest.php b/tests/Aggregation/AbstractSimpleAggregationTest.php index 2580fb5822..2e2740917a 100644 --- a/tests/Aggregation/AbstractSimpleAggregationTest.php +++ b/tests/Aggregation/AbstractSimpleAggregationTest.php @@ -1,5 +1,7 @@ _getIndexForTest()->search($query)->getAggregation('date'); $this->fail('Should throw exception to and from parameters in date_range aggregation are interpreted according of the target field'); } catch (ClientResponseException $e) { - $error = \json_decode($e->getResponse()->getBody(), true)['error'] ?? null; + $error = \json_decode((string) $e->getResponse()->getBody(), true)['error'] ?? null; $this->assertSame('search_phase_execution_exception', $error['type']); $this->assertStringStartsWith('failed to parse date field', $error['root_cause'][0]['reason']); diff --git a/tests/Aggregation/DerivativeTest.php b/tests/Aggregation/DerivativeTest.php index 8be63a119f..a0859a7292 100644 --- a/tests/Aggregation/DerivativeTest.php +++ b/tests/Aggregation/DerivativeTest.php @@ -1,5 +1,7 @@ _getHost().':'.$this->_getPort()]; + $config['hosts'] ??= [$this->_getHost().':'.$this->_getPort()]; - $config['transport_config']['node_pool'] = $config['transport_config']['node_pool'] ?? new TraceableSimpleNodePool( + $config['transport_config']['node_pool'] ??= new TraceableSimpleNodePool( new RoundRobin(), new NoResurrect() ); diff --git a/tests/BasePipeline.php b/tests/BasePipeline.php index 6d0b10c2dc..5737fd4e20 100644 --- a/tests/BasePipeline.php +++ b/tests/BasePipeline.php @@ -1,5 +1,7 @@ assertTrue($action->hasSource()); $expected = <<<'JSON' -{"update":{"_id":"1","_index":"index"}} -{"doc":{"foo":"bar"},"doc_as_upsert":true} -JSON; + {"update":{"_id":"1","_index":"index"}} + {"doc":{"foo":"bar"},"doc_as_upsert":true} + JSON; $this->assertSame($expected, \trim((string) $action)); @@ -81,9 +83,9 @@ public function testUpdateDocumentAsUpsert(): void $action->setDocument($document); $expected = <<<'JSON' -{"update":{"_id":"1","_index":"index"}} -{"doc":{"foo":"bar"}} -JSON; + {"update":{"_id":"1","_index":"index"}} + {"doc":{"foo":"bar"}} + JSON; $this->assertSame($expected, \trim((string) $action)); diff --git a/tests/Bulk/ActionTest.php b/tests/Bulk/ActionTest.php index 644bf6440e..c4200f856a 100644 --- a/tests/Bulk/ActionTest.php +++ b/tests/Bulk/ActionTest.php @@ -1,5 +1,7 @@ assertSame($expectedJson, \trim((string) $bulk)); diff --git a/tests/ClientConfigurationTest.php b/tests/ClientConfigurationTest.php index 5566843811..0e32eb5224 100644 --- a/tests/ClientConfigurationTest.php +++ b/tests/ClientConfigurationTest.php @@ -1,5 +1,7 @@ addDocument($doc2); $this->fail('should throw read only exception'); } catch (ClientResponseException $e) { - $error = \json_decode($e->getResponse()->getBody(), true)['error'] ?? null; + $error = \json_decode((string) $e->getResponse()->getBody(), true)['error']['root_cause'][0] ?? null; $this->assertSame('cluster_block_exception', $error['type']); $this->assertStringContainsString('cluster read-only', $error['reason']); diff --git a/tests/ClusterTest.php b/tests/ClusterTest.php index 88d6beabed..feaba72eea 100644 --- a/tests/ClusterTest.php +++ b/tests/ClusterTest.php @@ -1,5 +1,7 @@ delete(); $this->fail('Should throw exception because you should delete the concrete index and not the alias'); } catch (ClientResponseException $e) { - $response = ResponseConverter::toElastica($e->getResponse()); - $error = $response->getFullError(); + $error = \json_decode((string) $e->getResponse()->getBody(), true)['error']['root_cause'][0] ?? null; $this->assertSame('illegal_argument_exception', $error['type']); $this->assertStringContainsString('specify the corresponding concrete indices instead.', $error['reason']); @@ -349,8 +349,7 @@ public function testSetReadOnly(): void $index->addDocument($doc2); $this->fail('Should throw exception because of read only'); } catch (ClientResponseException $e) { - $response = ResponseConverter::toElastica($e->getResponse()); - $error = $response->getFullError(); + $error = \json_decode((string) $e->getResponse()->getBody(), true)['error']['root_cause'][0] ?? null; $this->assertSame('cluster_block_exception', $error['type']); $this->assertStringContainsString('read-only', $error['reason']); @@ -451,8 +450,7 @@ public function testNotFoundIndex(): void $index->getSettings()->get(); $this->fail('Should throw exception because of index not found'); } catch (ClientResponseException $e) { - $response = ResponseConverter::toElastica($e->getResponse()); - $error = $response->getFullError(); + $error = \json_decode((string) $e->getResponse()->getBody(), true)['error']['root_cause'][0] ?? null; $this->assertSame('index_not_found_exception', $error['type']); } diff --git a/tests/Index/StatsTest.php b/tests/Index/StatsTest.php index 85dce732a9..2e2874e9f0 100644 --- a/tests/Index/StatsTest.php +++ b/tests/Index/StatsTest.php @@ -1,5 +1,7 @@ create($template); try { $indexTemplate->create($template); - } catch (ClientResponseException $ex) { - $response = ResponseConverter::toElastica($ex->getResponse()); - $error = $response->getFullError(); + } catch (ClientResponseException $e) { + $error = \json_decode((string) $e->getResponse()->getBody(), true)['error']['root_cause'][0] ?? null; $this->assertNotEquals('index_template_already_exists_exception', $error['type']); $this->assertEquals('resource_already_exists_exception', $error['type']); - $this->assertEquals(400, $ex->getResponse()->getStatusCode()); + $this->assertEquals(400, $e->getResponse()->getStatusCode()); } } } diff --git a/tests/IndexTest.php b/tests/IndexTest.php index 74effafbfd..11c0f8bf55 100644 --- a/tests/IndexTest.php +++ b/tests/IndexTest.php @@ -1,5 +1,7 @@ deletePipeline('non_existent_pipeline'); $this->fail('an exception should be raised!'); } catch (ClientResponseException $e) { - $response = ResponseConverter::toElastica($e->getResponse()); - $result = $response->getFullError(); + $error = \json_decode((string) $e->getResponse()->getBody(), true)['error']['root_cause'][0] ?? null; - $this->assertEquals('resource_not_found_exception', $result['type']); - $this->assertEquals('pipeline [non_existent_pipeline] is missing', $result['reason']); + $this->assertEquals('resource_not_found_exception', $error['type']); + $this->assertEquals('pipeline [non_existent_pipeline] is missing', $error['reason']); } } } diff --git a/tests/PointInTimeTest.php b/tests/PointInTimeTest.php index 3320ea3035..822465e903 100644 --- a/tests/PointInTimeTest.php +++ b/tests/PointInTimeTest.php @@ -1,5 +1,7 @@ 1, 'title' => 'Rodolfo', 'body' => 'Moraes', 'abstract' => 'Lorem'], - ['id' => 2, 'title' => 'Tristan', 'body' => 'Maindron', 'abstract' => 'Dolor'], - ['id' => 3, 'title' => 'Monique', 'body' => 'Maindron', 'abstract' => 'Ipsum'], - ['id' => 4, 'title' => 'John', 'body' => 'not Doe', 'abstract' => 'Consectetur'], + ['id' => '1', 'title' => 'Rodolfo', 'body' => 'Moraes', 'abstract' => 'Lorem'], + ['id' => '2', 'title' => 'Tristan', 'body' => 'Maindron', 'abstract' => 'Dolor'], + ['id' => '3', 'title' => 'Monique', 'body' => 'Maindron', 'abstract' => 'Ipsum'], + ['id' => '4', 'title' => 'John', 'body' => 'not Doe', 'abstract' => 'Consectetur'], ]; /** @@ -143,7 +145,7 @@ private function _generateIndex(): Index ); foreach (self::$data as $key => $docData) { - $index->addDocument(new Document($key, $docData)); + $index->addDocument(new Document((string) $key, $docData)); } // Refresh index diff --git a/tests/Query/ConstantScoreTest.php b/tests/Query/ConstantScoreTest.php index bad3883434..87a1986aab 100644 --- a/tests/Query/ConstantScoreTest.php +++ b/tests/Query/ConstantScoreTest.php @@ -1,5 +1,7 @@ 1, 'name' => 'Rodolfo', 'last_name' => 'Moraes', 'full_name' => 'Rodolfo Moraes'], - ['id' => 2, 'name' => 'Tristan', 'last_name' => 'Maindron', 'full_name' => 'Tristan Maindron'], - ['id' => 3, 'name' => 'Monique', 'last_name' => 'Maindron', 'full_name' => 'Monique Maindron'], - ['id' => 4, 'name' => 'John', 'last_name' => 'not Doe', 'full_name' => 'John not Doe'], + ['id' => '1', 'name' => 'Rodolfo', 'last_name' => 'Moraes', 'full_name' => 'Rodolfo Moraes'], + ['id' => '2', 'name' => 'Tristan', 'last_name' => 'Maindron', 'full_name' => 'Tristan Maindron'], + ['id' => '3', 'name' => 'Monique', 'last_name' => 'Maindron', 'full_name' => 'Monique Maindron'], + ['id' => '4', 'name' => 'John', 'last_name' => 'not Doe', 'full_name' => 'John not Doe'], ]; /** @@ -216,7 +218,7 @@ private function _generateIndex(): Index ); foreach (self::$data as $key => $docData) { - $index->addDocument(new Document($key, $docData)); + $index->addDocument(new Document((string) $key, $docData)); } // Refresh index diff --git a/tests/Query/NestedTest.php b/tests/Query/NestedTest.php index 58e399c3c3..a8be50babd 100644 --- a/tests/Query/NestedTest.php +++ b/tests/Query/NestedTest.php @@ -1,5 +1,7 @@ assertEquals(['query_string' => $expected], $query->toArray()); $fields = []; - $max = \mt_rand(1, 10); + $max = \random_int(1, 10); for ($i = 0; $i < $max; ++$i) { $fields[] = \uniqid(); } @@ -105,14 +106,13 @@ public function testSearchFieldsValidationException(): void try { $index->search($query); } catch (ClientResponseException $e) { - $response = ResponseConverter::toElastica($e->getResponse()); - $error = $response->getFullError(); + $error = \json_decode((string) $e->getResponse()->getBody(), true)['error'] ?? null; $this->assertSame('query_shard_exception', $error['root_cause'][0]['type']); $this->assertStringContainsString('failed to create query', $error['root_cause'][0]['reason']); $this->assertStringContainsString('[fields] parameter in conjunction with [default_field]', $error['failed_shards'][0]['reason']['caused_by']['reason']); - $this->assertEquals(400, $response->getStatus()); + $this->assertEquals(400, $e->getResponse()->getStatusCode()); } } diff --git a/tests/Query/RangeTest.php b/tests/Query/RangeTest.php index 71320a7efa..f687b4cf19 100644 --- a/tests/Query/RangeTest.php +++ b/tests/Query/RangeTest.php @@ -1,5 +1,7 @@ hasMethod('__construct')) { $this->assertEmpty($method->getParameters(), 'Constructor is not defined, but method has some parameters'); } else { diff --git a/tests/QueryBuilder/DSL/AggregationTest.php b/tests/QueryBuilder/DSL/AggregationTest.php index a00b792852..5dd9fa4c63 100644 --- a/tests/QueryBuilder/DSL/AggregationTest.php +++ b/tests/QueryBuilder/DSL/AggregationTest.php @@ -1,5 +1,7 @@ getQueries() as $query) { $this->assertTrue( \method_exists($dsl[0], $query), - 'query "'.$query.'" in '.\get_class($version).' must be defined in '.\get_class($dsl[0]) + 'query "'.$query.'" in '.$version::class.' must be defined in '.\get_class($dsl[0]) ); } foreach ($version->getAggregations() as $aggregation) { $this->assertTrue( \method_exists($dsl[1], $aggregation), - 'aggregation "'.$aggregation.'" in '.\get_class($version).' must be defined in '.\get_class($dsl[2]) + 'aggregation "'.$aggregation.'" in '.$version::class.' must be defined in '.\get_class($dsl[2]) ); } foreach ($version->getSuggesters() as $suggester) { $this->assertTrue( \method_exists($dsl[2], $suggester), - 'suggester "'.$suggester.'" in '.\get_class($version).' must be defined in '.\get_class($dsl[2]) + 'suggester "'.$suggester.'" in '.$version::class.' must be defined in '.\get_class($dsl[2]) ); } foreach ($version->getCollapsers() as $collapser) { $this->assertTrue( \method_exists($dsl[3], $collapser), - 'suggester "'.$collapser.'" in '.\get_class($version).' must be defined in '.\get_class($dsl[3]) + 'suggester "'.$collapser.'" in '.$version::class.' must be defined in '.\get_class($dsl[3]) ); } } diff --git a/tests/QueryBuilderTest.php b/tests/QueryBuilderTest.php index ba0660e078..f7d0d28a79 100644 --- a/tests/QueryBuilderTest.php +++ b/tests/QueryBuilderTest.php @@ -1,5 +1,7 @@ getClient()->getLastRequest()->getUri()->getQuery(), $lastRequestQuery); - $lastRequestData = \json_decode($search->getClient()->getLastRequest()->getBody(), true); + $lastRequestData = \json_decode((string) $search->getClient()->getLastRequest()->getBody(), true); $this->assertFalse($result->getResponse()->hasError()); $this->assertCount(5, $result->getResults()); @@ -269,7 +270,7 @@ public function testSearchScrollRequest(): void ]); \parse_str($search->getClient()->getLastRequest()->getUri()->getQuery(), $lastRequestQuery); - $lastRequestData = \json_decode($search->getClient()->getLastRequest()->getBody(), true); + $lastRequestData = \json_decode((string) $search->getClient()->getLastRequest()->getBody(), true); $this->assertFalse($result->getResponse()->hasError()); $this->assertCount(0, $result->getResults()); @@ -686,8 +687,7 @@ public function testIgnoreUnavailableOption(): void $search->search($query); $this->fail('Should raise an Index not found exception'); } catch (ClientResponseException $e) { - $response = ResponseConverter::toElastica($e->getResponse()); - $error = $response->getFullError(); + $error = \json_decode((string) $e->getResponse()->getBody(), true)['error']['root_cause'][0] ?? null; $this->assertEquals('index_not_found_exception', $error['type']); $this->assertEquals('no such index [elastica_7086b4c2ee585bbb6740ece5ed7ece01]', $error['reason']); diff --git a/tests/SnapshotTest.php b/tests/SnapshotTest.php index 6a6169da7f..2082e102f2 100644 --- a/tests/SnapshotTest.php +++ b/tests/SnapshotTest.php @@ -1,5 +1,7 @@ getIndicesWithAlias($aliasName); $this->assertEquals([$indexName], \array_map( - static function ($index) { - return $index->getName(); - }, + static fn ($index) => $index->getName(), $indicesWithAlias )); } diff --git a/tests/Suggest/CompletionTest.php b/tests/Suggest/CompletionTest.php index 58df78ee97..7833319fdb 100644 --- a/tests/Suggest/CompletionTest.php +++ b/tests/Suggest/CompletionTest.php @@ -1,5 +1,7 @@