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([[
'url' => CRM_Utils_System::url('civicrm/admin/setting/preferences/display', 'reset=1'),
'title' => ts('Display Preferences'),
]]);
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),
],
......
......@@ -101,9 +101,9 @@ class CRM_Admin_Page_PaymentProcessor extends CRM_Core_Page_Basic {
CRM_Utils_System::setTitle(ts('Settings - Payment Processor'));
//CRM-15546
$paymentProcessorTypes = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_PaymentProcessor', 'payment_processor_type_id', array(
'labelColumn' => 'name',
'flip' => 1,
));
'labelColumn' => 'name',
'flip' => 1,
));
$this->assign('defaultPaymentProcessorType', $paymentProcessorTypes['PayPal']);
$breadCrumb = array(
array(
......
......@@ -131,21 +131,20 @@ class CRM_Badge_Form_Layout extends CRM_Admin_Form {
$this->addRule('width_participant_image', ts('Enter valid height'), 'positiveInteger');
$this->addButtons([
[
'type' => 'next',
'name' => ts('Save'),
'isDefault' => TRUE,
],
[
'type' => 'refresh',
'name' => ts('Save and Preview'),
],
[
'type' => 'cancel',
'name' => ts('Cancel'),
],
]
);
[
'type' => 'next',
'name' => ts('Save'),
'isDefault' => TRUE,
],
[
'type' => 'refresh',
'name' => ts('Save and Preview'),
],
[
'type' => 'cancel',
'name' => ts('Cancel'),
],
]);
}
/**
......
......@@ -177,17 +177,16 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form {
);
$this->addButtons([
[
'type' => 'upload',
'name' => ts('Validate & Process the Batch'),
'isDefault' => TRUE,
],
[
'type' => 'cancel',
'name' => ts('Save & Continue Later'),
],
]
);
[
'type' => 'upload',
'name' => ts('Validate & Process the Batch'),
'isDefault' => TRUE,
],
[
'type' => 'cancel',
'name' => ts('Save & Continue Later'),
],
]);
$this->assign('rowCount', $this->_batchInfo['item_count'] + 1);
......@@ -204,9 +203,9 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form {
for ($rowNumber = 1; $rowNumber <= $this->_batchInfo['item_count']; $rowNumber++) {
$this->addEntityRef("primary_contact_id[{$rowNumber}]", '', [
'create' => TRUE,
'placeholder' => ts('- select -'),
]);
'create' => TRUE,
'placeholder' => ts('- select -'),
]);
// special field specific to membership batch udpate
if ($this->_batchInfo['type_id'] == 2) {
......@@ -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)) {
......
......@@ -168,17 +168,16 @@ class CRM_Campaign_Form_Campaign extends CRM_Core_Form {
if ($this->_action & CRM_Core_Action::DELETE) {
$this->addButtons([
[
'type' => 'next',
'name' => ts('Delete'),
'isDefault' => TRUE,
],
[
'type' => 'cancel',
'name' => ts('Cancel'),
],
]
);
[
'type' => 'next',
'name' => ts('Delete'),
'isDefault' => TRUE,
],
[
'type' => 'cancel',
'name' => ts('Cancel'),
],
]);
return;
}
......
......@@ -297,13 +297,12 @@ class CRM_Campaign_Form_Petition_Signature extends CRM_Core_Form {
}
// add buttons
$this->addButtons([
[
'type' => 'upload',
'name' => ts('Sign the Petition'),
'isDefault' => TRUE,
],
]
);
[
'type' => 'upload',
'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 = [];
......
......@@ -72,17 +72,16 @@ class CRM_Campaign_Form_Survey_Delete extends CRM_Core_Form {
*/
public function buildQuickForm() {
$this->addButtons([
[
'type' => 'next',
'name' => ts('Delete'),
'isDefault' => TRUE,
],
[
'type' => 'cancel',
'name' => ts('Cancel'),
],
]
);
[
'type' => 'next',
'name' => ts('Delete'),
'isDefault' => TRUE,
],
[
'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.'),
];
......
......@@ -109,17 +109,16 @@ class CRM_Campaign_Form_Task extends CRM_Core_Form_Task {
*/
public function addDefaultButtons($title, $nextType = 'next', $backType = 'back', $submitOnce = FALSE) {
$this->addButtons([
[
'type' => $nextType,
'name' => $title,
'isDefault' => TRUE,
],
[
'type' => $backType,
'name' => ts('Cancel'),
],
]
);
[
'type' => $nextType,
'name' => $title,
'isDefault' => TRUE,
],
[
'type' => $backType,
'name' => ts('Cancel'),
],
]);
}
}
......@@ -75,10 +75,10 @@ class CRM_Campaign_Form_Task_Interview extends CRM_Campaign_Form_Task {
if ($this->_reserveToInterview || $this->_votingTab) {
//user came from voting tab / reserve form.
foreach ([
'surveyId',
'contactIds',
'interviewerId',
] as $fld) {
'surveyId',
'contactIds',
'interviewerId',
] as $fld) {
$this->{"_$fld"} = $this->get($fld);
}
//get the target voter ids.
......@@ -292,9 +292,9 @@ WHERE {$clause}
for ($i = 1; $i < count($options); $i++) {
$this->addElement('select', "order_bys[{$i}][column]", ts('Order by Column'), $options);
$this->addElement('select', "order_bys[{$i}][order]", ts('Order by Order'), [
'ASC' => ts('Ascending'),
'DESC' => ts('Descending'),
]);
'ASC' => ts('Ascending'),
'DESC' => ts('Descending'),
]);
}
//pickup the uf fields.
......@@ -443,10 +443,10 @@ WHERE {$clause}
elseif ($buttonName == '_qf_Interview_next_interviewToRelease') {
//get ready to jump to release form.
foreach ([
'surveyId',
'contactIds',
'interviewerId',
] as $fld) {
'surveyId',
'contactIds',
'interviewerId',
] as $fld) {
$this->controller->set($fld, $this->{"_$fld"});
}
$this->controller->set('interviewToRelease', TRUE);
......
......@@ -82,18 +82,17 @@ class CRM_Campaign_Form_Task_Print extends CRM_Campaign_Form_Task {
// just need to add a javacript to popup the window for printing
//
$this->addButtons([
[
'type' => 'next',
'name' => ts('Print Respondents'),
'js' => ['onclick' => 'window.print()'],
'isDefault' => TRUE,
],
[
'type' => 'back',
'name' => ts('Done'),
],
]
);
[
'type' => 'next',
'name' => ts('Print Respondents'),
'js' => ['onclick' => 'window.print()'],
'isDefault' => TRUE,
],
[
'type' => 'back',
'name' => ts('Done'),
],
]);
}
/**
......
......@@ -67,10 +67,10 @@ class CRM_Campaign_Form_Task_Release extends CRM_Campaign_Form_Task {
if ($this->_interviewToRelease) {
//user came from interview form.
foreach ([
'surveyId',
'contactIds',
'interviewerId',
] as $fld) {
'surveyId',
'contactIds',
'interviewerId',
] as $fld) {
$this->{"_$fld"} = $this->get($fld);
}
......@@ -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;
}
......
......@@ -47,13 +47,12 @@ class CRM_Campaign_Form_Task_Result extends CRM_Campaign_Form_Task {
*/
public function buildQuickForm() {
$this->addButtons([
[
'type' => 'done',
'name' => ts('Done'),
'isDefault' => TRUE,
],
]
);
[
'type' => 'done',
'name' => ts('Done'),
'isDefault' => TRUE,
],
]);
}
}
......@@ -158,9 +158,9 @@ class CRM_Campaign_Page_AJAX {
//format multi-select group and contact types.
foreach ([
'group',
'contact_type',
] as $param) {
'group',
'contact_type',
] as $param) {
$paramValue = CRM_Utils_Array::value($param, $params);
if ($paramValue) {
unset($params[$param]);
......@@ -173,10 +173,10 @@ class CRM_Campaign_Page_AJAX {
$voterClauseParams = [];
foreach ([
'campaign_survey_id',
'survey_interviewer_id',
'campaign_search_voter_for',
] as $fld) {
'campaign_survey_id',
'survey_interviewer_id',
'campaign_search_voter_for',
] as $fld) {
$voterClauseParams[$fld] = CRM_Utils_Array::value($fld, $params);
}
......@@ -602,11 +602,11 @@ class CRM_Campaign_Page_AJAX {
}
}
foreach ([
'sort',
'offset',
'rowCount',
'sortOrder',
] as $sortParam) {
'sort',
'offset',
'rowCount',
'sortOrder',
] as $sortParam) {
$params[$sortParam] = $$sortParam;
}
......@@ -707,11 +707,11 @@ class CRM_Campaign_Page_AJAX {
}
}
foreach ([
'sort',
'offset',
'rowCount',
'sortOrder',
] as $sortParam) {
'sort',
'offset',
'rowCount',
'sortOrder',
] as $sortParam) {
$params[$sortParam] = $$sortParam;
}
......@@ -807,11 +807,11 @@ class CRM_Campaign_Page_AJAX {
}
}
foreach ([
'sort',
'offset',
'rowCount',
'sortOrder',
] as $sortParam) {
'sort',
'offset',
'rowCount',
'sortOrder',
] as $sortParam) {
$params[$sortParam] = $$sortParam;
}
......
......@@ -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";
......
......@@ -208,10 +208,9 @@ class CRM_Case_Form_Activity_ChangeCaseStatus {
foreach ($form->_oldCaseStatus as $statuskey => $statusval) {
if ($activity->subject == 'null') {
$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),
]
);
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;
......@@ -153,9 +154,9 @@ class CRM_Case_Form_Activity_OpenCase {
}
if ($form->_context == 'standalone') {
$form->addEntityRef('client_id', ts('Client'), [
'create' => TRUE,
'multiple' => $form->_allowMultiClient,
], TRUE);
'create' => TRUE,
'multiple' => $form->_allowMultiClient,
], TRUE);
}
$element = $form->addField('case_type_id', [
......@@ -193,24 +194,23 @@ class CRM_Case_Form_Activity_OpenCase {
$form->add('wysiwyg', 'activity_details', ts('Details'), ['rows' => 4, 'cols' => 60], FALSE);
$form->addButtons([
[
'type' => 'upload',
'name' => ts('Save'),
'isDefault' => TRUE,
'submitOnce' => TRUE,
],
[
'type' => 'upload',
'name' => ts('Save and New'),
'subName' => 'new',
'submitOnce' => TRUE,
],
[
'type' => 'cancel',
'name' => ts('Cancel'),
],
]
);
[
'type' => 'upload',
'name' => ts('Save'),
'isDefault' => TRUE,
'submitOnce' => TRUE,
],
[
'type' => 'upload',
'name' => ts('Save and New'),
'subName' => 'new',
'submitOnce' => TRUE,
],
[
'type' => 'cancel',
'name' => ts('Cancel'),
],
]);
}
/**
......
......@@ -239,18 +239,17 @@ class CRM_Case_Form_Case extends CRM_Core_Form {
$title = ts('Restore');
}
$this->addButtons([
[
'type' => 'next',
'name' => $title,
'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
'isDefault' => TRUE,
],
[
'type' => 'cancel',
'name' => ts('Cancel'),
],
]
);
[
'type' => 'next',
'name' => $title,
'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
'isDefault' => TRUE,