Various PSR12 code cleanup

This commit is contained in:
James Cole
2022-12-29 19:42:26 +01:00
parent dbf3e76ecc
commit 6cfdc58cb1
415 changed files with 7462 additions and 6874 deletions

View File

@@ -52,8 +52,8 @@ class RecurrenceUpdateService
*
* TODO if the user updates the type, the accounts must be validated again.
*
* @param Recurrence $recurrence
* @param array $data
* @param Recurrence $recurrence
* @param array $data
*
* @return Recurrence
* @throws FireflyException
@@ -79,7 +79,7 @@ class RecurrenceUpdateService
$recurrence->repetitions = 0;
}
if (array_key_exists('nr_of_repetitions', $info)) {
if (0 !== (int) $info['nr_of_repetitions']) {
if (0 !== (int)$info['nr_of_repetitions']) {
$recurrence->repeat_until = null;
}
$recurrence->repetitions = $info['nr_of_repetitions'];
@@ -115,8 +115,8 @@ class RecurrenceUpdateService
}
/**
* @param Recurrence $recurrence
* @param string $text
* @param Recurrence $recurrence
* @param string $text
*/
private function setNoteText(Recurrence $recurrence, string $text): void
{
@@ -142,8 +142,8 @@ class RecurrenceUpdateService
/**
*
* @param Recurrence $recurrence
* @param array $repetitions
* @param Recurrence $recurrence
* @param array $repetitions
*
* @throws FireflyException
*/
@@ -187,8 +187,8 @@ class RecurrenceUpdateService
}
/**
* @param Recurrence $recurrence
* @param array $data
* @param Recurrence $recurrence
* @param array $data
*
* @return RecurrenceRepetition|null
*/
@@ -201,11 +201,12 @@ class RecurrenceUpdateService
return $recurrence->recurrenceRepetitions()->first();
}
// find it:
$fields = ['id' => 'id',
'type' => 'repetition_type',
'moment' => 'repetition_moment',
'skip' => 'repetition_skip',
'weekend' => 'weekend',
$fields = [
'id' => 'id',
'type' => 'repetition_type',
'moment' => 'repetition_moment',
'skip' => 'repetition_skip',
'weekend' => 'weekend',
];
$query = $recurrence->recurrenceRepetitions();
foreach ($fields as $field => $column) {
@@ -220,8 +221,8 @@ class RecurrenceUpdateService
/**
* TODO this method is very complex.
*
* @param Recurrence $recurrence
* @param array $transactions
* @param Recurrence $recurrence
* @param array $transactions
*
* @throws FireflyException
*/
@@ -258,7 +259,7 @@ class RecurrenceUpdateService
unset($current['currency_id'], $current['currency_code']);
}
if (null !== $currency) {
$current['currency_id'] = (int) $currency->id;
$current['currency_id'] = (int)$currency->id;
}
if (array_key_exists('foreign_currency_id', $current) || array_key_exists('foreign_currency_code', $current)) {
$foreignCurrency = $currencyFactory->find($current['foreign_currency_id'] ?? null, $currency['foreign_currency_code'] ?? null);
@@ -267,7 +268,7 @@ class RecurrenceUpdateService
unset($current['foreign_currency_id'], $currency['foreign_currency_code']);
}
if (null !== $foreignCurrency) {
$current['foreign_currency_id'] = (int) $foreignCurrency->id;
$current['foreign_currency_id'] = (int)$foreignCurrency->id;
}
// update fields
@@ -288,35 +289,35 @@ class RecurrenceUpdateService
}
// update meta data
if (array_key_exists('budget_id', $current)) {
$this->setBudget($match, (int) $current['budget_id']);
$this->setBudget($match, (int)$current['budget_id']);
}
if (array_key_exists('bill_id', $current)) {
$this->setBill($match, (int) $current['bill_id']);
$this->setBill($match, (int)$current['bill_id']);
}
// reset category if name is set but empty:
// can be removed when v1 is retired.
if (array_key_exists('category_name', $current) && '' === (string) $current['category_name']) {
if (array_key_exists('category_name', $current) && '' === (string)$current['category_name']) {
$current['category_name'] = null;
$current['category_id'] = 0;
}
if (array_key_exists('category_id', $current)) {
$this->setCategory($match, (int) $current['category_id']);
$this->setCategory($match, (int)$current['category_id']);
}
if (array_key_exists('tags', $current) && is_array($current['tags'])) {
$this->updateTags($match, $current['tags']);
}
if (array_key_exists('piggy_bank_id', $current)) {
$this->updatePiggyBank($match, (int) $current['piggy_bank_id']);
$this->updatePiggyBank($match, (int)$current['piggy_bank_id']);
}
}
}
}
/**
* @param Recurrence $recurrence
* @param array $data
* @param Recurrence $recurrence
* @param array $data
*
* @return RecurrenceTransaction|null
*/