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
3 changes: 2 additions & 1 deletion CRM/Banking/BAO/BankTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ public function getDataParsed($update = FALSE) {
if ($this->_decoded_data_parsed == NULL || $update) {
if (isset($this->data_parsed)) {
$this->_decoded_data_parsed = json_decode($this->data_parsed, TRUE);
} else {
}
else {
$this->_decoded_data_parsed = [];
}
}
Expand Down
18 changes: 11 additions & 7 deletions CRM/Banking/PluginImpl/Matcher/AccountLookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
if (!empty($data[$prefix . $type_name])) {
// we have an account reference => look it up
$ba_id = $this->lookupBankAccount($type_id, $data[$prefix . $type_name], $context);
if ($ba_id) {

Check failure on line 105 in CRM/Banking/PluginImpl/Matcher/AccountLookup.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.4 prefer-stable

Only booleans are allowed in an if condition, string|null given.

Check failure on line 105 in CRM/Banking/PluginImpl/Matcher/AccountLookup.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.1 prefer-lowest

Only booleans are allowed in an if condition, string|null given.

Check failure on line 105 in CRM/Banking/PluginImpl/Matcher/AccountLookup.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.1 prefer-stable

Only booleans are allowed in an if condition, string|null given.

Check failure on line 105 in CRM/Banking/PluginImpl/Matcher/AccountLookup.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.4 prefer-lowest

Only booleans are allowed in an if condition, string|null given.
if ($ba_id != $btx->$ba_attribute) {
// the account differs => set and return
$btx->$ba_attribute = $ba_id;
Expand All @@ -121,13 +121,13 @@
/**
* cached bank account lookup
*/
protected function lookupBankAccount($type_id, string $reference, CRM_Banking_Matcher_Context $context) : ?string {
protected function lookupBankAccount($type_id, string $reference, CRM_Banking_Matcher_Context $context): ?string {
$account_cache = $context->getCachedEntry('analyser_account.cached_references');
if ($account_cache === NULL) {

Check failure on line 126 in CRM/Banking/PluginImpl/Matcher/AccountLookup.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.4 prefer-stable

Identical: Possible insane comparison between null and the.

Check failure on line 126 in CRM/Banking/PluginImpl/Matcher/AccountLookup.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.1 prefer-lowest

Identical: Possible insane comparison between null and the.

Check failure on line 126 in CRM/Banking/PluginImpl/Matcher/AccountLookup.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.1 prefer-stable

Identical: Possible insane comparison between null and the.

Check failure on line 126 in CRM/Banking/PluginImpl/Matcher/AccountLookup.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.4 prefer-lowest

Identical: Possible insane comparison between null and the.
$account_cache = [];
}

if (!isset($account_cache[$type_id][$reference])) {

Check failure on line 130 in CRM/Banking/PluginImpl/Matcher/AccountLookup.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.4 prefer-stable

Cannot access offset mixed on array{}|the.

Check failure on line 130 in CRM/Banking/PluginImpl/Matcher/AccountLookup.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.1 prefer-lowest

Cannot access offset mixed on array{}|the.

Check failure on line 130 in CRM/Banking/PluginImpl/Matcher/AccountLookup.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.1 prefer-stable

Cannot access offset mixed on array{}|the.

Check failure on line 130 in CRM/Banking/PluginImpl/Matcher/AccountLookup.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.4 prefer-lowest

Cannot access offset mixed on array{}|the.
// look up the account
try {
$result = civicrm_api3('BankingAccountReference', 'getsingle', [
Expand All @@ -135,20 +135,23 @@
'reference_type_id' => $type_id,
]);
if (!empty($result['is_error']) || empty($result['ba_id'])) {
$account_cache[$type_id][$reference] = NULL;

Check failure on line 138 in CRM/Banking/PluginImpl/Matcher/AccountLookup.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.4 prefer-stable

Cannot access offset mixed on array{}|the.

Check failure on line 138 in CRM/Banking/PluginImpl/Matcher/AccountLookup.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.1 prefer-lowest

Cannot access offset mixed on array{}|the.

Check failure on line 138 in CRM/Banking/PluginImpl/Matcher/AccountLookup.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.1 prefer-stable

Cannot access offset mixed on array{}|the.

Check failure on line 138 in CRM/Banking/PluginImpl/Matcher/AccountLookup.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.4 prefer-lowest

Cannot access offset mixed on array{}|the.
} else {
}
else {
$account_cache[$type_id][$reference] = $result['ba_id'];

Check failure on line 141 in CRM/Banking/PluginImpl/Matcher/AccountLookup.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.4 prefer-stable

Cannot access offset mixed on array{}|the.

Check failure on line 141 in CRM/Banking/PluginImpl/Matcher/AccountLookup.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.1 prefer-lowest

Cannot access offset mixed on array{}|the.

Check failure on line 141 in CRM/Banking/PluginImpl/Matcher/AccountLookup.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.1 prefer-stable

Cannot access offset mixed on array{}|the.

Check failure on line 141 in CRM/Banking/PluginImpl/Matcher/AccountLookup.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.4 prefer-lowest

Cannot access offset mixed on array{}|the.
}
$context->setCachedEntry('analyser_account.cached_references', $account_cache);
} catch (CRM_Core_Exception $e) {
$this->logMessage("Error while looking up bank account reference: " . $e->getMessage());
return null;
}
catch (CRM_Core_Exception $e) {
$this->logMessage('Error while looking up bank account reference: ' . $e->getMessage());
return NULL;
}

// finally set the account for the btx
return $account_cache[$type_id][$reference];
} else {
return null;
}
else {
return NULL;
}
}

Expand All @@ -164,4 +167,5 @@
}
return $types;
}

}
9 changes: 5 additions & 4 deletions CRM/Banking/PluginImpl/Matcher/ExistingContribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
*
* phpcs:disable Generic.Metrics.CyclomaticComplexity.TooHigh
*/
public function rateContribution($contribution, $context) : int|float {
public function rateContribution($contribution, $context): int|float {
// phpcs:enable
$config = $this->_plugin_config;
$parsed_data = $context->btx->getDataParsed();
Expand Down Expand Up @@ -284,7 +284,7 @@
*
* @return array with contributions
*/
public function getPotentialContributionsForContact($contact_id, CRM_Banking_Matcher_Context $context) : array {
public function getPotentialContributionsForContact($contact_id, CRM_Banking_Matcher_Context $context): array {

Check failure on line 287 in CRM/Banking/PluginImpl/Matcher/ExistingContribution.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.4 prefer-stable

Method CRM_Banking_PluginImpl_Matcher_ExistingContribution::getPotentialContributionsForContact() return type has no value type specified in iterable type array.

Check failure on line 287 in CRM/Banking/PluginImpl/Matcher/ExistingContribution.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.1 prefer-lowest

Method CRM_Banking_PluginImpl_Matcher_ExistingContribution::getPotentialContributionsForContact() return type has no value type specified in iterable type array.

Check failure on line 287 in CRM/Banking/PluginImpl/Matcher/ExistingContribution.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.1 prefer-stable

Method CRM_Banking_PluginImpl_Matcher_ExistingContribution::getPotentialContributionsForContact() return type has no value type specified in iterable type array.

Check failure on line 287 in CRM/Banking/PluginImpl/Matcher/ExistingContribution.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.4 prefer-lowest

Method CRM_Banking_PluginImpl_Matcher_ExistingContribution::getPotentialContributionsForContact() return type has no value type specified in iterable type array.
$config = $this->_plugin_config;

// check in cache
Expand All @@ -292,7 +292,7 @@
$cache_key = "_contributions_{$contact_id}_{$range_back}_{$config->received_date_check}";
$contributions = $context->getCachedEntry($cache_key);
if ($contributions != NULL) {
return $contributions;

Check failure on line 295 in CRM/Banking/PluginImpl/Matcher/ExistingContribution.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.1 prefer-lowest

Method CRM_Banking_PluginImpl_Matcher_ExistingContribution::getPotentialContributionsForContact() should return array but returns the.

Check failure on line 295 in CRM/Banking/PluginImpl/Matcher/ExistingContribution.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.4 prefer-lowest

Method CRM_Banking_PluginImpl_Matcher_ExistingContribution::getPotentialContributionsForContact() should return array but returns the.
}

$contributions = [];
Expand All @@ -318,7 +318,7 @@
*
* @return array a list of with contribution status IDs
*/
protected function getAcceptedContributionStatusIDs() : array {
protected function getAcceptedContributionStatusIDs(): array {
$accepted_status_ids = [];
foreach ($this->_plugin_config->accepted_contribution_states as $status_name) {
$status_id = banking_helper_optionvalue_by_groupname_and_name('contribution_status', $status_name);
Expand Down Expand Up @@ -386,7 +386,8 @@
$contributions[$contribution['id']] = $contribution_probability;
$contribution2contact[$contribution['id']] = $contact_id;
$contribution2totalamount[$contribution['id']] = $contribution['total_amount'];
} else {
}
else {
$this->logMessage("Potentially relevant contribution [{$contribution['id']}] dropped, probability too low.", LOG_DEBUG);
}
}
Expand Down
2 changes: 1 addition & 1 deletion CRM/Banking/PluginImpl/Matcher/RegexAnalyser.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function analyse(CRM_Banking_BAO_BankTransaction $btx, CRM_Banking_Matche
foreach ($variables as $variable) {
if (preg_match("#\[\[$variable\]\]#", $pattern)) {
$value = $this->getVariable($variable);
$pattern = preg_replace("#\[\[$variable\]\]#", print_r($value, true), $pattern);
$pattern = preg_replace("#\[\[$variable\]\]#", print_r($value, TRUE), $pattern);
}
}

Expand Down
2 changes: 1 addition & 1 deletion CRM/Banking/PluginImpl/Matcher/SepaMandate.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public function match(CRM_Banking_BAO_BankTransaction $btx, CRM_Banking_Matcher_
WHERE contribution_recur_id = {$contribution_recur_id}
AND receive_date <= DATE('$latest_date')
AND receive_date >= DATE('$earliest_date');";
$this->logMessage("SepaMandate Query: " . $find_contribution_query, 'debug');
$this->logMessage('SepaMandate Query: ' . $find_contribution_query, 'debug');
$found_contribution = CRM_Core_DAO::executeQuery($find_contribution_query);
while ($found_contribution->fetch()) {
if (!$contribution_id) {
Expand Down
17 changes: 6 additions & 11 deletions CRM/Banking/PluginModel/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private function setDAO($plugin_dao) {
$this->_plugin_title = $plugin_dao->description;
$this->_plugin_name = $plugin_dao->name;
$this->_plugin_config = json_decode($plugin_dao->config);
if (is_null($this->_plugin_config)) {
if (NULL === $this->_plugin_config) {
CRM_Core_Error::statusBounce('Configuration for CiviBanking plugin (id: ' . $plugin_dao->id . ') is not a valid JSON string.');
$this->_plugin_config = [];
}
Expand All @@ -78,8 +78,7 @@ private function setDAO($plugin_dao) {
/**
* Generic logging function for any plugin
*/
public function logMessage($message, $log_level = 'debug'): void
{
public function logMessage($message, $log_level = 'debug'): void {
// TODO: evaluate log_level
if (isset($this->_plugin_config->log_level) && $this->_plugin_config->log_level != 'off') {
$this->logger->log("[{$this->_plugin_id}]: {$message}", $this->_plugin_config->log_level);
Expand All @@ -89,8 +88,7 @@ public function logMessage($message, $log_level = 'debug'): void
/**
* Generic logging function for any plugin
*/
public function logTime($process, $timer): void
{
public function logTime($process, $timer): void {
// TODO: evaluate log_level
if (isset($this->_plugin_config->log_level) && $this->_plugin_config->log_level != 'off') {
$this->logger->logTime("[{$this->_plugin_id}]: {$process}", $timer);
Expand All @@ -106,8 +104,7 @@ public function logTime($process, $timer): void
*
* TODO: data format? float [0..1]?
*/
public function setProgressCallback($callback): void
{
public function setProgressCallback($callback): void {
// TODO: sanity checks?
$this->_progress_callback = $callback;
$this->_progress_log = [];
Expand Down Expand Up @@ -210,8 +207,7 @@ public function getConfig() {
*
* @return array of contacts
*/
public function findContact($attributes): array
{
public function findContact($attributes): array {
// TODO implement
return [];
}
Expand All @@ -223,8 +219,7 @@ public function findContact($attributes): array
*
* @return array of contacts
*/
public function findContribution($attributes): array
{
public function findContribution($attributes): array {
// TODO implement
return [];
}
Expand Down
3 changes: 1 addition & 2 deletions CRM/Banking/PluginModel/BtxBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ abstract class CRM_Banking_PluginModel_BtxBase extends CRM_Banking_PluginModel_B
*
* phpcs:disable Generic.Metrics.CyclomaticComplexity.MaxExceeded, Generic.Metrics.NestingLevel.TooHigh
*/
public function requiredValuesPresent(CRM_Banking_BAO_BankTransaction &$btx, $required_values_override = NULL): bool
{
public function requiredValuesPresent(CRM_Banking_BAO_BankTransaction &$btx, $required_values_override = NULL): bool {
// phpcs:enable
$config = $this->_plugin_config;

Expand Down
Loading