From dd3d81f3a45eaa419858ce02e263dcc721b46cec Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Fri, 26 Aug 2022 14:15:09 -0700 Subject: [PATCH] (NFC) CRM/Core/BAO - Autoformat `list()` statements --- CRM/Core/BAO/CustomField.php | 6 +++--- CRM/Core/BAO/CustomGroup.php | 8 ++++---- CRM/Core/BAO/CustomQuery.php | 6 +++--- CRM/Core/BAO/File.php | 12 ++++++------ CRM/Core/BAO/Log.php | 2 +- CRM/Core/BAO/Mapping.php | 6 +++--- CRM/Core/BAO/PrevNextCache.php | 2 +- CRM/Core/BAO/UFField.php | 2 +- CRM/Core/BAO/UFGroup.php | 28 ++++++++++++++-------------- CRM/Core/BAO/UFMatch.php | 2 +- 10 files changed, 37 insertions(+), 37 deletions(-) diff --git a/CRM/Core/BAO/CustomField.php b/CRM/Core/BAO/CustomField.php index 9c1fa009a9..90b23a803c 100644 --- a/CRM/Core/BAO/CustomField.php +++ b/CRM/Core/BAO/CustomField.php @@ -1057,7 +1057,7 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField { $attributes = []; foreach (explode(' ', $attrString) as $at) { if (strpos($at, '=')) { - list($k, $v) = explode('=', $at); + [$k, $v] = explode('=', $at); $attributes[$k] = trim($v, ' "'); } } @@ -1430,7 +1430,7 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField { 'entity_id', 'file_id' ); - list($path) = CRM_Core_BAO_File::path($fileID, $entityId); + [$path] = CRM_Core_BAO_File::path($fileID, $entityId); $fileHash = CRM_Core_BAO_File::generateFileHash($entityId, $fileID); $url = CRM_Utils_System::url('civicrm/file', "reset=1&id=$fileID&eid=$entityId&fcs=$fileHash", @@ -1524,7 +1524,7 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField { return NULL; } - list($tableName, $columnName, $groupID) = self::getTableColumnGroup($customFieldId); + [$tableName, $columnName, $groupID] = self::getTableColumnGroup($customFieldId); if (!$customValueId && // we always create new entites for is_multiple unless specified diff --git a/CRM/Core/BAO/CustomGroup.php b/CRM/Core/BAO/CustomGroup.php index 9da9be2bae..491da279d0 100644 --- a/CRM/Core/BAO/CustomGroup.php +++ b/CRM/Core/BAO/CustomGroup.php @@ -577,7 +577,7 @@ ORDER BY civicrm_custom_group.weight, } if (empty($groupTree)) { - list($multipleFieldGroups, $groupTree) = self::buildGroupTree($entityType, $toReturn, $subTypes, $queryString, $params, $subType); + [$multipleFieldGroups, $groupTree] = self::buildGroupTree($entityType, $toReturn, $subTypes, $queryString, $params, $subType); $cache->set($cacheKey, $groupTree); $cache->set($multipleFieldGroupCacheKey, $multipleFieldGroups); @@ -885,10 +885,10 @@ ORDER BY civicrm_custom_group.weight, ); $customValue['imageURL'] = str_replace('persist/contribute', 'custom', $config->imageUploadURL) . $fileDAO->uri; - list($path) = CRM_Core_BAO_File::path($fileDAO->id, $entityId); + [$path] = CRM_Core_BAO_File::path($fileDAO->id, $entityId); if ($path && file_exists($path)) { - list($imageWidth, $imageHeight) = getimagesize($path); - list($imageThumbWidth, $imageThumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($imageWidth, $imageHeight); + [$imageWidth, $imageHeight] = getimagesize($path); + [$imageThumbWidth, $imageThumbHeight] = CRM_Contact_BAO_Contact::getThumbSize($imageWidth, $imageHeight); $customValue['imageThumbWidth'] = $imageThumbWidth; $customValue['imageThumbHeight'] = $imageThumbHeight; } diff --git a/CRM/Core/BAO/CustomQuery.php b/CRM/Core/BAO/CustomQuery.php index 92093305da..621441bc76 100644 --- a/CRM/Core/BAO/CustomQuery.php +++ b/CRM/Core/BAO/CustomQuery.php @@ -184,7 +184,7 @@ class CRM_Core_BAO_CustomQuery { } foreach ($values as $tuple) { - list($name, $op, $value, $grouping, $wildcard) = $tuple; + [$name, $op, $value, $grouping, $wildcard] = $tuple; $field = $this->_fields[$id]; @@ -333,7 +333,7 @@ class CRM_Core_BAO_CustomQuery { && substr($name, -5, 5) !== '_high') { // Relative dates are handled in the buildRelativeDateQuery function. $this->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause($fieldName, $op, $value, 'Date'); - list($qillOp, $qillVal) = CRM_Contact_BAO_Query::buildQillForFieldValue(NULL, $field['label'], $value, $op, [], CRM_Utils_Type::T_DATE); + [$qillOp, $qillVal] = CRM_Contact_BAO_Query::buildQillForFieldValue(NULL, $field['label'], $value, $op, [], CRM_Utils_Type::T_DATE); $this->_qill[$grouping][] = "{$field['label']} $qillOp '$qillVal'"; } break; @@ -407,7 +407,7 @@ class CRM_Core_BAO_CustomQuery { $joinTableAlias = $joinTable; // Set location-specific query if (isset($this->_locationSpecificCustomFields[$field['id']])) { - list($locationType, $locationTypeId) = $this->_locationSpecificCustomFields[$field['id']]; + [$locationType, $locationTypeId] = $this->_locationSpecificCustomFields[$field['id']]; $joinTableAlias = "$locationType-address"; $joinClause = "\nLEFT JOIN $joinTable `$locationType-address` ON (`$locationType-address`.contact_id = contact_a.id AND `$locationType-address`.location_type_id = $locationTypeId)"; } diff --git a/CRM/Core/BAO/File.php b/CRM/Core/BAO/File.php index a69700fecc..5f1bca7f7c 100644 --- a/CRM/Core/BAO/File.php +++ b/CRM/Core/BAO/File.php @@ -133,10 +133,10 @@ class CRM_Core_BAO_File extends CRM_Core_DAO_File { // to get id's if ($overwrite && $fileTypeID) { - list($sql, $params) = self::sql($entityTable, $entityID, $fileTypeID); + [$sql, $params] = self::sql($entityTable, $entityID, $fileTypeID); } else { - list($sql, $params) = self::sql($entityTable, $entityID, 0); + [$sql, $params] = self::sql($entityTable, $entityID, 0); } $dao = CRM_Core_DAO::executeQuery($sql, $params); @@ -207,7 +207,7 @@ class CRM_Core_BAO_File extends CRM_Core_DAO_File { CRM_Utils_Hook::pre('delete', 'File', $fileID, $fileDAO); // get the table and column name - list($tableName, $columnName, $groupID) = CRM_Core_BAO_CustomField::getTableColumnGroup($fieldID); + [$tableName, $columnName, $groupID] = CRM_Core_BAO_CustomField::getTableColumnGroup($fieldID); $entityFileDAO = new CRM_Core_DAO_EntityFile(); $entityFileDAO->file_id = $fileID; @@ -231,7 +231,7 @@ class CRM_Core_BAO_File extends CRM_Core_DAO_File { * The $useWhere is used so that the signature matches the parent class * * public function delete($useWhere = FALSE) { - * list($fileID, $entityID, $fieldID) = func_get_args(); + * [$fileID, $entityID, $fieldID] = func_get_args(); * * self::deleteFileReferences($fileID, $entityID, $fieldID); * } */ @@ -255,7 +255,7 @@ class CRM_Core_BAO_File extends CRM_Core_DAO_File { $config = CRM_Core_Config::singleton(); - list($sql, $params) = self::sql($entityTable, $entityID, $fileTypeID, $fileID); + [$sql, $params] = self::sql($entityTable, $entityID, $fileTypeID, $fileID); $dao = CRM_Core_DAO::executeQuery($sql, $params); $cfIDs = []; @@ -323,7 +323,7 @@ class CRM_Core_BAO_File extends CRM_Core_DAO_File { $config = CRM_Core_Config::singleton(); - list($sql, $params) = self::sql($entityTable, $entityID, NULL); + [$sql, $params] = self::sql($entityTable, $entityID, NULL); $dao = CRM_Core_DAO::executeQuery($sql, $params); $results = []; while ($dao->fetch()) { diff --git a/CRM/Core/BAO/Log.php b/CRM/Core/BAO/Log.php index 719245f55c..3d10a68537 100644 --- a/CRM/Core/BAO/Log.php +++ b/CRM/Core/BAO/Log.php @@ -39,7 +39,7 @@ class CRM_Core_BAO_Log extends CRM_Core_DAO_Log { $displayName = $result = $contactImage = NULL; if ($log->find(TRUE)) { if ($log->modified_id) { - list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($log->modified_id); + [$displayName, $contactImage] = CRM_Contact_BAO_Contact::getDisplayAndImage($log->modified_id); } $result = [ 'id' => $log->modified_id, diff --git a/CRM/Core/BAO/Mapping.php b/CRM/Core/BAO/Mapping.php index a4b1344cf0..0fbe33d61b 100644 --- a/CRM/Core/BAO/Mapping.php +++ b/CRM/Core/BAO/Mapping.php @@ -310,7 +310,7 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping implements \Civi\Core\Ho asort($relationshipTypes); foreach ($relationshipTypes as $key => $var) { - list($type) = explode('_', $key); + [$type] = explode('_', $key); $relationships[$key]['title'] = $var; $relationships[$key]['headerPattern'] = '/' . preg_quote($var, '/') . '/'; @@ -352,7 +352,7 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping implements \Civi\Core\Ho foreach ($subTypeRelationshipTypes as $key => $var) { if (!array_key_exists($key, $fields[$info['parent']])) { - list($type) = explode('_', $key); + [$type] = explode('_', $key); $csRelationships[$key]['title'] = $var; $csRelationships[$key]['headerPattern'] = '/' . preg_quote($var, '/') . '/'; @@ -488,7 +488,7 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping implements \Civi\Core\Ho // Handle mapping for 'related contact' fields if (count(explode('_', CRM_Utils_Array::value('1', $v))) > 2) { - list($id, $first, $second) = explode('_', CRM_Utils_Array::value('1', $v)); + [$id, $first, $second] = explode('_', CRM_Utils_Array::value('1', $v)); if (($first == 'a' && $second == 'b') || ($first == 'b' && $second == 'a')) { if (!empty($v['2'])) { diff --git a/CRM/Core/BAO/PrevNextCache.php b/CRM/Core/BAO/PrevNextCache.php index c63e2e9bdf..e848df2edd 100644 --- a/CRM/Core/BAO/PrevNextCache.php +++ b/CRM/Core/BAO/PrevNextCache.php @@ -35,7 +35,7 @@ class CRM_Core_BAO_PrevNextCache extends CRM_Core_DAO_PrevNextCache { */ public static function getPositions($cacheKey, $id1, $id2, &$mergeId = NULL, $join = NULL, $where = NULL, $flip = FALSE) { if ($flip) { - list($id1, $id2) = [$id2, $id1]; + [$id1, $id2] = [$id2, $id1]; } if ($mergeId == NULL) { diff --git a/CRM/Core/BAO/UFField.php b/CRM/Core/BAO/UFField.php index 9818e7b231..3abb2774db 100644 --- a/CRM/Core/BAO/UFField.php +++ b/CRM/Core/BAO/UFField.php @@ -747,7 +747,7 @@ SELECT id */ public static function assignAddressField($key, &$profileAddressFields, $profileFilter, $paymentProcessorBillingFields = NULL) { $billing_id = CRM_Core_BAO_LocationType::getBilling(); - list($prefixName, $index) = CRM_Utils_System::explode('-', $key, 2); + [$prefixName, $index] = CRM_Utils_System::explode('-', $key, 2); $profileFields = civicrm_api3('uf_field', 'get', array_merge($profileFilter, [ diff --git a/CRM/Core/BAO/UFGroup.php b/CRM/Core/BAO/UFGroup.php index 7007ad7114..063fe93f16 100644 --- a/CRM/Core/BAO/UFGroup.php +++ b/CRM/Core/BAO/UFGroup.php @@ -338,10 +338,10 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { $field = CRM_Core_DAO::executeQuery($query); $importableFields = self::getProfileFieldMetadata($showAll); - list($customFields, $addressCustomFields) = self::getCustomFields($ctype, $skipPermission ? FALSE : $permissionType); + [$customFields, $addressCustomFields] = self::getCustomFields($ctype, $skipPermission ? FALSE : $permissionType); while ($field->fetch()) { - list($name, $formattedField) = self::formatUFField($group, $field, $customFields, $addressCustomFields, $importableFields, $permissionType); + [$name, $formattedField] = self::formatUFField($group, $field, $customFields, $addressCustomFields, $importableFields, $permissionType); if ($formattedField !== NULL) { $fields[$name] = $formattedField; } @@ -398,7 +398,7 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { $profileType = CRM_Core_BAO_UFField::calculateProfileType(implode(',', $ufGroupType)); $contactActivityProfile = CRM_Core_BAO_UFField::checkContactActivityProfileTypeByGroupType(implode(',', $ufGroupType)); $importableFields = self::getImportableFields($showAll, $profileType, $contactActivityProfile); - list($customFields, $addressCustomFields) = self::getCustomFields($ctype, $permissionType); + [$customFields, $addressCustomFields] = self::getCustomFields($ctype, $permissionType); $formattedFields = []; foreach ($fieldArrs as $fieldArr) { @@ -407,7 +407,7 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { continue; } - list($name, $formattedField) = self::formatUFField($group, $field, $customFields, $addressCustomFields, $importableFields, $permissionType); + [$name, $formattedField] = self::formatUFField($group, $field, $customFields, $addressCustomFields, $importableFields, $permissionType); if ($formattedField !== NULL) { $formattedFields[$name] = $formattedField; } @@ -1177,8 +1177,8 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { } } elseif ($name == 'image_URL') { - list($width, $height) = getimagesize(CRM_Utils_String::unstupifyUrl($details->$name)); - list($thumbWidth, $thumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($width, $height); + [$width, $height] = getimagesize(CRM_Utils_String::unstupifyUrl($details->$name)); + [$thumbWidth, $thumbHeight] = CRM_Contact_BAO_Contact::getThumbSize($width, $height); $image_URL = ''; $values[$index] = "{$image_URL}"; @@ -1211,7 +1211,7 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { } } elseif (strpos($name, '-') !== FALSE) { - list($fieldName, $id, $type) = CRM_Utils_System::explode('-', $name, 3); + [$fieldName, $id, $type] = CRM_Utils_System::explode('-', $name, 3); if (!in_array($fieldName, $multipleFields)) { if ($id == 'Primary') { @@ -1917,7 +1917,7 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) } } elseif (CRM_Utils_Array::value('name', $field) == 'membership_type') { - list($orgInfo, $types) = CRM_Member_BAO_MembershipType::getMembershipTypeInfo(); + [$orgInfo, $types] = CRM_Member_BAO_MembershipType::getMembershipTypeInfo(); $sel = &$form->addElement('hierselect', $name, $title); $select = ['' => ts('- select membership type -')]; if (count($orgInfo) == 1 && $field['is_required']) { @@ -2063,7 +2063,7 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) } } elseif (substr($fieldName, 0, 14) === 'address_custom') { - list($fName, $locTypeId) = CRM_Utils_System::explode('-', $fieldName, 2); + [$fName, $locTypeId] = CRM_Utils_System::explode('-', $fieldName, 2); $customFieldID = CRM_Core_BAO_CustomField::getKeyID(substr($fName, 8)); if ($customFieldID) { CRM_Core_BAO_CustomField::addQuickFormElement($form, $name, $customFieldID, $required, $search, $title); @@ -2077,7 +2077,7 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) $form->addMoney("soft_credit_amount[{$rowNumber}]", ts('Amount'), FALSE, NULL, FALSE); } elseif ($fieldName === 'product_name') { - list($products, $options) = CRM_Contribute_BAO_Premium::getPremiumProductInfo(); + [$products, $options] = CRM_Contribute_BAO_Premium::getPremiumProductInfo(); $sel = &$form->addElement('hierselect', $name, $title); $products = ['0' => ts('- select %1 -', [1 => $title])] + $products; $sel->setOptions([$products, $options]); @@ -2329,7 +2329,7 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) } else { $blocks = ['email', 'phone', 'im', 'openid']; - list($fieldName, $locTypeId, $phoneTypeId) = CRM_Utils_System::explode('-', $name, 3); + [$fieldName, $locTypeId, $phoneTypeId] = CRM_Utils_System::explode('-', $name, 3); if (!in_array($fieldName, $multipleFields)) { if (is_array($details)) { foreach ($details as $key => $value) { @@ -2678,7 +2678,7 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) ); //get the default domain email address. - 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/domain', 'action=update&reset=1'); @@ -2771,7 +2771,7 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) public static function formatFields($params, $contactId = NULL) { if ($contactId) { // get the primary location type id and email - list($name, $primaryEmail, $primaryLocationType) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactId); + [$name, $primaryEmail, $primaryLocationType] = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactId); } else { $defaultLocationType = CRM_Core_BAO_LocationType::getDefault(); @@ -2783,7 +2783,7 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) $count = 1; $primaryLocation = 0; foreach ($params as $key => $value) { - list($fieldName, $locTypeId, $phoneTypeId) = explode('-', $key); + [$fieldName, $locTypeId, $phoneTypeId] = explode('-', $key); if ($locTypeId == 'Primary') { $locTypeId = $primaryLocationType; diff --git a/CRM/Core/BAO/UFMatch.php b/CRM/Core/BAO/UFMatch.php index 67b04f4ba9..8100e72a31 100644 --- a/CRM/Core/BAO/UFMatch.php +++ b/CRM/Core/BAO/UFMatch.php @@ -125,7 +125,7 @@ class CRM_Core_BAO_UFMatch extends CRM_Core_DAO_UFMatch { // add current contact to recently viewed if ($ufmatch->contact_id) { - list($displayName, $contactImage, $contactType, $contactSubtype, $contactImageUrl) + [$displayName, $contactImage, $contactType, $contactSubtype, $contactImageUrl] = CRM_Contact_BAO_Contact::getDisplayAndImage($ufmatch->contact_id, TRUE, TRUE); $otherRecent = [ -- 2.25.1