Unverified Commit b69a33ed authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3161223 by andypost, longwave, Hardik_Patel_12, alexpott, jungle, dww:...

Issue #3161223 by andypost, longwave, Hardik_Patel_12, alexpott, jungle, dww: Use PHP 7.0 "spaceship" operator for user sort functions where possible
parent 11c0e0a6
Loading
Loading
Loading
Loading
+1 −5
Original line number Diff line number Diff line
@@ -122,11 +122,7 @@ public static function sortByKeyInt($a, $b, $key) {
    $a_weight = (is_array($a) && isset($a[$key])) ? $a[$key] : 0;
    $b_weight = (is_array($b) && isset($b[$key])) ? $b[$key] : 0;

    if ($a_weight == $b_weight) {
      return 0;
    }

    return ($a_weight < $b_weight) ? -1 : 1;
    return $a_weight <=> $b_weight;
  }

}
+1 −1
Original line number Diff line number Diff line
@@ -235,7 +235,7 @@ public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b)
      $b_label = $b->label() ?? '';
      return strnatcasecmp($a_label, $b_label);
    }
    return ($a_weight < $b_weight) ? -1 : 1;
    return $a_weight <=> $b_weight;
  }

  /**
+1 −1
Original line number Diff line number Diff line
@@ -160,7 +160,7 @@ public static function sort(&$languages) {
        }
        return strnatcasecmp($a_name, $b_name);
      }
      return ($a_weight < $b_weight) ? -1 : 1;
      return $a_weight <=> $b_weight;
    });
  }

+1 −1
Original line number Diff line number Diff line
@@ -392,7 +392,7 @@ protected function routeProviderRouteCompare(array $a, array $b) {
    }
    // Reverse sort from highest to lowest fit. PHP should cast to int, but
    // the explicit cast makes this sort more robust against unexpected input.
    return (int) $a['fit'] < (int) $b['fit'] ? 1 : -1;
    return (int) $b['fit'] <=> (int) $a['fit'];
  }

  /**
+1 −1
Original line number Diff line number Diff line
@@ -94,7 +94,7 @@ public function sortHelper($aID, $bID) {
      return !empty($a->status) ? -1 : 1;
    }
    if ($a->weight != $b->weight) {
      return $a->weight < $b->weight ? -1 : 1;
      return $a->weight <=> $b->weight;
    }
    if ($a->provider != $b->provider) {
      return strnatcasecmp($a->provider, $b->provider);
Loading