From c34aad582358ef56238c0fb1ae627e9bfd97f7eb Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Fri, 7 Apr 2023 16:06:41 +1200 Subject: [PATCH] Remove some uses of legacy array format --- CRM/Admin/Form/Job.php | 2 +- CRM/Admin/Form/PaymentProcessor.php | 4 +-- CRM/Admin/Form/Setting/Smtp.php | 10 +++---- CRM/Admin/Page/Job.php | 46 ++++++++++++++--------------- CRM/Financial/Page/AJAX.php | 6 ++-- 5 files changed, 34 insertions(+), 34 deletions(-) diff --git a/CRM/Admin/Form/Job.php b/CRM/Admin/Form/Job.php index d156f3a33d..3a53bf9ddf 100644 --- a/CRM/Admin/Form/Job.php +++ b/CRM/Admin/Form/Job.php @@ -233,7 +233,7 @@ class CRM_Admin_Form_Job extends CRM_Admin_Form { if ($ts > time()) { $dao->scheduled_run_date = CRM_Utils_Date::currentDBDate($ts); // warn about monthly/quarterly scheduling, if applicable - if (($dao->run_frequency == 'Monthly') || ($dao->run_frequency == 'Quarter')) { + if (($dao->run_frequency === 'Monthly') || ($dao->run_frequency === 'Quarter')) { $info = getdate($ts); if ($info['mday'] > 28) { CRM_Core_Session::setStatus( diff --git a/CRM/Admin/Form/PaymentProcessor.php b/CRM/Admin/Form/PaymentProcessor.php index d247be0030..9cf1fe6394 100644 --- a/CRM/Admin/Form/PaymentProcessor.php +++ b/CRM/Admin/Form/PaymentProcessor.php @@ -469,10 +469,10 @@ class CRM_Admin_Form_PaymentProcessor extends CRM_Admin_Form { $this->set('pp', $this->_paymentProcessorType); } else { - $paymentProcessorTypes = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_PaymentProcessor', 'payment_processor_type_id', array( + $paymentProcessorTypes = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_PaymentProcessor', 'payment_processor_type_id', [ 'labelColumn' => 'name', 'flip' => 1, - )); + ]); $this->_paymentProcessorType = CRM_Utils_Request::retrieve('pp', 'String', $this, FALSE, $paymentProcessorTypes['PayPal']); } } diff --git a/CRM/Admin/Form/Setting/Smtp.php b/CRM/Admin/Form/Setting/Smtp.php index b8eeea9d9f..16afa30d36 100644 --- a/CRM/Admin/Form/Setting/Smtp.php +++ b/CRM/Admin/Form/Setting/Smtp.php @@ -70,7 +70,7 @@ class CRM_Admin_Form_Setting_Smtp extends CRM_Admin_Form_Setting { $this->getElement('buttons')->setElements($buttons); if (!empty($setStatus)) { - CRM_Core_Session::setStatus(ts("Some fields are loaded as 'readonly' as they have been set (overridden) in civicrm.settings.php."), '', 'info', array('expires' => 0)); + CRM_Core_Session::setStatus(ts("Some fields are loaded as 'readonly' as they have been set (overridden) in civicrm.settings.php."), '', 'info', ['expires' => 0]); } } @@ -101,13 +101,13 @@ class CRM_Admin_Form_Setting_Smtp extends CRM_Admin_Form_Setting { else { $session = CRM_Core_Session::singleton(); $userID = $session->get('userID'); - list($toDisplayName, $toEmail) = CRM_Contact_BAO_Contact::getContactDetails($userID); + [$toDisplayName, $toEmail] = CRM_Contact_BAO_Contact::getContactDetails($userID); //get the default domain email address.CRM-4250 - list($domainEmailName, $domainEmailAddress) = CRM_Core_BAO_Domain::getNameAndEmail(); + [$domainEmailName, $domainEmailAddress] = CRM_Core_BAO_Domain::getNameAndEmail(); - if (!$domainEmailAddress || $domainEmailAddress == 'info@EXAMPLE.ORG') { - $fixUrl = CRM_Utils_System::url("civicrm/admin/options/from_email_address", 'action=update&reset=1'); + if (!$domainEmailAddress || $domainEmailAddress === 'info@EXAMPLE.ORG') { + $fixUrl = CRM_Utils_System::url('civicrm/admin/options/from_email_address', 'action=update&reset=1'); CRM_Core_Error::statusBounce(ts('The site administrator needs to enter a valid \'FROM Email Address\' in Administer CiviCRM » System Settings » Option Groups » From Email Address. The email address used may need to be a valid mail account with your email service provider.', [1 => $fixUrl])); } if (!$toEmail) { diff --git a/CRM/Admin/Page/Job.php b/CRM/Admin/Page/Job.php index 4808d676e2..0beb9c218b 100644 --- a/CRM/Admin/Page/Job.php +++ b/CRM/Admin/Page/Job.php @@ -25,7 +25,7 @@ class CRM_Admin_Page_Job extends CRM_Core_Page_Basic { * * @var array */ - public static $_links = NULL; + public static $_links; /** * Get BAO Name. @@ -45,48 +45,48 @@ class CRM_Admin_Page_Job extends CRM_Core_Page_Basic { */ public function &links() { if (!(self::$_links)) { - self::$_links = array( - CRM_Core_Action::FOLLOWUP => array( + self::$_links = [ + CRM_Core_Action::FOLLOWUP => [ 'name' => ts('View Job Log'), 'url' => 'civicrm/admin/joblog', 'qs' => 'jid=%%id%%&reset=1', 'title' => ts('See log entries for this Scheduled Job'), - ), - CRM_Core_Action::UPDATE => array( + ], + CRM_Core_Action::UPDATE => [ 'name' => ts('Edit'), 'url' => 'civicrm/admin/job', 'qs' => 'action=update&id=%%id%%&reset=1', 'title' => ts('Edit Scheduled Job'), - ), - CRM_Core_Action::VIEW => array( + ], + CRM_Core_Action::VIEW => [ 'name' => ts('Execute Now'), 'url' => 'civicrm/admin/job', 'qs' => 'action=view&id=%%id%%&reset=1', 'title' => ts('Execute Scheduled Job Now'), - ), - CRM_Core_Action::DISABLE => array( + ], + CRM_Core_Action::DISABLE => [ 'name' => ts('Disable'), 'ref' => 'crm-enable-disable', 'title' => ts('Disable Scheduled Job'), - ), - CRM_Core_Action::ENABLE => array( + ], + CRM_Core_Action::ENABLE => [ 'name' => ts('Enable'), 'ref' => 'crm-enable-disable', 'title' => ts('Enable Scheduled Job'), - ), - CRM_Core_Action::DELETE => array( + ], + CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), 'url' => 'civicrm/admin/job', 'qs' => 'action=delete&id=%%id%%', 'title' => ts('Delete Scheduled Job'), - ), - CRM_Core_Action::COPY => array( + ], + CRM_Core_Action::COPY => [ 'name' => ts('Copy'), 'url' => 'civicrm/admin/job', 'qs' => 'action=copy&id=%%id%%', 'title' => ts('Copy Scheduled Job'), - ), - ); + ], + ]; } return self::$_links; } @@ -101,14 +101,14 @@ class CRM_Admin_Page_Job extends CRM_Core_Page_Basic { public function run() { // set title and breadcrumb CRM_Utils_System::setTitle(ts('Settings - Scheduled Jobs')); - $breadCrumb = array( - array( + $breadCrumb = [ + [ 'title' => ts('Scheduled Jobs'), 'url' => CRM_Utils_System::url('civicrm/admin', 'reset=1' ), - ), - ); + ], + ]; CRM_Utils_System::appendBreadCrumb($breadCrumb); $this->_id = CRM_Utils_Request::retrieve('id', 'String', @@ -123,7 +123,7 @@ class CRM_Admin_Page_Job extends CRM_Core_Page_Basic { if (($this->_action & CRM_Core_Action::COPY) && (!empty($this->_id))) { try { - $jobResult = civicrm_api3('Job', 'clone', array('id' => $this->_id)); + $jobResult = civicrm_api3('Job', 'clone', ['id' => $this->_id]); if ($jobResult['count'] > 0) { CRM_Core_Session::setStatus($jobResult['values'][$jobResult['id']]['name'], ts('Job copied successfully'), 'success'); } @@ -143,7 +143,7 @@ class CRM_Admin_Page_Job extends CRM_Core_Page_Basic { public function browse() { // check if non-prod mode is enabled. if (CRM_Core_Config::environment() != 'Production') { - CRM_Core_Session::setStatus(ts('Execution of scheduled jobs has been turned off by default since this is a non-production environment. You can override this for particular jobs by adding runInNonProductionEnvironment=TRUE as a parameter. This will ignore email settings for this job and will send actual emails if this job is sending mails!'), ts("Non-production Environment"), "warning", array('expires' => 0)); + CRM_Core_Session::setStatus(ts('Execution of scheduled jobs has been turned off by default since this is a non-production environment. You can override this for particular jobs by adding runInNonProductionEnvironment=TRUE as a parameter. This will ignore email settings for this job and will send actual emails if this job is sending mails!'), ts('Non-production Environment'), 'warning', ['expires' => 0]); } else { $cronError = Civi\Api4\System::check(FALSE) diff --git a/CRM/Financial/Page/AJAX.php b/CRM/Financial/Page/AJAX.php index 08d7e33dff..0efab6185e 100644 --- a/CRM/Financial/Page/AJAX.php +++ b/CRM/Financial/Page/AJAX.php @@ -35,7 +35,7 @@ class CRM_Financial_Page_AJAX { CRM_Utils_System::civiExit(); } $defaultId = NULL; - if ($_GET['_value'] == 'select') { + if ($_GET['_value'] === 'select') { $result = CRM_Contribute_PseudoConstant::financialAccount(); } else { @@ -78,7 +78,7 @@ class CRM_Financial_Page_AJAX { CRM_Utils_System::civiExit(); } - if ($_GET['_value'] != 'select') { + if ($_GET['_value'] !== 'select') { $financialAccountType = CRM_Financial_BAO_FinancialAccount::getfinancialAccountRelations(TRUE); $financialAccountId = CRM_Utils_Request::retrieve('_value', 'Positive'); $financialAccountTypeId = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialAccount', $financialAccountId, 'financial_account_type_id'); @@ -201,7 +201,7 @@ class CRM_Financial_Page_AJAX { if (method_exists($recordBAO, $methods[$op]) & !empty($params)) { try { - $updated = call_user_func_array(array($recordBAO, $methods[$op]), array(&$params)); + $updated = call_user_func_array([$recordBAO, $methods[$op]], [&$params]); } catch (\CRM_Core_Exception $e) { $errorMessage = $e->getMessage(); -- 2.25.1