From 11d593edde82e7de962ec9056cfebe87975fb499 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Fri, 4 Jun 2021 17:20:13 +1000 Subject: [PATCH] [php8-compat] Fix issue with returning bool from uasort by using the spaceship operator --- CRM/Core/BAO/Dashboard.php | 2 +- CRM/Utils/Check.php | 2 +- api/v3/Profile.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CRM/Core/BAO/Dashboard.php b/CRM/Core/BAO/Dashboard.php index c5ade57f4a..5ef7321b15 100644 --- a/CRM/Core/BAO/Dashboard.php +++ b/CRM/Core/BAO/Dashboard.php @@ -96,7 +96,7 @@ class CRM_Core_BAO_Dashboard extends CRM_Core_DAO_Dashboard { if (!isset($a['dashboard_contact.weight'])) { return 1; } - return $a['dashboard_contact.weight'] > $b['dashboard_contact.weight']; + return $a['dashboard_contact.weight'] <=> $b['dashboard_contact.weight']; }); } return Civi::$statics[__CLASS__][__FUNCTION__][$cid] ?? []; diff --git a/CRM/Utils/Check.php b/CRM/Utils/Check.php index 290de63123..618b332b7b 100644 --- a/CRM/Utils/Check.php +++ b/CRM/Utils/Check.php @@ -114,7 +114,7 @@ class CRM_Utils_Check { return strcmp($a->getName(), $b->getName()); } // The Message constructor guarantees that these will always be integers. - return ($aSeverity < $bSeverity); + return ($aSeverity <=> $bSeverity); } /** diff --git a/api/v3/Profile.php b/api/v3/Profile.php index 84d642bf05..c7c337d209 100644 --- a/api/v3/Profile.php +++ b/api/v3/Profile.php @@ -615,7 +615,7 @@ function _civicrm_api3_buildprofile_submitfields($profileID, $optionsBehaviour, * @return bool */ function _civicrm_api3_order_by_weight($a, $b) { - return ($b['weight'] ?? 0) < ($a['weight'] ?? 0); + return ($b['weight'] ?? 0) < ($a['weight'] ?? 0) ? 1 : -1; } /** -- 2.25.1