From fc651f915405ea35253b84e089a47175a9a2d280 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Tue, 21 Jun 2022 16:11:57 +1000 Subject: [PATCH] [REF][PHP8.1] Fix a couple of deprecations in php8.1 by specifying that return type may change in BaseParamQuery and by ensuring that we don't pass null into function_exists in I18n class Replace some ReturnTypeWillChange with later return types as they should be backward compatible Dave D Fix Completely switch to just not empty on the customTranslationFunction check --- CRM/Core/I18n.php | 2 +- CRM/Utils/SQL/BaseParamQuery.php | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CRM/Core/I18n.php b/CRM/Core/I18n.php index bcb214d66e..9c3c0fe212 100644 --- a/CRM/Core/I18n.php +++ b/CRM/Core/I18n.php @@ -801,7 +801,7 @@ function ts($text, $params = []) { if ($bootstrapReady) { // just got ready: determine whether there is a working custom translation function $config = CRM_Core_Config::singleton(); - if (isset($config->customTranslateFunction) and function_exists($config->customTranslateFunction)) { + if (!empty($config->customTranslateFunction) && function_exists($config->customTranslateFunction)) { $function = $config->customTranslateFunction; } } diff --git a/CRM/Utils/SQL/BaseParamQuery.php b/CRM/Utils/SQL/BaseParamQuery.php index b0bf8633d0..960dec4cbf 100644 --- a/CRM/Utils/SQL/BaseParamQuery.php +++ b/CRM/Utils/SQL/BaseParamQuery.php @@ -184,7 +184,7 @@ class CRM_Utils_SQL_BaseParamQuery implements ArrayAccess { * * @return bool */ - public function offsetExists($offset) { + public function offsetExists($offset): bool { return isset($this->params[$offset]); } @@ -202,6 +202,7 @@ class CRM_Utils_SQL_BaseParamQuery implements ArrayAccess { * @see param() * @see ArrayAccess::offsetGet */ + #[ReturnTypeWillChange] public function offsetGet($offset) { return $this->params[$offset]; } @@ -223,7 +224,7 @@ class CRM_Utils_SQL_BaseParamQuery implements ArrayAccess { * @see param() * @see ArrayAccess::offsetSet */ - public function offsetSet($offset, $value) { + public function offsetSet($offset, $value): void { $this->param($offset, $value); } @@ -234,7 +235,7 @@ class CRM_Utils_SQL_BaseParamQuery implements ArrayAccess { * @see param() * @see ArrayAccess::offsetUnset */ - public function offsetUnset($offset) { + public function offsetUnset($offset): void { unset($this->params[$offset]); } -- 2.25.1