Skip to content

Commit

Permalink
Enable declare_strict_types option and apply @PHP80Migration set with… (
Browse files Browse the repository at this point in the history
#2190)

* 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
  • Loading branch information
sidz authored Mar 25, 2024
1 parent 78d5a9e commit cbc602a
Show file tree
Hide file tree
Showing 425 changed files with 917 additions and 82 deletions.
5 changes: 4 additions & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

$finder = (new PhpCsFixer\Finder())
->in(__DIR__.'/src')
->in(__DIR__.'/tests')
Expand All @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions src/AbstractUpdateAction.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica;

use Elastica\Exception\InvalidException;
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/AbstractAggregation.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

use Elastica\Exception\InvalidException;
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/AbstractSimpleAggregation.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

use Elastica\Exception\InvalidException;
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/AbstractTermsAggregation.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/AdjacencyMatrix.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

use Elastica\Query\AbstractQuery;
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/AutoDateHistogram.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

use Elastica\Aggregation\Traits\MissingTrait;
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/Avg.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/AvgBucket.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/BucketScript.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/BucketSelector.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/Cardinality.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/Children.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/Composite.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

class Composite extends AbstractAggregation
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/CumulativeSum.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/DateHistogram.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/DateRange.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/Derivative.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/DiversifiedSampler.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/ExtendedStats.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/ExtendedStatsBucket.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/Filter.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

use Elastica\Exception\InvalidException;
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/Filters.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

use Elastica\Exception\InvalidException;
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/GapPolicyInterface.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

use Elastica\Aggregation\Traits\GapPolicyTrait;
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/GeoBounds.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/GeoCentroid.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/GeoDistance.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

use Elastica\Exception\InvalidException;
Expand Down
4 changes: 3 additions & 1 deletion src/Aggregation/GeohashGrid.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

/**
Expand Down Expand Up @@ -46,7 +48,7 @@ public function setField(string $field): self
public function setPrecision($precision): self
{
if (!\is_int($precision) && !\is_string($precision)) {
throw new \TypeError(\sprintf('Argument 1 passed to "%s()" must be of type int|string, %s given.', __METHOD__, \is_object($precision) ? \get_class($precision) : \gettype($precision)));
throw new \TypeError(\sprintf('Argument 1 passed to "%s()" must be of type int|string, %s given.', __METHOD__, \is_object($precision) ? $precision::class : \gettype($precision)));
}

return $this->setParam('precision', $precision);
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/GeotileGridAggregation.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/GlobalAggregation.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/Histogram.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/IpRange.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

use Elastica\Exception\InvalidException;
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/Max.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/Min.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/Missing.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/Nested.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/NormalizeAggregation.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/ParentAggregation.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/Percentiles.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/PercentilesBucket.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/Range.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

use Elastica\Exception\InvalidException;
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/ReverseNested.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/Sampler.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/ScriptedMetric.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/SerialDiff.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/SignificantTerms.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

use Elastica\Query\AbstractQuery;
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/Stats.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elastica\Aggregation;

/**
Expand Down
Loading

0 comments on commit cbc602a

Please sign in to comment.