Mild code cleanup.

This commit is contained in:
James Cole 2023-08-26 18:42:18 +02:00
parent 63297c43b7
commit 66cc3f48bc
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80
10 changed files with 85 additions and 79 deletions

View File

@ -379,16 +379,16 @@
}, },
{ {
"name": "friendsofphp/php-cs-fixer", "name": "friendsofphp/php-cs-fixer",
"version": "v3.22.0", "version": "v3.23.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git",
"reference": "92b019f6c8d79aa26349d0db7671d37440dc0ff3" "reference": "35af3cbbacfa91e164b252a28ec0b644f1ed4e78"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/92b019f6c8d79aa26349d0db7671d37440dc0ff3", "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/35af3cbbacfa91e164b252a28ec0b644f1ed4e78",
"reference": "92b019f6c8d79aa26349d0db7671d37440dc0ff3", "reference": "35af3cbbacfa91e164b252a28ec0b644f1ed4e78",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -464,7 +464,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues",
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.22.0" "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.23.0"
}, },
"funding": [ "funding": [
{ {
@ -472,7 +472,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2023-07-16T23:08:06+00:00" "time": "2023-08-14T12:27:35+00:00"
}, },
{ {
"name": "psr/cache", "name": "psr/cache",
@ -745,16 +745,16 @@
}, },
{ {
"name": "symfony/console", "name": "symfony/console",
"version": "v6.3.2", "version": "v6.3.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/console.git", "url": "https://github.com/symfony/console.git",
"reference": "aa5d64ad3f63f2e48964fc81ee45cb318a723898" "reference": "eca495f2ee845130855ddf1cf18460c38966c8b6"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/aa5d64ad3f63f2e48964fc81ee45cb318a723898", "url": "https://api.github.com/repos/symfony/console/zipball/eca495f2ee845130855ddf1cf18460c38966c8b6",
"reference": "aa5d64ad3f63f2e48964fc81ee45cb318a723898", "reference": "eca495f2ee845130855ddf1cf18460c38966c8b6",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -815,7 +815,7 @@
"terminal" "terminal"
], ],
"support": { "support": {
"source": "https://github.com/symfony/console/tree/v6.3.2" "source": "https://github.com/symfony/console/tree/v6.3.4"
}, },
"funding": [ "funding": [
{ {
@ -831,7 +831,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2023-07-19T20:17:28+00:00" "time": "2023-08-16T10:10:12+00:00"
}, },
{ {
"name": "symfony/deprecation-contracts", "name": "symfony/deprecation-contracts",
@ -1744,16 +1744,16 @@
}, },
{ {
"name": "symfony/process", "name": "symfony/process",
"version": "v6.3.2", "version": "v6.3.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/process.git", "url": "https://github.com/symfony/process.git",
"reference": "c5ce962db0d9b6e80247ca5eb9af6472bd4d7b5d" "reference": "0b5c29118f2e980d455d2e34a5659f4579847c54"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/process/zipball/c5ce962db0d9b6e80247ca5eb9af6472bd4d7b5d", "url": "https://api.github.com/repos/symfony/process/zipball/0b5c29118f2e980d455d2e34a5659f4579847c54",
"reference": "c5ce962db0d9b6e80247ca5eb9af6472bd4d7b5d", "reference": "0b5c29118f2e980d455d2e34a5659f4579847c54",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1785,7 +1785,7 @@
"description": "Executes commands in sub-processes", "description": "Executes commands in sub-processes",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"support": { "support": {
"source": "https://github.com/symfony/process/tree/v6.3.2" "source": "https://github.com/symfony/process/tree/v6.3.4"
}, },
"funding": [ "funding": [
{ {
@ -1801,7 +1801,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2023-07-12T16:00:22+00:00" "time": "2023-08-07T10:39:22+00:00"
}, },
{ {
"name": "symfony/service-contracts", "name": "symfony/service-contracts",

View File

@ -1,4 +1,6 @@
<?php <?php
declare(strict_types=1);
/* /*
* StoreController.php * StoreController.php
* Copyright (c) 2023 james@firefly-iii.org * Copyright (c) 2023 james@firefly-iii.org

View File

@ -181,8 +181,8 @@ class BudgetLimitHandler
); );
// overlap in days: // overlap in days:
$limitPeriod = Period::make( $limitPeriod = Period::make(
$budgetLimit->start_date, $budgetLimit->start_date,
$budgetLimit->end_date, $budgetLimit->end_date,
precision : Precision::DAY(), precision : Precision::DAY(),
boundaries: Boundaries::EXCLUDE_NONE() boundaries: Boundaries::EXCLUDE_NONE()
); );
@ -227,8 +227,8 @@ class BudgetLimitHandler
return '0'; return '0';
} }
$limitPeriod = Period::make( $limitPeriod = Period::make(
$budgetLimit->start_date, $budgetLimit->start_date,
$budgetLimit->end_date, $budgetLimit->end_date,
precision : Precision::DAY(), precision : Precision::DAY(),
boundaries: Boundaries::EXCLUDE_NONE() boundaries: Boundaries::EXCLUDE_NONE()
); );

View File

@ -138,7 +138,7 @@ class IndexController extends Controller
// get budgeted for default currency: // get budgeted for default currency:
if (0 === count($availableBudgets)) { if (0 === count($availableBudgets)) {
$budgeted = $this->blRepository->budgeted($start, $end, $defaultCurrency,); $budgeted = $this->blRepository->budgeted($start, $end, $defaultCurrency, );
$spentArr = $this->opsRepository->sumExpenses($start, $end, null, null, $defaultCurrency); $spentArr = $this->opsRepository->sumExpenses($start, $end, null, null, $defaultCurrency);
$spent = $spentArr[$defaultCurrency->id]['sum'] ?? '0'; $spent = $spentArr[$defaultCurrency->id]['sum'] ?? '0';
unset($spentArr); unset($spentArr);
@ -197,7 +197,7 @@ class IndexController extends Controller
$array['spent'] = $spentArr[$entry->transaction_currency_id]['sum'] ?? '0'; $array['spent'] = $spentArr[$entry->transaction_currency_id]['sum'] ?? '0';
// budgeted in period: // budgeted in period:
$budgeted = $this->blRepository->budgeted($entry->start_date, $entry->end_date, $entry->transactionCurrency,); $budgeted = $this->blRepository->budgeted($entry->start_date, $entry->end_date, $entry->transactionCurrency, );
$array['budgeted'] = $budgeted; $array['budgeted'] = $budgeted;
$availableBudgets[] = $array; $availableBudgets[] = $array;
unset($spentArr); unset($spentArr);

View File

@ -87,11 +87,13 @@ class BoxController extends Controller
$availableBudgets = $availableBudgets->filter( $availableBudgets = $availableBudgets->filter(
static function (AvailableBudget $availableBudget) use ($currency) { static function (AvailableBudget $availableBudget) use ($currency) {
if ($availableBudget->transaction_currency_id === $currency->id) { if ($availableBudget->transaction_currency_id === $currency->id) {
app('log')->debug(sprintf('Will include AB #%d: from %s-%s amount %s', app('log')->debug(sprintf(
$availableBudget->id, 'Will include AB #%d: from %s-%s amount %s',
$availableBudget->start_date->format('Y-m-d'), $availableBudget->id,
$availableBudget->end_date->format('Y-m-d'), $availableBudget->start_date->format('Y-m-d'),
$availableBudget->amount)); $availableBudget->end_date->format('Y-m-d'),
$availableBudget->amount
));
return $availableBudget; return $availableBudget;
} }

View File

@ -43,7 +43,9 @@ class NewAccessToken extends Notification
* *
* @return void * @return void
*/ */
public function __construct() {} public function __construct()
{
}
/** /**
* Get the array representation of the notification. * Get the array representation of the notification.

View File

@ -1,4 +1,6 @@
<?php <?php
declare(strict_types=1);
/* /*
* UrlValidator.php * UrlValidator.php
* Copyright (c) 2023 james@firefly-iii.org * Copyright (c) 2023 james@firefly-iii.org
@ -26,7 +28,6 @@ namespace FireflyIII\Support\Notifications;
*/ */
class UrlValidator class UrlValidator
{ {
/** /**
* @param string $url * @param string $url
* *

View File

@ -259,14 +259,14 @@ class OperatorQuerySearch implements SearchInterface
default: default:
Log::error(sprintf('No such operator: %s', $operator)); Log::error(sprintf('No such operator: %s', $operator));
throw new FireflyException(sprintf('Unsupported search operator: "%s"', $operator)); throw new FireflyException(sprintf('Unsupported search operator: "%s"', $operator));
// some search operators are ignored, basically: // some search operators are ignored, basically:
case 'user_action': case 'user_action':
Log::info(sprintf('Ignore search operator "%s"', $operator)); Log::info(sprintf('Ignore search operator "%s"', $operator));
return false; return false;
// //
// all account related searches: // all account related searches:
// //
case 'account_is': case 'account_is':
$this->searchAccount($value, 3, 4); $this->searchAccount($value, 3, 4);
break; break;
@ -497,9 +497,9 @@ class OperatorQuerySearch implements SearchInterface
$this->collector->findNothing(); $this->collector->findNothing();
} }
break; break;
// //
// cash account // cash account
// //
case 'source_is_cash': case 'source_is_cash':
$account = $this->getCashAccount(); $account = $this->getCashAccount();
$this->collector->setSourceAccounts(new Collection([$account])); $this->collector->setSourceAccounts(new Collection([$account]));
@ -524,9 +524,9 @@ class OperatorQuerySearch implements SearchInterface
$account = $this->getCashAccount(); $account = $this->getCashAccount();
$this->collector->excludeAccounts(new Collection([$account])); $this->collector->excludeAccounts(new Collection([$account]));
break; break;
// //
// description // description
// //
case 'description_starts': case 'description_starts':
$this->collector->descriptionStarts([$value]); $this->collector->descriptionStarts([$value]);
break; break;
@ -553,9 +553,9 @@ class OperatorQuerySearch implements SearchInterface
case '-description_is': case '-description_is':
$this->collector->descriptionIsNot($value); $this->collector->descriptionIsNot($value);
break; break;
// //
// currency // currency
// //
case 'currency_is': case 'currency_is':
$currency = $this->findCurrency($value); $currency = $this->findCurrency($value);
if (null !== $currency) { if (null !== $currency) {
@ -592,9 +592,9 @@ class OperatorQuerySearch implements SearchInterface
$this->collector->findNothing(); $this->collector->findNothing();
} }
break; break;
// //
// attachments // attachments
// //
case 'has_attachments': case 'has_attachments':
case '-has_no_attachments': case '-has_no_attachments':
Log::debug('Set collector to filter on attachments.'); Log::debug('Set collector to filter on attachments.');
@ -605,8 +605,8 @@ class OperatorQuerySearch implements SearchInterface
Log::debug('Set collector to filter on NO attachments.'); Log::debug('Set collector to filter on NO attachments.');
$this->collector->hasNoAttachments(); $this->collector->hasNoAttachments();
break; break;
// //
// categories // categories
case '-has_any_category': case '-has_any_category':
case 'has_no_category': case 'has_no_category':
$this->collector->withoutCategory(); $this->collector->withoutCategory();
@ -684,9 +684,9 @@ class OperatorQuerySearch implements SearchInterface
$this->collector->findNothing(); $this->collector->findNothing();
} }
break; break;
// //
// budgets // budgets
// //
case '-has_any_budget': case '-has_any_budget':
case 'has_no_budget': case 'has_no_budget':
$this->collector->withoutBudget(); $this->collector->withoutBudget();
@ -765,9 +765,9 @@ class OperatorQuerySearch implements SearchInterface
$this->collector->findNothing(); $this->collector->findNothing();
} }
break; break;
// //
// bill // bill
// //
case '-has_any_bill': case '-has_any_bill':
case 'has_no_bill': case 'has_no_bill':
$this->collector->withoutBill(); $this->collector->withoutBill();
@ -844,9 +844,9 @@ class OperatorQuerySearch implements SearchInterface
$this->collector->findNothing(); $this->collector->findNothing();
} }
break; break;
// //
// tags // tags
// //
case '-has_any_tag': case '-has_any_tag':
case 'has_no_tag': case 'has_no_tag':
$this->collector->withoutTags(); $this->collector->withoutTags();
@ -874,9 +874,9 @@ class OperatorQuerySearch implements SearchInterface
$this->collector->setWithoutSpecificTags($result); $this->collector->setWithoutSpecificTags($result);
} }
break; break;
// //
// notes // notes
// //
case 'notes_contains': case 'notes_contains':
$this->collector->notesContain($value); $this->collector->notesContain($value);
break; break;
@ -915,9 +915,9 @@ class OperatorQuerySearch implements SearchInterface
case '-reconciled': case '-reconciled':
$this->collector->isNotReconciled(); $this->collector->isNotReconciled();
break; break;
// //
// amount // amount
// //
case 'amount_is': case 'amount_is':
// strip comma's, make dots. // strip comma's, make dots.
Log::debug(sprintf('Original value "%s"', $value)); Log::debug(sprintf('Original value "%s"', $value));
@ -988,9 +988,9 @@ class OperatorQuerySearch implements SearchInterface
Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $amount)); Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $amount));
$this->collector->foreignAmountMore($amount); $this->collector->foreignAmountMore($amount);
break; break;
// //
// transaction type // transaction type
// //
case 'transaction_type': case 'transaction_type':
$this->collector->setTypes([ucfirst($value)]); $this->collector->setTypes([ucfirst($value)]);
Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $value)); Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $value));
@ -999,9 +999,9 @@ class OperatorQuerySearch implements SearchInterface
$this->collector->excludeTypes([ucfirst($value)]); $this->collector->excludeTypes([ucfirst($value)]);
Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $value)); Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $value));
break; break;
// //
// dates // dates
// //
case '-date_on': case '-date_on':
case 'date_on': case 'date_on':
$range = $this->parseDateRange($operator, $value); $range = $this->parseDateRange($operator, $value);
@ -1151,9 +1151,9 @@ class OperatorQuerySearch implements SearchInterface
$range = $this->parseDateRange($operator, $value); $range = $this->parseDateRange($operator, $value);
$this->setObjectDateAfterParams('updated_at', $range); $this->setObjectDateAfterParams('updated_at', $range);
return false; return false;
// //
// external URL // external URL
// //
case '-any_external_url': case '-any_external_url':
case 'no_external_url': case 'no_external_url':
$this->collector->withoutExternalUrl(); $this->collector->withoutExternalUrl();
@ -1196,9 +1196,9 @@ class OperatorQuerySearch implements SearchInterface
$this->collector->externalUrlDoesNotEnd($value); $this->collector->externalUrlDoesNotEnd($value);
break; break;
// //
// other fields // other fields
// //
case 'external_id_is': case 'external_id_is':
$this->collector->setExternalId($value); $this->collector->setExternalId($value);
break; break;

View File

@ -302,7 +302,7 @@ class TransactionGroupTransformer extends AbstractTransformer
if (null === $string) { if (null === $string) {
return null; return null;
} }
// Log::debug(sprintf('Now in date("%s")', $string)); // Log::debug(sprintf('Now in date("%s")', $string));
if (10 === strlen($string)) { if (10 === strlen($string)) {
return Carbon::createFromFormat('Y-m-d', $string, config('app.timezone')); return Carbon::createFromFormat('Y-m-d', $string, config('app.timezone'));
} }

View File

@ -204,8 +204,7 @@ trait TransactionValidation
array $transaction, array $transaction,
string $transactionType, string $transactionType,
int $index int $index
): void ): void {
{
Log::debug('Now in sanityCheckForeignCurrency()'); Log::debug('Now in sanityCheckForeignCurrency()');
if (0 !== $validator->errors()->count()) { if (0 !== $validator->errors()->count()) {
Log::debug('Already have errors, return'); Log::debug('Already have errors, return');