Skip to content

Commit 98b2f9d

Browse files
committed
Update PHP-cs-fixer settings and apply fixes
1 parent e701617 commit 98b2f9d

File tree

275 files changed

+3433
-2752
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

275 files changed

+3433
-2752
lines changed

.php_cs.dist

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,25 @@ $finder = PhpCsFixer\Finder::create()
77
return PhpCsFixer\Config::create()
88
->setFinder($finder)
99
->setRules([
10+
'@PHP71Migration' => true,
11+
'@PhpCsFixer' => true,
12+
'@PHPUnit75Migration:risky' => true,
1013
'@PSR2' => true,
1114
'@Symfony' => true,
12-
'@PHPUnit75Migration:risky' => true,
13-
'single_blank_line_before_namespace' => false,
14-
'ordered_imports' => true,
1515
'array_syntax' => ['syntax' => 'short'],
16-
'phpdoc_order' => true,
17-
'ternary_to_null_coalescing' => true,
18-
'no_useless_else' => true,
19-
'php_unit_dedicate_assert' => ['target' => 'newest'],
16+
'is_null' => true,
17+
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
2018
'native_function_invocation' => true,
2119
'no_alias_functions' => true,
20+
'no_useless_else' => true,
2221
'nullable_type_declaration_for_default_null_value' => true,
22+
'ordered_imports' => true,
23+
'php_unit_dedicate_assert' => ['target' => 'newest'],
24+
'php_unit_test_class_requires_covers' => false,
25+
'phpdoc_order' => true,
26+
'phpdoc_types_order' => ['null_adjustment' => 'always_last'],
27+
'ternary_to_null_coalescing' => true,
2328
'visibility_required' => ['property', 'method', 'const'],
29+
'void_return' => true,
2430
])
2531
;

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616
* Added `Elastica\Pipeline->getId(): ?string` [#1752](https://github.com/ruflin/Elastica/pull/1752)
1717

1818
### Changed
19+
- Updated PHP coding standards to adhere to PSR-12 [#1760](https://github.com/ruflin/Elastica/pull/1760)
1920
- Updated to PHPUnit v8.5 [#1759](https://github.com/ruflin/Elastica/pull/1759)
2021
- Refactored code structure: use `src/` and `tests/` folders [#1755](https://github.com/ruflin/Elastica/pull/1755)
2122
- Require elastica-php library >= v7.1.1, fixes an issue on Ingestion/Put() type-hinting

src/AbstractUpdateAction.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function setVersion($version)
8181
/**
8282
* Returns document version.
8383
*
84-
* @return string|int Document version
84+
* @return int|string Document version
8585
*/
8686
public function getVersion()
8787
{
@@ -112,7 +112,7 @@ public function setVersionType($versionType)
112112
/**
113113
* Returns document version type.
114114
*
115-
* @return string|int Document version type
115+
* @return int|string Document version type
116116
*/
117117
public function getVersionType()
118118
{
@@ -356,7 +356,7 @@ public function hasReplication()
356356
}
357357

358358
/**
359-
* @param Document|array $data
359+
* @param array|Document $data
360360
*
361361
* @return $this
362362
*/

src/Aggregation/AbstractSimpleAggregation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function setField(string $field): self
2121
/**
2222
* Set a script for this aggregation.
2323
*
24-
* @param string|\Elastica\Script\AbstractScript $script
24+
* @param \Elastica\Script\AbstractScript|string $script
2525
*
2626
* @return $this
2727
*/

src/Aggregation/BucketScript.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ public function toArray(): array
7171
{
7272
if (!$this->hasParam('buckets_path')) {
7373
throw new InvalidException('Buckets path is required');
74-
} elseif (!$this->hasParam('script')) {
74+
}
75+
if (!$this->hasParam('script')) {
7576
throw new InvalidException('Script parameter is required');
7677
}
7778

src/Aggregation/GeoDistance.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class GeoDistance extends AbstractAggregation
2020
/**
2121
* @param string $name the name if this aggregation
2222
* @param string $field the field on which to perform this aggregation
23-
* @param string|array $origin the point from which distances will be calculated
23+
* @param array|string $origin the point from which distances will be calculated
2424
*/
2525
public function __construct(string $name, string $field, $origin)
2626
{
@@ -43,7 +43,7 @@ public function setField(string $field): self
4343
/**
4444
* Set the origin point from which distances will be calculated.
4545
*
46-
* @param string|array $origin valid formats are array("lat" => 52.3760, "lon" => 4.894), "52.3760, 4.894", and array(4.894, 52.3760)
46+
* @param array|string $origin valid formats are array("lat" => 52.3760, "lon" => 4.894), "52.3760, 4.894", and array(4.894, 52.3760)
4747
*
4848
* @return $this
4949
*/

src/Aggregation/ParentAggregation.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@
99
*/
1010
class ParentAggregation extends AbstractAggregation
1111
{
12-
protected function _getBaseName()
13-
{
14-
return 'parent';
15-
}
16-
1712
/**
1813
* Set the child type for this aggregation.
1914
*
@@ -25,4 +20,9 @@ public function setType($type): self
2520
{
2621
return $this->setParam('type', $type);
2722
}
23+
24+
protected function _getBaseName()
25+
{
26+
return 'parent';
27+
}
2828
}

src/Aggregation/Range.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ class Range extends AbstractSimpleAggregation
1414
/**
1515
* Add a range to this aggregation.
1616
*
17-
* @param int|float $fromValue low end of this range, exclusive (greater than or equal to)
18-
* @param int|float $toValue high end of this range, exclusive (less than)
17+
* @param float|int $fromValue low end of this range, exclusive (greater than or equal to)
18+
* @param float|int $toValue high end of this range, exclusive (less than)
1919
* @param string $key customized key value
2020
*
2121
* @throws \Elastica\Exception\InvalidException

src/Aggregation/TopHits.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function setSort(array $sortArgs): self
5858
/**
5959
* Allows to control how the _source field is returned with every hit.
6060
*
61-
* @param array|string|bool $params Fields to be returned or false to disable source
61+
* @param array|bool|string $params Fields to be returned or false to disable source
6262
*
6363
* @return $this
6464
*/

src/Bulk.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,13 @@ public function __construct(Client $client)
4545
$this->_client = $client;
4646
}
4747

48+
public function __toString(): string
49+
{
50+
return $this->toString();
51+
}
52+
4853
/**
49-
* @param string|Index $index
54+
* @param Index|string $index
5055
*
5156
* @return $this
5257
*/
@@ -153,6 +158,7 @@ public function addScript(AbstractScript $script, ?string $opType = null): self
153158

154159
/**
155160
* @param Document[] $scripts
161+
* @param mixed|null $opType
156162
*
157163
* @return $this
158164
*/
@@ -166,7 +172,7 @@ public function addScripts(array $scripts, $opType = null): self
166172
}
167173

168174
/**
169-
* @param \Elastica\Script\AbstractScript|\Elastica\Document|array $data
175+
* @param array|\Elastica\Document|\Elastica\Script\AbstractScript $data
170176
*
171177
* @return $this
172178
*/
@@ -254,11 +260,6 @@ public function setShardTimeout(string $time): self
254260
return $this->setRequestParam('timeout', $time);
255261
}
256262

257-
public function __toString(): string
258-
{
259-
return $this->toString();
260-
}
261-
262263
public function toString(): string
263264
{
264265
$data = '';

0 commit comments

Comments
 (0)