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 14, 2020
1 parent 129cf7c commit 2d42904
Show file tree
Hide file tree
Showing 275 changed files with 3,448 additions and 2,768 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,
'@PHPUnit60Migration:risky' => true,
'@PSR2' => true,
'@Symfony' => 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,
'@PHPUnit60Migration:risky' => 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,
])
;
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 2d42904

Please sign in to comment.