Skip to content

Commit 053efe6

Browse files
committed
Add Symfony ruleset in ECS
1 parent 8beaed2 commit 053efe6

22 files changed

+43
-42
lines changed

ecs.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111
$containerConfigurator->import(SetList::SYMPLIFY);
1212
$containerConfigurator->import(SetList::COMMON);
1313
$containerConfigurator->import(SetList::CLEAN_CODE);
14+
$containerConfigurator->import(SetList::SYMFONY);
1415

1516
$parameters = $containerConfigurator->parameters();
1617

1718
$parameters->set(Option::PARALLEL, true);
1819

19-
$parameters->set(Option::PATHS, [__DIR__ . '/src', __DIR__ . '/tests', __DIR__ . '/ecs.php']);
20+
$parameters->set(Option::PATHS, [__DIR__.'/src', __DIR__.'/tests', __DIR__.'/ecs.php']);
2021
};

src/Aggregation/CardinalityAggregation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ protected function buildAggregation(): array
4242
{
4343
$build = parent::buildAggregation();
4444

45-
if ($this->precisionThreshold !== null) {
45+
if (null !== $this->precisionThreshold) {
4646
$build['precision_threshold'] = $this->precisionThreshold;
4747
}
4848

src/Aggregation/MetricAggregation.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function __construct(
2626
) {
2727
parent::__construct($nameAndField, $aggregations);
2828

29-
if ($fieldOrSource === null) {
29+
if (null === $fieldOrSource) {
3030
$fieldOrSource = $nameAndField;
3131
}
3232

@@ -72,13 +72,13 @@ public function setMissing(?int $missing): self
7272
protected function buildAggregation(): array
7373
{
7474
$term = [];
75-
if ($this->script !== null) {
75+
if (null !== $this->script) {
7676
$term = $this->script->build();
77-
} elseif ($this->field !== null) {
77+
} elseif (null !== $this->field) {
7878
$term = $this->field->build();
7979
}
8080

81-
if ($this->missing !== null) {
81+
if (null !== $this->missing) {
8282
$term['missing'] = $this->missing;
8383
}
8484

src/Aggregation/RangesAggregation.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ class RangesAggregation extends AbstractAggregation
1414
* Builds automatically range aggregation with simple ranges array of numeric.
1515
*
1616
* @param array<int> $ranges pass desired ranges that will be converted to
17-
* linear range
17+
* linear range
1818
* @param array<AbstractAggregation> $aggregations
1919
* @param bool $equalConditionOnToRange Se to true if you want to do a histogram with 0
20-
* - 10, 10 - 15, and correctly count the number
21-
* (entry with 10 will be in first and seconds
22-
* segment
20+
* - 10, 10 - 15, and correctly count the number
21+
* (entry with 10 will be in first and seconds
22+
* segment
2323
*/
2424
public function __construct(
2525
string $name,
@@ -65,7 +65,7 @@ protected function buildAggregation(): array
6565

6666
// Append "others"
6767
$ranges[] = [
68-
'key' => $prevValue . '-*',
68+
'key' => $prevValue.'-*',
6969
'from' => $prevValue,
7070
];
7171

src/Aggregation/TermsAggregation.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,27 +76,27 @@ public function setExclude(array|string|null $exclude): self
7676
protected function buildAggregation(): array
7777
{
7878
$build = [];
79-
if ($this->script !== null) {
79+
if (null !== $this->script) {
8080
$build = [
8181
'script' => $this->script->build(),
8282
];
83-
} elseif ($this->field !== null) {
83+
} elseif (null !== $this->field) {
8484
$build = $this->field->build() + [
8585
'size' => $this->size,
8686
];
8787
}
8888

89-
if ($this->orderField !== null) {
89+
if (null !== $this->orderField) {
9090
$build['order'] = [
9191
$this->orderField => $this->orderValue,
9292
];
9393
}
9494

95-
if ($this->include !== null) {
95+
if (null !== $this->include) {
9696
$build['include'] = $this->include;
9797
}
9898

99-
if ($this->exclude !== null) {
99+
if (null !== $this->exclude) {
100100
$build['exclude'] = $this->exclude;
101101
}
102102

src/Aggregation/TopHitsAggregation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ protected function buildAggregation(): array
3939
'size' => $this->size,
4040
];
4141

42-
if ($this->script !== null) {
42+
if (null !== $this->script) {
4343
$data['_source'] = [
4444
'includes' => $this->script,
4545
];

src/Features/HasAggregations.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function getAggregations(): ?array
4040

4141
protected function buildAggregationsTo(array &$toArray): self
4242
{
43-
if (count($this->aggregations) === 0) {
43+
if (0 === count($this->aggregations)) {
4444
return $this;
4545
}
4646

src/Features/HasCollapse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function getCollapse(): ?Collapse
3636
*/
3737
protected function buildCollapseTo(array &$toArray): self
3838
{
39-
if ($this->collapse !== null) {
39+
if (null !== $this->collapse) {
4040
$toArray['collapse'] = $this->collapse->build();
4141
}
4242

src/Features/HasOperator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function setOperator(?string $operator): self
1717

1818
public function buildOperatorTo(array &$array): self
1919
{
20-
if ($this->operator === null) {
20+
if (null === $this->operator) {
2121
return $this;
2222
}
2323

src/Features/HasSorting.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function addSort(string $field, string|array $config = SortDirections::AS
3232
*/
3333
protected function buildSortTo(array &$toArray): self
3434
{
35-
if (empty($this->sort) === false) {
35+
if (false === empty($this->sort)) {
3636
foreach ($this->sort as $sort => $config) {
3737
$toArray['sort'][$sort] = $config;
3838
}

0 commit comments

Comments
 (0)