Skip to content

Commit

Permalink
Update PHP-cs-fixer settings and apply fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
thePanz committed Feb 17, 2020
1 parent e701617 commit 98b2f9d
Show file tree
Hide file tree
Showing 275 changed files with 3,433 additions and 2,752 deletions.
20 changes: 13 additions & 7 deletions .php_cs.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,25 @@ $finder = PhpCsFixer\Finder::create()
return PhpCsFixer\Config::create()
->setFinder($finder)
->setRules([
'@PHP71Migration' => true,
'@PhpCsFixer' => true,
'@PHPUnit75Migration:risky' => true,
'@PSR2' => true,
'@Symfony' => true,
'@PHPUnit75Migration:risky' => true,
'single_blank_line_before_namespace' => false,
'ordered_imports' => true,
'array_syntax' => ['syntax' => 'short'],
'phpdoc_order' => true,
'ternary_to_null_coalescing' => true,
'no_useless_else' => true,
'php_unit_dedicate_assert' => ['target' => 'newest'],
'is_null' => true,
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
'native_function_invocation' => true,
'no_alias_functions' => true,
'no_useless_else' => true,
'nullable_type_declaration_for_default_null_value' => true,
'ordered_imports' => true,
'php_unit_dedicate_assert' => ['target' => 'newest'],
'php_unit_test_class_requires_covers' => false,
'phpdoc_order' => true,
'phpdoc_types_order' => ['null_adjustment' => 'always_last'],
'ternary_to_null_coalescing' => true,
'visibility_required' => ['property', 'method', 'const'],
'void_return' => true,
])
;
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Added `Elastica\Pipeline->getId(): ?string` [#1752](https://github.com/ruflin/Elastica/pull/1752)

### Changed
- Updated PHP coding standards to adhere to PSR-12 [#1760](https://github.com/ruflin/Elastica/pull/1760)
- Updated to PHPUnit v8.5 [#1759](https://github.com/ruflin/Elastica/pull/1759)
- Refactored code structure: use `src/` and `tests/` folders [#1755](https://github.com/ruflin/Elastica/pull/1755)
- Require elastica-php library >= v7.1.1, fixes an issue on Ingestion/Put() type-hinting
Expand Down
6 changes: 3 additions & 3 deletions src/AbstractUpdateAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function setVersion($version)
/**
* Returns document version.
*
* @return string|int Document version
* @return int|string Document version
*/
public function getVersion()
{
Expand Down Expand Up @@ -112,7 +112,7 @@ public function setVersionType($versionType)
/**
* Returns document version type.
*
* @return string|int Document version type
* @return int|string Document version type
*/
public function getVersionType()
{
Expand Down Expand Up @@ -356,7 +356,7 @@ public function hasReplication()
}

/**
* @param Document|array $data
* @param array|Document $data
*
* @return $this
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Aggregation/AbstractSimpleAggregation.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function setField(string $field): self
/**
* Set a script for this aggregation.
*
* @param string|\Elastica\Script\AbstractScript $script
* @param \Elastica\Script\AbstractScript|string $script
*
* @return $this
*/
Expand Down
3 changes: 2 additions & 1 deletion src/Aggregation/BucketScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ public function toArray(): array
{
if (!$this->hasParam('buckets_path')) {
throw new InvalidException('Buckets path is required');
} elseif (!$this->hasParam('script')) {
}
if (!$this->hasParam('script')) {
throw new InvalidException('Script parameter is required');
}

Expand Down
4 changes: 2 additions & 2 deletions src/Aggregation/GeoDistance.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class GeoDistance extends AbstractAggregation
/**
* @param string $name the name if this aggregation
* @param string $field the field on which to perform this aggregation
* @param string|array $origin the point from which distances will be calculated
* @param array|string $origin the point from which distances will be calculated
*/
public function __construct(string $name, string $field, $origin)
{
Expand All @@ -43,7 +43,7 @@ public function setField(string $field): self
/**
* Set the origin point from which distances will be calculated.
*
* @param string|array $origin valid formats are array("lat" => 52.3760, "lon" => 4.894), "52.3760, 4.894", and array(4.894, 52.3760)
* @param array|string $origin valid formats are array("lat" => 52.3760, "lon" => 4.894), "52.3760, 4.894", and array(4.894, 52.3760)
*
* @return $this
*/
Expand Down
10 changes: 5 additions & 5 deletions src/Aggregation/ParentAggregation.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
*/
class ParentAggregation extends AbstractAggregation
{
protected function _getBaseName()
{
return 'parent';
}

/**
* Set the child type for this aggregation.
*
Expand All @@ -25,4 +20,9 @@ public function setType($type): self
{
return $this->setParam('type', $type);
}

protected function _getBaseName()
{
return 'parent';
}
}
4 changes: 2 additions & 2 deletions src/Aggregation/Range.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class Range extends AbstractSimpleAggregation
/**
* Add a range to this aggregation.
*
* @param int|float $fromValue low end of this range, exclusive (greater than or equal to)
* @param int|float $toValue high end of this range, exclusive (less than)
* @param float|int $fromValue low end of this range, exclusive (greater than or equal to)
* @param float|int $toValue high end of this range, exclusive (less than)
* @param string $key customized key value
*
* @throws \Elastica\Exception\InvalidException
Expand Down
2 changes: 1 addition & 1 deletion src/Aggregation/TopHits.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function setSort(array $sortArgs): self
/**
* Allows to control how the _source field is returned with every hit.
*
* @param array|string|bool $params Fields to be returned or false to disable source
* @param array|bool|string $params Fields to be returned or false to disable source
*
* @return $this
*/
Expand Down
15 changes: 8 additions & 7 deletions src/Bulk.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,13 @@ public function __construct(Client $client)
$this->_client = $client;
}

public function __toString(): string
{
return $this->toString();
}

/**
* @param string|Index $index
* @param Index|string $index
*
* @return $this
*/
Expand Down Expand Up @@ -153,6 +158,7 @@ public function addScript(AbstractScript $script, ?string $opType = null): self

/**
* @param Document[] $scripts
* @param mixed|null $opType
*
* @return $this
*/
Expand All @@ -166,7 +172,7 @@ public function addScripts(array $scripts, $opType = null): self
}

/**
* @param \Elastica\Script\AbstractScript|\Elastica\Document|array $data
* @param array|\Elastica\Document|\Elastica\Script\AbstractScript $data
*
* @return $this
*/
Expand Down Expand Up @@ -254,11 +260,6 @@ public function setShardTimeout(string $time): self
return $this->setRequestParam('timeout', $time);
}

public function __toString(): string
{
return $this->toString();
}

public function toString(): string
{
$data = '';
Expand Down
4 changes: 2 additions & 2 deletions src/Bulk/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function hasSource(): bool
}

/**
* @param string|Index $index
* @param Index|string $index
*
* @return $this
*/
Expand All @@ -131,7 +131,7 @@ public function setId(string $id): self
}

/**
* @param string|int $routing
* @param int|string $routing
*
* @return $this
*/
Expand Down
12 changes: 6 additions & 6 deletions src/Bulk/Action/AbstractDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
abstract class AbstractDocument extends Action
{
/**
* @var Document|AbstractScript
* @var AbstractScript|Document
*/
protected $_data;

/**
* @param Document|AbstractScript $document
* @param AbstractScript|Document $document
*/
public function __construct($document)
{
Expand Down Expand Up @@ -102,21 +102,19 @@ public function getScript()
}

/**
* @return Document|AbstractScript
* @return AbstractScript|Document
*/
public function getData()
{
return $this->_data;
}

abstract protected function _getMetadata(AbstractUpdateAction $source): array;

/**
* Creates a bulk action for a document or a script.
*
* The action can be index, update, create or delete based on the $opType param (by default index).
*
* @param Document|AbstractScript $data
* @param AbstractScript|Document $data
* @param string $opType
*
* @return static
Expand Down Expand Up @@ -162,4 +160,6 @@ public static function create($data, ?string $opType = null): self

return $action;
}

abstract protected function _getMetadata(AbstractUpdateAction $source): array;
}
4 changes: 2 additions & 2 deletions src/Bulk/ResponseSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function current(): Response
/**
* {@inheritdoc}
*/
public function next()
public function next(): void
{
++$this->_position;
}
Expand All @@ -118,7 +118,7 @@ public function valid(): bool
/**
* {@inheritdoc}
*/
public function rewind()
public function rewind(): void
{
$this->_position = 0;
}
Expand Down
Loading

0 comments on commit 98b2f9d

Please sign in to comment.