Commit 0d48f1cc authored by totten's avatar totten

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

Method:

* Checkout latest merged branch of civicrm/coder (`8.x-2.x-civi`)
* Run this command to autoclean a batch of 100 files
 `PG=1 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 cf9ccf98
......@@ -30,7 +30,6 @@
* @copyright CiviCRM LLC (c) 2004-2019
*/
use Civi\ActionSchedule\RecipientBuilder;
/**
* Class CRM_Activity_ActionMapping
......
......@@ -1207,7 +1207,7 @@ class CRM_Activity_BAO_Activity extends CRM_Activity_DAO_Activity {
}
if (!isset($contactDetails) && !isset($contactIds)) {
Throw new CRM_Core_Exception('You must specify either $contactDetails or $contactIds');
throw new CRM_Core_Exception('You must specify either $contactDetails or $contactIds');
}
// Populate $contactDetails and $contactIds if only one is set
if (is_array($contactIds) && !empty($contactIds) && empty($contactDetails)) {
......
......@@ -260,11 +260,7 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
if (CRM_Contact_Form_Search::isSearchContext($this->_context)) {
$this->_context = 'search';
}
elseif (!in_array($this->_context, [
'dashlet',
'case',
'dashletFullscreen',
])
elseif (!in_array($this->_context, ['dashlet', 'case', 'dashletFullscreen'])
&& $this->_currentlyViewedContactId
) {
$this->_context = 'activity';
......
......@@ -109,7 +109,8 @@ class CRM_Activity_Form_Task_FileOnCase extends CRM_Activity_Form_Task {
}
}
else {
CRM_Core_Session::setStatus(ts('Not permitted to file activity %1 %2.', [
CRM_Core_Session::setStatus(
ts('Not permitted to file activity %1 %2.', [
1 => empty($defaults['subject']) ? '' : $defaults['subject'],
2 => $defaults['activity_date_time'],
]),
......
......@@ -240,30 +240,24 @@ abstract class CRM_Activity_Import_Parser extends CRM_Import_Parser {
}
if ($this->_invalidRowCount) {
// removed view url for invlaid contacts
$headers = array_merge([
ts('Line Number'),
ts('Reason'),
],
$headers = array_merge(
[ts('Line Number'), ts('Reason')],
$customHeaders
);
$this->_errorFileName = self::errorFileName(self::ERROR);
self::exportCSV($this->_errorFileName, $headers, $this->_errors);
}
if ($this->_conflictCount) {
$headers = array_merge([
ts('Line Number'),
ts('Reason'),
],
$headers = array_merge(
[ts('Line Number'), ts('Reason')],
$customHeaders
);
$this->_conflictFileName = self::errorFileName(self::CONFLICT);
self::exportCSV($this->_conflictFileName, $headers, $this->_conflicts);
}
if ($this->_duplicateCount) {
$headers = array_merge([
ts('Line Number'),
ts('View Activity History URL'),
],
$headers = array_merge(
[ts('Line Number'), ts('View Activity History URL')],
$customHeaders
);
......
......@@ -78,7 +78,8 @@ class CRM_Activity_Tokens extends \Civi\Token\AbstractTokenSubscriber {
// Q: Could we simplify & move the extra AND clauses into `where(...)`?
$e->query->param('casEntityJoinExpr', 'e.id = reminder.entity_id AND e.is_current_revision = 1 AND e.is_deleted = 0');
$e->query->select('e.*'); // FIXME: seems too broad.
// FIXME: seems too broad.
$e->query->select('e.*');
$e->query->select('ov.label as activity_type, e.id as activity_id');
$e->query->join("og", "!casMailingJoinType civicrm_option_group og ON og.name = 'activity_type'");
......
......@@ -133,8 +133,7 @@ class CRM_Admin_Form extends CRM_Core_Form {
'name' => ts('Done'),
'isDefault' => TRUE,
],
]
);
]);
}
else {
$this->addButtons([
......@@ -147,8 +146,7 @@ class CRM_Admin_Form extends CRM_Core_Form {
'type' => 'cancel',
'name' => ts('Cancel'),
],
]
);
]);
}
}
......
......@@ -51,8 +51,7 @@ class CRM_Admin_Form_CMSUser extends CRM_Core_Form {
'type' => 'cancel',
'name' => ts('Cancel'),
],
]
);
]);
}
/**
......
......@@ -146,8 +146,7 @@ class CRM_Admin_Form_Extensions extends CRM_Admin_Form {
'type' => 'cancel',
'name' => ts('Cancel'),
],
]
);
]);
}
/**
......
......@@ -93,8 +93,7 @@ class CRM_Admin_Form_Generic extends CRM_Core_Form {
'type' => 'cancel',
'name' => ts('Cancel'),
],
]
);
]);
}
/**
......
......@@ -101,8 +101,7 @@ class CRM_Admin_Form_MessageTemplates extends CRM_Admin_Form {
'js' => ['onclick' => "location.href='{$cancelURL}'; return false;"],
'isDefault' => TRUE,
],
]
);
]);
}
else {
$this->_workflow_id = CRM_Utils_Array::value('workflow_id', $this->_values);
......
......@@ -193,11 +193,8 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form {
$this->add('color', 'color', ts('Color'));
}
if (!in_array($this->_gName, [
'email_greeting',
'postal_greeting',
'addressee',
]) && !$isReserved
if (!in_array($this->_gName, ['email_greeting', 'postal_greeting', 'addressee'])
&& !$isReserved
) {
$this->addRule('label',
ts('This Label already exists in the database for this option group. Please select a different Label.'),
......@@ -323,11 +320,8 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form {
}
// get contact type for which user want to create a new greeting/addressee type, CRM-4575
if (in_array($this->_gName, [
'email_greeting',
'postal_greeting',
'addressee',
]) && !$isReserved
if (in_array($this->_gName, ['email_greeting', 'postal_greeting', 'addressee'])
&& !$isReserved
) {
$values = [
1 => ts('Individual'),
......@@ -372,11 +366,8 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form {
$errors['grouping'] = ts('Status class is a required field');
}
if (in_array($self->_gName, [
'email_greeting',
'postal_greeting',
'addressee',
]) && empty($self->_defaultValues['is_reserved'])
if (in_array($self->_gName, ['email_greeting', 'postal_greeting', 'addressee'])
&& empty($self->_defaultValues['is_reserved'])
) {
$label = $fields['label'];
$condition = " AND v.label = '{$label}' ";
......
......@@ -82,8 +82,7 @@ class CRM_Admin_Form_Persistent extends CRM_Core_Form {
'type' => 'cancel',
'name' => ts('Cancel'),
],
]
);
]);
}
public function postProcess() {
......
......@@ -237,8 +237,7 @@ class CRM_Admin_Form_Preferences extends CRM_Core_Form {
'type' => 'cancel',
'name' => ts('Cancel'),
],
]
);
]);
if ($this->_action == CRM_Core_Action::VIEW) {
$this->freeze();
......
......@@ -69,11 +69,11 @@ class CRM_Admin_Form_RelationshipType extends CRM_Admin_Form {
],
'label_b_a' => [
'name' => 'label_b_a',
'description' => ts("Label for the relationship from Contact B to Contact A. EXAMPLE: Contact B is 'Child of' Contact A. You may leave this blank for relationships where the name is the same in both directions (e.g. Spouse).")
'description' => ts("Label for the relationship from Contact B to Contact A. EXAMPLE: Contact B is 'Child of' Contact A. You may leave this blank for relationships where the name is the same in both directions (e.g. Spouse)."),
],
'description' => [
'name' => 'description',
'description' => ''
'description' => '',
],
'contact_types_a' => ['name' => 'contact_types_a', 'not-auto-addable' => TRUE],
'contact_types_b' => ['name' => 'contact_types_b', 'not-auto-addable' => TRUE],
......
......@@ -83,8 +83,7 @@ class CRM_Admin_Form_Setting extends CRM_Core_Form {
'type' => 'cancel',
'name' => ts('Cancel'),
],
]
);
]);
$this->addFieldsDefinedInSettingsMetadata();
......@@ -143,7 +142,8 @@ class CRM_Admin_Form_Setting extends CRM_Core_Form {
}
CRM_Core_Config::clearDBCache();
Civi::cache('session')->clear(); // This doesn't make a lot of sense to me, but it maintains pre-existing behavior.
// This doesn't make a lot of sense to me, but it maintains pre-existing behavior.
Civi::cache('session')->clear();
CRM_Utils_System::flushCache();
CRM_Core_Resources::singleton()->resetCacheCode();
......
......@@ -85,7 +85,8 @@ class CRM_Admin_Form_Setting_UF extends CRM_Admin_Form_Setting {
if ($config->userFramework === 'Backdrop') {
$tablePrefixes = '$database_prefix = array(';
}
$tablePrefixes .= "\n 'default' => '$drupal_prefix',"; // add default prefix: the drupal database prefix
// add default prefix: the drupal database prefix
$tablePrefixes .= "\n 'default' => '$drupal_prefix',";
$prefix = "";
if ($config->dsn != $config->userFrameworkDSN) {
$prefix = "`{$dsnArray['database']}`.";
......
......@@ -148,8 +148,7 @@ class CRM_Admin_Form_WordReplacements extends CRM_Core_Form {
'type' => 'cancel',
'name' => ts('Cancel'),
],
]
);
]);
$this->addFormRule(['CRM_Admin_Form_WordReplacements', 'formRule'], $this);
}
......
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