Skip to content
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
9 changes: 6 additions & 3 deletions CRM/Banking/PluginImpl/Importer/CSV.php
Original file line number Diff line number Diff line change
Expand Up @@ -412,10 +412,10 @@ protected function import_line($line, $line_nr, $progress, $header, $params) {
*/
protected function getValue($key, $btx, $line = NULL, $header = [], $params = []) {
// get value
if ($this->startsWith($key, '_constant:')) {
if ($this->startsWith((string) $key, '_constant:')) {
return substr($key, 10);
}
elseif ($this->startsWith($key, '_params:')) {
elseif ($this->startsWith((string) $key, '_params:')) {
$param_name = substr($key, 8);
return $params[$param_name] ?? '';
}
Expand Down Expand Up @@ -478,7 +478,10 @@ protected function apply_rule($rule, $line, &$btx, $header, $params) {
}

// execute the rule
if ($this->startsWith($rule->type, 'set')) {
if (!is_string($rule->type)) {
$this->logMessage('Rule type is missing or invalid', 'error');
}
elseif ($this->startsWith($rule->type, 'set')) {
// SET is a simple copy command:
$btx[$rule->to] = $value;

Expand Down
11 changes: 7 additions & 4 deletions CRM/Banking/PluginImpl/Importer/XML.php
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ protected function import_payment($payment_spec, $payment_node, $stmt_data, $ind

// copy tx. prefixed payment data
foreach ($stmt_data as $key => $value) {
if ($this->startsWith($key, 'tx.')) {
if ($this->startsWith((string) $key, 'tx.')) {
$data[substr($key, 3)] = $value;
}
}
Expand Down Expand Up @@ -467,7 +467,10 @@ protected function apply_rule($rule, $context, &$data) {
}

// execute the rule
if ($this->startsWith($rule->type, 'set')) {
if (!is_string($rule->type)) {
$this->logMessage('Rule type is missing or invalid', 'error');
}
elseif ($this->startsWith($rule->type, 'set')) {
// SET is a simple copy command:
$value = $this->getValue($rule->from, $data, $context);
$data[$rule->to] = $value;
Expand Down Expand Up @@ -583,10 +586,10 @@ protected function apply_rule($rule, $context, &$data) {
*/
protected function getValue($key, $data, $context = NULL) {
// get value
if ($this->startsWith($key, '_constant:')) {
if ($this->startsWith((string) $key, '_constant:')) {
return substr($key, 10);
}
elseif ($this->startsWith($key, 'xpath:')) {
elseif ($this->startsWith((string) $key, 'xpath:')) {
$path = substr($key, 6);
$result = $this->xpath->evaluate($path, $context);
if (get_class($result) == 'DOMNode') {
Expand Down
4 changes: 2 additions & 2 deletions CRM/Banking/PluginModel/Importer.php
Original file line number Diff line number Diff line change
Expand Up @@ -526,8 +526,8 @@ public function checkAndStoreBTX($btx, $progress, $params = []) {
/**
* helper function for prefix testing
*/
protected function startsWith($string, $prefix) {
return substr($string, 0, strlen($prefix)) === $prefix;
protected function startsWith(string $string, string $prefix): bool {
return str_starts_with($string, $prefix);
}

}
6 changes: 5 additions & 1 deletion api/v3/BankingTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@ function civicrm_api3_banking_transaction_get($params) {
function civicrm_api3_banking_transaction_deletelist($params) {
$result = ['tx_count' => 0, 'tx_batch_count' => 0];

// first, delete the indivdual transactions
if (is_int($params['s_list'] ?? NULL)) {
$params['s_list'] = (string) $params['s_list'];
}

// first, delete the individual transactions
$tx_ids = _civicrm_api3_banking_transaction_getTxIDs($params);
foreach ($tx_ids as $tx_id) {
civicrm_api3('BankingTransaction', 'delete', ['id' => $tx_id]);
Expand Down
18 changes: 0 additions & 18 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -10495,24 +10495,6 @@ parameters:
count: 1
path: CRM/Banking/PluginModel/Importer.php

-
message: '#^Method CRM_Banking_PluginModel_Importer\:\:startsWith\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: CRM/Banking/PluginModel/Importer.php

-
message: '#^Method CRM_Banking_PluginModel_Importer\:\:startsWith\(\) has parameter \$prefix with no type specified\.$#'
identifier: missingType.parameter
count: 1
path: CRM/Banking/PluginModel/Importer.php

-
message: '#^Method CRM_Banking_PluginModel_Importer\:\:startsWith\(\) has parameter \$string with no type specified\.$#'
identifier: missingType.parameter
count: 1
path: CRM/Banking/PluginModel/Importer.php

-
message: '#^Only booleans are allowed in &&, string\|null given on the left side\.$#'
identifier: booleanAnd.leftNotBoolean
Expand Down