Commit 5d4fcf54 authored by totten's avatar totten

(NFC) Apply upcoming civicrm/coder policies (batch 2)

Method:

* Checkout latest merged branch of civicrm/coder (`8.x-2.x-civi`)
* Run this command to autoclean a batch of 100 files
  `PG=2 SIZE=100 ; find Civi/ CRM/ api/ bin/ extern/ tests/ -name '*.php' | grep -v /examples/ | grep -v /DAO/ | sort | head -n $(( $PG  * $SIZE )) | tail -n $SIZE | xargs phpcbf-civi`
* Go through the diff. For anything that looks wonky, open in an editor and find a better solution.

Note: The automated checker makes good points about awkward indentation, but the automated cleanup often makes it
worse.  So that's why I have to open it up.
parent 0d48f1cc
......@@ -106,10 +106,12 @@ class CRM_Admin_Page_CKEditorConfig extends CRM_Core_Page {
$this->assign('configUrl', $configUrl);
$this->assign('revertConfirm', htmlspecialchars(ts('Are you sure you want to revert all changes?', ['escape' => 'js'])));
CRM_Utils_System::appendBreadCrumb([[
CRM_Utils_System::appendBreadCrumb([
[
'url' => CRM_Utils_System::url('civicrm/admin/setting/preferences/display', 'reset=1'),
'title' => ts('Display Preferences'),
]]);
],
]);
return parent::run();
}
......
......@@ -160,7 +160,8 @@ class CRM_Admin_Page_Extensions extends CRM_Core_Page_Basic {
$mapper = CRM_Extension_System::singleton()->getMapper();
$manager = CRM_Extension_System::singleton()->getManager();
$localExtensionRows = []; // array($pseudo_id => extended_CRM_Extension_Info)
// array($pseudo_id => extended_CRM_Extension_Info)
$localExtensionRows = [];
$keys = array_keys($manager->getStatuses());
sort($keys);
foreach ($keys as $key) {
......
......@@ -24,7 +24,8 @@ class CRM_Admin_Page_ExtensionsUpgrade extends CRM_Core_Page {
]);
CRM_Core_Error::debug_log_message('CRM_Admin_Page_ExtensionsUpgrade: Start upgrades');
$runner->runAllViaWeb(); // does not return
// does not return
$runner->runAllViaWeb();
}
/**
......
......@@ -161,7 +161,8 @@ class CRM_Admin_Page_MessageTemplates extends CRM_Core_Page_Basic {
}
// rebuild the action links HTML, as we need to handle %%orig_id%% for revertible templates
$values['action'] = CRM_Core_Action::formLink($links, $action, [
$values['action'] = CRM_Core_Action::formLink($links, $action,
[
'id' => $object->id,
'orig_id' => CRM_Utils_Array::value($object->id, $this->_revertible),
],
......
......@@ -144,8 +144,7 @@ class CRM_Badge_Form_Layout extends CRM_Admin_Form {
'type' => 'cancel',
'name' => ts('Cancel'),
],
]
);
]);
}
/**
......
......@@ -186,8 +186,7 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form {
'type' => 'cancel',
'name' => ts('Save & Continue Later'),
],
]
);
]);
$this->assign('rowCount', $this->_batchInfo['item_count'] + 1);
......@@ -254,7 +253,8 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form {
// Notes: $this->_elementIndex gives an approximate count of the variables being sent
// An offset value is set to deal with additional vars that are likely passed.
// There may be a more accurate way to do this...
$offset = 50; // set an offset to account for other vars we are not counting
// set an offset to account for other vars we are not counting
$offset = 50;
if ((count($this->_elementIndex) + $offset) > ini_get("max_input_vars")) {
CRM_Core_Error::fatal(ts('Batch size is too large. Increase value of php.ini setting "max_input_vars" (current val = ' . ini_get("max_input_vars") . ')'));
}
......
......@@ -716,7 +716,8 @@ INNER JOIN civicrm_group grp ON ( grp.id = campgrp.entity_id )
'url' => CRM_Utils_System::url('civicrm/campaign/add', "reset=1",
NULL, NULL, FALSE, FALSE, TRUE),
'type' => 'Campaign',
]];
],
];
}
return FALSE;
}
......
......@@ -398,10 +398,7 @@ INNER JOIN civicrm_custom_group grp on fld.custom_group_id = grp.id
$dao = CRM_Core_DAO::executeQuery($query, [1 => ['Voter_Info', 'String']]);
$customSearchFields = [];
while ($dao->fetch()) {
foreach ([
'ward',
'precinct',
] as $name) {
foreach (['ward', 'precinct'] as $name) {
if (stripos($name, $dao->label) !== FALSE) {
$fieldId = $dao->id;
$fieldName = 'custom_' . $dao->id;
......
......@@ -439,11 +439,8 @@ SELECT survey.id as id,
$autocompleteContactSearch = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'contact_autocomplete_options'
);
$returnProperties = array_fill_keys(array_merge([
'contact_type',
'contact_sub_type',
'sort_name',
],
$returnProperties = array_fill_keys(array_merge(
['contact_type', 'contact_sub_type', 'sort_name'],
array_keys($autocompleteContactSearch)
), 1);
}
......@@ -913,7 +910,7 @@ INNER JOIN civicrm_contact contact_a ON ( activityTarget.contact_id = contact_a
*
* @return mixed
*/
public Static function getReportID($surveyId) {
public static function getReportID($surveyId) {
static $reportIds = [];
if (!array_key_exists($surveyId, $reportIds)) {
......
......@@ -177,8 +177,7 @@ class CRM_Campaign_Form_Campaign extends CRM_Core_Form {
'type' => 'cancel',
'name' => ts('Cancel'),
],
]
);
]);
return;
}
......
......@@ -302,8 +302,7 @@ class CRM_Campaign_Form_Petition_Signature extends CRM_Core_Form {
'name' => ts('Sign the Petition'),
'isDefault' => TRUE,
],
]
);
]);
}
/**
......
......@@ -339,11 +339,7 @@ class CRM_Campaign_Form_Search extends CRM_Core_Form_Search {
//apply filter of survey contact type for search.
$contactType = CRM_Campaign_BAO_Survey::getSurveyContactType(CRM_Utils_Array::value('campaign_survey_id', $this->_formValues));
if ($contactType && in_array($this->_operation, array(
'reserve',
'interview',
))
) {
if ($contactType && in_array($this->_operation, ['reserve', 'interview'])) {
$this->_formValues['contact_type'][$contactType] = 1;
}
......
......@@ -110,8 +110,7 @@ class CRM_Campaign_Form_Search_Campaign extends CRM_Core_Form {
'' => ts('- select -'),
'0' => ts('Yes'),
'1' => ts('No'),
]
);
]);
//build the array of all search params.
$this->_searchParams = [];
......
......@@ -81,8 +81,7 @@ class CRM_Campaign_Form_Survey_Delete extends CRM_Core_Form {
'type' => 'cancel',
'name' => ts('Cancel'),
],
]
);
]);
}
/**
......
......@@ -66,7 +66,8 @@ class CRM_Campaign_Form_Survey_Questions extends CRM_Campaign_Form_Survey {
public function buildQuickForm() {
$subTypeId = CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Survey', $this->_surveyId, 'activity_type_id');
if (!CRM_Core_BAO_CustomGroup::autoCreateByActivityType($subTypeId)) {
$activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE, FALSE); // everything
// everything
$activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE, FALSE);
// FIXME: Displays weird "/\ Array" message; doesn't work with tabs
CRM_Core_Session::setStatus(
ts(
......
......@@ -413,7 +413,8 @@ class CRM_Campaign_Form_Survey_Results extends CRM_Campaign_Form_Survey {
'name' => "survey_{$survey->id}",
'title' => $params['report_title'] ? $params['report_title'] : $this->_values['title'],
'status_id_op' => 'eq',
'status_id_value' => $activityStatus['Scheduled'], // reserved status
// reserved status
'status_id_value' => $activityStatus['Scheduled'],
'survey_id_value' => [$survey->id],
'description' => ts('Detailed report for canvassing, phone-banking, walk lists or other surveys.'),
];
......
......@@ -118,8 +118,7 @@ class CRM_Campaign_Form_Task extends CRM_Core_Form_Task {
'type' => $backType,
'name' => ts('Cancel'),
],
]
);
]);
}
}
......@@ -92,8 +92,7 @@ class CRM_Campaign_Form_Task_Print extends CRM_Campaign_Form_Task {
'type' => 'back',
'name' => ts('Done'),
],
]
);
]);
}
/**
......
......@@ -101,9 +101,7 @@ class CRM_Campaign_Form_Task_Release extends CRM_Campaign_Form_Task {
$activityStatus = CRM_Core_PseudoConstant::activityStatus('name');
$statusIds = [];
foreach ([
'Scheduled',
] as $name) {
foreach (['Scheduled'] as $name) {
if ($statusId = array_search($name, $activityStatus)) {
$statusIds[] = $statusId;
}
......
......@@ -52,8 +52,7 @@ class CRM_Campaign_Form_Task_Result extends CRM_Campaign_Form_Task {
'name' => ts('Done'),
'isDefault' => TRUE,
],
]
);
]);
}
}
......@@ -119,8 +119,7 @@ class CRM_Campaign_Page_Vote extends CRM_Core_Page {
'administer CiviCampaign',
"{$name} campaign contacts",
],
])
) {
])) {
continue;
}
......
......@@ -76,7 +76,8 @@ class CRM_Case_BAO_Case extends CRM_Case_DAO_Case {
$caseDAO = new CRM_Case_DAO_Case();
$caseDAO->copyValues($params);
$result = $caseDAO->save();
$caseDAO->find(TRUE); // Get other case values (required by XML processor), this adds to $result array
// Get other case values (required by XML processor), this adds to $result array
$caseDAO->find(TRUE);
return $result;
}
......
......@@ -160,7 +160,8 @@ class CRM_Case_BAO_CaseType extends CRM_Case_DAO_CaseType {
}
break;
case 'sequence': // passthrough
// passthrough
case 'sequence':
case 'timeline':
if ($setVal) {
$xmlFile .= "<{$index}>true</{$index}>\n";
......
......@@ -210,8 +210,7 @@ class CRM_Case_Form_Activity_ChangeCaseStatus {
$activity->subject = ts('Case status changed from %1 to %2', [
1 => CRM_Utils_Array::value($statusval, $form->_caseStatus),
2 => CRM_Utils_Array::value($params['case_status_id'], $form->_caseStatus),
]
);
]);
$activity->save();
}
}
......
......@@ -107,7 +107,8 @@ class CRM_Case_Form_Activity_OpenCase {
else {
$caseStatus = CRM_Core_OptionGroup::values('case_status', FALSE, FALSE, FALSE, 'AND is_default = 1');
if (count($caseStatus) == 1) {
$caseStatus = key($caseStatus); //$defaults['status_id'] = key($caseStatus);
//$defaults['status_id'] = key($caseStatus);
$caseStatus = key($caseStatus);
}
}
$defaults['status_id'] = $caseStatus;
......@@ -209,8 +210,7 @@ class CRM_Case_Form_Activity_OpenCase {
'type' => 'cancel',
'name' => ts('Cancel'),
],
]
);
]);
}
/**
......
......@@ -249,8 +249,7 @@ class CRM_Case_Form_Case extends CRM_Core_Form {
'type' => 'cancel',
'name' => ts('Cancel'),
],
]
);
]);
return;
}
......@@ -293,8 +292,7 @@ class CRM_Case_Form_Case extends CRM_Core_Form {
'type' => 'cancel',
'name' => ts('Cancel'),
],
]
);
]);
$className = "CRM_Case_Form_Activity_{$this->_activityTypeFile}";
$className::buildQuickForm($this);
......
......@@ -404,8 +404,7 @@ class CRM_Case_Form_CaseView extends CRM_Core_Form {
'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
'isDefault' => TRUE,
],
]
);
]);
}
/**
......
......@@ -108,8 +108,7 @@ class CRM_Case_Form_CustomData extends CRM_Core_Form {
'type' => 'cancel',
'name' => ts('Cancel'),
],
]
);
]);
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment