From a150908bd92b66dbcb7d11061d6dc541b47cdfd0 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Fri, 26 Aug 2022 14:22:40 -0700 Subject: [PATCH] (NFC) CRM/Contact - Autoformat `list()` statements --- CRM/Contact/BAO/Group.php | 2 +- CRM/Contact/BAO/ProximityQuery.php | 6 +- CRM/Contact/BAO/Query.php | 138 ++++++++++++++-------------- CRM/Contact/BAO/Relationship.php | 10 +- CRM/Contact/BAO/SearchCustom.php | 4 +- CRM/Contact/Form/Relationship.php | 6 +- CRM/Contact/Form/Search/Builder.php | 4 +- CRM/Contact/Page/AJAX.php | 6 +- CRM/Contact/Selector.php | 10 +- CRM/Contact/StateMachine/Search.php | 8 +- 10 files changed, 97 insertions(+), 97 deletions(-) diff --git a/CRM/Contact/BAO/Group.php b/CRM/Contact/BAO/Group.php index b5db2bc37f..804cc9c3b2 100644 --- a/CRM/Contact/BAO/Group.php +++ b/CRM/Contact/BAO/Group.php @@ -180,7 +180,7 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { public static function getMember($groupID, $useCache = TRUE, $limit = 0) { $params = [['group', '=', $groupID, 0, 0]]; $returnProperties = ['contact_id']; - list($contacts) = CRM_Contact_BAO_Query::apiQuery($params, $returnProperties, NULL, NULL, 0, $limit, $useCache); + [$contacts] = CRM_Contact_BAO_Query::apiQuery($params, $returnProperties, NULL, NULL, 0, $limit, $useCache); $aMembers = []; foreach ($contacts as $contact) { diff --git a/CRM/Contact/BAO/ProximityQuery.php b/CRM/Contact/BAO/ProximityQuery.php index f4a671b807..e69fb7c11f 100644 --- a/CRM/Contact/BAO/ProximityQuery.php +++ b/CRM/Contact/BAO/ProximityQuery.php @@ -175,8 +175,8 @@ class CRM_Contact_BAO_ProximityQuery { public static function where($latitude, $longitude, $distance, $tablePrefix = 'civicrm_address') { self::initialize(); - list($minLongitude, $maxLongitude) = self::earthLongitudeRange($longitude, $latitude, $distance); - list($minLatitude, $maxLatitude) = self::earthLatitudeRange($longitude, $latitude, $distance); + [$minLongitude, $maxLongitude] = self::earthLongitudeRange($longitude, $latitude, $distance); + [$minLatitude, $maxLatitude] = self::earthLatitudeRange($longitude, $latitude, $distance); // DONT consider NAN values (which is returned by rad2deg php function) // for checking BETWEEN geo_code's criteria as it throws obvious 'NAN' field not found DB: Error @@ -218,7 +218,7 @@ ACOS( * @throws Exception */ public static function process(&$query, &$values) { - list($name, $op, $distance, $grouping, $wildcard) = $values; + [$name, $op, $distance, $grouping, $wildcard] = $values; // also get values array for all address related info $proximityVars = [ diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index 20a918c3b8..3200224475 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -789,7 +789,7 @@ class CRM_Contact_BAO_Query { } } elseif (isset($field['where'])) { - list($tableName, $fieldName) = explode('.', $field['where'], 2); + [$tableName, $fieldName] = explode('.', $field['where'], 2); if (isset($tableName)) { if (!empty(self::$_dependencies[$tableName])) { $this->_tables['civicrm_address'] = 1; @@ -1095,7 +1095,7 @@ class CRM_Contact_BAO_Query { if ((in_array($elementCmpName, self::$_locationSpecificFields) || !empty($addressCustomFieldIds)) && !in_array($elementCmpName, ['email', 'phone', 'im', 'openid']) ) { - list($aName, $addressJoin) = $this->addAddressTable($name, $lCond); + [$aName, $addressJoin] = $this->addAddressTable($name, $lCond); $locationTypeJoin[$tName] = " ( $aName.location_type_id = $ltName.id ) "; $processed[$aName] = 1; } @@ -1103,7 +1103,7 @@ class CRM_Contact_BAO_Query { $cond = $elementType = ''; if (strpos($elementName, '-') !== FALSE) { // this is either phone, email or IM - list($elementName, $elementType) = explode('-', $elementName); + [$elementName, $elementType] = explode('-', $elementName); if (($elementName != 'phone') && ($elementName != 'im')) { $cond = self::getPrimaryCondition($elementType); @@ -1186,7 +1186,7 @@ class CRM_Contact_BAO_Query { } if ($field && isset($field['where'])) { - list($tableName, $fieldName) = explode('.', $field['where'], 2); + [$tableName, $fieldName] = explode('.', $field['where'], 2); $pf = substr($tableName, 8); $tName = $name . '-' . $pf . $elementType; if (isset($tableName)) { @@ -1445,7 +1445,7 @@ class CRM_Contact_BAO_Query { else { if (!empty($this->_paramLookup['group'])) { - list($name, $op, $value, $grouping, $wildcard) = $this->_paramLookup['group'][0]; + [$name, $op, $value, $grouping, $wildcard] = $this->_paramLookup['group'][0]; if (is_array($value) && in_array(key($value), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) { $this->_paramLookup['group'][0][1] = key($value); @@ -1560,7 +1560,7 @@ class CRM_Contact_BAO_Query { */ public static function fixDateValues($relative, &$from, &$to) { if ($relative) { - list($from, $to) = CRM_Utils_Date::getFromTo($relative, $from, $to); + [$from, $to] = CRM_Utils_Date::getFromTo($relative, $from, $to); } } @@ -2061,7 +2061,7 @@ class CRM_Contact_BAO_Query { if ($this->_params[$id][0] == 'id' || $this->_params[$id][0] == 'contact_id') { $this->_where[0][] = self::buildClause("contact_a.id", $this->_params[$id][1], $this->_params[$id][2]); $field = $this->_fields['id'] ?? NULL; - list($qillop, $qillVal) = CRM_Contact_BAO_Query::buildQillForFieldValue( + [$qillop, $qillVal] = CRM_Contact_BAO_Query::buildQillForFieldValue( 'CRM_Contact_BAO_Contact', "contact_a.id", $this->_params[$id][2], @@ -2190,7 +2190,7 @@ class CRM_Contact_BAO_Query { $this->_where[$grouping][] = self::buildClause($where, $op, $value); $this->_tables[$aName] = $this->_whereTables[$aName] = 1; - list($qillop, $qillVal) = self::buildQillForFieldValue('CRM_Core_DAO_Address', "state_province_id", $value, $op); + [$qillop, $qillVal] = self::buildQillForFieldValue('CRM_Core_DAO_Address', "state_province_id", $value, $op); $this->_qill[$grouping][] = ts("%1 %2 %3", [1 => $field['title'], 2 => $qillop, 3 => $qillVal]); } elseif (!empty($field['pseudoconstant'])) { @@ -2221,7 +2221,7 @@ class CRM_Contact_BAO_Query { $this->_where[$grouping][] = self::buildClause($where, $op, $value, 'Positive'); $this->_tables[$aName] = $this->_whereTables[$aName] = 1; - list($qillop, $qillVal) = CRM_Contact_BAO_Query::buildQillForFieldValue(NULL, $name, $value, $op); + [$qillop, $qillVal] = CRM_Contact_BAO_Query::buildQillForFieldValue(NULL, $name, $value, $op); $this->_qill[$grouping][] = ts("%1 %2 %3", [1 => $field['title'], 2 => $qillop, 3 => $qillVal]); } elseif ($name === 'world_region') { @@ -2296,7 +2296,7 @@ class CRM_Contact_BAO_Query { $type = CRM_Utils_Type::typeToString($field['type']); } - list($tableName, $fieldName) = explode('.', $field['where'], 2); + [$tableName, $fieldName] = explode('.', $field['where'], 2); if (isset($locType[1]) && is_numeric($locType[1]) @@ -2304,7 +2304,7 @@ class CRM_Contact_BAO_Query { $setTables = FALSE; //get the location name - list($tName, $fldName) = self::getLocationTableName($field['where'], $locType); + [$tName, $fldName] = self::getLocationTableName($field['where'], $locType); $fieldName = "`$tName`.$fldName"; // we set both _tables & whereTables because whereTables doesn't seem to do what the name implies it should @@ -2320,7 +2320,7 @@ class CRM_Contact_BAO_Query { } } - list($qillop, $qillVal) = self::buildQillForFieldValue(NULL, $field['title'], $value, $op); + [$qillop, $qillVal] = self::buildQillForFieldValue(NULL, $field['title'], $value, $op); $this->_qill[$grouping][] = ts("%1 %2 %3", [ 1 => $field['title'], 2 => $qillop, @@ -2359,7 +2359,7 @@ class CRM_Contact_BAO_Query { } if ($setTables && isset($field['where'])) { - list($tableName, $fieldName) = explode('.', $field['where'], 2); + [$tableName, $fieldName] = explode('.', $field['where'], 2); if (isset($tableName)) { $this->_tables[$tableName] = 1; $this->_whereTables[$tableName] = 1; @@ -2376,7 +2376,7 @@ class CRM_Contact_BAO_Query { */ public static function getLocationTableName(&$where, &$locType) { if (isset($locType[1]) && is_numeric($locType[1])) { - list($tbName, $fldName) = explode(".", $where); + [$tbName, $fldName] = explode(".", $where); //get the location name $locationType = CRM_Core_DAO_Address::buildOptions('location_type_id', 'validate'); @@ -2833,7 +2833,7 @@ class CRM_Contact_BAO_Query { * @param array $values */ public function deletedContacts($values) { - list($_, $_, $value, $grouping, $_) = $values; + [$_, $_, $value, $grouping, $_] = $values; if ($value) { // *prepend* to the relevant grouping as this is quite an important factor array_unshift($this->_qill[$grouping], ts('Search in Trash')); @@ -2848,7 +2848,7 @@ class CRM_Contact_BAO_Query { * @throws \CRM_Core_Exception */ public function contactType(&$values) { - list($name, $op, $value, $grouping, $wildcard) = $values; + [$name, $op, $value, $grouping, $wildcard] = $values; $subTypes = []; $clause = []; @@ -2868,7 +2868,7 @@ class CRM_Contact_BAO_Query { $subType = NULL; $contactType = $k; if (strpos($k, CRM_Core_DAO::VALUE_SEPARATOR)) { - list($contactType, $subType) = explode(CRM_Core_DAO::VALUE_SEPARATOR, $k, 2); + [$contactType, $subType] = explode(CRM_Core_DAO::VALUE_SEPARATOR, $k, 2); } if (!empty($subType)) { @@ -2913,7 +2913,7 @@ class CRM_Contact_BAO_Query { * @param array $values */ public function contactSubType(&$values) { - list($name, $op, $value, $grouping, $wildcard) = $values; + [$name, $op, $value, $grouping, $wildcard] = $values; $this->includeContactSubTypes($value, $grouping, $op); } @@ -2966,7 +2966,7 @@ class CRM_Contact_BAO_Query { * @throws \Exception */ public function group($values) { - list($name, $op, $value, $grouping, $wildcard) = $values; + [$name, $op, $value, $grouping, $wildcard] = $values; // If the $value is in OK (operator as key) array format we need to extract the key as operator and value first if (is_array($value) && in_array(key($value), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) { @@ -3097,7 +3097,7 @@ class CRM_Contact_BAO_Query { $this->_where[$grouping][] = ' ( ' . implode($and, $groupClause) . ' ) '; } - list($qillop, $qillVal) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Contact_DAO_Group', 'id', $value, $op); + [$qillop, $qillVal] = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Contact_DAO_Group', 'id', $value, $op); $this->_qill[$grouping][] = ts("Group(s) %1 %2", [1 => $qillop, 2 => $qillVal]); if (strpos($op, 'NULL') === FALSE) { $this->_qill[$grouping][] = ts("Group Status %1", [1 => implode(' ' . ts('or') . ' ', $this->getSelectedGroupStatuses($grouping))]); @@ -3194,7 +3194,7 @@ WHERE $smartGroupClause * @param $values */ public function ufUser(&$values) { - list($name, $op, $value, $grouping, $wildcard) = $values; + [$name, $op, $value, $grouping, $wildcard] = $values; if ($value == 1) { $this->_tables['civicrm_uf_match'] = $this->_whereTables['civicrm_uf_match'] = ' INNER JOIN civicrm_uf_match ON civicrm_uf_match.contact_id = contact_a.id '; @@ -3217,7 +3217,7 @@ WHERE $smartGroupClause * @throws \CRM_Core_Exception */ public function tagSearch(&$values) { - list($name, $op, $value, $grouping, $wildcard) = $values; + [$name, $op, $value, $grouping, $wildcard] = $values; $op = "LIKE"; $value = "%{$value}%"; @@ -3282,7 +3282,7 @@ WHERE $smartGroupClause * @throws \CRM_Core_Exception */ public function tag(&$values) { - list($name, $op, $value, $grouping, $wildcard) = $values; + [$name, $op, $value, $grouping, $wildcard] = $values; // API/Search Builder format array(operator => array(values)) if (is_array($value)) { @@ -3307,7 +3307,7 @@ WHERE $smartGroupClause } } - list($qillop, $qillVal) = self::buildQillForFieldValue('CRM_Core_DAO_EntityTag', "tag_id", $value, $op, ['onlyActive' => FALSE]); + [$qillop, $qillVal] = self::buildQillForFieldValue('CRM_Core_DAO_EntityTag', "tag_id", $value, $op, ['onlyActive' => FALSE]); // implode array, then remove all spaces $value = str_replace(' ', '', implode(',', (array) $value)); @@ -3383,7 +3383,7 @@ WHERE $smartGroupClause * @throws \CRM_Core_Exception */ public function notes(&$values) { - list($name, $op, $value, $grouping, $wildcard) = $values; + [$name, $op, $value, $grouping, $wildcard] = $values; $noteOptionValues = $this->getWhereValues('note_option', $grouping); $noteOption = CRM_Utils_Array::value('2', $noteOptionValues, '6'); @@ -3417,7 +3417,7 @@ WHERE $smartGroupClause $label = $label ? ts('Note: Body and Subject') : ts('Note: Subject Only'); } $this->_where[$grouping][] = "( " . implode(' OR ', $clauses) . " )"; - list($qillOp, $qillVal) = self::buildQillForFieldValue(NULL, $name, $n, $op); + [$qillOp, $qillVal] = self::buildQillForFieldValue(NULL, $name, $n, $op); $this->_qill[$grouping][] = ts("%1 %2 %3", [1 => $label, 2 => $qillOp, 3 => $qillVal]); } @@ -3457,7 +3457,7 @@ WHERE $smartGroupClause * @param array $values */ public function sortName(&$values) { - list($fieldName, $op, $value, $grouping, $wildcard) = $values; + [$fieldName, $op, $value, $grouping, $wildcard] = $values; // handle IS NULL / IS NOT NULL / IS EMPTY / IS NOT EMPTY if ($this->nameNullOrEmptyOp($fieldName, $op, $grouping)) { @@ -3531,10 +3531,10 @@ WHERE $smartGroupClause * @throws \CRM_Core_Exception */ public function greetings(&$values) { - list($name, $op, $value, $grouping, $wildcard) = $values; + [$name, $op, $value, $grouping, $wildcard] = $values; $name .= '_display'; - list($qillop, $qillVal) = CRM_Contact_BAO_Query::buildQillForFieldValue(NULL, $name, $value, $op); + [$qillop, $qillVal] = CRM_Contact_BAO_Query::buildQillForFieldValue(NULL, $name, $value, $op); $this->_qill[$grouping][] = ts('Greeting %1 %2', [1 => $qillop, 2 => $qillVal]); $this->_where[$grouping][] = self::buildClause("contact_a.{$name}", $op, $value, 'String'); } @@ -3548,7 +3548,7 @@ WHERE $smartGroupClause * @throws \CRM_Core_Exception */ protected function email(&$values, $isForcePrimaryOnly) { - list($name, $op, $value, $grouping, $wildcard) = $values; + [$name, $op, $value, $grouping, $wildcard] = $values; $this->_tables['civicrm_email'] = $this->_whereTables['civicrm_email'] = 1; // CRM-18147: for Contact's GET API, email fieldname got appended with its entity as in {$apiEntiy}_{$name} @@ -3595,7 +3595,7 @@ WHERE $smartGroupClause * @throws \CRM_Core_Exception */ public function phone_numeric(&$values) { - list($name, $op, $value, $grouping, $wildcard) = $values; + [$name, $op, $value, $grouping, $wildcard] = $values; // Strip non-numeric characters; allow wildcards $number = preg_replace('/[^\d%]/', '', $value); if ($number) { @@ -3617,7 +3617,7 @@ WHERE $smartGroupClause * @throws \CRM_Core_Exception */ public function phone_option_group($values) { - list($name, $op, $value, $grouping, $wildcard) = $values; + [$name, $op, $value, $grouping, $wildcard] = $values; $option = ($name == 'phone_phone_type_id' ? 'phone_type_id' : 'location_type_id'); $options = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', $option); $optionName = $options[$value]; @@ -3634,7 +3634,7 @@ WHERE $smartGroupClause * @throws \CRM_Core_Exception */ public function street_address(&$values) { - list($name, $op, $value, $grouping) = $values; + [$name, $op, $value, $grouping] = $values; if (!$op) { $op = 'LIKE'; @@ -3667,7 +3667,7 @@ WHERE $smartGroupClause * @throws \CRM_Core_Exception */ public function street_number(&$values) { - list($name, $op, $value, $grouping, $wildcard) = $values; + [$name, $op, $value, $grouping, $wildcard] = $values; if (!$op) { $op = '='; @@ -3698,7 +3698,7 @@ WHERE $smartGroupClause * @param array $values */ public function sortByCharacter(&$values) { - list($name, $op, $value, $grouping, $wildcard) = $values; + [$name, $op, $value, $grouping, $wildcard] = $values; $name = trim($value); $cond = " contact_a.sort_name LIKE '" . CRM_Core_DAO::escapeWildCardString($name) . "%'"; @@ -3739,7 +3739,7 @@ WHERE $smartGroupClause return; } - list($name, $op, $value, $grouping, $wildcard) = $values; + [$name, $op, $value, $grouping, $wildcard] = $values; // Handle numeric postal code range searches properly by casting the column as numeric if (is_numeric($value)) { @@ -3783,7 +3783,7 @@ WHERE $smartGroupClause * @return string */ public function locationType(&$values, $status = NULL) { - list($name, $op, $value, $grouping, $wildcard) = $values; + [$name, $op, $value, $grouping, $wildcard] = $values; if (is_array($value)) { $this->_where[$grouping][] = 'civicrm_address.location_type_id IN (' . implode(',', $value) . ')'; @@ -3815,7 +3815,7 @@ WHERE $smartGroupClause * @throws \CRM_Core_Exception */ public function country(&$values, $fromStateProvince = TRUE) { - list($name, $op, $value, $grouping, $wildcard) = $values; + [$name, $op, $value, $grouping, $wildcard] = $values; if (!$fromStateProvince) { $stateValues = $this->getWhereValues('state_province', $grouping); @@ -3832,7 +3832,7 @@ WHERE $smartGroupClause $this->_whereTables['civicrm_address'] = 1; $countryClause = self::buildClause('civicrm_address.country_id', $op, $value, 'Positive'); - list($qillop, $qillVal) = CRM_Contact_BAO_Query::buildQillForFieldValue(NULL, 'country_id', $value, $op); + [$qillop, $qillVal] = CRM_Contact_BAO_Query::buildQillForFieldValue(NULL, 'country_id', $value, $op); $countryQill = ts("%1 %2 %3", [1 => 'Country', 2 => $qillop, 3 => $qillVal]); if (!$fromStateProvince) { @@ -3863,7 +3863,7 @@ WHERE $smartGroupClause * @return string */ public function county(&$values, $status = NULL) { - list($name, $op, $value, $grouping, $wildcard) = $values; + [$name, $op, $value, $grouping, $wildcard] = $values; if (!is_array($value)) { // force the county to be an array @@ -3933,14 +3933,14 @@ WHERE $smartGroupClause * @throws \CRM_Core_Exception */ public function stateProvince(&$values, $status = NULL) { - list($name, $op, $value, $grouping, $wildcard) = $values; + [$name, $op, $value, $grouping, $wildcard] = $values; $stateClause = self::buildClause('civicrm_address.state_province_id', $op, $value, 'Positive'); $this->_tables['civicrm_address'] = 1; $this->_whereTables['civicrm_address'] = 1; $countryValues = $this->getWhereValues('country', $grouping); - list($countryClause, $countryQill) = $this->country($countryValues, TRUE); + [$countryClause, $countryQill] = $this->country($countryValues, TRUE); if ($countryClause) { $clause = "( $stateClause AND $countryClause )"; } @@ -3949,7 +3949,7 @@ WHERE $smartGroupClause } $this->_where[$grouping][] = $clause; - list($qillop, $qillVal) = self::buildQillForFieldValue('CRM_Core_DAO_Address', "state_province_id", $value, $op); + [$qillop, $qillVal] = self::buildQillForFieldValue('CRM_Core_DAO_Address', "state_province_id", $value, $op); if (!$status) { $this->_qill[$grouping][] = ts("State/Province %1 %2 %3", [1 => $qillop, 2 => $qillVal, 3 => $countryQill]); } @@ -3964,7 +3964,7 @@ WHERE $smartGroupClause * @param array $values */ public function changeLog(&$values) { - list($name, $op, $value, $grouping, $wildcard) = $values; + [$name, $op, $value, $grouping, $wildcard] = $values; $targetName = $this->getWhereValues('changed_by', $grouping); if (!$targetName) { @@ -3978,7 +3978,7 @@ WHERE $smartGroupClause $this->_tables['civicrm_log'] = $this->_whereTables['civicrm_log'] = 1; $fieldTitle = ts('Altered By'); - list($qillop, $qillVal) = self::buildQillForFieldValue(NULL, 'changed_by', $name, 'LIKE'); + [$qillop, $qillVal] = self::buildQillForFieldValue(NULL, 'changed_by', $name, 'LIKE'); $this->_qill[$grouping][] = ts("%1 %2 '%3'", [ 1 => $fieldTitle, 2 => $qillop, @@ -4017,7 +4017,7 @@ WHERE $smartGroupClause * @throws \CRM_Core_Exception */ public function demographics(&$values) { - list($name, $op, $value, $grouping, $wildcard) = $values; + [$name, $op, $value, $grouping, $wildcard] = $values; if (($name == 'age_low') || ($name == 'age_high')) { $this->ageRangeQueryBuilder($values, @@ -4044,7 +4044,7 @@ WHERE $smartGroupClause * @param $values */ public function privacy(&$values) { - list($name, $op, $value, $grouping) = $values; + [$name, $op, $value, $grouping] = $values; if (is_array($value)) { if (in_array(key($value), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) { $op = key($value); @@ -4063,7 +4063,7 @@ WHERE $smartGroupClause * @param $values */ public function privacyOptions($values) { - list($name, $op, $value, $grouping, $wildcard) = $values; + [$name, $op, $value, $grouping, $wildcard] = $values; if (empty($value) || !is_array($value)) { return; @@ -4106,7 +4106,7 @@ WHERE $smartGroupClause * @throws \CRM_Core_Exception */ public function preferredCommunication(&$values) { - list($name, $op, $value, $grouping, $wildcard) = $values; + [$name, $op, $value, $grouping, $wildcard] = $values; if (!is_array($value)) { $value = str_replace(['(', ')'], '', explode(",", $value)); @@ -4115,7 +4115,7 @@ WHERE $smartGroupClause $op = key($value); $value = $value[$op]; } - list($qillop, $qillVal) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Contact_DAO_Contact', $name, $value, $op); + [$qillop, $qillVal] = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Contact_DAO_Contact', $name, $value, $op); if (self::caseImportant($op)) { $value = implode("[[:cntrl:]]|[[:cntrl:]]", (array) $value); @@ -4133,7 +4133,7 @@ WHERE $smartGroupClause * @param array $values */ public function relationship(&$values) { - list($name, $op, $value, $grouping, $wildcard) = $values; + [$name, $op, $value, $grouping, $wildcard] = $values; if ($this->_relationshipValuesAdded) { return; } @@ -4545,7 +4545,7 @@ civicrm_relationship.start_date > {$today} */ public static function getQuery($params = NULL, $returnProperties = NULL, $count = FALSE) { $query = new CRM_Contact_BAO_Query($params, $returnProperties); - list($select, $from, $where, $having) = $query->query(); + [$select, $from, $where, $having] = $query->query(); $groupBy = ($query->_useGroupBy) ? 'GROUP BY contact_a.id' : ''; $query = "$select $from $where $groupBy $having"; @@ -4617,7 +4617,7 @@ civicrm_relationship.start_date > {$today} // note : this modifies _fromClause and _simpleFromClause $query->includePseudoFieldsJoin($sort); - list($select, $from, $where, $having) = $query->query($count); + [$select, $from, $where, $having] = $query->query($count); if (!empty($query->_permissionWhereClause)) { if (!empty($query->_permissionFromClause) && !stripos($from, 'aclContactCache')) { @@ -4720,7 +4720,7 @@ civicrm_relationship.start_date > {$today} $customFieldName = self::getCustomFieldName($fieldName); if (substr($fieldName, -9, 9) == '_relative') { - list($from, $to) = CRM_Utils_Date::getFromTo($values, NULL, NULL); + [$from, $to] = CRM_Utils_Date::getFromTo($values, NULL, NULL); } else { if ($fieldName == $customFieldName . '_to' && !empty($formValues[$customFieldName . '_from'])) { @@ -4732,7 +4732,7 @@ civicrm_relationship.start_date > {$today} $to = $formValues[$customFieldName . '_to'] ?? NULL; if (self::isCustomDateField($customFieldName)) { - list($from, $to) = CRM_Utils_Date::getFromTo(NULL, $from, $to); + [$from, $to] = CRM_Utils_Date::getFromTo(NULL, $from, $to); } } @@ -4843,7 +4843,7 @@ civicrm_relationship.start_date > {$today} $groupBy = array_map('trim', (array) $groupBy); $aggregateFunctions = '/(ROUND|AVG|COUNT|GROUP_CONCAT|SUM|MAX|MIN|IF)[[:blank:]]*\(/i'; foreach ($selectClauses as $key => &$val) { - list($selectColumn, $alias) = array_pad(preg_split('/ as /i', $val), 2, NULL); + [$selectColumn, $alias] = array_pad(preg_split('/ as /i', $val), 2, NULL); // append ANY_VALUE() keyword if (!in_array($selectColumn, $groupBy) && preg_match($aggregateFunctions, trim($selectColumn)) !== 1) { $val = ($aggregateFunction == 'GROUP_CONCAT') ? @@ -4906,7 +4906,7 @@ civicrm_relationship.start_date > {$today} } } else { - list($selectColumn, $alias) = array_pad($aliasArray, 2, NULL); + [$selectColumn, $alias] = array_pad($aliasArray, 2, NULL); $dateRegex = '/^(DATE_FORMAT|DATE_ADD|CASE)/i'; $tableName = current(explode('.', $selectColumn)); $primaryKey = "{$tableName}.id"; @@ -5020,7 +5020,7 @@ civicrm_relationship.start_date > {$today} CRM_Utils_Type::validateAll($cids, 'Positive'); $this->_includeContactIds = $includeContactIds; $onlyDeleted = in_array(['deleted_contacts', '=', '1', '0', '0'], $this->_params); - list($select, $from, $where) = $this->query(FALSE, FALSE, FALSE, $onlyDeleted); + [$select, $from, $where] = $this->query(FALSE, FALSE, FALSE, $onlyDeleted); $select .= sprintf(", (%s) AS _wgt", $this->createSqlCase('contact_a.id', $cids)); $where .= sprintf(' AND contact_a.id IN (%s)', implode(',', $cids)); $order = 'ORDER BY _wgt'; @@ -5132,7 +5132,7 @@ civicrm_relationship.start_date > {$today} * @throws \CRM_Core_Exception */ public function summaryContribution($context = NULL) { - list($innerselect, $from, $where, $having) = $this->query(TRUE); + [$innerselect, $from, $where, $having] = $this->query(TRUE); if (!empty($this->_permissionFromClause) && !stripos($from, 'aclContactCache')) { $from .= " $this->_permissionFromClause"; } @@ -5297,7 +5297,7 @@ civicrm_relationship.start_date > {$today} $highDBFieldName = NULL ) { // @todo - remove dateFormat - pretty sure it's never passed in... - list($name, $op, $value, $grouping, $wildcard) = $values; + [$name, $op, $value, $grouping, $wildcard] = $values; if ($name !== $fieldName && $name !== "{$fieldName}_low" && $name !== "{$fieldName}_high") { CRM_Core_Error::deprecatedFunctionWarning('Date query builder called unexpectedly'); return; @@ -5436,7 +5436,7 @@ civicrm_relationship.start_date > {$today} $dbFieldName, $fieldTitle, $options = NULL ) { - list($name, $op, $value, $grouping, $wildcard) = $values; + [$name, $op, $value, $grouping, $wildcard] = $values; if ($name == "{$fieldName}_low" || $name == "{$fieldName}_high" @@ -5518,7 +5518,7 @@ civicrm_relationship.start_date > {$today} $dbFieldName, $fieldTitle, $options = NULL ) { - list($name, $op, $value, $grouping, $wildcard) = $values; + [$name, $op, $value, $grouping, $wildcard] = $values; $asofDateValues = $this->getWhereValues("{$fieldName}_asof_date", $grouping); // will be treated as current day @@ -5807,7 +5807,7 @@ AND displayRelType.is_active = 1 "; } else { - list($relType, $dirOne, $dirTwo) = explode('_', $this->_displayRelationshipType); + [$relType, $dirOne, $dirTwo] = explode('_', $this->_displayRelationshipType); if ($dirOne == 'a') { $relationshipTypeLabel = $rTypes[$relType]['label_a_b']; $qcache['from'] .= " @@ -5928,7 +5928,7 @@ AND displayRelType.is_active = 1 'addressee', ]; - list($tableName, $fieldName) = explode('.', $field['where'], 2); + [$tableName, $fieldName] = explode('.', $field['where'], 2); if ($tableName == 'civicrm_contact') { $wc = "contact_a.$fieldName"; } @@ -5953,7 +5953,7 @@ AND displayRelType.is_active = 1 $field['name'] = $name; } - list($qillop, $qillVal) = CRM_Contact_BAO_Query::buildQillForFieldValue($daoName, $field['name'], $value, $op); + [$qillop, $qillVal] = CRM_Contact_BAO_Query::buildQillForFieldValue($daoName, $field['name'], $value, $op); $this->_qill[$grouping][] = ts("%1 %2 %3", [1 => $label, 2 => $qillop, 3 => $qillVal]); $this->_where[$grouping][] = self::buildClause($wc, $op, $value, $dataType); } @@ -6286,7 +6286,7 @@ AND displayRelType.is_active = 1 * @return string */ public static function getQillValue($daoName, string $name, $value, $op, string $label) { - list($op, $value) = self::buildQillForFieldValue($daoName, $name, $value, $op); + [$op, $value] = self::buildQillForFieldValue($daoName, $name, $value, $op); return ts('%1 %2 %3', [1 => $label, 2 => $op, 3 => $value]); } @@ -6535,7 +6535,7 @@ AND displayRelType.is_active = 1 */ public function setQillAndWhere($name, $op, $value, $grouping, $field) { $this->_where[$grouping][] = self::buildClause("contact_a.{$name}", $op, $value); - list($qillop, $qillVal) = CRM_Contact_BAO_Query::buildQillForFieldValue(NULL, $name, $value, $op); + [$qillop, $qillVal] = CRM_Contact_BAO_Query::buildQillForFieldValue(NULL, $name, $value, $op); $this->_qill[$grouping][] = ts("%1 %2 %3", [ 1 => $field['title'], 2 => $qillop, @@ -6877,7 +6877,7 @@ AND displayRelType.is_active = 1 //CRM-15967 $this->includePseudoFieldsJoin($sort); - list($select, $from, $where, $having) = $this->query($count, $sortByChar, $groupContacts, $onlyDeleted); + [$select, $from, $where, $having] = $this->query($count, $sortByChar, $groupContacts, $onlyDeleted); if ($additionalWhereClause) { $where = $where . ' AND ' . $additionalWhereClause; @@ -7229,7 +7229,7 @@ AND displayRelType.is_active = 1 * @return string */ public function getQillForField($name, $value, $op, $fieldSpec = [], $labelOverride = NULL): string { - list($qillop, $qillVal) = CRM_Contact_BAO_Query::buildQillForFieldValue($fieldSpec['bao'] ?? NULL, $name, $value, $op); + [$qillop, $qillVal] = CRM_Contact_BAO_Query::buildQillForFieldValue($fieldSpec['bao'] ?? NULL, $name, $value, $op); return (string) ts("%1 %2 %3", [ 1 => $labelOverride ?? $fieldSpec['title'], 2 => $qillop, diff --git a/CRM/Contact/BAO/Relationship.php b/CRM/Contact/BAO/Relationship.php index 46e1794613..92bdbddf19 100644 --- a/CRM/Contact/BAO/Relationship.php +++ b/CRM/Contact/BAO/Relationship.php @@ -245,7 +245,7 @@ class CRM_Contact_BAO_Relationship extends CRM_Contact_DAO_Relationship { // explode the string with _ to get the relationship type id // and to know which contact has to be inserted in // contact_id_a and which one in contact_id_b - list($relationshipTypeID) = explode('_', $relationshipTypes); + [$relationshipTypeID] = explode('_', $relationshipTypes); $relationship = new CRM_Contact_BAO_Relationship(); if (!empty($params['id'])) { @@ -833,7 +833,7 @@ class CRM_Contact_BAO_Relationship extends CRM_Contact_DAO_Relationship { */ public static function checkDuplicateRelationship($params, $id, $contactId = 0, $relationshipId = 0) { $relationshipTypeId = $params['relationship_type_id'] ?? NULL; - list($type) = explode('_', $relationshipTypeId); + [$type] = explode('_', $relationshipTypeId); $queryString = " SELECT id @@ -1203,10 +1203,10 @@ LEFT JOIN civicrm_country ON (civicrm_address.country_id = civicrm_country.id) return $values; } - list($select1, $from1, $where1) = self::makeURLClause($contactId, $status, $numRelationship, + [$select1, $from1, $where1] = self::makeURLClause($contactId, $status, $numRelationship, $count, $relationshipId, 'a_b', $params ); - list($select2, $from2, $where2) = self::makeURLClause($contactId, $status, $numRelationship, + [$select2, $from2, $where2] = self::makeURLClause($contactId, $status, $numRelationship, $count, $relationshipId, 'b_a', $params ); @@ -1551,7 +1551,7 @@ LEFT JOIN civicrm_country ON (civicrm_address.country_id = civicrm_country.id) $relTypeIds = []; if ($action & CRM_Core_Action::DELETE) { // @todo don't return relTypeId here - but it seems to be used later in a cryptic way (hint cryptic is not a complement). - list($relTypeId, $isDeletable) = self::isInheritedMembershipInvalidated($membershipValues, $values, $cid); + [$relTypeId, $isDeletable] = self::isInheritedMembershipInvalidated($membershipValues, $values, $cid); if ($isDeletable) { CRM_Member_BAO_Membership::deleteRelatedMemberships($membershipValues['owner_membership_id'], $membershipValues['contact_id']); } diff --git a/CRM/Contact/BAO/SearchCustom.php b/CRM/Contact/BAO/SearchCustom.php index 8d913e4eac..f945abb91a 100644 --- a/CRM/Contact/BAO/SearchCustom.php +++ b/CRM/Contact/BAO/SearchCustom.php @@ -90,7 +90,7 @@ class CRM_Contact_BAO_SearchCustom { * @throws CRM_Core_Exception */ public static function customClass($csID, $ssID) { - list($customSearchID, $customSearchClass, $formValues) = self::details($csID, $ssID); + [$customSearchID, $customSearchClass, $formValues] = self::details($csID, $ssID); if (!$customSearchID) { throw new CRM_Core_Exception('Could not resolve custom search ID'); @@ -124,7 +124,7 @@ class CRM_Contact_BAO_SearchCustom { $values = explode("\n", $args); $formValues = []; foreach ($values as $value) { - list($n, $v) = CRM_Utils_System::explode('=', $value, 2); + [$n, $v] = CRM_Utils_System::explode('=', $value, 2); if (!empty($v)) { $formValues[$n] = $v; } diff --git a/CRM/Contact/Form/Relationship.php b/CRM/Contact/Form/Relationship.php index fae9c92d43..6203c629e6 100644 --- a/CRM/Contact/Form/Relationship.php +++ b/CRM/Contact/Form/Relationship.php @@ -523,7 +523,7 @@ class CRM_Contact_Form_Relationship extends CRM_Core_Form { * @throws \CRM_Core_Exception */ private function updateAction($params) { - list($params, $_) = $this->preparePostProcessParameters($params); + [$params, $_] = $this->preparePostProcessParameters($params); try { civicrm_api3('relationship', 'create', $params); } @@ -544,7 +544,7 @@ class CRM_Contact_Form_Relationship extends CRM_Core_Form { * @throws \CRM_Core_Exception */ private function createAction($params) { - list($params, $primaryContactLetter) = $this->preparePostProcessParameters($params); + [$params, $primaryContactLetter] = $this->preparePostProcessParameters($params); $outcome = CRM_Contact_BAO_Relationship::createMultiple($params, $primaryContactLetter); @@ -564,7 +564,7 @@ class CRM_Contact_Form_Relationship extends CRM_Core_Form { */ private function preparePostProcessParameters($values) { $params = $values; - list($relationshipTypeId, $a, $b) = explode('_', $params['relationship_type_id']); + [$relationshipTypeId, $a, $b] = explode('_', $params['relationship_type_id']); $params['relationship_type_id'] = $relationshipTypeId; $params['contact_id_' . $a] = $this->_contactId; diff --git a/CRM/Contact/Form/Search/Builder.php b/CRM/Contact/Form/Search/Builder.php index 097269685d..4441dd702c 100644 --- a/CRM/Contact/Form/Search/Builder.php +++ b/CRM/Contact/Form/Search/Builder.php @@ -178,7 +178,7 @@ class CRM_Contact_Form_Search_Builder extends CRM_Contact_Form_Search { else { if (substr($v[0], 0, 7) == 'custom_') { // Get rid of appended location type id - list($fieldKey) = explode('-', $v[0]); + [$fieldKey] = explode('-', $v[0]); $type = $fields[$fieldKey]['data_type']; // hack to handle custom data of type state and country @@ -719,7 +719,7 @@ class CRM_Contact_Form_Search_Builder extends CRM_Contact_Form_Search { $jsSet = FALSE; if (isset($mappingId)) { - list($mappingName, $defaults, $noneArray, $jsSet) = $this->loadSavedMapping($mappingLocation, $x, $i, $mappingName, $mapperFields, $mappingContactType, $mappingRelation, $specialFields, $mappingPhoneType, $defaults, $noneArray, $mappingImProvider, $mappingOperator, $mappingValue); + [$mappingName, $defaults, $noneArray, $jsSet] = $this->loadSavedMapping($mappingLocation, $x, $i, $mappingName, $mapperFields, $mappingContactType, $mappingRelation, $specialFields, $mappingPhoneType, $defaults, $noneArray, $mappingImProvider, $mappingOperator, $mappingValue); } //Fix for Search Builder $j = 4; diff --git a/CRM/Contact/Page/AJAX.php b/CRM/Contact/Page/AJAX.php index 0b4531f1e1..2529fcaf11 100644 --- a/CRM/Contact/Page/AJAX.php +++ b/CRM/Contact/Page/AJAX.php @@ -221,7 +221,7 @@ class CRM_Contact_Page_AJAX { $ret = ['is_error' => 0]; - list($relTypeId, $b, $a) = explode('_', $relType); + [$relTypeId, $b, $a] = explode('_', $relType); if ($relationshipID && $originalCid) { CRM_Case_BAO_Case::endCaseRole($caseID, $a, $originalCid, $relTypeId); @@ -362,7 +362,7 @@ class CRM_Contact_Page_AJAX { $rowCount = Civi::settings()->get('search_autocomplete_count'); // add acl clause here - list($aclFrom, $aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause('cc'); + [$aclFrom, $aclWhere] = CRM_Contact_BAO_Contact_Permission::cacheClause('cc'); if ($aclWhere) { $aclWhere = "AND {$aclWhere}"; } @@ -426,7 +426,7 @@ LIMIT {$rowCount} $rowCount = (int) CRM_Utils_Request::retrieveValue('rowcount', 'Integer', 20, FALSE, 'GET'); // add acl clause here - list($aclFrom, $aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause('cc'); + [$aclFrom, $aclWhere] = CRM_Contact_BAO_Contact_Permission::cacheClause('cc'); if ($aclWhere) { $aclWhere = " AND $aclWhere"; } diff --git a/CRM/Contact/Selector.php b/CRM/Contact/Selector.php index 872004d475..c5d8f8d26d 100644 --- a/CRM/Contact/Selector.php +++ b/CRM/Contact/Selector.php @@ -248,7 +248,7 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se * @return array */ public static function &links() { - list($context, $contextMenu, $key) = func_get_args(); + [$context, $contextMenu, $key] = func_get_args(); $extraParams = ($key) ? "&key={$key}" : NULL; $searchContext = ($context) ? "&context=$context" : NULL; @@ -413,7 +413,7 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se !in_array($name, $skipFields) ) { if (strpos($name, '-') !== FALSE) { - list($fieldName, $lType, $type) = CRM_Utils_System::explode('-', $name, 3); + [$fieldName, $lType, $type] = CRM_Utils_System::explode('-', $name, 3); if ($lType == 'Primary') { $locationTypeName = 1; @@ -477,7 +477,7 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se foreach ($properties as $prop) { if (strpos($prop, '-')) { - list($loc, $fld, $phoneType) = CRM_Utils_System::explode('-', $prop, 3); + [$loc, $fld, $phoneType] = CRM_Utils_System::explode('-', $prop, 3); $title = $this->_query->_fields[$fld]['title']; if (trim($phoneType) && !is_numeric($phoneType) && strtolower($phoneType) != $fld) { $title .= "-{$phoneType}"; @@ -602,7 +602,7 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se !in_array($key, $skipFields) ) { if (strpos($key, '-') !== FALSE) { - list($fieldName, $id, $type) = CRM_Utils_System::explode('-', $key, 3); + [$fieldName, $id, $type] = CRM_Utils_System::explode('-', $key, 3); if ($id == 'Primary') { $locationTypeName = 1; @@ -715,7 +715,7 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se $row[$property] = $websiteUrl; } elseif (strpos($property, '-email') !== FALSE) { - list($locType) = explode("-email", $property); + [$locType] = explode("-email", $property); $onholdProperty = "{$locType}-on_hold"; $row[$property] = $result->$property ?? NULL; diff --git a/CRM/Contact/StateMachine/Search.php b/CRM/Contact/StateMachine/Search.php index 12cf525f85..5d952a0a13 100644 --- a/CRM/Contact/StateMachine/Search.php +++ b/CRM/Contact/StateMachine/Search.php @@ -35,20 +35,20 @@ class CRM_Contact_StateMachine_Search extends CRM_Core_StateMachine { $this->_pages = []; if ($action == CRM_Core_Action::ADVANCED) { $this->_pages['CRM_Contact_Form_Search_Advanced'] = NULL; - list($task, $result) = $this->taskName($controller, 'Advanced'); + [$task, $result] = $this->taskName($controller, 'Advanced'); } elseif ($action == CRM_Core_Action::PROFILE) { $this->_pages['CRM_Contact_Form_Search_Builder'] = NULL; - list($task, $result) = $this->taskName($controller, 'Builder'); + [$task, $result] = $this->taskName($controller, 'Builder'); } // @todo - this 'should' be removable but it's getting to this controller, for now elseif ($action == CRM_Core_Action::COPY) { $this->_pages['CRM_Contact_Form_Search_Custom'] = NULL; - list($task, $result) = $this->taskName($controller, 'Custom'); + [$task, $result] = $this->taskName($controller, 'Custom'); } else { $this->_pages['CRM_Contact_Form_Search_Basic'] = NULL; - list($task, $result) = $this->taskName($controller, 'Basic'); + [$task, $result] = $this->taskName($controller, 'Basic'); } $this->_task = $task; if (is_array($task)) { -- 2.25.1