Skip to content

Commit a3baa5c

Browse files
author
Stanislav Idolov
authored
ENGCOM-2925: Replace sort callbacks to spaceship operator #17938
2 parents 872e489 + 89cb354 commit a3baa5c

File tree

5 files changed

+5
-34
lines changed

5 files changed

+5
-34
lines changed

lib/internal/Magento/Framework/App/RouterList.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,6 @@ public function rewind()
119119
*/
120120
protected function compareRoutersSortOrder($routerDataFirst, $routerDataSecond)
121121
{
122-
if ((int)$routerDataFirst['sortOrder'] == (int)$routerDataSecond['sortOrder']) {
123-
return 0;
124-
}
125-
126-
if ((int)$routerDataFirst['sortOrder'] < (int)$routerDataSecond['sortOrder']) {
127-
return -1;
128-
} else {
129-
return 1;
130-
}
122+
return (int)$routerDataFirst['sortOrder'] <=> (int)$routerDataSecond['sortOrder'];
131123
}
132124
}

lib/internal/Magento/Framework/Config/Reader.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,7 @@ function ($item) {
6363
uasort(
6464
$array,
6565
function ($firstItem, $nexItem) {
66-
if ((int)$firstItem['sortOrder'] == (int)$nexItem['sortOrder']) {
67-
return 0;
68-
}
69-
return (int)$firstItem['sortOrder'] < (int)$nexItem['sortOrder'] ? -1 : 1;
66+
return (int)$firstItem['sortOrder'] <=> (int)$nexItem['sortOrder'];
7067
}
7168
);
7269

lib/internal/Magento/Framework/MessageQueue/Config/CompositeReader.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,10 @@ function ($firstItem, $secondItem) {
7171
if (isset($firstItem['sortOrder'])) {
7272
$firstValue = intval($firstItem['sortOrder']);
7373
}
74-
7574
if (isset($secondItem['sortOrder'])) {
7675
$secondValue = intval($secondItem['sortOrder']);
7776
}
78-
79-
if ($firstValue == $secondValue) {
80-
return 0;
81-
}
82-
return $firstValue < $secondValue ? -1 : 1;
77+
return $firstValue <=> $secondValue;
8378
}
8479
);
8580
return $readers;

lib/internal/Magento/Framework/MessageQueue/Config/Reader/Xml/CompositeConverter.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,10 @@ function ($firstItem, $secondItem) {
7070
if (isset($firstItem['sortOrder'])) {
7171
$firstValue = intval($firstItem['sortOrder']);
7272
}
73-
7473
if (isset($secondItem['sortOrder'])) {
7574
$secondValue = intval($secondItem['sortOrder']);
7675
}
77-
78-
if ($firstValue == $secondValue) {
79-
return 0;
80-
}
81-
return $firstValue < $secondValue ? -1 : 1;
76+
return $firstValue <=> $secondValue;
8277
}
8378
);
8479
return $converters;

lib/internal/Magento/Framework/ObjectManager/Helper/Composite.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,7 @@ function ($component) {
3535
uasort(
3636
$declaredComponents,
3737
function ($firstComponent, $secondComponent) {
38-
$firstComponentSortOrder = (int)$firstComponent['sortOrder'];
39-
$secondComponentSortOrder = (int)$secondComponent['sortOrder'];
40-
if ($firstComponentSortOrder == $secondComponentSortOrder) {
41-
return 0;
42-
} elseif ($firstComponentSortOrder < $secondComponentSortOrder) {
43-
return -1;
44-
} else {
45-
return 1;
46-
}
38+
return (int)$firstComponent['sortOrder'] <=> (int)$secondComponent['sortOrder'];
4739
}
4840
);
4941
$declaredComponents = array_values($declaredComponents);

0 commit comments

Comments
 (0)