From 3655bea4bfdca18d0a888052aada39bf0d2218da Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sun, 7 Apr 2019 11:31:17 +1000 Subject: [PATCH] (NFC) Update CRM/SMS/ CRM/UF/ CRM/Upgrade/ CRM/Tag/ to be up to speed with the new coder standard --- CRM/SMS/BAO/Provider.php | 2 +- CRM/SMS/Message.php | 47 ++++++++++---------- CRM/SMS/Page/Provider.php | 2 +- CRM/SMS/Provider.php | 6 ++- CRM/Tag/Form/Edit.php | 6 +-- CRM/Tag/Form/Merge.php | 3 +- CRM/UF/Form/AbstractPreview.php | 1 + CRM/UF/Form/Field.php | 8 ++-- CRM/UF/Page/ProfileEditor.php | 1 + CRM/Upgrade/Form.php | 5 +++ CRM/Upgrade/Headless.php | 6 ++- CRM/Upgrade/Incremental/General.php | 26 +++++------ CRM/Upgrade/Incremental/MessageTemplates.php | 12 ++--- CRM/Upgrade/Incremental/php/FiveEleven.php | 4 +- CRM/Upgrade/Incremental/php/FiveTwelve.php | 4 +- CRM/Upgrade/Incremental/php/FourFive.php | 8 ++-- CRM/Upgrade/Incremental/php/FourFour.php | 14 +++--- CRM/Upgrade/Incremental/php/FourSeven.php | 4 ++ CRM/Upgrade/Incremental/php/FourSix.php | 3 +- CRM/Upgrade/Incremental/php/FourThree.php | 3 +- CRM/Upgrade/Page/Cleanup.php | 1 + CRM/Upgrade/Page/Upgrade.php | 3 +- 22 files changed, 93 insertions(+), 76 deletions(-) diff --git a/CRM/SMS/BAO/Provider.php b/CRM/SMS/BAO/Provider.php index 932d180029..45973eed24 100644 --- a/CRM/SMS/BAO/Provider.php +++ b/CRM/SMS/BAO/Provider.php @@ -148,7 +148,7 @@ class CRM_SMS_BAO_Provider extends CRM_SMS_DAO_Provider { $dao = new CRM_SMS_DAO_Provider(); $dao->id = $providerID; - $dao->whereAdd = "(domain_id = " . CRM_Core_Config::domainID() . "OR domain_id IS NULL)"; + $dao->whereAdd = "(domain_id = " . CRM_Core_Config::domainID() . "OR domain_id IS NULL)"; if (!$dao->find(TRUE)) { return NULL; } diff --git a/CRM/SMS/Message.php b/CRM/SMS/Message.php index 8b0787f602..c6b1557ca1 100644 --- a/CRM/SMS/Message.php +++ b/CRM/SMS/Message.php @@ -1,31 +1,30 @@ formatPhone($this->stripPhone($message->from), $like, "like"); $message->fromContactID = CRM_Core_DAO::singleValueQuery("SELECT contact_id FROM civicrm_phone JOIN civicrm_contact ON civicrm_contact.id = civicrm_phone.contact_id WHERE !civicrm_contact.is_deleted AND phone LIKE %1", array( - 1 => array($formatFrom, 'String'))); + 1 => array($formatFrom, 'String'), + )); } if (!$message->fromContactID) { @@ -254,7 +255,8 @@ INNER JOIN civicrm_mailing_job mj ON mj.mailing_id = m.id AND mj.id = %1"; // find recipient if $toContactID not set by hook if ($message->to) { $message->toContactID = CRM_Core_DAO::singleValueQuery("SELECT contact_id FROM civicrm_phone JOIN civicrm_contact ON civicrm_contact.id = civicrm_phone.contact_id WHERE !civicrm_contact.is_deleted AND phone LIKE %1", array( - 1 => array('%' . $message->to, 'String'))); + 1 => array('%' . $message->to, 'String'), + )); } else { $message->toContactID = $message->fromContactID; diff --git a/CRM/Tag/Form/Edit.php b/CRM/Tag/Form/Edit.php index b4feead66f..14b4adb6e1 100644 --- a/CRM/Tag/Form/Edit.php +++ b/CRM/Tag/Form/Edit.php @@ -128,9 +128,9 @@ class CRM_Tag_Form_Edit extends CRM_Admin_Form { CRM_Core_DAO::getAttribute('CRM_Core_DAO_Tag', 'name'), TRUE ); $this->addRule('name', ts('Name already exists in Database.'), 'objectExists', [ - 'CRM_Core_DAO_Tag', - $this->_id, - ]); + 'CRM_Core_DAO_Tag', + $this->_id, + ]); $this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Tag', 'description') diff --git a/CRM/Tag/Form/Merge.php b/CRM/Tag/Form/Merge.php index a581bf141f..67ef526fb4 100644 --- a/CRM/Tag/Form/Merge.php +++ b/CRM/Tag/Form/Merge.php @@ -77,8 +77,7 @@ class CRM_Tag_Form_Merge extends CRM_Core_Form { 'type' => 'cancel', 'name' => ts('Cancel'), ], - ] - ); + ]); } /** diff --git a/CRM/UF/Form/AbstractPreview.php b/CRM/UF/Form/AbstractPreview.php index 2379f2fef6..d0b0889b03 100644 --- a/CRM/UF/Form/AbstractPreview.php +++ b/CRM/UF/Form/AbstractPreview.php @@ -111,6 +111,7 @@ class CRM_UF_Form_AbstractPreview extends CRM_Core_Form { * * @return string */ + /** * @return string */ diff --git a/CRM/UF/Form/Field.php b/CRM/UF/Form/Field.php index 7617d6f804..9086dfc0b1 100644 --- a/CRM/UF/Form/Field.php +++ b/CRM/UF/Form/Field.php @@ -688,7 +688,7 @@ class CRM_UF_Form_Field extends CRM_Core_Form { $fieldTypeValues = CRM_Core_BAO_UFGroup::groupTypeValues($gid, $fieldType); if (empty($fieldTypeValues[$fieldType])) { - return; + return $errors; } $disallowedTypes = array_diff($extendsColumnValues, $fieldTypeValues[$fieldType]); @@ -1007,9 +1007,9 @@ class CRM_UF_Form_Field extends CRM_Core_Form { $message = ts('For best results, the Country field should precede the State-Province field in your Profile form. You can use the up and down arrows on field listing page for this profile to change the order of these fields or manually edit weight for Country/State-Province Field.'); if (in_array($fieldName, [ - 'country', - 'state_province', - ]) && count(CRM_Core_Config::singleton()->countryLimit) > 1 + 'country', + 'state_province', + ]) && count(CRM_Core_Config::singleton()->countryLimit) > 1 ) { // get state or country field weight if exists $ufFieldDAO = new CRM_Core_DAO_UFField(); diff --git a/CRM/UF/Page/ProfileEditor.php b/CRM/UF/Page/ProfileEditor.php index d0724c3eb6..9d4e38a7b1 100644 --- a/CRM/UF/Page/ProfileEditor.php +++ b/CRM/UF/Page/ProfileEditor.php @@ -7,6 +7,7 @@ require_once 'CRM/Core/Page.php'; * widgets */ class CRM_UF_Page_ProfileEditor extends CRM_Core_Page { + /** * Run page. * diff --git a/CRM/Upgrade/Form.php b/CRM/Upgrade/Form.php index 7bb04d65f4..483125451f 100644 --- a/CRM/Upgrade/Form.php +++ b/CRM/Upgrade/Form.php @@ -52,6 +52,9 @@ class CRM_Upgrade_Form extends CRM_Core_Form { */ const MINIMUM_PHP_VERSION = '5.6'; + /** + * @var \CRM_Core_Config + */ protected $_config; /** @@ -208,6 +211,7 @@ class CRM_Upgrade_Form extends CRM_Core_Form { * * @return string */ + /** * @return string */ @@ -234,6 +238,7 @@ class CRM_Upgrade_Form extends CRM_Core_Form { * * @return string */ + /** * @return string */ diff --git a/CRM/Upgrade/Headless.php b/CRM/Upgrade/Headless.php index 122dac41f5..397481a572 100644 --- a/CRM/Upgrade/Headless.php +++ b/CRM/Upgrade/Headless.php @@ -36,7 +36,8 @@ class CRM_Upgrade_Headless { * @param bool $enablePrint * * @throws Exception - * @return array, with keys: + * @return array + * - with keys: * - message: string, HTML-ish blob */ public function run($enablePrint = TRUE) { @@ -71,7 +72,8 @@ class CRM_Upgrade_Headless { if ($enablePrint) { print ($errorMessage); } - throw $queueResult['exception']; // FIXME test + // FIXME test + throw $queueResult['exception']; } CRM_Upgrade_Form::doFinish(); diff --git a/CRM/Upgrade/Incremental/General.php b/CRM/Upgrade/Incremental/General.php index 7653db11db..6bad351708 100644 --- a/CRM/Upgrade/Incremental/General.php +++ b/CRM/Upgrade/Incremental/General.php @@ -68,9 +68,9 @@ class CRM_Upgrade_Incremental_General { if (version_compare(phpversion(), self::MIN_RECOMMENDED_PHP_VER) < 0) { $preUpgradeMessage .= '

'; $preUpgradeMessage .= ts('You may proceed with the upgrade and CiviCRM %1 will continue working normally, but future releases will require PHP %2 or above. We recommend PHP version %3.', [ - 1 => $latestVer, - 2 => self::MIN_RECOMMENDED_PHP_VER, - 3 => self::RECOMMENDED_PHP_VER, + 1 => $latestVer, + 2 => self::MIN_RECOMMENDED_PHP_VER, + 3 => self::RECOMMENDED_PHP_VER, ]); $preUpgradeMessage .= '

'; } @@ -84,13 +84,13 @@ class CRM_Upgrade_Incremental_General { if (file_exists($ofcFile)) { if (@unlink($ofcFile)) { $preUpgradeMessage .= '
' . ts('This system included an outdated, insecure script (%1). The file was automatically deleted.', [ - 1 => $ofcFile, - ]); + 1 => $ofcFile, + ]); } else { $preUpgradeMessage .= '
' . ts('This system includes an outdated, insecure script (%1). Please delete it.', [ - 1 => $ofcFile, - ]); + 1 => $ofcFile, + ]); } } @@ -136,9 +136,9 @@ class CRM_Upgrade_Incremental_General { }, array_keys($messages), $messages); $message .= '
' . ts("The default copies of the message templates listed below will be updated to handle new features or correct a problem. Your installation has customized versions of these message templates, and you will need to apply the updates manually after running this upgrade. Click here for detailed instructions. %2", [ - 1 => 'http://wiki.civicrm.org/confluence/display/CRMDOC/Message+Templates#MessageTemplates-UpgradesandCustomizedSystemWorkflowTemplates', - 2 => '', - ]); + 1 => 'http://wiki.civicrm.org/confluence/display/CRMDOC/Message+Templates#MessageTemplates-UpgradesandCustomizedSystemWorkflowTemplates', + 2 => '', + ]); $messageObj->updateTemplates(); } @@ -213,9 +213,9 @@ class CRM_Upgrade_Incremental_General { $html = "