Skip to content

Commit dc2d91c

Browse files
committed
Use <=> for sort comparisons to avoid PHP8 notices
1 parent 827aa4c commit dc2d91c

File tree

5 files changed

+6
-30
lines changed

5 files changed

+6
-30
lines changed

src/Commands/CheckCommand.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,7 @@ private function templates()
9898
}
9999

100100
$items->sortUsing(function (Template $t1, Template $t2) {
101-
if ($t1->name() === $t2->name()) {
102-
return 0;
103-
}
104-
105-
return ($t1->name() < $t2->name()) ? -1 : 1;
101+
return $t1->name() <=> $t2->name();
106102
});
107103

108104
return $items;

src/Commands/Libraries/ListCommand.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
5151
->libraries()
5252
->list()
5353
->sortUsing(function (Library $a, Library $b) {
54-
if ($a->name() === $b->name()) {
55-
return 0;
56-
}
57-
58-
return $a->name() > $b->name() ? 1 : -1;
54+
return $a->name() <=> $b->name();
5955
})
6056
->each(function (Library $service) use ($table) {
6157
$table->addRow([

src/Commands/Projects/CurrentProjectCommand.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
5353
->libraries()
5454
->list()
5555
->sortUsing(function (Library $a, Library $b) {
56-
if ($a->name() === $b->name()) {
57-
return 0;
58-
}
59-
60-
return $a->name() > $b->name() ? 1 : -1;
56+
return $a->name() <=> $b->name();
6157
})->each(function (Library $lib, $key) use (&$i) {
6258
$this->tools()->step(++$i, $lib->name());
6359
})
@@ -71,11 +67,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
7167
->services()
7268
->list()
7369
->sortUsing(function (Service $a, Service $b) {
74-
if ($a->name() === $b->name()) {
75-
return 0;
76-
}
77-
78-
return $a->name() > $b->name() ? 1 : -1;
70+
return $a->name() <=> $b->name();
7971
})
8072
->each(function (Service $lib, $key) use (&$i) {
8173
$this->tools()->step(++$i, $lib->name());

src/Commands/Services/ListCommand.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
5454
->services()
5555
->list()
5656
->sortUsing(function (Service $a, Service $b) {
57-
if ($a->name() === $b->name()) {
58-
return 0;
59-
}
60-
61-
return $a->name() > $b->name() ? 1 : -1;
57+
return $a->name() <=> $b->name();
6258
})
6359
->each(function (Service $service) use ($table) {
6460
$service->appContainer() ? $this->docker->resolve($service) : null;

src/Commands/Services/StatusCommand.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,7 @@ private function fetchStatusData(Project $project, bool $disableSyncit = false):
7777
->docker
7878
->status($project->docker()->get('compose_project_name'))
7979
->sortUsing(function ($r1, $r2) {
80-
if ($r1['name'] == $r2['name']) {
81-
return 0;
82-
}
83-
84-
return $r1['name'] > $r2['name'];
80+
return $r1['name'] <=> $r2['name'];
8581
})
8682
->each(function (array $row) use ($data, $project, $disableSyncit) {
8783
$mounts = $this->getMountsFromString($row['mounts']);

0 commit comments

Comments
 (0)