Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REF] Use empty() instead of CRM_Utils_Array::value() in inline conditionals #16729

Merged
merged 1 commit into from
Mar 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CRM/Case/XMLProcessor/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ public function createActivity($activityTypeXML, &$params) {
'source_contact_id' => $params['creatorID'],
'is_auto' => FALSE,
'is_current_revision' => 1,
'subject' => CRM_Utils_Array::value('subject', $params) ? $params['subject'] : $activityTypeName,
'subject' => !empty($params['subject']) ? $params['subject'] : $activityTypeName,
'status_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_status_id', $statusName),
'target_contact_id' => $client,
'medium_id' => CRM_Utils_Array::value('medium_id', $params),
Expand Down
4 changes: 2 additions & 2 deletions CRM/Contribute/BAO/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -1102,7 +1102,7 @@ private static function updateFinancialAccountsOnContributionStatusChange(&$para
elseif (($previousContributionStatus == 'Pending'
&& $params['prevContribution']->is_pay_later) || $previousContributionStatus == 'In Progress'
) {
$financialTypeID = CRM_Utils_Array::value('financial_type_id', $params) ? $params['financial_type_id'] : $params['prevContribution']->financial_type_id;
$financialTypeID = !empty($params['financial_type_id']) ? $params['financial_type_id'] : $params['prevContribution']->financial_type_id;
$arAccountId = CRM_Contribute_PseudoConstant::getRelationalFinancialAccount($financialTypeID, 'Accounts Receivable Account is');

if ($currentContributionStatus == 'Cancelled') {
Expand Down Expand Up @@ -5557,7 +5557,7 @@ public static function recordAlwaysAccountsReceivable(&$trxnParams, $contributio
}

$params = $trxnParams;
$financialTypeID = CRM_Utils_Array::value('financial_type_id', $contributionParams) ? $contributionParams['financial_type_id'] : $contributionParams['prevContribution']->financial_type_id;
$financialTypeID = !empty($contributionParams['financial_type_id']) ? $contributionParams['financial_type_id'] : $contributionParams['prevContribution']->financial_type_id;
$arAccountId = CRM_Contribute_PseudoConstant::getRelationalFinancialAccount($financialTypeID, 'Accounts Receivable Account is');
$params['to_financial_account_id'] = $arAccountId;
$params['status_id'] = array_search('Pending', $contributionStatuses);
Expand Down
2 changes: 1 addition & 1 deletion CRM/Contribute/Form/Contribution/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ public function buildQuickForm() {
if (!($allAreBillingModeProcessors && !$this->_values['is_pay_later'])) {
$submitButton = [
'type' => 'upload',
'name' => CRM_Utils_Array::value('is_confirm_enabled', $this->_values) ? ts('Confirm Contribution') : ts('Contribute'),
'name' => !empty($this->_values['is_confirm_enabled']) ? ts('Confirm Contribution') : ts('Contribute'),
'spacing' => '         ',
'isDefault' => TRUE,
];
Expand Down
2 changes: 1 addition & 1 deletion CRM/Core/BAO/FinancialTrxn.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ public static function createPremiumTrxn($params) {
'to_financial_account_id' => CRM_Contribute_PseudoConstant::getRelationalFinancialAccount($params['financial_type_id'], $toFinancialAccountType),
'from_financial_account_id' => CRM_Contribute_PseudoConstant::getRelationalFinancialAccount($params['financial_type_id'], $fromFinancialAccountType),
'trxn_date' => date('YmdHis'),
'total_amount' => CRM_Utils_Array::value('cost', $params) ? $params['cost'] : 0,
'total_amount' => !empty($params['cost']) ? $params['cost'] : 0,
'currency' => CRM_Utils_Array::value('currency', $params),
'status_id' => array_search('Completed', $contributionStatuses),
'entity_table' => 'civicrm_contribution',
Expand Down
2 changes: 1 addition & 1 deletion CRM/Core/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ protected function preProcessPaymentOptions() {
// minimums with the payment processor minimums. This would lead to fields like 'postal_code'
// only being on the form if either the admin has configured it as wanted or the processor
// requires it.
$this->assign('billing_profile_id', (CRM_Utils_Array::value('is_billing_required', $this->_values) ? 'billing' : ''));
$this->assign('billing_profile_id', (!empty($this->_values['is_billing_required']) ? 'billing' : ''));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion CRM/Financial/Page/AJAX.php
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ public static function getFinancialTransactionsList() {
);
}
if ($financialItem->contact_id) {
$row[$financialItem->id]['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage(CRM_Utils_Array::value('contact_sub_type', $row[$financialItem->id]) ? $row[$financialItem->id]['contact_sub_type'] : CRM_Utils_Array::value('contact_type', $row[$financialItem->id]), FALSE, $financialItem->contact_id);
$row[$financialItem->id]['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage(!empty($row[$financialItem->id]['contact_sub_type']) ? $row[$financialItem->id]['contact_sub_type'] : CRM_Utils_Array::value('contact_type', $row[$financialItem->id]), FALSE, $financialItem->contact_id);
}
$financialitems = $row;
}
Expand Down
2 changes: 1 addition & 1 deletion CRM/Mailing/BAO/Mailing.php
Original file line number Diff line number Diff line change
Expand Up @@ -2102,7 +2102,7 @@ public static function &report($id, $skipDetails = FALSE, $isSMS = FALSE) {
'link_unique' => CRM_Utils_System::url($path, "reset=1&event=click&mid=$mailing_id&uid={$mailing->id}&distinct=1"),
'clicks' => $mailing->clicks,
'unique' => $mailing->unique_clicks,
'rate' => CRM_Utils_Array::value('delivered', $report['event_totals']) ? (100.0 * $mailing->unique_clicks) / $report['event_totals']['delivered'] : 0,
'rate' => !empty($report['event_totals']['delivered']) ? (100.0 * $mailing->unique_clicks) / $report['event_totals']['delivered'] : 0,
'report' => CRM_Report_Utils_Report::getNextUrl('mailing/clicks', "reset=1&mailing_id_value={$mailing_id}&url_value={$mailing->url}", FALSE, TRUE),
];
}
Expand Down
4 changes: 2 additions & 2 deletions CRM/Price/BAO/PriceField.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,15 @@ public static function create(&$params) {
'membership_type_id' => CRM_Utils_Array::value($index, CRM_Utils_Array::value('membership_type_id', $params), NULL),
'weight' => $params['option_weight'][$index],
'is_active' => 1,
'is_default' => CRM_Utils_Array::value($params['option_weight'][$index], $defaultArray) ? $defaultArray[$params['option_weight'][$index]] : 0,
'is_default' => !empty($defaultArray[$params['option_weight'][$index]]) ? $defaultArray[$params['option_weight'][$index]] : 0,
'membership_num_terms' => NULL,
'non_deductible_amount' => CRM_Utils_Array::value('non_deductible_amount', $params),
'visibility_id' => CRM_Utils_Array::value($index, CRM_Utils_Array::value('option_visibility_id', $params), self::getVisibilityOptionID('public')),
];

if ($options['membership_type_id']) {
$options['membership_num_terms'] = CRM_Utils_Array::value($index, CRM_Utils_Array::value('membership_num_terms', $params), 1);
$options['is_default'] = CRM_Utils_Array::value($params['membership_type_id'][$index], $defaultArray) ? $defaultArray[$params['membership_type_id'][$index]] : 0;
$options['is_default'] = !empty($defaultArray[$params['membership_type_id'][$index]]) ? $defaultArray[$params['membership_type_id'][$index]] : 0;
}

if (CRM_Utils_Array::value($index, CRM_Utils_Array::value('option_financial_type_id', $params))) {
Expand Down
8 changes: 4 additions & 4 deletions api/v3/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -608,13 +608,13 @@ function _civicrm_api3_buildprofile_submitfields($profileID, $optionsBehaviour =
}

/**
* @param $a
* @param $b
* @param array $a
* @param array $b
*
* @return bool
*/
function _civicrm_api3_order_by_weight($a, $b) {
return CRM_Utils_Array::value('weight', $b) < CRM_Utils_Array::value('weight', $a) ? TRUE : FALSE;
return ($b['weight'] ?? 0) < ($a['weight'] ?? 0);
}

/**
Expand Down Expand Up @@ -731,7 +731,7 @@ function _civicrm_api3_profile_appendaliases($values, $entity) {
}
//special case on membership & contribution - can't see how to handle in a generic way
if (in_array($entity, ['membership', 'contribution'])) {
$values['send_receipt'] = ['title' => 'Send Receipt', 'type' => (int) 16];
$values['send_receipt'] = ['title' => 'Send Receipt', 'type' => 16];
}
return $values;
}
Expand Down