Skip to content

Firefly III: a personal finances manager

Code cleaning stuff.

James Cole71fb9d8fa581
diff --git a/app/Api/V1/Controllers/AboutController.php b/app/Api/V1/Controllers/AboutController.php
index fa5dca3bbc..ed4ec478aa 100644
--- a/app/Api/V1/Controllers/AboutController.php
+++ b/app/Api/V1/Controllers/AboutController.php
@@ -60,7 +60,7 @@ class AboutController extends Controller
'driver' => $currentDriver,
];
- return response()->json(['data' => $data], 200)->header('Content-Type', 'application/vnd.api+json');
+ return response()->json(['data' => $data])->header('Content-Type', 'application/vnd.api+json');
}
/**
diff --git a/app/Api/V1/Controllers/AttachmentController.php b/app/Api/V1/Controllers/AttachmentController.php
index 6956758f57..14c6e59cda 100644
--- a/app/Api/V1/Controllers/AttachmentController.php
+++ b/app/Api/V1/Controllers/AttachmentController.php
@@ -100,7 +100,7 @@ class AttachmentController extends Controller
$quoted = sprintf('"%s"', addcslashes(basename($attachment->filename), '"\\'));
/** @var LaravelResponse $response */
- $response = response($content, 200);
+ $response = response($content);
$response
->header('Content-Description', 'File Transfer')
->header('Content-Type', 'application/octet-stream')
diff --git a/app/Api/V1/Controllers/AvailableBudgetController.php b/app/Api/V1/Controllers/AvailableBudgetController.php
index ccdd94b45d..5008f39387 100644
--- a/app/Api/V1/Controllers/AvailableBudgetController.php
+++ b/app/Api/V1/Controllers/AvailableBudgetController.php
@@ -24,12 +24,10 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Controllers;
use FireflyIII\Api\V1\Requests\AvailableBudgetRequest;
-use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Factory\TransactionCurrencyFactory;
use FireflyIII\Models\AvailableBudget;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
-use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Transformers\AvailableBudgetTransformer;
use FireflyIII\User;
use Illuminate\Http\JsonResponse;
@@ -48,8 +46,6 @@ use League\Fractal\Serializer\JsonApiSerializer;
*/
class AvailableBudgetController extends Controller
{
- /** @var CurrencyRepositoryInterface The currency repository */
- private $currencyRepository;
/** @var BudgetRepositoryInterface The budget repository */
private $repository;
@@ -62,9 +58,8 @@ class AvailableBudgetController extends Controller
$this->middleware(
function ($request, $next) {
/** @var User $user */
- $user = auth()->user();
- $this->repository = app(BudgetRepositoryInterface::class);
- $this->currencyRepository = app(CurrencyRepositoryInterface::class);
+ $user = auth()->user();
+ $this->repository = app(BudgetRepositoryInterface::class);
$this->repository->setUser($user);
return $next($request);
@@ -103,16 +98,18 @@ class AvailableBudgetController extends Controller
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
// get list of available budgets. Count it and split it.
- $collection = $this->repository->getAvailableBudgets();
+ $collection = $this->repository->getAvailableBudgets();
// filter list on start and end date, if present.
// TODO: put this in the query.
$start = $this->parameters->get('start');
- $end = $this->parameters->get('end');
- if(null !== $start && null !== $end) {
- $collection = $collection->filter(function(AvailableBudget $availableBudget) use ($start, $end) {
- return $availableBudget->start_date->gte($start) && $availableBudget->end_date->lte($end);
- });
+ $end = $this->parameters->get('end');
+ if (null !== $start && null !== $end) {
+ $collection = $collection->filter(
+ function (AvailableBudget $availableBudget) use ($start, $end) {
+ return $availableBudget->start_date->gte($start) && $availableBudget->end_date->lte($end);
+ }
+ );
}
$count = $collection->count();
@@ -164,7 +161,6 @@ class AvailableBudgetController extends Controller
* @param AvailableBudgetRequest $request
*
* @return JsonResponse
- * @throws FireflyException
*/
public function store(AvailableBudgetRequest $request): JsonResponse
{
diff --git a/app/Api/V1/Controllers/Chart/AccountController.php b/app/Api/V1/Controllers/Chart/AccountController.php
index fcb2a0739e..40adb4502c 100644
--- a/app/Api/V1/Controllers/Chart/AccountController.php
+++ b/app/Api/V1/Controllers/Chart/AccountController.php
@@ -156,6 +156,70 @@ class AccountController extends Controller
return response()->json($chartData);
}
+ /**
+ * @param Request $request
+ *
+ * @return JsonResponse
+ * @throws FireflyException
+ */
+ public function overview(Request $request): JsonResponse
+ {
+ // parameters for chart:
+ $start = (string)$request->get('start');
+ $end = (string)$request->get('end');
+ if ('' === $start || '' === $end) {
+ throw new FireflyException('Start and end are mandatory parameters.');
+ }
+
+ $start = Carbon::createFromFormat('Y-m-d', $start);
+ $end = Carbon::createFromFormat('Y-m-d', $end);
+
+ // user's preferences
+ $defaultSet = $this->repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET])->pluck('id')->toArray();
+ $frontPage = app('preferences')->get('frontPageAccounts', $defaultSet);
+ $default = app('amount')->getDefaultCurrency();
+ if (0 === \count($frontPage->data)) {
+ $frontPage->data = $defaultSet;
+ $frontPage->save();
+ }
+
+ // get accounts:
+ $accounts = $this->repository->getAccountsById($frontPage->data);
+ $chartData = [];
+ /** @var Account $account */
+ foreach ($accounts as $account) {
+ $currency = $this->repository->getAccountCurrency($account);
+ if (null === $currency) {
+ $currency = $default;
+ }
+ $currentSet = [
+ 'label' => $account->name,
+ 'currency_id' => $currency->id,
+ 'currency_code' => $currency->code,
+ 'currency_symbol' => $currency->symbol,
+ 'currency_decimal_places' => $currency->decimal_places,
+ 'type' => 'line', // line, area or bar
+ 'yAxisID' => 0, // 0, 1, 2
+ 'entries' => [],
+ ];
+
+ $currentStart = clone $start;
+ $range = app('steam')->balanceInRange($account, $start, clone $end);
+ $previous = round(array_values($range)[0], 12);
+ while ($currentStart <= $end) {
+ $format = $currentStart->format('Y-m-d');
+ $label = $currentStart->format('Y-m-d');
+ $balance = isset($range[$format]) ? round($range[$format], 12) : $previous;
+ $previous = $balance;
+ $currentStart->addDay();
+ $currentSet['entries'][$label] = $balance;
+ }
+ $chartData[] = $currentSet;
+ }
+
+ return response()->json($chartData);
+ }
+
/**
* @param Request $request
*
@@ -202,7 +266,7 @@ class AccountController extends Controller
// store the values in a temporary array.
$tempData[] = [
'name' => $accountNames[$accountId],
- 'difference' => bcmul($diff,'-1'),
+ 'difference' => bcmul($diff, '-1'),
'diff_float' => (float)$diff * -1,
'currency_id' => $currencyId,
];
@@ -244,70 +308,6 @@ class AccountController extends Controller
return response()->json($chartData);
}
- /**
- * @param Request $request
- *
- * @return JsonResponse
- * @throws FireflyException
- */
- public function overview(Request $request): JsonResponse
- {
- // parameters for chart:
- $start = (string)$request->get('start');
- $end = (string)$request->get('end');
- if ('' === $start || '' === $end) {
- throw new FireflyException('Start and end are mandatory parameters.');
- }
-
- $start = Carbon::createFromFormat('Y-m-d', $start);
- $end = Carbon::createFromFormat('Y-m-d', $end);
-
- // user's preferences
- $defaultSet = $this->repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET])->pluck('id')->toArray();
- $frontPage = app('preferences')->get('frontPageAccounts', $defaultSet);
- $default = app('amount')->getDefaultCurrency();
- if (0 === \count($frontPage->data)) {
- $frontPage->data = $defaultSet;
- $frontPage->save();
- }
-
- // get accounts:
- $accounts = $this->repository->getAccountsById($frontPage->data);
- $chartData = [];
- /** @var Account $account */
- foreach ($accounts as $account) {
- $currency = $this->repository->getAccountCurrency($account);
- if (null === $currency) {
- $currency = $default;
- }
- $currentSet = [
- 'label' => $account->name,
- 'currency_id' => $currency->id,
- 'currency_code' => $currency->code,
- 'currency_symbol' => $currency->symbol,
- 'currency_decimal_places' => $currency->decimal_places,
- 'type' => 'line', // line, area or bar
- 'yAxisID' => 0, // 0, 1, 2
- 'entries' => [],
- ];
-
- $currentStart = clone $start;
- $range = app('steam')->balanceInRange($account, $start, clone $end);
- $previous = round(array_values($range)[0], 12);
- while ($currentStart <= $end) {
- $format = $currentStart->format('Y-m-d');
- $label = $currentStart->format('Y-m-d');
- $balance = isset($range[$format]) ? round($range[$format], 12) : $previous;
- $previous = $balance;
- $currentStart->addDay();
- $currentSet['entries'][$label] = $balance;
- }
- $chartData[] = $currentSet;
- }
-
- return response()->json($chartData);
- }
-
/**
* Small helper function for the revenue and expense account charts.
* TODO should include Trait instead of doing this.
diff --git a/app/Api/V1/Controllers/Chart/AvailableBudgetController.php b/app/Api/V1/Controllers/Chart/AvailableBudgetController.php
index 8335acc3bc..c876d4b2df 100644
--- a/app/Api/V1/Controllers/Chart/AvailableBudgetController.php
+++ b/app/Api/V1/Controllers/Chart/AvailableBudgetController.php
@@ -30,7 +30,6 @@ use FireflyIII\Models\AvailableBudget;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\User;
use Illuminate\Http\JsonResponse;
-use Illuminate\Http\Request;
use Illuminate\Support\Collection;
/**
@@ -60,13 +59,11 @@ class AvailableBudgetController extends Controller
}
/**
- * @param Request $request
- *
* @param AvailableBudget $availableBudget
*
* @return JsonResponse
*/
- public function overview(Request $request, AvailableBudget $availableBudget): JsonResponse
+ public function overview(AvailableBudget $availableBudget): JsonResponse
{
$currency = $availableBudget->transactionCurrency;
$budgets = $this->repository->getActiveBudgets();
diff --git a/app/Api/V1/Controllers/ConfigurationController.php b/app/Api/V1/Controllers/ConfigurationController.php
index b3b3ab803f..12ee8c55dd 100644
--- a/app/Api/V1/Controllers/ConfigurationController.php
+++ b/app/Api/V1/Controllers/ConfigurationController.php
@@ -54,7 +54,6 @@ class ConfigurationController extends Controller
$admin = auth()->user();
if (!$this->repository->hasRole($admin, 'owner')) {
- /** @noinspection ExceptionsAnnotatingAndHandlingInspection */
throw new FireflyException('No access to method.'); // @codeCoverageIgnore
}
@@ -72,7 +71,7 @@ class ConfigurationController extends Controller
{
$configData = $this->getConfigData();
- return response()->json(['data' => $configData], 200)->header('Content-Type', 'application/vnd.api+json');
+ return response()->json(['data' => $configData])->header('Content-Type', 'application/vnd.api+json');
}
/**
@@ -82,7 +81,6 @@ class ConfigurationController extends Controller
* @param string $name
*
* @return JsonResponse
- * @throws FireflyException
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function update(ConfigurationRequest $request, string $name): JsonResponse
@@ -91,7 +89,7 @@ class ConfigurationController extends Controller
app('fireflyconfig')->set($name, $data['value']);
$configData = $this->getConfigData();
- return response()->json(['data' => $configData], 200)->header('Content-Type', 'application/vnd.api+json');
+ return response()->json(['data' => $configData])->header('Content-Type', 'application/vnd.api+json');
}
/**
diff --git a/app/Api/V1/Controllers/CurrencyController.php b/app/Api/V1/Controllers/CurrencyController.php
index 45d82f6cd2..61a6f2a798 100644
--- a/app/Api/V1/Controllers/CurrencyController.php
+++ b/app/Api/V1/Controllers/CurrencyController.php
@@ -263,7 +263,9 @@ class CurrencyController extends Controller
/**
* List all budget limits
*
- * @param Request $request
+ * @param Request $request
+ *
+ * @param TransactionCurrency $currency
*
* @return JsonResponse
*/
@@ -489,7 +491,9 @@ class CurrencyController extends Controller
/**
* List all recurring transactions.
*
- * @param Request $request
+ * @param Request $request
+ *
+ * @param TransactionCurrency $currency
*
* @return JsonResponse]
*/
diff --git a/app/Api/V1/Controllers/ImportController.php b/app/Api/V1/Controllers/ImportController.php
index 7eee249099..ecaa5b5acc 100644
--- a/app/Api/V1/Controllers/ImportController.php
+++ b/app/Api/V1/Controllers/ImportController.php
@@ -127,6 +127,7 @@ class ImportController extends Controller
/**
* Show all transactions
*
+ * @param Request $request
* @param ImportJob $importJob
*
* @return JsonResponse
diff --git a/app/Api/V1/Controllers/LinkTypeController.php b/app/Api/V1/Controllers/LinkTypeController.php
index 8d95bcf068..5171d68a3a 100644
--- a/app/Api/V1/Controllers/LinkTypeController.php
+++ b/app/Api/V1/Controllers/LinkTypeController.php
@@ -90,7 +90,7 @@ class LinkTypeController extends Controller
if (false === $linkType->editable) {
throw new FireflyException(sprintf('You cannot delete this link type (#%d, "%s")', $linkType->id, $linkType->name));
}
- $this->repository->destroy($linkType, null);
+ $this->repository->destroy($linkType);
return response()->json([], 204);
}
@@ -190,6 +190,7 @@ class LinkTypeController extends Controller
/**
* Delete the resource.
*
+ * @param Request $request
* @param LinkType $linkType
*
* @return JsonResponse
diff --git a/app/Api/V1/Controllers/PreferenceController.php b/app/Api/V1/Controllers/PreferenceController.php
index c3999d6f70..16e0ffad09 100644
--- a/app/Api/V1/Controllers/PreferenceController.php
+++ b/app/Api/V1/Controllers/PreferenceController.php
@@ -59,7 +59,7 @@ class PreferenceController extends Controller
// an important fallback is that the frontPageAccount array gets refilled automatically
// when it turns up empty.
$frontPageAccounts = app('preferences')->getForUser($user, 'frontPageAccounts', [])->data;
- if (\count($frontPageAccounts) === 0) {
+ if (0 === \count($frontPageAccounts)) {
/** @var Collection $accounts */
$accounts = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
$accountIds = $accounts->pluck('id')->toArray();
diff --git a/app/Api/V1/Controllers/RecurrenceController.php b/app/Api/V1/Controllers/RecurrenceController.php
index 2e3d36b82c..6a01d17d61 100644
--- a/app/Api/V1/Controllers/RecurrenceController.php
+++ b/app/Api/V1/Controllers/RecurrenceController.php
@@ -247,7 +247,7 @@ class RecurrenceController extends Controller
return response()->json([], 204);
}
if (true === $result) {
- return response()->json([], 200);
+ return response()->json();
}
return response()->json([], 418); // @codeCoverageIgnore
diff --git a/app/Api/V1/Controllers/SummaryController.php b/app/Api/V1/Controllers/SummaryController.php
index a56ccc1671..5ad99006a8 100644
--- a/app/Api/V1/Controllers/SummaryController.php
+++ b/app/Api/V1/Controllers/SummaryController.php
@@ -105,6 +105,7 @@ class SummaryController extends Controller
$spentData = $this->getLeftToSpendInfo($start, $end);
$networthData = $this->getNetWorthInfo($start, $end);
$total = array_merge($balanceData, $billData, $spentData, $networthData);
+
// TODO: liabilities with icon line-chart
return response()->json($total);
@@ -361,8 +362,11 @@ class SummaryController extends Controller
*/
private function getNetWorthInfo(Carbon $start, Carbon $end): array
{
+ /** @var User $user */
+ $user = auth()->user();
$date = Carbon::create()->startOfDay();
+
// start and end in the future? use $end
if ($this->notInDateRange($date, $start, $end)) {
/** @var Carbon $date */
@@ -371,7 +375,7 @@ class SummaryController extends Controller
/** @var NetWorthInterface $netWorthHelper */
$netWorthHelper = app(NetWorthInterface::class);
- $netWorthHelper->setUser(auth()->user());
+ $netWorthHelper->setUser($user);
$allAccounts = $this->accountRepository->getActiveAccountsByType([AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE]);
// filter list on preference of being included.
@@ -389,7 +393,7 @@ class SummaryController extends Controller
/** @var TransactionCurrency $currency */
$currency = $data['currency'];
$amount = round($data['balance'], $currency->decimal_places);
- if ($amount === 0.0) {
+ if (0.0 === $amount) {
continue;
}
// return stuff
diff --git a/app/Api/V1/Controllers/TransactionController.php b/app/Api/V1/Controllers/TransactionController.php
index 9199ec45e9..a00438536b 100644
--- a/app/Api/V1/Controllers/TransactionController.php
+++ b/app/Api/V1/Controllers/TransactionController.php
@@ -179,7 +179,7 @@ class TransactionController extends Controller
$baseUrl = $request->getSchemeAndHttpHost() . '/api/v1';
$manager->setSerializer(new JsonApiSerializer($baseUrl));
- $events = $this->repository->getPiggyBankEventsByTr($transaction);
+ $events = $this->repository->getPiggyBankEventsbyTr($transaction);
/** @var PiggyBankEventTransformer $transformer */
$transformer = app(PiggyBankEventTransformer::class);
diff --git a/app/Api/V1/Controllers/TransactionLinkController.php b/app/Api/V1/Controllers/TransactionLinkController.php
index 1c58a560e1..9a4dec565a 100644
--- a/app/Api/V1/Controllers/TransactionLinkController.php
+++ b/app/Api/V1/Controllers/TransactionLinkController.php
@@ -29,7 +29,6 @@ use FireflyIII\Models\TransactionJournalLink;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface;
use FireflyIII\Support\Http\Api\TransactionFilter;
-use FireflyIII\Transformers\JournalLinkTransformer;
use FireflyIII\Transformers\TransactionLinkTransformer;
use FireflyIII\User;
use Illuminate\Http\JsonResponse;
diff --git a/app/Api/V1/Requests/BillRequest.php b/app/Api/V1/Requests/BillRequest.php
index d65b1a9861..58a7d6bbfe 100644
--- a/app/Api/V1/Requests/BillRequest.php
+++ b/app/Api/V1/Requests/BillRequest.php
@@ -52,7 +52,7 @@ class BillRequest extends Request
public function getAll(): array
{
$active = true;
- if(null !== $this->get('active')) {
+ if (null !== $this->get('active')) {
$active = $this->boolean('active');
}
diff --git a/app/Api/V1/Requests/CategoryRequest.php b/app/Api/V1/Requests/CategoryRequest.php
index 23cd21def8..369304ed3c 100644
--- a/app/Api/V1/Requests/CategoryRequest.php
+++ b/app/Api/V1/Requests/CategoryRequest.php
@@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests;
use FireflyIII\Models\Category;
-use FireflyIII\Rules\IsBoolean;
/**
* Class CategoryRequest
@@ -50,7 +49,7 @@ class CategoryRequest extends Request
public function getAll(): array
{
return [
- 'name' => $this->string('name')
+ 'name' => $this->string('name'),
];
}
@@ -62,7 +61,7 @@ class CategoryRequest extends Request
public function rules(): array
{
$rules = [
- 'name' => 'required|between:1,100|uniqueObjectForUser:categories,name'
+ 'name' => 'required|between:1,100|uniqueObjectForUser:categories,name',
];
switch ($this->method()) {
default:
diff --git a/app/Api/V1/Requests/TransactionLinkRequest.php b/app/Api/V1/Requests/TransactionLinkRequest.php
index ad74b713f6..77a4306a9b 100644
--- a/app/Api/V1/Requests/TransactionLinkRequest.php
+++ b/app/Api/V1/Requests/TransactionLinkRequest.php
@@ -25,6 +25,7 @@ namespace FireflyIII\Api\V1\Requests;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface;
+use FireflyIII\User;
use Illuminate\Validation\Validator;
/**
@@ -98,13 +99,15 @@ class TransactionLinkRequest extends Request
*/
private function validateExistingLink(Validator $validator): void
{
+ /** @var User $user */
+ $user = auth()->user();
/** @var LinkTypeRepositoryInterface $repository */
$repository = app(LinkTypeRepositoryInterface::class);
- $repository->setUser(auth()->user());
+ $repository->setUser($user);
/** @var JournalRepositoryInterface $journalRepos */
$journalRepos = app(JournalRepositoryInterface::class);
- $journalRepos->setUser(auth()->user());
+ $journalRepos->setUser($user);
$data = $validator->getData();
$inwardId = (int)($data['inward_id'] ?? 0);
diff --git a/app/Console/Commands/ApplyRules.php b/app/Console/Commands/ApplyRules.php
index f8ae0519c1..5246fbffde 100644
--- a/app/Console/Commands/ApplyRules.php
+++ b/app/Console/Commands/ApplyRules.php
@@ -41,6 +41,7 @@ use Illuminate\Support\Collection;
/**
*
* Class ApplyRules
+ *
* @codeCoverageIgnore
*/
class ApplyRules extends Command
@@ -184,6 +185,8 @@ class ApplyRules extends Command
private function applyRuleSelection(Collection $rules, Collection $transactions, bool $breakProcessing): void
{
$bar = $this->output->createProgressBar($rules->count() * $transactions->count());
+
+ /** @var Rule $rule */
foreach ($rules as $rule) {
/** @var Processor $processor */
$processor = app(Processor::class);
@@ -191,7 +194,7 @@ class ApplyRules extends Command
/** @var Transaction $transaction */
foreach ($transactions as $transaction) {
- /** @var Rule $rule */
+ /** @noinspection DisconnectedForeachInstructionInspection */
$bar->advance();
$result = $processor->handleTransaction($transaction);
if (true === $result) {
@@ -210,6 +213,7 @@ class ApplyRules extends Command
/**
*
+ * @throws \FireflyIII\Exceptions\FireflyException
*/
private function grabAllRules(): void
{
@@ -226,6 +230,7 @@ class ApplyRules extends Command
/**
*
+ * @throws \FireflyIII\Exceptions\FireflyException
*/
private function parseDates(): void
{
diff --git a/app/Console/Commands/CreateExport.php b/app/Console/Commands/CreateExport.php
index 4c66cceb91..75390480f9 100644
--- a/app/Console/Commands/CreateExport.php
+++ b/app/Console/Commands/CreateExport.php
@@ -134,8 +134,8 @@ class CreateExport extends Command
}
$processor->createZipFile();
- $disk = Storage::disk('export');
- $fileName = sprintf('export-%s.zip', date('Y-m-d_H-i-s'));
+ $disk = Storage::disk('export');
+ $fileName = sprintf('export-%s.zip', date('Y-m-d_H-i-s'));
$localPath = storage_path('export') . '/' . $job->key . '.zip';
// "move" from local to export disk
diff --git a/app/Console/Commands/CreateImport.php b/app/Console/Commands/CreateImport.php
index 15234cb3aa..eacf0a54b3 100644
--- a/app/Console/Commands/CreateImport.php
+++ b/app/Console/Commands/CreateImport.php
@@ -97,7 +97,7 @@ class CreateImport extends Command
return 1;
}
- if (\strlen($configuration) > 0) {
+ if ('' !== $configuration) {
$configurationData = json_decode(file_get_contents($configuration), true);
if (null === $configurationData) {
$this->errorLine(sprintf('Firefly III cannot read the contents of configuration file "%s" (working directory: "%s").', $configuration, $cwd));
@@ -136,7 +136,7 @@ class CreateImport extends Command
}
// store file as attachment.
- if (\strlen($file) > 0) {
+ if ('' !== $file) {
$messages = $jobRepository->storeCLIUpload($importJob, 'import_file', $file);
if ($messages->count() > 0) {
$this->errorLine($messages->first());
diff --git a/app/Console/Commands/Cron.php b/app/Console/Commands/Cron.php
index a6f48049c0..ac7dfb6ff4 100644
--- a/app/Console/Commands/Cron.php
+++ b/app/Console/Commands/Cron.php
@@ -48,16 +48,6 @@ class Cron extends Command
*/
protected $signature = 'firefly:cron';
- /**
- * Create a new command instance.
- *
- * @return void
- */
- public function __construct()
- {
- parent::__construct();
- }
-
/**
* Execute the console command.
*
diff --git a/app/Console/Commands/DecryptDatabase.php b/app/Console/Commands/DecryptDatabase.php
index ad8a83e4a3..672dbe7db0 100644
--- a/app/Console/Commands/DecryptDatabase.php
+++ b/app/Console/Commands/DecryptDatabase.php
@@ -113,7 +113,7 @@ class DecryptDatabase extends Command
$configName = sprintf('is_decrypted_%s', $table);
$configVar = FireflyConfig::get($configName, false);
if (null !== $configVar) {
- return $configVar->data;
+ return (bool)$configVar->data;
}
return false;
@@ -130,7 +130,7 @@ class DecryptDatabase extends Command
try {
$value = Crypt::decrypt($value);
} catch (DecryptException $e) {
- //Log::debug(sprintf('Could not decrypt. %s', $e->getMessage()));
+ Log::debug(sprintf('Could not decrypt. %s', $e->getMessage()));
}
return $value;
diff --git a/app/Console/Commands/UpgradeDatabase.php b/app/Console/Commands/UpgradeDatabase.php
index 7b982207f2..77052e0923 100644
--- a/app/Console/Commands/UpgradeDatabase.php
+++ b/app/Console/Commands/UpgradeDatabase.php
@@ -35,6 +35,7 @@ use FireflyIII\Models\AccountMeta;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\Attachment;
use FireflyIII\Models\Bill;
+use FireflyIII\Models\Budget;
use FireflyIII\Models\BudgetLimit;
use FireflyIII\Models\Note;
use FireflyIII\Models\Preference;
@@ -272,7 +273,7 @@ class UpgradeDatabase extends Command
->whereNull('transactions.deleted_at')
->groupBy(['transaction_journals.id'])
->select(['transaction_journals.id', DB::raw('COUNT(transactions.id) AS t_count')]);
- $result = DB::table(DB::raw('(' . $subQuery->toSql() . ') AS derived'))
+ $result = DB::table((string)DB::raw('(' . $subQuery->toSql() . ') AS derived'))
->mergeBindings($subQuery->getQuery())
->where('t_count', '>', 2)
->select(['id', 't_count']);
@@ -448,6 +449,7 @@ class UpgradeDatabase extends Command
/** @var BudgetLimit $budgetLimit */
foreach ($budgetLimits as $budgetLimit) {
if (null === $budgetLimit->transaction_currency_id) {
+ /** @var Budget $budget */
$budget = $budgetLimit->budget;
if (null !== $budget) {
$user = $budget->user;
@@ -465,7 +467,7 @@ class UpgradeDatabase extends Command
}
/**
- *
+ *
*/
private function createNewTypes(): void
{
@@ -493,7 +495,7 @@ class UpgradeDatabase extends Command
// move description:
$description = (string)$att->description;
- if (\strlen($description) > 0) {
+ if ('' !== $description) {
// find or create note:
$note = $att->notes()->first();
if (null === $note) {
@@ -544,19 +546,19 @@ class UpgradeDatabase extends Command
*/
private function removeCCLiabilities(): void
{
- $ccType = AccountType::where('type', AccountType::CREDITCARD)->first();
- $debtType =AccountType::where('type', AccountType::DEBT)->first();
- if(null === $ccType || null === $debtType) {
+ $ccType = AccountType::where('type', AccountType::CREDITCARD)->first();
+ $debtType = AccountType::where('type', AccountType::DEBT)->first();
+ if (null === $ccType || null === $debtType) {
return;
}
/** @var Collection $accounts */
$accounts = Account::where('account_type_id', $ccType->id)->get();
- foreach($accounts as $account) {
+ foreach ($accounts as $account) {
$account->account_type_id = $debtType->id;
$account->save();
$this->line(sprintf('Converted credit card liability account "%s" (#%d) to generic debt liability.', $account->name, $account->id));
}
- if($accounts->count() > 0) {
+ if ($accounts->count() > 0) {
$this->info('Credit card liability types are no longer supported and have been converted to generic debts. See: http://bit.ly/FF3-credit-cards');
}
}
diff --git a/app/Console/Commands/VerifyDatabase.php b/app/Console/Commands/VerifyDatabase.php
index 8a2cadf470..11e2582404 100644
--- a/app/Console/Commands/VerifyDatabase.php
+++ b/app/Console/Commands/VerifyDatabase.php
@@ -25,7 +25,6 @@ declare(strict_types=1);
namespace FireflyIII\Console\Commands;
-use Crypt;
use DB;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountMeta;
@@ -42,10 +41,8 @@ use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\User;
use Illuminate\Console\Command;
-use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Collection;
-use Log;
use Schema;
use stdClass;
diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php
index 1b3fdb5311..9ede16c879 100644
--- a/app/Console/Kernel.php
+++ b/app/Console/Kernel.php
@@ -30,6 +30,7 @@ use Log;
/**
* File to make sure commands work.
+ *
* @codeCoverageIgnore
*/
class Kernel extends ConsoleKernel
@@ -54,7 +55,9 @@ class Kernel extends ConsoleKernel
{
$schedule->call(
function () {
- Log::error('Firefly III no longer users the Laravel scheduler to do cron jobs! Please read the instructions at https://firefly-iii.readthedocs.io/en/latest/');
+ Log::error(
+ 'Firefly III no longer users the Laravel scheduler to do cron jobs! Please read the instructions at https://firefly-iii.readthedocs.io/en/latest/'
+ );
echo "\n";
echo '------------';
echo "\n";
diff --git a/app/Events/AdminRequestedTestMessage.php b/app/Events/AdminRequestedTestMessage.php
index 0a82c434cc..2f5b225800 100644
--- a/app/Events/AdminRequestedTestMessage.php
+++ b/app/Events/AdminRequestedTestMessage.php
@@ -30,6 +30,7 @@ use Log;
/**
* Class AdminRequestedTestMessage.
+ *
* @codeCoverageIgnore
*/
class AdminRequestedTestMessage extends Event
diff --git a/app/Events/Event.php b/app/Events/Event.php
index 84ea6bdb2b..14c8a1e436 100644
--- a/app/Events/Event.php
+++ b/app/Events/Event.php
@@ -26,6 +26,7 @@ namespace FireflyIII\Events;
/**
* Class Event.
+ *
* @codeCoverageIgnore
*/
abstract class Event
diff --git a/app/Events/RegisteredUser.php b/app/Events/RegisteredUser.php
index c576b16f94..8e7fc80ef1 100644
--- a/app/Events/RegisteredUser.php
+++ b/app/Events/RegisteredUser.php
@@ -29,6 +29,7 @@ use Illuminate\Queue\SerializesModels;
/**
* Class RegisteredUser.
+ *
* @codeCoverageIgnore
*/
class RegisteredUser extends Event
diff --git a/app/Events/RequestedNewPassword.php b/app/Events/RequestedNewPassword.php
index 7dce83c05d..b7c85c2f8c 100644
--- a/app/Events/RequestedNewPassword.php
+++ b/app/Events/RequestedNewPassword.php
@@ -29,6 +29,7 @@ use Illuminate\Queue\SerializesModels;
/**
* Class RequestedNewPassword.
+ *
* @codeCoverageIgnore
*/
class RequestedNewPassword extends Event
diff --git a/app/Events/StoredTransactionJournal.php b/app/Events/StoredTransactionJournal.php
index bc66a813fc..c631e7b148 100644
--- a/app/Events/StoredTransactionJournal.php
+++ b/app/Events/StoredTransactionJournal.php
@@ -46,6 +46,6 @@ class StoredTransactionJournal extends Event
*/
public function __construct(TransactionJournal $journal)
{
- $this->journal = $journal;
+ $this->journal = $journal;
}
}
diff --git a/app/Export/Collector/AttachmentCollector.php b/app/Export/Collector/AttachmentCollector.php
index a0a354451b..d47c7c0dea 100644
--- a/app/Export/Collector/AttachmentCollector.php
+++ b/app/Export/Collector/AttachmentCollector.php
@@ -28,6 +28,7 @@ use Crypt;
use FireflyIII\Models\Attachment;
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
use Illuminate\Contracts\Encryption\DecryptException;
+use Illuminate\Contracts\Filesystem\FileNotFoundException;
use Illuminate\Support\Collection;
use Log;
use Storage;
@@ -110,7 +111,7 @@ class AttachmentCollector extends BasicCollector implements CollectorInterface
if ($this->uploadDisk->exists($file)) {
try {
$decrypted = Crypt::decrypt($this->uploadDisk->get($file));
- } catch (DecryptException $e) {
+ } catch (DecryptException|FileNotFoundException $e) {
Log::error('Catchable error: could not decrypt attachment #' . $attachment->id . ' because: ' . $e->getMessage());
return false;
diff --git a/app/Export/Collector/UploadCollector.php b/app/Export/Collector/UploadCollector.php
index e2637b940f..85852944c5 100644
--- a/app/Export/Collector/UploadCollector.php
+++ b/app/Export/Collector/UploadCollector.php
@@ -110,7 +110,7 @@ class UploadCollector extends BasicCollector implements CollectorInterface
Log::error(sprintf('Could not decrypt old import file "%s". Skipped because: %s', $key, $e->getMessage()));
}
- if (\strlen($content) > 0) {
+ if ('' !== $content) {
// add to export disk.
$date = $job->created_at->format('Y-m-d');
$file = sprintf('%s-Old %s import dated %s.%s', $this->job->key, strtoupper($job->file_type), $date, $job->file_type);
diff --git a/app/Export/Entry/Entry.php b/app/Export/Entry/Entry.php
index 7f036095d4..01386cbfcc 100644
--- a/app/Export/Entry/Entry.php
+++ b/app/Export/Entry/Entry.php
@@ -49,48 +49,24 @@ use FireflyIII\Models\Transaction;
*/
final class Entry
{
- /** @var int ID of the journal */
- public $journal_id;
- /** @var int ID of the transaction */
- public $transaction_id = 0;
- /** @var string The date. */
- public $date;
- /** @var string The description */
- public $description;
- /** @var string The currency code. */
- public $currency_code;
/** @var string The amount. */
public $amount;
- /** @var string The foreign currency code */
- public $foreign_currency_code = '';
- /** @var string Foreign amount */
- public $foreign_amount = '0';
- /** @var string Transaction type */
- public $transaction_type;
+ /** @var string Asset account BIC */
+ public $asset_account_bic;
+ /** @var string Asset account IBAN */
+ public $asset_account_iban;
/** @var string Asset account ID */
public $asset_account_id;
/** @var string Asset account name */
public $asset_account_name;
- /** @var string Asset account IBAN */
- public $asset_account_iban;
- /** @var string Asset account BIC */
- public $asset_account_bic;
/** @var string Asset account number */
public $asset_account_number;
/** @var string Asset account currency code */
public $asset_currency_code;
- /** @var string Opposing account ID */
- public $opposing_account_id;
- /** @var string Opposing account name */
- public $opposing_account_name;
- /** @var string Opposing account IBAN */
- public $opposing_account_iban;
- /** @var string Opposing account BIC */
- public $opposing_account_bic;
- /** @var string Opposing account number */
- public $opposing_account_number;
- /** @var string Opposing account code */
- public $opposing_currency_code;
+ /** @var string Bill ID */
+ public $bill_id;
+ /** @var string Bill name */
+ public $bill_name;
/** @var string Budget ID */
public $budget_id;
/** @var string Budget name */
@@ -99,14 +75,38 @@ final class Entry
public $category_id;
/** @var string Category name */
public $category_name;
- /** @var string Bill ID */
- public $bill_id;
- /** @var string Bill name */
- public $bill_name;
+ /** @var string The currency code. */
+ public $currency_code;
+ /** @var string The date. */
+ public $date;
+ /** @var string The description */
+ public $description;
+ /** @var string Foreign amount */
+ public $foreign_amount = '0';
+ /** @var string The foreign currency code */
+ public $foreign_currency_code = '';
+ /** @var int ID of the journal */
+ public $journal_id;
/** @var string Notes */
public $notes;
+ /** @var string Opposing account BIC */
+ public $opposing_account_bic;
+ /** @var string Opposing account IBAN */
+ public $opposing_account_iban;
+ /** @var string Opposing account ID */
+ public $opposing_account_id;
+ /** @var string Opposing account name */
+ public $opposing_account_name;
+ /** @var string Opposing account number */
+ public $opposing_account_number;
+ /** @var string Opposing account code */
+ public $opposing_currency_code;
/** @var string Tags */
public $tags;
+ /** @var int ID of the transaction */
+ public $transaction_id = 0;
+ /** @var string Transaction type */
+ public $transaction_type;
/**
* Entry constructor.
@@ -132,7 +132,7 @@ final class Entry
$entry->transaction_id = $transaction->id;
$entry->date = $transaction->date->format('Ymd');
$entry->description = $transaction->description;
- if (\strlen((string)$transaction->transaction_description) > 0) {
+ if ('' !== (string)$transaction->transaction_description) {
$entry->description = $transaction->transaction_description . '(' . $transaction->description . ')';
}
$entry->currency_code = $transaction->transactionCurrency->code;
diff --git a/app/Export/ExpandedProcessor.php b/app/Export/ExpandedProcessor.php
index 157520116a..e021133ab3 100644
--- a/app/Export/ExpandedProcessor.php
+++ b/app/Export/ExpandedProcessor.php
@@ -25,7 +25,6 @@ declare(strict_types=1);
namespace FireflyIII\Export;
-use Crypt;
use DB;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Export\Collector\AttachmentCollector;
@@ -41,8 +40,8 @@ use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use Illuminate\Support\Collection;
-use Log;
use Illuminate\Support\Facades\Storage;
+use Log;
use ZipArchive;
/**
@@ -193,8 +192,8 @@ class ExpandedProcessor implements ProcessorInterface
*/
public function createZipFile(): bool
{
- $zip = new ZipArchive;
- $file = $this->job->key . '.zip';
+ $zip = new ZipArchive;
+ $file = $this->job->key . '.zip';
$localPath = storage_path('export') . '/' . $file;
if (true !== $zip->open($localPath, ZipArchive::CREATE)) {
@@ -339,7 +338,7 @@ class ExpandedProcessor implements ProcessorInterface
$return = [];
/** @var Note $note */
foreach ($notes as $note) {
- if (\strlen(trim((string)$note->text)) > 0) {
+ if ('' !== trim((string)$note->text)) {
$id = (int)$note->noteable_id;
$return[$id] = $note->text;
}
diff --git a/app/Export/Exporter/CsvExporter.php b/app/Export/Exporter/CsvExporter.php
index f7d57c26b8..00d909d762 100644
--- a/app/Export/Exporter/CsvExporter.php
+++ b/app/Export/Exporter/CsvExporter.php
@@ -25,8 +25,8 @@ declare(strict_types=1);
namespace FireflyIII\Export\Exporter;
use FireflyIII\Export\Entry\Entry;
-use League\Csv\Writer;
use Illuminate\Support\Facades\Storage;
+use League\Csv\Writer;
/**
* Class CsvExporter.
diff --git a/app/Factory/AccountFactory.php b/app/Factory/AccountFactory.php
index 13c5059c68..ccb86beda8 100644
--- a/app/Factory/AccountFactory.php
+++ b/app/Factory/AccountFactory.php
@@ -49,6 +49,7 @@ class AccountFactory
/**
* AccountFactory constructor.
+ *
* @codeCoverageIgnore
*/
public function __construct()
@@ -103,7 +104,7 @@ class AccountFactory
// use default currency:
$currency = app('amount')->getDefaultCurrencyByUser($this->user);
}
- $currency->enabled =true;
+ $currency->enabled = true;
$currency->save();
unset($data['currency_code']);
diff --git a/app/Factory/AccountMetaFactory.php b/app/Factory/AccountMetaFactory.php
index 0435efe7b9..a6c156e299 100644
--- a/app/Factory/AccountMetaFactory.php
+++ b/app/Factory/AccountMetaFactory.php
@@ -43,6 +43,7 @@ class AccountMetaFactory
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
}
}
+
/**
* @param array $data
*
@@ -73,6 +74,7 @@ class AccountMetaFactory
// if $data has field and $entry is null, create new one:
if (null === $entry) {
Log::debug(sprintf('Created meta-field "%s":"%s" for account #%d ("%s") ', $field, $value, $account->id, $account->name));
+
return $this->create(['account_id' => $account->id, 'name' => $field, 'data' => $value]);
}
@@ -89,6 +91,7 @@ class AccountMetaFactory
} catch (Exception $e) { // @codeCoverageIgnore
Log::debug(sprintf('Could not delete entry: %s', $e->getMessage())); // @codeCoverageIgnore
}
+
return null;
}
diff --git a/app/Factory/BillFactory.php b/app/Factory/BillFactory.php
index 660113c4f9..e9a7363fd8 100644
--- a/app/Factory/BillFactory.php
+++ b/app/Factory/BillFactory.php
@@ -38,6 +38,9 @@ class BillFactory
{
use BillServiceTrait;
+ /** @var User */
+ private $user;
+
/**
* Constructor.
*/
@@ -48,9 +51,6 @@ class BillFactory
}
}
- /** @var User */
- private $user;
-
/**
* @param array $data
*
@@ -63,7 +63,7 @@ class BillFactory
/** @var TransactionCurrency $currency */
$currency = $factory->find((int)($data['currency_id'] ?? null), (string)($data['currency_code'] ?? null));
- if(null === $currency) {
+ if (null === $currency) {
// use default currency:
$currency = app('amount')->getDefaultCurrencyByUser($this->user);
}
@@ -111,7 +111,7 @@ class BillFactory
}
// then find by name:
- if (null === $bill && \strlen($billName) > 0) {
+ if (null === $bill && '' !== $billName) {
$bill = $this->findByName($billName);
}
diff --git a/app/Factory/BudgetFactory.php b/app/Factory/BudgetFactory.php
index d102245c81..a4474f5877 100644
--- a/app/Factory/BudgetFactory.php
+++ b/app/Factory/BudgetFactory.php
@@ -34,6 +34,9 @@ use Log;
*/
class BudgetFactory
{
+ /** @var User */
+ private $user;
+
/**
* Constructor.
*/
@@ -44,10 +47,6 @@ class BudgetFactory
}
}
- /** @var User */
- private $user;
-
-
/**
* @param int|null $budgetId
* @param null|string $budgetName
diff --git a/app/Factory/CategoryFactory.php b/app/Factory/CategoryFactory.php
index c5f5abcf43..5d9ce23274 100644
--- a/app/Factory/CategoryFactory.php
+++ b/app/Factory/CategoryFactory.php
@@ -34,6 +34,9 @@ use Log;
*/
class CategoryFactory
{
+ /** @var User */
+ private $user;
+
/**
* Constructor.
*/
@@ -44,9 +47,6 @@ class CategoryFactory
}
}
- /** @var User */
- private $user;
-
/**
* @param string $name
*
@@ -94,7 +94,7 @@ class CategoryFactory
}
}
- if (\strlen($categoryName) > 0) {
+ if ('' !== $categoryName) {
$category = $this->findByName($categoryName);
if (null !== $category) {
return $category;
diff --git a/app/Factory/PiggyBankFactory.php b/app/Factory/PiggyBankFactory.php
index f24bbda978..424e1e6f6e 100644
--- a/app/Factory/PiggyBankFactory.php
+++ b/app/Factory/PiggyBankFactory.php
@@ -33,6 +33,9 @@ use Log;
*/
class PiggyBankFactory
{
+ /** @var User */
+ private $user;
+
/**
* Constructor.
*/
@@ -43,9 +46,6 @@ class PiggyBankFactory
}
}
- /** @var User */
- private $user;
-
/**
* @param int|null $piggyBankId
* @param null|string $piggyBankName
@@ -70,7 +70,7 @@ class PiggyBankFactory
}
// then find by name:
- if (\strlen($piggyBankName) > 0) {
+ if ('' !== $piggyBankName) {
/** @var PiggyBank $piggyBank */
$piggyBank = $this->findByName($piggyBankName);
if (null !== $piggyBank) {
diff --git a/app/Factory/RecurrenceFactory.php b/app/Factory/RecurrenceFactory.php
index cc0b290ce9..1a71192710 100644
--- a/app/Factory/RecurrenceFactory.php
+++ b/app/Factory/RecurrenceFactory.php
@@ -39,6 +39,11 @@ use Log;
*/
class RecurrenceFactory
{
+ /** @var User */
+ private $user;
+
+ use TransactionTypeTrait, TransactionServiceTrait, RecurringTransactionTrait;
+
/**
* Constructor.
*/
@@ -49,11 +54,6 @@ class RecurrenceFactory
}
}
- use TransactionTypeTrait, TransactionServiceTrait, RecurringTransactionTrait;
-
- /** @var User */
- private $user;
-
/**
* @param array $data
*
diff --git a/app/Factory/TransactionCurrencyFactory.php b/app/Factory/TransactionCurrencyFactory.php
index 02ca1a35a9..c29658311a 100644
--- a/app/Factory/TransactionCurrencyFactory.php
+++ b/app/Factory/TransactionCurrencyFactory.php
@@ -38,6 +38,7 @@ class TransactionCurrencyFactory
{
/**
* TransactionCurrencyFactory constructor.
+ *
* @codeCoverageIgnore
*/
public function __construct()
@@ -100,7 +101,7 @@ class TransactionCurrencyFactory
Log::warning(sprintf('Currency ID is %d but found nothing!', $currencyId));
}
// then by code:
- if (\strlen($currencyCode) > 0) {
+ if ('' !== $currencyCode) {
$currency = TransactionCurrency::whereCode($currencyCode)->first();
if (null !== $currency) {
return $currency;
diff --git a/app/Factory/TransactionFactory.php b/app/Factory/TransactionFactory.php
index e94a0da9c3..9dcd6d8c8e 100644
--- a/app/Factory/TransactionFactory.php
+++ b/app/Factory/TransactionFactory.php
@@ -115,7 +115,7 @@ class TransactionFactory
$currency = $currency ?? $defaultCurrency;
// enable currency:
- if(false === $currency->enabled) {
+ if (false === $currency->enabled) {
$currency->enabled = true;
$currency->save();
}
diff --git a/app/Factory/TransactionJournalFactory.php b/app/Factory/TransactionJournalFactory.php
index 9dc5c3c654..0e6dca0a05 100644
--- a/app/Factory/TransactionJournalFactory.php
+++ b/app/Factory/TransactionJournalFactory.php
@@ -72,9 +72,9 @@ class TransactionJournalFactory
$description = app('steam')->cleanString($data['description']);
$description = str_replace(["\n", "\t", "\r"], "\x20", $description);
/** @var Carbon $carbon */
- $carbon = $data['date'];
+ $carbon = $data['date'];
$carbon->setTimezone(config('app.timezone'));
-
+
$journal = TransactionJournal::create(
[
'user_id' => $data['user'],
diff --git a/app/Factory/TransactionTypeFactory.php b/app/Factory/TransactionTypeFactory.php
index e70cef27cb..9497cae39b 100644
--- a/app/Factory/TransactionTypeFactory.php
+++ b/app/Factory/TransactionTypeFactory.php
@@ -27,6 +27,7 @@ namespace FireflyIII\Factory;
use FireflyIII\Models\TransactionType;
use Log;
+
/**
* Class TransactionTypeFactory
*/
diff --git a/app/Generator/Chart/Basic/ChartJsGenerator.php b/app/Generator/Chart/Basic/ChartJsGenerator.php
index 8885c6c37d..74447a7257 100644
--- a/app/Generator/Chart/Basic/ChartJsGenerator.php
+++ b/app/Generator/Chart/Basic/ChartJsGenerator.php
@@ -24,6 +24,7 @@ namespace FireflyIII\Generator\Chart\Basic;
use FireflyIII\Support\ChartColour;
use Log;
+
/**
* Class ChartJsGenerator.
*/
@@ -39,6 +40,46 @@ class ChartJsGenerator implements GeneratorInterface
}
}
+ /**
+ * Expects data as:.
+ *
+ * key => [value => x, 'currency_symbol' => 'x']
+ *
+ * @param array $data
+ *
+ * @return array
+ */
+ public function multiCurrencyPieChart(array $data): array
+ {
+ $chartData = [
+ 'datasets' => [
+ 0 => [],
+ ],
+ 'labels' => [],
+ ];
+
+ $amounts = array_column($data, 'amount');
+ $next = next($amounts);
+ $sortFlag = SORT_ASC;
+ if (!\is_bool($next) && 1 === bccomp((string)$next, '0')) {
+ $sortFlag = SORT_DESC;
+ }
+ array_multisort($amounts, $sortFlag, $data);
+ unset($next, $sortFlag, $amounts);
+
+ $index = 0;
+ foreach ($data as $key => $valueArray) {
+ // make larger than 0
+ $chartData['datasets'][0]['data'][] = (float)app('steam')->positive((string)$valueArray['amount']);
+ $chartData['datasets'][0]['backgroundColor'][] = ChartColour::getColour($index);
+ $chartData['datasets'][0]['currency_symbol'][] = $valueArray['currency_symbol'];
+ $chartData['labels'][] = $key;
+ ++$index;
+ }
+
+ return $chartData;
+ }
+
/**
* Will generate a Chart JS compatible array from the given input. Expects this format.
*
@@ -150,46 +191,6 @@ class ChartJsGenerator implements GeneratorInterface
return $chartData;
}
- /**
- * Expects data as:.
- *
- * key => [value => x, 'currency_symbol' => 'x']
- *
- * @param array $data
- *
- * @return array
- */
- public function multiCurrencyPieChart(array $data): array
- {
- $chartData = [
- 'datasets' => [
- 0 => [],
- ],
- 'labels' => [],
- ];
-
- $amounts = array_column($data, 'amount');
- $next = next($amounts);
- $sortFlag = SORT_ASC;
- if (!\is_bool($next) && 1 === bccomp((string)$next, '0')) {
- $sortFlag = SORT_DESC;
- }
- array_multisort($amounts, $sortFlag, $data);
- unset($next, $sortFlag, $amounts);
-
- $index = 0;
- foreach ($data as $key => $valueArray) {
- // make larger than 0
- $chartData['datasets'][0]['data'][] = (float)app('steam')->positive((string)$valueArray['amount']);
- $chartData['datasets'][0]['backgroundColor'][] = ChartColour::getColour($index);
- $chartData['datasets'][0]['currency_symbol'][] = $valueArray['currency_symbol'];
- $chartData['labels'][] = $key;
- ++$index;
- }
-
- return $chartData;
- }
-
/**
* Will generate a (ChartJS) compatible array from the given input. Expects this format:.
*
diff --git a/app/Generator/Report/Audit/MultiYearReportGenerator.php b/app/Generator/Report/Audit/MultiYearReportGenerator.php
index ade7d0b84b..a775e2a5bd 100644
--- a/app/Generator/Report/Audit/MultiYearReportGenerator.php
+++ b/app/Generator/Report/Audit/MultiYearReportGenerator.php
@@ -24,6 +24,7 @@ namespace FireflyIII\Generator\Report\Audit;
/**
* Class MultiYearReportGenerator.
+ *
* @codeCoverageIgnore
*/
class MultiYearReportGenerator extends MonthReportGenerator
diff --git a/app/Generator/Report/Audit/YearReportGenerator.php b/app/Generator/Report/Audit/YearReportGenerator.php
index 4ff82713f4..a292b3f2a9 100644
--- a/app/Generator/Report/Audit/YearReportGenerator.php
+++ b/app/Generator/Report/Audit/YearReportGenerator.php
@@ -24,6 +24,7 @@ namespace FireflyIII\Generator\Report\Audit;
/**
* Class YearReportGenerator.
+ *
* @codeCoverageIgnore
*/
class YearReportGenerator extends MonthReportGenerator
diff --git a/app/Generator/Report/Budget/MultiYearReportGenerator.php b/app/Generator/Report/Budget/MultiYearReportGenerator.php
index ecfad642be..8eea0b4d74 100644
--- a/app/Generator/Report/Budget/MultiYearReportGenerator.php
+++ b/app/Generator/Report/Budget/MultiYearReportGenerator.php
@@ -24,6 +24,7 @@ namespace FireflyIII\Generator\Report\Budget;
/**
* Class MultiYearReportGenerator.
+ *
* @codeCoverageIgnore
*/
class MultiYearReportGenerator extends MonthReportGenerator
diff --git a/app/Generator/Report/Budget/YearReportGenerator.php b/app/Generator/Report/Budget/YearReportGenerator.php
index 4323ce2ddd..08dc432561 100644
--- a/app/Generator/Report/Budget/YearReportGenerator.php
+++ b/app/Generator/Report/Budget/YearReportGenerator.php
@@ -24,6 +24,7 @@ namespace FireflyIII\Generator\Report\Budget;
/**
* Class YearReportGenerator.
+ *
* @codeCoverageIgnore
*/
class YearReportGenerator extends MonthReportGenerator
diff --git a/app/Generator/Report/Category/MonthReportGenerator.php b/app/Generator/Report/Category/MonthReportGenerator.php
index ad477f15f1..cb7a299ac4 100644
--- a/app/Generator/Report/Category/MonthReportGenerator.php
+++ b/app/Generator/Report/Category/MonthReportGenerator.php
@@ -40,6 +40,7 @@ use Throwable;
/**
* Class MonthReportGenerator.
+ *
* @codeCoverageIgnore
*/
class MonthReportGenerator extends Support implements ReportGeneratorInterface
diff --git a/app/Generator/Report/Category/MultiYearReportGenerator.php b/app/Generator/Report/Category/MultiYearReportGenerator.php
index 39a881178e..0f693f62d7 100644
--- a/app/Generator/Report/Category/MultiYearReportGenerator.php
+++ b/app/Generator/Report/Category/MultiYearReportGenerator.php
@@ -24,6 +24,7 @@ namespace FireflyIII\Generator\Report\Category;
/**
* Class MultiYearReportGenerator.
+ *
* @codeCoverageIgnore
*/
class MultiYearReportGenerator extends MonthReportGenerator
diff --git a/app/Generator/Report/Category/YearReportGenerator.php b/app/Generator/Report/Category/YearReportGenerator.php
index 57f07fd975..ed8742664f 100644
--- a/app/Generator/Report/Category/YearReportGenerator.php
+++ b/app/Generator/Report/Category/YearReportGenerator.php
@@ -24,6 +24,7 @@ namespace FireflyIII\Generator\Report\Category;
/**
* Class YearReportGenerator.
+ *
* @codeCoverageIgnore
*/
class YearReportGenerator extends MonthReportGenerator
diff --git a/app/Generator/Report/ReportGeneratorFactory.php b/app/Generator/Report/ReportGeneratorFactory.php
index 04e264bb3d..2185a335d3 100644
--- a/app/Generator/Report/ReportGeneratorFactory.php
+++ b/app/Generator/Report/ReportGeneratorFactory.php
@@ -27,6 +27,7 @@ use FireflyIII\Exceptions\FireflyException;
/**
* Class ReportGeneratorFactory.
+ *
* @codeCoverageIgnore
*/
class ReportGeneratorFactory
diff --git a/app/Generator/Report/Standard/MonthReportGenerator.php b/app/Generator/Report/Standard/MonthReportGenerator.php
index ba6fc749a3..05bf049cc4 100644
--- a/app/Generator/Report/Standard/MonthReportGenerator.php
+++ b/app/Generator/Report/Standard/MonthReportGenerator.php
@@ -31,6 +31,7 @@ use Throwable;
/**
* Class MonthReportGenerator.
+ *
* @codeCoverageIgnore
*/
class MonthReportGenerator implements ReportGeneratorInterface
diff --git a/app/Generator/Report/Standard/MultiYearReportGenerator.php b/app/Generator/Report/Standard/MultiYearReportGenerator.php
index e9ba9d40f5..b92b31322f 100644
--- a/app/Generator/Report/Standard/MultiYearReportGenerator.php
+++ b/app/Generator/Report/Standard/MultiYearReportGenerator.php
@@ -30,6 +30,7 @@ use Throwable;
/**
* Class MonthReportGenerator.
+ *
* @codeCoverageIgnore
*/
class MultiYearReportGenerator implements ReportGeneratorInterface
diff --git a/app/Generator/Report/Standard/YearReportGenerator.php b/app/Generator/Report/Standard/YearReportGenerator.php
index 7479aa7024..b93c18a820 100644
--- a/app/Generator/Report/Standard/YearReportGenerator.php
+++ b/app/Generator/Report/Standard/YearReportGenerator.php
@@ -30,6 +30,7 @@ use Throwable;
/**
* Class MonthReportGenerator.
+ *
* @codeCoverageIgnore
*/
class YearReportGenerator implements ReportGeneratorInterface
diff --git a/app/Generator/Report/Support.php b/app/Generator/Report/Support.php
index d2b6c76f32..dad556dc7a 100644
--- a/app/Generator/Report/Support.php
+++ b/app/Generator/Report/Support.php
@@ -31,6 +31,7 @@ use Illuminate\Support\Collection;
* Class Support.
* @method Collection getExpenses()
* @method Collection getIncome()
+ *
* @codeCoverageIgnore
*/
class Support
diff --git a/app/Generator/Report/Tag/MultiYearReportGenerator.php b/app/Generator/Report/Tag/MultiYearReportGenerator.php
index c34136289a..26049c1679 100644
--- a/app/Generator/Report/Tag/MultiYearReportGenerator.php
+++ b/app/Generator/Report/Tag/MultiYearReportGenerator.php
@@ -24,6 +24,7 @@ namespace FireflyIII\Generator\Report\Tag;
/**
* Class MultiYearReportGenerator.
+ *
* @codeCoverageIgnore
*/
class MultiYearReportGenerator extends MonthReportGenerator
diff --git a/app/Generator/Report/Tag/YearReportGenerator.php b/app/Generator/Report/Tag/YearReportGenerator.php
index 087485a166..3a1927a61a 100644
--- a/app/Generator/Report/Tag/YearReportGenerator.php
+++ b/app/Generator/Report/Tag/YearReportGenerator.php
@@ -24,6 +24,7 @@ namespace FireflyIII\Generator\Report\Tag;
/**
* Class YearReportGenerator.
+ *
* @codeCoverageIgnore
*/
class YearReportGenerator extends MonthReportGenerator
diff --git a/app/Handlers/Events/StoredJournalEventHandler.php b/app/Handlers/Events/StoredJournalEventHandler.php
index f42d814b49..0b20bb6cf5 100644
--- a/app/Handlers/Events/StoredJournalEventHandler.php
+++ b/app/Handlers/Events/StoredJournalEventHandler.php
@@ -49,7 +49,7 @@ class StoredJournalEventHandler
/** @var RuleGroupRepositoryInterface $ruleGroupRepos */
$ruleGroupRepos = app(RuleGroupRepositoryInterface::class);
$ruleGroupRepos->setUser($journal->user);
- $groups = $ruleGroupRepos->getActiveGroups($journal->user);
+ $groups = $ruleGroupRepos->getActiveGroups($journal->user);
/** @var RuleGroup $group */
foreach ($groups as $group) {
diff --git a/app/Handlers/Events/UpdatedJournalEventHandler.php b/app/Handlers/Events/UpdatedJournalEventHandler.php
index 30ffeb83ab..0561ad928f 100644
--- a/app/Handlers/Events/UpdatedJournalEventHandler.php
+++ b/app/Handlers/Events/UpdatedJournalEventHandler.php
@@ -50,7 +50,7 @@ class UpdatedJournalEventHandler
$ruleGroupRepos = app(RuleGroupRepositoryInterface::class);
$ruleGroupRepos->setUser($journal->user);
- $groups = $ruleGroupRepos->getActiveGroups($journal->user);
+ $groups = $ruleGroupRepos->getActiveGroups($journal->user);
/** @var RuleGroup $group */
foreach ($groups as $group) {
diff --git a/app/Handlers/Events/UserEventHandler.php b/app/Handlers/Events/UserEventHandler.php
index 0e1f5f0ce2..b4a3ebb92d 100644
--- a/app/Handlers/Events/UserEventHandler.php
+++ b/app/Handlers/Events/UserEventHandler.php
@@ -146,6 +146,7 @@ class UserEventHandler
} catch (Exception $e) {
Log::error($e->getMessage());
}
+
// @codeCoverageIgnoreEnd
return true;
@@ -172,6 +173,7 @@ class UserEventHandler
} catch (Exception $e) {
Log::error($e->getMessage());
}
+
// @codeCoverageIgnoreEnd
return true;
@@ -199,6 +201,7 @@ class UserEventHandler
} catch (Exception $e) {
Log::error($e->getMessage());
}
+
// @codeCoverageIgnoreEnd
return true;
diff --git a/app/Helpers/Attachments/AttachmentHelper.php b/app/Helpers/Attachments/AttachmentHelper.php
index 955f689773..0da5cd83c7 100644
--- a/app/Helpers/Attachments/AttachmentHelper.php
+++ b/app/Helpers/Attachments/AttachmentHelper.php
@@ -26,11 +26,12 @@ use Crypt;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Attachment;
use Illuminate\Contracts\Encryption\DecryptException;
+use Illuminate\Contracts\Filesystem\FileNotFoundException;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
+use Illuminate\Support\Facades\Storage;
use Illuminate\Support\MessageBag;
use Log;
-use Illuminate\Support\Facades\Storage;
use Symfony\Component\HttpFoundation\File\UploadedFile;
/**
@@ -85,7 +86,7 @@ class AttachmentHelper implements AttachmentHelperInterface
try {
$content = Crypt::decrypt($this->uploadDisk->get(sprintf('at-%d.data', $attachment->id)));
- } catch (DecryptException $e) {
+ } catch (DecryptException|FileNotFoundException $e) {
Log::error(sprintf('Could not decrypt data of attachment #%d: %s', $attachment->id, $e->getMessage()));
$content = '';
}
@@ -102,8 +103,7 @@ class AttachmentHelper implements AttachmentHelperInterface
*/
public function getAttachmentLocation(Attachment $attachment): string
{
- $path = sprintf('%sat-%d.data', DIRECTORY_SEPARATOR, (int)$attachment->id);
- return $path;
+ return sprintf('%sat-%d.data', DIRECTORY_SEPARATOR, (int)$attachment->id);
}
/**
@@ -186,11 +186,11 @@ class AttachmentHelper implements AttachmentHelperInterface
* @param array|null $files
*
* @return bool
- * @throws \Illuminate\Contracts\Encryption\EncryptException
+ * @throws FireflyException
*/
public function saveAttachmentsForModel(object $model, ?array $files): bool
{
- if(!($model instanceof Model)) {
+ if (!($model instanceof Model)) {
return false; // @codeCoverageIgnore
}
Log::debug(sprintf('Now in saveAttachmentsForModel for model %s', \get_class($model)));
@@ -265,10 +265,10 @@ class AttachmentHelper implements AttachmentHelperInterface
$attachment->save();
Log::debug('Created attachment:', $attachment->toArray());
- $fileObject = $file->openFile('r');
+ $fileObject = $file->openFile();
$fileObject->rewind();
- if(0 === $file->getSize()) {
+ if (0 === $file->getSize()) {
throw new FireflyException('Cannot upload empty or non-existent file.'); // @codeCoverageIgnore
}
diff --git a/app/Helpers/Collector/TransactionCollectorInterface.php b/app/Helpers/Collector/TransactionCollectorInterface.php
index fe41b2d6fa..b1bd615c68 100644
--- a/app/Helpers/Collector/TransactionCollectorInterface.php
+++ b/app/Helpers/Collector/TransactionCollectorInterface.php
@@ -145,15 +145,6 @@ interface TransactionCollectorInterface
*/
public function setAllAssetAccounts(): TransactionCollectorInterface;
- /**
- * Set the required currency (local or foreign)
- *
- * @param TransactionCurrency $currency
- *
- * @return TransactionCollectorInterface
- */
- public function setCurrency(TransactionCurrency $currency): TransactionCollectorInterface;
-
/**
* Collect transactions before a specific date.
*
@@ -208,6 +199,15 @@ interface TransactionCollectorInterface
*/
public function setCategory(Category $category): TransactionCollectorInterface;
+ /**
+ * Set the required currency (local or foreign)
+ *
+ * @param TransactionCurrency $currency
+ *
+ * @return TransactionCollectorInterface
+ */
+ public function setCurrency(TransactionCurrency $currency): TransactionCollectorInterface;
+
/**
* Set the journal IDs to filter on.
*
diff --git a/app/Helpers/Filter/CountAttachmentsFilter.php b/app/Helpers/Filter/CountAttachmentsFilter.php
index c47cb838d9..6c67591299 100644
--- a/app/Helpers/Filter/CountAttachmentsFilter.php
+++ b/app/Helpers/Filter/CountAttachmentsFilter.php
@@ -31,6 +31,7 @@ use Illuminate\Support\Collection;
/**
* Class CountAttachmentsFilter
+ *
* @codeCoverageIgnore
*/
class CountAttachmentsFilter implements FilterInterface
diff --git a/app/Helpers/Filter/TransferFilter.php b/app/Helpers/Filter/TransferFilter.php
index ab606ca1f2..ed0dec3350 100644
--- a/app/Helpers/Filter/TransferFilter.php
+++ b/app/Helpers/Filter/TransferFilter.php
@@ -26,6 +26,7 @@ use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionType;
use Illuminate\Support\Collection;
use Log;
+
/**
* Class TransferFilter.
*
diff --git a/app/Helpers/Help/Help.php b/app/Helpers/Help/Help.php
index c1de07fe15..f93dfc505a 100644
--- a/app/Helpers/Help/Help.php
+++ b/app/Helpers/Help/Help.php
@@ -25,7 +25,6 @@ namespace FireflyIII\Helpers\Help;
use Cache;
use Exception;
use GuzzleHttp\Client;
-use GuzzleHttp\Exception\GuzzleException;
use League\CommonMark\CommonMarkConverter;
use Log;
use Route;
@@ -87,14 +86,14 @@ class Help implements HelpInterface
$res = $client->request('GET', $uri, $opt);
$statusCode = $res->getStatusCode();
$content = trim($res->getBody()->getContents());
- } catch (GuzzleException|Exception $e) {
+ } catch (Exception $e) {
Log::info($e->getMessage());
Log::info($e->getTraceAsString());
}
Log::debug(sprintf('Status code is %d', $statusCode));
- if (\strlen($content) > 0) {
+ if ('' !== $content) {
Log::debug('Content is longer than zero. Expect something.');
$converter = new CommonMarkConverter();
$content = $converter->convertToHtml($content);
@@ -153,7 +152,7 @@ class Help implements HelpInterface
public function putInCache(string $route, string $language, string $content): void
{
$key = sprintf(self::CACHEKEY, $route, $language);
- if (\strlen($content) > 0) {
+ if ('' !== $content) {
Log::debug(sprintf('Will store entry in cache: %s', $key));
Cache::put($key, $content, 10080); // a week.
diff --git a/app/Helpers/Report/NetWorth.php b/app/Helpers/Report/NetWorth.php
index c4dd6d81b4..3afec01a1b 100644
--- a/app/Helpers/Report/NetWorth.php
+++ b/app/Helpers/Report/NetWorth.php
@@ -25,7 +25,6 @@ namespace FireflyIII\Helpers\Report;
use Carbon\Carbon;
use FireflyIII\Models\Account;
-use FireflyIII\Models\AccountType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Support\CacheProperties;
diff --git a/app/Helpers/Report/PopupReport.php b/app/Helpers/Report/PopupReport.php
index 200a822847..634935ed74 100644
--- a/app/Helpers/Report/PopupReport.php
+++ b/app/Helpers/Report/PopupReport.php
@@ -31,6 +31,7 @@ use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use Illuminate\Support\Collection;
use Log;
+
/**
* Class PopupReport.
*
@@ -186,7 +187,7 @@ class PopupReport implements PopupReportInterface
$collector->setAccounts(new Collection([$account]))->setRange($attributes['startDate'], $attributes['endDate'])
->setTypes([TransactionType::DEPOSIT, TransactionType::TRANSFER]);
$transactions = $collector->getTransactions();
- $report = $attributes['accounts']->pluck('id')->toArray(); // accounts used in this report
+ $report = $attributes['accounts']->pluck('id')->toArray(); // accounts used in this report
// filter the set so the destinations outside of $attributes['accounts'] are not included.
$transactions = $transactions->filter(
diff --git a/app/Helpers/Report/ReportHelper.php b/app/Helpers/Report/ReportHelper.php
index 1435630984..f84868512b 100644
--- a/app/Helpers/Report/ReportHelper.php
+++ b/app/Helpers/Report/ReportHelper.php
@@ -33,6 +33,7 @@ use FireflyIII\Repositories\Bill\BillRepositoryInterface;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use Illuminate\Support\Collection;
use Log;
+
/**
* Class ReportHelper.
*
diff --git a/app/Helpers/Update/UpdateTrait.php b/app/Helpers/Update/UpdateTrait.php
index 0d040c4a0e..e57b1f12a4 100644
--- a/app/Helpers/Update/UpdateTrait.php
+++ b/app/Helpers/Update/UpdateTrait.php
@@ -96,7 +96,7 @@ trait UpdateTrait
// has it been released for at least three days?
$today = new Carbon;
$releaseDate = $release->getUpdated();
- if ($today->diffInDays($releaseDate, true) > 3) {
+ if ($today->diffInDays($releaseDate) > 3) {
Log::debug('New version is older than 3 days!');
$monthAndDayFormat = (string)trans('config.month_and_day');
$return = (string)trans(
diff --git a/app/Http/Controllers/Account/CreateController.php b/app/Http/Controllers/Account/CreateController.php
index 50bf7ac4ac..dcaf2cd6d7 100644
--- a/app/Http/Controllers/Account/CreateController.php
+++ b/app/Http/Controllers/Account/CreateController.php
@@ -84,9 +84,9 @@ class CreateController extends Controller
$loan = $this->repository->getAccountTypeByType(AccountType::LOAN);
$mortgage = $this->repository->getAccountTypeByType(AccountType::MORTGAGE);
$liabilityTypes = [
- $debt->id => (string)trans('firefly.account_type_' . AccountType::DEBT),
- $loan->id => (string)trans('firefly.account_type_' . AccountType::LOAN),
- $mortgage->id => (string)trans('firefly.account_type_' . AccountType::MORTGAGE),
+ $debt->id => (string)trans('firefly.account_type_' . AccountType::DEBT),
+ $loan->id => (string)trans('firefly.account_type_' . AccountType::LOAN),
+ $mortgage->id => (string)trans('firefly.account_type_' . AccountType::MORTGAGE),
];
asort($liabilityTypes);
@@ -112,6 +112,7 @@ class CreateController extends Controller
}
$request->session()->forget('accounts.create.fromStore');
Log::channel('audit')->info('Create new account.');
+
return view('accounts.create', compact('subTitleIcon', 'what', 'interestPeriods', 'subTitle', 'roles', 'liabilityTypes'));
}
diff --git a/app/Http/Controllers/Account/EditController.php b/app/Http/Controllers/Account/EditController.php
index b984efb5cb..b714381a38 100644
--- a/app/Http/Controllers/Account/EditController.php
+++ b/app/Http/Controllers/Account/EditController.php
@@ -91,9 +91,9 @@ class EditController extends Controller
$loan = $this->repository->getAccountTypeByType(AccountType::LOAN);
$mortgage = $this->repository->getAccountTypeByType(AccountType::MORTGAGE);
$liabilityTypes = [
- $debt->id => (string)trans('firefly.account_type_' . AccountType::DEBT),
- $loan->id => (string)trans('firefly.account_type_' . AccountType::LOAN),
- $mortgage->id => (string)trans('firefly.account_type_' . AccountType::MORTGAGE),
+ $debt->id => (string)trans('firefly.account_type_' . AccountType::DEBT),
+ $loan->id => (string)trans('firefly.account_type_' . AccountType::LOAN),
+ $mortgage->id => (string)trans('firefly.account_type_' . AccountType::MORTGAGE),
];
asort($liabilityTypes);
diff --git a/app/Http/Controllers/Account/ShowController.php b/app/Http/Controllers/Account/ShowController.php
index 6032d1fb78..db60db7ab0 100644
--- a/app/Http/Controllers/Account/ShowController.php
+++ b/app/Http/Controllers/Account/ShowController.php
@@ -145,7 +145,6 @@ class ShowController extends Controller
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View
*
- * @throws FireflyException
*
*/
public function showAll(Request $request, Account $account)
@@ -177,7 +176,7 @@ class ShowController extends Controller
return view(
'accounts.show',
- compact('account', 'showAll','isLiability', 'currency', 'today', 'chartUri', 'periods', 'subTitleIcon', 'transactions', 'subTitle', 'start', 'end')
+ compact('account', 'showAll', 'isLiability', 'currency', 'today', 'chartUri', 'periods', 'subTitleIcon', 'transactions', 'subTitle', 'start', 'end')
);
}
diff --git a/app/Http/Controllers/Admin/ConfigurationController.php b/app/Http/Controllers/Admin/ConfigurationController.php
index 159b717e3b..f9932b5236 100644
--- a/app/Http/Controllers/Admin/ConfigurationController.php
+++ b/app/Http/Controllers/Admin/ConfigurationController.php
@@ -27,7 +27,6 @@ use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Middleware\IsDemoUser;
use FireflyIII\Http\Middleware\IsSandStormUser;
use FireflyIII\Http\Requests\ConfigurationRequest;
-use FireflyIII\Support\Facades\FireflyConfig;
use Illuminate\Http\RedirectResponse;
use Log;
@@ -69,8 +68,8 @@ class ConfigurationController extends Controller
// all available configuration and their default value in case
// they don't exist yet.
- $singleUserMode = FireflyConfig::get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
- $isDemoSite = FireflyConfig::get('is_demo_site', config('firefly.configuration.is_demo_site'))->data;
+ $singleUserMode = app('fireflyconfig')->get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
+ $isDemoSite = app('fireflyconfig')->get('is_demo_site', config('firefly.configuration.is_demo_site'))->data;
$siteOwner = config('firefly.site_owner');
return view(
@@ -94,8 +93,8 @@ class ConfigurationController extends Controller
Log::channel('audit')->info('User updates global configuration.', $data);
// store config values
- FireflyConfig::set('single_user_mode', $data['single_user_mode']);
- FireflyConfig::set('is_demo_site', $data['is_demo_site']);
+ app('fireflyconfig')->set('single_user_mode', $data['single_user_mode']);
+ app('fireflyconfig')->set('is_demo_site', $data['is_demo_site']);
// flash message
session()->flash('success', (string)trans('firefly.configuration_updated'));
diff --git a/app/Http/Controllers/Admin/UpdateController.php b/app/Http/Controllers/Admin/UpdateController.php
index 18aa985518..6ffd5a4b2d 100644
--- a/app/Http/Controllers/Admin/UpdateController.php
+++ b/app/Http/Controllers/Admin/UpdateController.php
@@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Admin;
-use FireflyConfig;
use FireflyIII\Helpers\Update\UpdateTrait;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Middleware\IsDemoUser;
@@ -87,8 +86,8 @@ class UpdateController extends Controller
public function post(Request $request)
{
$checkForUpdates = (int)$request->get('check_for_updates');
- FireflyConfig::set('permission_update_check', $checkForUpdates);
- FireflyConfig::set('last_update_check', time());
+ app('fireflyconfig')->set('permission_update_check', $checkForUpdates);
+ app('fireflyconfig')->set('last_update_check', time());
session()->flash('success', (string)trans('firefly.configuration_updated'));
return redirect(route('admin.update-check'));
@@ -107,7 +106,7 @@ class UpdateController extends Controller
// flash info
session()->flash('info', $resultString);
}
- FireflyConfig::set('last_update_check', time());
+ app('fireflyconfig')->set('last_update_check', time());
return response()->json(['result' => $resultString]);
}
diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php
index 1a49e5d93d..683269c659 100644
--- a/app/Http/Controllers/Admin/UserController.php
+++ b/app/Http/Controllers/Admin/UserController.php
@@ -178,7 +178,7 @@ class UserController extends Controller
$data = $request->getUserData();
// update password
- if (\strlen($data['password']) > 0) {
+ if ('' !== $data['password']) {
$repository->changePassword($user, $data['password']);
}
diff --git a/app/Http/Controllers/AttachmentController.php b/app/Http/Controllers/AttachmentController.php
index 443ad3e62a..7b58dbaf23 100644
--- a/app/Http/Controllers/AttachmentController.php
+++ b/app/Http/Controllers/AttachmentController.php
@@ -111,7 +111,7 @@ class AttachmentController extends Controller
$quoted = sprintf('"%s"', addcslashes(basename($attachment->filename), '"\\'));
/** @var LaravelResponse $response */
- $response = response($content, 200);
+ $response = response($content);
$response
->header('Content-Description', 'File Transfer')
->header('Content-Type', 'application/octet-stream')
diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php
index d52efa85a0..1ce51d9dab 100644
--- a/app/Http/Controllers/Auth/ForgotPasswordController.php
+++ b/app/Http/Controllers/Auth/ForgotPasswordController.php
@@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Auth;
-use FireflyConfig;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\User;
@@ -65,6 +64,7 @@ class ForgotPasswordController extends Controller
if ('eloquent' !== $loginProvider) {
$message = sprintf('Cannot reset password when authenticating over "%s".', $loginProvider);
Log::error($message);
+
return view('error', compact('message'));
}
// @codeCoverageIgnoreEnd
@@ -109,7 +109,7 @@ class ForgotPasswordController extends Controller
}
// is allowed to?
- $singleUserMode = FireflyConfig::get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
+ $singleUserMode = app('fireflyconfig')->get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
$userCount = User::count();
$allowRegistration = true;
$pageTitle = (string)trans('firefly.forgot_pw_page_title');
diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php
index 113488efca..f825140819 100644
--- a/app/Http/Controllers/Auth/LoginController.php
+++ b/app/Http/Controllers/Auth/LoginController.php
@@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Auth;
use DB;
-use FireflyConfig;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\User;
use Illuminate\Cookie\CookieJar;
@@ -140,7 +139,7 @@ class LoginController extends Controller
$request->session()->forget('twoFactorAuthenticated');
// is allowed to?
- $singleUserMode = FireflyConfig::get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
+ $singleUserMode = app('fireflyconfig')->get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
$userCount = User::count();
$allowRegistration = true;
$allowReset = true;
diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php
index 312fc6931a..272ed44bb4 100644
--- a/app/Http/Controllers/Auth/RegisterController.php
+++ b/app/Http/Controllers/Auth/RegisterController.php
@@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Auth;
-use FireflyConfig;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Support\Http\Controllers\CreateStuff;
use FireflyIII\Support\Http\Controllers\RequestInformation;
@@ -73,7 +72,7 @@ class RegisterController extends Controller
// is allowed to?
$allowRegistration = true;
$loginProvider = config('firefly.login_provider');
- $singleUserMode = FireflyConfig::get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
+ $singleUserMode = app('fireflyconfig')->get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
$userCount = User::count();
if (true === $singleUserMode && $userCount > 0 && 'eloquent' === $loginProvider) {
$allowRegistration = false;
@@ -114,8 +113,8 @@ class RegisterController extends Controller
{
$allowRegistration = true;
$loginProvider = config('firefly.login_provider');
- $isDemoSite = FireflyConfig::get('is_demo_site', config('firefly.configuration.is_demo_site'))->data;
- $singleUserMode = FireflyConfig::get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
+ $isDemoSite = app('fireflyconfig')->get('is_demo_site', config('firefly.configuration.is_demo_site'))->data;
+ $singleUserMode = app('fireflyconfig')->get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
$userCount = User::count();
$pageTitle = (string)trans('firefly.register_page_title');
diff --git a/app/Http/Controllers/Auth/ResetPasswordController.php b/app/Http/Controllers/Auth/ResetPasswordController.php
index c6699d24e3..fe5aeed45c 100644
--- a/app/Http/Controllers/Auth/ResetPasswordController.php
+++ b/app/Http/Controllers/Auth/ResetPasswordController.php
@@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Auth;
-use FireflyConfig;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\User;
use Illuminate\Foundation\Auth\ResetsPasswords;
@@ -121,7 +120,7 @@ class ResetPasswordController extends Controller
}
// is allowed to register?
- $singleUserMode = FireflyConfig::get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
+ $singleUserMode = app('fireflyconfig')->get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
$userCount = User::count();
$allowRegistration = true;
$pageTitle = (string)trans('firefly.reset_pw_page_title');
diff --git a/app/Http/Controllers/Budget/AmountController.php b/app/Http/Controllers/Budget/AmountController.php
index f6d7a52ba0..1f760649b9 100644
--- a/app/Http/Controllers/Budget/AmountController.php
+++ b/app/Http/Controllers/Budget/AmountController.php
@@ -186,11 +186,13 @@ class AmountController extends Controller
// the default suggestion is the money the user has spent, on average, over this period.
$suggested = $spentAverage;
- Log::debug(sprintf('Suggested is now %s (spent average)',$suggested));
+ Log::debug(sprintf('Suggested is now %s (spent average)', $suggested));
// if the user makes less per period, suggest that amount instead.
if (1 === bccomp($spentAverage, $earnedAverage)) {
- Log::debug(sprintf('Because earned average (%s) is less than spent average (%s) will suggest earned average instead.', $earnedAverage, $spentAverage));
+ Log::debug(
+ sprintf('Because earned average (%s) is less than spent average (%s) will suggest earned average instead.', $earnedAverage, $spentAverage)
+ );
$suggested = $earnedAverage;
}
diff --git a/app/Http/Controllers/Budget/IndexController.php b/app/Http/Controllers/Budget/IndexController.php
index 8db0e98e64..d9aa50ae96 100644
--- a/app/Http/Controllers/Budget/IndexController.php
+++ b/app/Http/Controllers/Budget/IndexController.php
@@ -135,7 +135,9 @@ class IndexController extends Controller
}
/**
- * @param Request $request
+ * @param Request $request
+ *
+ * @param BudgetRepositoryInterface $repository
*
* @return JsonResponse
*/
diff --git a/app/Http/Controllers/Category/ShowController.php b/app/Http/Controllers/Category/ShowController.php
index 7f2c3f3a50..79c552729a 100644
--- a/app/Http/Controllers/Category/ShowController.php
+++ b/app/Http/Controllers/Category/ShowController.php
@@ -28,9 +28,7 @@ use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
use FireflyIII\Helpers\Filter\InternalTransferFilter;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Category;
-use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
-use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Support\Http\Controllers\PeriodOverview;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
@@ -45,10 +43,6 @@ use Log;
class ShowController extends Controller
{
use PeriodOverview;
- /** @var AccountRepositoryInterface The account repository */
- private $accountRepos;
- /** @var JournalRepositoryInterface Journals and transactions overview */
- private $journalRepos;
/** @var CategoryRepositoryInterface The category repository */
private $repository;
@@ -63,9 +57,7 @@ class ShowController extends Controller
function ($request, $next) {
app('view')->share('title', (string)trans('firefly.categories'));
app('view')->share('mainTitleIcon', 'fa-bar-chart');
- $this->journalRepos = app(JournalRepositoryInterface::class);
- $this->repository = app(CategoryRepositoryInterface::class);
- $this->accountRepos = app(AccountRepositoryInterface::class);
+ $this->repository = app(CategoryRepositoryInterface::class);
return $next($request);
}
diff --git a/app/Http/Controllers/Chart/CategoryController.php b/app/Http/Controllers/Chart/CategoryController.php
index c290fe557b..b91e690b29 100644
--- a/app/Http/Controllers/Chart/CategoryController.php
+++ b/app/Http/Controllers/Chart/CategoryController.php
@@ -168,7 +168,7 @@ class CategoryController extends Controller
$cache->addProperty($end);
$cache->addProperty('chart.category.frontpage');
if ($cache->has()) {
- //return response()->json($cache->get()); // @codeCoverageIgnore
+ return response()->json($cache->get()); // @codeCoverageIgnore
}
// currency repos:
@@ -186,8 +186,8 @@ class CategoryController extends Controller
foreach ($categories as $category) {
$spentArray = $repository->spentInPeriodPerCurrency(new Collection([$category]), $accounts, $start, $end);
foreach ($spentArray as $categoryId => $spentInfo) {
- foreach($spentInfo['spent'] as $currencyId => $row) {
- $spent= $row['spent'];
+ foreach ($spentInfo['spent'] as $currencyId => $row) {
+ $spent = $row['spent'];
if (bccomp($spent, '0') === -1) {
$currencies[$currencyId] = $currencies[$currencyId] ?? $currencyRepository->findNull((int)$currencyId);
$tempData[] = [
diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php
index 4df71b4219..286fcec349 100644
--- a/app/Http/Controllers/Controller.php
+++ b/app/Http/Controllers/Controller.php
@@ -22,7 +22,6 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers;
-use FireflyConfig;
use FireflyIII\Support\Http\Controllers\RequestInformation;
use FireflyIII\Support\Http\Controllers\UserNavigation;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
@@ -61,7 +60,7 @@ class Controller extends BaseController
app('view')->share('hideTags', false);
// is site a demo site?
- $isDemoSite = FireflyConfig::get('is_demo_site', config('firefly.configuration.is_demo_site'))->data;
+ $isDemoSite = app('fireflyconfig')->get('is_demo_site', config('firefly.configuration.is_demo_site'))->data;
app('view')->share('IS_DEMO_SITE', $isDemoSite);
app('view')->share('DEMO_USERNAME', config('firefly.demo_username'));
app('view')->share('DEMO_PASSWORD', config('firefly.demo_password'));
diff --git a/app/Http/Controllers/CurrencyController.php b/app/Http/Controllers/CurrencyController.php
index 622ca191e6..45d932919b 100644
--- a/app/Http/Controllers/CurrencyController.php
+++ b/app/Http/Controllers/CurrencyController.php
@@ -189,6 +189,7 @@ class CurrencyController extends Controller
}
/**
+ * @param Request $request
* @param TransactionCurrency $currency
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
diff --git a/app/Http/Controllers/DebugController.php b/app/Http/Controllers/DebugController.php
index 4557973b66..c0966526cd 100644
--- a/app/Http/Controllers/DebugController.php
+++ b/app/Http/Controllers/DebugController.php
@@ -171,7 +171,7 @@ class DebugController extends Controller
}
}
}
- if (strlen($logContent) > 0) {
+ if ('' !== $logContent) {
// last few lines
$logContent = 'Truncated from this point <----|' . substr($logContent, -8192);
}
diff --git a/app/Http/Controllers/ExportController.php b/app/Http/Controllers/ExportController.php
index 5561d7ec07..687be4e2b3 100644
--- a/app/Http/Controllers/ExportController.php
+++ b/app/Http/Controllers/ExportController.php
@@ -80,7 +80,7 @@ class ExportController extends Controller
$repository->changeStatus($job, 'export_downloaded');
/** @var LaravelResponse $response */
- $response = response($content, 200);
+ $response = response($content);
$response
->header('Content-Description', 'File Transfer')
->header('Content-Type', 'application/octet-stream')
diff --git a/app/Http/Controllers/Import/CallbackController.php b/app/Http/Controllers/Import/CallbackController.php
index 97299ec2d7..95f0fca4d1 100644
--- a/app/Http/Controllers/Import/CallbackController.php
+++ b/app/Http/Controllers/Import/CallbackController.php
@@ -46,8 +46,8 @@ class CallbackController extends Controller
*/
public function ynab(Request $request, ImportJobRepositoryInterface $repository)
{
- $code = (string)$request->get('code');
- $jobKey = (string)$request->get('state');
+ $code = (string)$request->get('code');
+ $jobKey = (string)$request->get('state');
if ('' === $code) {
return view('error')->with('message', 'You Need A Budget did not reply with a valid authorization code. Firefly III cannot continue.');
diff --git a/app/Http/Controllers/Import/IndexController.php b/app/Http/Controllers/Import/IndexController.php
index fd8817913b..38ffcbf7bb 100644
--- a/app/Http/Controllers/Import/IndexController.php
+++ b/app/Http/Controllers/Import/IndexController.php
@@ -84,18 +84,19 @@ class IndexController extends Controller
$isDemoUser = $this->userRepository->hasRole(auth()->user(), 'demo');
Log::debug(sprintf('Will create job for provider "%s"', $importProvider));
- Log::debug(sprintf('Is demo user? %s',var_export($isDemoUser, true)));
- Log::debug(sprintf('Is allowed for user? %s',var_export($allowedForDemo, true)));
- Log::debug(sprintf('Has prerequisites? %s',var_export($hasPreReq, true)));
- Log::debug(sprintf('Has config? %s',var_export($hasConfig, true)));
+ Log::debug(sprintf('Is demo user? %s', var_export($isDemoUser, true)));
+ Log::debug(sprintf('Is allowed for user? %s', var_export($allowedForDemo, true)));
+ Log::debug(sprintf('Has prerequisites? %s', var_export($hasPreReq, true)));
+ Log::debug(sprintf('Has config? %s', var_export($hasConfig, true)));
if ($isDemoUser && !$allowedForDemo) {
Log::debug('User is demo and this provider doesnt work for demo users.');
+
return redirect(route('import.index'));
}
- $importJob = $this->repository->create($importProvider);
+ $importJob = $this->repository->create($importProvider);
Log::debug(sprintf('Created job #%d for provider %s', $importJob->id, $importProvider));
@@ -163,7 +164,7 @@ class IndexController extends Controller
$result = json_encode($config, JSON_PRETTY_PRINT);
$name = sprintf('"%s"', addcslashes('import-configuration-' . date('Y-m-d') . '.json', '"\\'));
/** @var LaravelResponse $response */
- $response = response($result, 200);
+ $response = response($result);
$response->header('Content-disposition', 'attachment; filename=' . $name)
->header('Content-Type', 'application/json')
->header('Content-Description', 'File Transfer')
diff --git a/app/Http/Controllers/Import/JobStatusController.php b/app/Http/Controllers/Import/JobStatusController.php
index 93e0a6e3c5..456fca6f08 100644
--- a/app/Http/Controllers/Import/JobStatusController.php
+++ b/app/Http/Controllers/Import/JobStatusController.php
@@ -154,6 +154,7 @@ class JobStatusController extends Controller
// @codeCoverageIgnoreStart
$message = sprintf('Cannot find import routine class for job of type "%s".', $importProvider);
Log::error($message);
+
return response()->json(
['status' => 'NOK', 'message' => $message]
);
@@ -182,6 +183,7 @@ class JobStatusController extends Controller
// expect nothing from routine, just return OK to user.
Log::info('Now finished with JobStatusController::start');
+
return response()->json(['status' => 'OK', 'message' => 'stage_finished']);
}
@@ -227,6 +229,7 @@ class JobStatusController extends Controller
$this->repository->setStatus($importJob, 'storage_finished');
Log::info('Now finished with JobStatusController::start');
+
// expect nothing from routine, just return OK to user.
return response()->json(['status' => 'OK', 'message' => 'storage_finished']);
}
diff --git a/app/Http/Controllers/JavascriptController.php b/app/Http/Controllers/JavascriptController.php
index dd81fccb52..30f4a847cf 100644
--- a/app/Http/Controllers/JavascriptController.php
+++ b/app/Http/Controllers/JavascriptController.php
@@ -68,7 +68,7 @@ class JavascriptController extends Controller
}
return response()
- ->view('javascript.accounts', $data, 200)
+ ->view('javascript.accounts', $data)
->header('Content-Type', 'text/javascript');
}
@@ -91,7 +91,7 @@ class JavascriptController extends Controller
}
return response()
- ->view('javascript.currencies', $data, 200)
+ ->view('javascript.currencies', $data)
->header('Content-Type', 'text/javascript');
}
@@ -141,7 +141,7 @@ class JavascriptController extends Controller
$request->session()->keep(['two-factor-secret']);
return response()
- ->view('javascript.variables', $data, 200)
+ ->view('javascript.variables', $data)
->header('Content-Type', 'text/javascript');
}
diff --git a/app/Http/Controllers/Json/BoxController.php b/app/Http/Controllers/Json/BoxController.php
index 60027f0a83..49caa3ca68 100644
--- a/app/Http/Controllers/Json/BoxController.php
+++ b/app/Http/Controllers/Json/BoxController.php
@@ -257,7 +257,7 @@ class BoxController extends Controller
/** @var AccountRepositoryInterface $accountRepository */
$accountRepository = app(AccountRepositoryInterface::class);
- $allAccounts = $accountRepository->getActiveAccountsByType(
+ $allAccounts = $accountRepository->getActiveAccountsByType(
[AccountType::DEFAULT, AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::CREDITCARD]
);
Log::debug(sprintf('Found %d accounts.', $allAccounts->count()));
@@ -281,7 +281,7 @@ class BoxController extends Controller
$return = [];
foreach ($netWorthSet as $index => $data) {
/** @var TransactionCurrency $currency */
- $currency = $data['currency'];
+ $currency = $data['currency'];
$return[$currency->id] = app('amount')->formatAnything($currency, $data['balance'], false);
}
$return = [
diff --git a/app/Http/Controllers/Json/ReconcileController.php b/app/Http/Controllers/Json/ReconcileController.php
index 7c523d8430..3e0f407f18 100644
--- a/app/Http/Controllers/Json/ReconcileController.php
+++ b/app/Http/Controllers/Json/ReconcileController.php
@@ -194,7 +194,6 @@ class ReconcileController extends Controller
*
* @return mixed
*
- * @throws FireflyException
*/
public function transactions(Account $account, Carbon $start, Carbon $end)
{
diff --git a/app/Http/Controllers/Json/RecurrenceController.php b/app/Http/Controllers/Json/RecurrenceController.php
index 37f2e58b81..cfabc0ff56 100644
--- a/app/Http/Controllers/Json/RecurrenceController.php
+++ b/app/Http/Controllers/Json/RecurrenceController.php
@@ -83,7 +83,7 @@ class RecurrenceController extends Controller
// if $firstDate is beyond $end, simply return an empty array.
if ($firstDate->gt($end)) {
- return response()->json([]);
+ return response()->json();
}
// if $firstDate is beyond start, use that one:
$actualStart = clone $firstDate;
diff --git a/app/Http/Controllers/JsonController.php b/app/Http/Controllers/JsonController.php
index a3f36b4ad0..ee325185c9 100644
--- a/app/Http/Controllers/JsonController.php
+++ b/app/Http/Controllers/JsonController.php
@@ -54,6 +54,7 @@ class JsonController extends Controller
Log::error(sprintf('Cannot render rules.partials.action: %s', $e->getMessage()));
$view = 'Could not render view.';
}
+
// @codeCoverageIgnoreEnd
return response()->json(['html' => $view]);
@@ -85,6 +86,7 @@ class JsonController extends Controller
Log::error(sprintf('Cannot render rules.partials.trigger: %s', $e->getMessage()));
$view = 'Could not render view.';
}
+
// @codeCoverageIgnoreEnd
return response()->json(['html' => $view]);
diff --git a/app/Http/Controllers/PiggyBankController.php b/app/Http/Controllers/PiggyBankController.php
index fff7716d4a..6261a88888 100644
--- a/app/Http/Controllers/PiggyBankController.php
+++ b/app/Http/Controllers/PiggyBankController.php
@@ -445,9 +445,9 @@ class PiggyBankController extends Controller
/** @var PiggyBankTransformer $transformer */
$transformer = app(PiggyBankTransformer::class);
$transformer->setParameters($parameters);
- $piggy = $transformer->transform($piggyBank);
- $events = $this->piggyRepos->getEvents($piggyBank);
- $subTitle = $piggyBank->name;
+ $piggy = $transformer->transform($piggyBank);
+ $events = $this->piggyRepos->getEvents($piggyBank);
+ $subTitle = $piggyBank->name;
return view('piggy-banks.show', compact('piggyBank', 'events', 'subTitle', 'piggy'));
}
diff --git a/app/Http/Controllers/PreferencesController.php b/app/Http/Controllers/PreferencesController.php
index c0fb2157f4..439fd8f4ae 100644
--- a/app/Http/Controllers/PreferencesController.php
+++ b/app/Http/Controllers/PreferencesController.php
@@ -72,7 +72,7 @@ class PreferencesController extends Controller
// an important fallback is that the frontPageAccount array gets refilled automatically
// when it turns up empty.
- if (\count($frontPageAccounts->data) === 0) {
+ if (0 === \count($frontPageAccounts->data)) {
$frontPageAccounts = $accountIds;
}
diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php
index 370cc1c240..472255734d 100644
--- a/app/Http/Controllers/ProfileController.php
+++ b/app/Http/Controllers/ProfileController.php
@@ -80,6 +80,8 @@ class ProfileController extends Controller
/**
* Change your email address.
*
+ * @param Request $request
+ *
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function changeEmail(Request $request)
@@ -104,6 +106,8 @@ class ProfileController extends Controller
/**
* Change your password.
*
+ * @param Request $request
+ *
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function changePassword(Request $request)
@@ -135,7 +139,7 @@ class ProfileController extends Controller
$secret = Google2FA::generateSecretKey();
session()->flash('two-factor-secret', $secret);
- $image = Google2FA::getQRCodeInline($domain, auth()->user()->email, $secret, 200);
+ $image = Google2FA::getQRCodeInline($domain, auth()->user()->email, $secret);
return view('profile.code', compact('image', 'secret'));
}
@@ -187,6 +191,8 @@ class ProfileController extends Controller
/**
* Delete your account view.
*
+ * @param Request $request
+ *
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function deleteAccount(Request $request)
diff --git a/app/Http/Controllers/Recurring/EditController.php b/app/Http/Controllers/Recurring/EditController.php
index f9ee3f51cf..02ce761a85 100644
--- a/app/Http/Controllers/Recurring/EditController.php
+++ b/app/Http/Controllers/Recurring/EditController.php
@@ -85,8 +85,8 @@ class EditController extends Controller
$transformer = app(RecurrenceTransformer::class);
$transformer->setParameters(new ParameterBag);
- $array = $transformer->transform($recurrence);
- $budgets = app('expandedform')->makeSelectListWithEmpty($this->budgets->getActiveBudgets());
+ $array = $transformer->transform($recurrence);
+ $budgets = app('expandedform')->makeSelectListWithEmpty($this->budgets->getActiveBudgets());
/** @var RecurrenceRepetition $repetition */
$repetition = $recurrence->recurrenceRepetitions()->first();
diff --git a/app/Http/Controllers/Recurring/IndexController.php b/app/Http/Controllers/Recurring/IndexController.php
index 1c1f2719e1..a4f66c5fa1 100644
--- a/app/Http/Controllers/Recurring/IndexController.php
+++ b/app/Http/Controllers/Recurring/IndexController.php
@@ -90,7 +90,7 @@ class IndexController extends Controller
$transformer = app(RecurrenceTransformer::class);
$transformer->setParameters(new ParameterBag);
- $recurring = [];
+ $recurring = [];
/** @var Recurrence $recurrence */
foreach ($recurrences as $recurrence) {
$array = $transformer->transform($recurrence);
diff --git a/app/Http/Controllers/Report/CategoryController.php b/app/Http/Controllers/Report/CategoryController.php
index 941a851d78..b7efe0e0e2 100644
--- a/app/Http/Controllers/Report/CategoryController.php
+++ b/app/Http/Controllers/Report/CategoryController.php
@@ -169,6 +169,7 @@ class CategoryController extends Controller
Log::error(sprintf('Could not render category::expenses: %s', $e->getMessage()));
$result = 'An error prevented Firefly III from rendering. Apologies.';
}
+
// @codeCoverageIgnoreEnd
return $result;
diff --git a/app/Http/Controllers/Rule/CreateController.php b/app/Http/Controllers/Rule/CreateController.php
index 60c52e102f..03f47f7dee 100644
--- a/app/Http/Controllers/Rule/CreateController.php
+++ b/app/Http/Controllers/Rule/CreateController.php
@@ -29,13 +29,10 @@ use FireflyIII\Http\Requests\RuleFormRequest;
use FireflyIII\Models\Bill;
use FireflyIII\Models\RuleGroup;
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
-use FireflyIII\Support\Http\Controllers\AugumentData;
use FireflyIII\Support\Http\Controllers\ModelInformation;
use FireflyIII\Support\Http\Controllers\RuleManagement;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
-use Log;
-use Throwable;
/**
* Class CreateController
diff --git a/app/Http/Controllers/Rule/EditController.php b/app/Http/Controllers/Rule/EditController.php
index 53c2dd44dd..299c613d37 100644
--- a/app/Http/Controllers/Rule/EditController.php
+++ b/app/Http/Controllers/Rule/EditController.php
@@ -27,16 +27,11 @@ namespace FireflyIII\Http\Controllers\Rule;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Requests\RuleFormRequest;
use FireflyIII\Models\Rule;
-use FireflyIII\Models\RuleAction;
-use FireflyIII\Models\RuleTrigger;
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
-use FireflyIII\Support\Http\Controllers\ModelInformation;
use FireflyIII\Support\Http\Controllers\RenderPartialViews;
use FireflyIII\Support\Http\Controllers\RuleManagement;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
-use Log;
-use Throwable;
/**
* Class EditController
diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php
index e82a6c9d35..1ab40fe1ac 100644
--- a/app/Http/Controllers/SearchController.php
+++ b/app/Http/Controllers/SearchController.php
@@ -107,6 +107,7 @@ class SearchController extends Controller
Log::error(sprintf('Cannot render search.search: %s', $e->getMessage()));
$html = 'Could not render view.';
}
+
// @codeCoverageIgnoreEnd
return response()->json(['count' => $transactions->count(), 'html' => $html]);
diff --git a/app/Http/Controllers/System/InstallController.php b/app/Http/Controllers/System/InstallController.php
index c4c779c1db..fabdd79b01 100644
--- a/app/Http/Controllers/System/InstallController.php
+++ b/app/Http/Controllers/System/InstallController.php
@@ -57,6 +57,33 @@ class InstallController extends Controller
// empty on purpose.
}
+ /**
+ * Do database decrypt.
+ *
+ * @return \Illuminate\Http\JsonResponse
+ */
+ public function decrypt(): JsonResponse
+ {
+ if ($this->hasForbiddenFunctions()) {
+ return response()->json(['error' => true, 'message' => self::FORBIDDEN_ERROR]);
+ }
+ try {
+ Log::debug('Am now calling decrypt database routine...');
+ Artisan::call('firefly:decrypt-all');
+ Log::debug(Artisan::output());
+ } catch (Exception $e) {
+ Log::error($e->getMessage());
+ Log::error($e->getTraceAsString());
+ if (strpos($e->getMessage(), 'open_basedir restriction in effect')) {
+ return response()->json(['error' => true, 'message' => self::BASEDIR_ERROR]);
+ }
+
+ return response()->json(['error' => true, 'message' => self::OTHER_ERROR . ' ' . $e->getMessage()]);
+ }
+
+ return response()->json(['error' => false, 'message' => 'OK']);
+ }
+
/**
* Show index.
*
@@ -153,34 +180,6 @@ class InstallController extends Controller
return response()->json(['error' => false, 'message' => 'OK']);
}
- /**
- * Do database decrypt.
- *
- * @return \Illuminate\Http\JsonResponse
- */
- public function decrypt(): JsonResponse
- {
- if ($this->hasForbiddenFunctions()) {
- return response()->json(['error' => true, 'message' => self::FORBIDDEN_ERROR]);
- }
- try {
- Log::debug('Am now calling decrypt database routine...');
- Artisan::call('firefly:decrypt-all');
- Log::debug(Artisan::output());
- } catch (Exception $e) {
- Log::error($e->getMessage());
- Log::error($e->getTraceAsString());
- if (strpos($e->getMessage(), 'open_basedir restriction in effect')) {
- return response()->json(['error' => true, 'message' => self::BASEDIR_ERROR]);
- }
-
- return response()->json(['error' => true, 'message' => self::OTHER_ERROR . ' ' . $e->getMessage()]);
- }
-
- return response()->json(['error' => false, 'message' => 'OK']);
- }
-
-
/**
* Do database verification.
*
diff --git a/app/Http/Controllers/Transaction/MassController.php b/app/Http/Controllers/Transaction/MassController.php
index e15f6b5325..56ac2f8173 100644
--- a/app/Http/Controllers/Transaction/MassController.php
+++ b/app/Http/Controllers/Transaction/MassController.php
@@ -25,7 +25,6 @@ namespace FireflyIII\Http\Controllers\Transaction;
use Carbon\Carbon;
use FireflyIII\Events\UpdatedTransactionJournal;
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
-use FireflyIII\Helpers\Filter\InternalTransferFilter;
use FireflyIII\Helpers\Filter\TransactionViewFilter;
use FireflyIII\Helpers\Filter\TransferFilter;
use FireflyIII\Http\Controllers\Controller;
diff --git a/app/Http/Controllers/Transaction/SingleController.php b/app/Http/Controllers/Transaction/SingleController.php
index 7a2cec0444..ddd474c7ab 100644
--- a/app/Http/Controllers/Transaction/SingleController.php
+++ b/app/Http/Controllers/Transaction/SingleController.php
@@ -190,6 +190,7 @@ class SingleController extends Controller
* Show a special JSONified view of a transaction, for easier debug purposes.
*
* @param TransactionJournal $journal
+ *
* @codeCoverageIgnore
* @return JsonResponse
*/
diff --git a/app/Http/Controllers/TransactionController.php b/app/Http/Controllers/TransactionController.php
index 4003586059..1da5411663 100644
--- a/app/Http/Controllers/TransactionController.php
+++ b/app/Http/Controllers/TransactionController.php
@@ -26,7 +26,6 @@ namespace FireflyIII\Http\Controllers;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
-use FireflyIII\Helpers\Attachments\AttachmentHelper;
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
use FireflyIII\Helpers\Filter\CountAttachmentsFilter;
use FireflyIII\Helpers\Filter\InternalTransferFilter;
@@ -218,7 +217,6 @@ class TransactionController extends Controller
*
* @param TransactionJournal $journal
* @param LinkTypeRepositoryInterface $linkTypeRepository
- * @param AttachmentHelper $attHelper
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View
* @throws FireflyException
@@ -267,7 +265,7 @@ class TransactionController extends Controller
$what = strtolower($transactionType);
$subTitle = trans('firefly.' . $what) . ' "' . $journal->description . '"';
- return view('transactions.show', compact('journal','attachments', 'events', 'subTitle', 'what', 'transactions', 'linkTypes', 'links'));
+ return view('transactions.show', compact('journal', 'attachments', 'events', 'subTitle', 'what', 'transactions', 'linkTypes', 'links'));
}
diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php
index 90ad53be88..0544006f2c 100644
--- a/app/Http/Kernel.php
+++ b/app/Http/Kernel.php
@@ -82,7 +82,7 @@ class Kernel extends HttpKernel
// does not check login
// does not check 2fa
// does not check activation
- 'web' => [
+ 'web' => [
Sandstorm::class,
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php
index fbedb02879..2c68878759 100644
--- a/app/Http/Middleware/Authenticate.php
+++ b/app/Http/Middleware/Authenticate.php
@@ -77,12 +77,12 @@ class Authenticate
/**
* Determine if the user is logged in to any of the given guards.
*
+ * @param $request
* @param array $guards
*
* @return mixed
- * @throws \Illuminate\Auth\AuthenticationException
+ * @throws AuthenticationException
* @throws FireflyException
- *
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
diff --git a/app/Http/Middleware/Installer.php b/app/Http/Middleware/Installer.php
index f7f96d5300..70c3dd964f 100644
--- a/app/Http/Middleware/Installer.php
+++ b/app/Http/Middleware/Installer.php
@@ -26,13 +26,13 @@ namespace FireflyIII\Http\Middleware;
use Closure;
use DB;
-use FireflyConfig;
use FireflyIII\Exceptions\FireflyException;
use Illuminate\Database\QueryException;
use Log;
/**
* Class Installer
+ *
* @codeCoverageIgnore
*
*/
@@ -84,7 +84,7 @@ class Installer
// older version in config than database?
$configVersion = (int)config('firefly.db_version');
- $dbVersion = (int)FireflyConfig::getFresh('db_version', 1)->data;
+ $dbVersion = (int)app('fireflyconfig')->getFresh('db_version', 1)->data;
if ($configVersion > $dbVersion) {
Log::warning(
sprintf(
diff --git a/app/Http/Middleware/SecureHeaders.php b/app/Http/Middleware/SecureHeaders.php
index 492574bf23..e7e9bfc3ae 100644
--- a/app/Http/Middleware/SecureHeaders.php
+++ b/app/Http/Middleware/SecureHeaders.php
@@ -61,7 +61,7 @@ class SecureHeaders
];
$route = $request->route();
- if (null !== $route && $route->uri !== 'oauth/authorize') {
+ if (null !== $route && 'oauth/authorize' !== $route->uri) {
$csp[] = "form-action 'self'";
}
diff --git a/app/Http/Requests/JournalLinkRequest.php b/app/Http/Requests/JournalLinkRequest.php
index 9e99a3f43f..d5fac5708f 100644
--- a/app/Http/Requests/JournalLinkRequest.php
+++ b/app/Http/Requests/JournalLinkRequest.php
@@ -53,7 +53,7 @@ class JournalLinkRequest extends Request
$parts = explode('_', $linkType);
$return['link_type_id'] = (int)$parts[0];
$return['transaction_journal_id'] = $this->integer('link_journal_id');
- $return['notes'] = \strlen($this->string('notes')) > 0 ? $this->string('notes') : '';
+ $return['notes'] = $this->string('notes');
$return['direction'] = $parts[1];
if (0 === $return['transaction_journal_id'] && ctype_digit($this->string('link_other'))) {
$return['transaction_journal_id'] = $this->integer('link_other');
diff --git a/app/Http/Requests/RecurrenceFormRequest.php b/app/Http/Requests/RecurrenceFormRequest.php
index c28d22ff58..f80821163e 100644
--- a/app/Http/Requests/RecurrenceFormRequest.php
+++ b/app/Http/Requests/RecurrenceFormRequest.php
@@ -227,6 +227,7 @@ class RecurrenceFormRequest extends Request
$rules['title'] = 'required|between:1,255|uniqueObjectForUser:recurrences,title,' . $recurrence->id;
$rules['first_date'] = 'required|date';
}
+
return $rules;
}
diff --git a/app/Http/Requests/TagFormRequest.php b/app/Http/Requests/TagFormRequest.php
index 003fcc266c..db1341cc44 100644
--- a/app/Http/Requests/TagFormRequest.php
+++ b/app/Http/Requests/TagFormRequest.php
@@ -63,7 +63,7 @@ class TagFormRequest extends Request
'description' => $this->string('description'),
'latitude' => $latitude,
'longitude' => $longitude,
- 'zoom_level' => $zoomLevel,
+ 'zoom_level' => $zoomLevel,
];
return $data;
@@ -93,7 +93,7 @@ class TagFormRequest extends Request
'date' => 'date|nullable',
'latitude' => 'numeric|min:-90|max:90|nullable',
'longitude' => 'numeric|min:-180|max:180|nullable',
- 'zoom_level' => 'numeric|min:0|max:80|nullable',
+ 'zoom_level' => 'numeric|min:0|max:80|nullable',
];
}
}
diff --git a/app/Import/Converter/Amount.php b/app/Import/Converter/Amount.php
index d595249e59..a2ee082264 100644
--- a/app/Import/Converter/Amount.php
+++ b/app/Import/Converter/Amount.php
@@ -82,7 +82,7 @@ class Amount implements ConverterInterface
$value = str_replace($search, '', $value);
Log::debug(sprintf('No decimal character found. Converted amount from "%s" to "%s".', $original, $value));
}
- if ('.' === $value{0}) {
+ if (strpos($value, '.') === 0) {
$value = '0' . $value;
}
diff --git a/app/Import/Mapper/AssetAccountIbans.php b/app/Import/Mapper/AssetAccountIbans.php
index 35c9880377..8b4956e744 100644
--- a/app/Import/Mapper/AssetAccountIbans.php
+++ b/app/Import/Mapper/AssetAccountIbans.php
@@ -53,7 +53,7 @@ class AssetAccountIbans implements MapperInterface
foreach ($set as $account) {
$iban = $account->iban ?? '';
$accountId = (int)$account->id;
- if (\strlen($iban) > 0) {
+ if ('' !== $iban) {
$name = $account->iban . ' (' . $account->name . ')';
// is a liability?
diff --git a/app/Import/Mapper/AssetAccounts.php b/app/Import/Mapper/AssetAccounts.php
index 91c5962f03..43dce07ffa 100644
--- a/app/Import/Mapper/AssetAccounts.php
+++ b/app/Import/Mapper/AssetAccounts.php
@@ -40,7 +40,9 @@ class AssetAccounts implements MapperInterface
{
/** @var AccountRepositoryInterface $accountRepository */
$accountRepository = app(AccountRepositoryInterface::class);
- $set = $accountRepository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::CREDITCARD, AccountType::MORTGAGE,]);
+ $set = $accountRepository->getAccountsByType(
+ [AccountType::DEFAULT, AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::CREDITCARD, AccountType::MORTGAGE,]
+ );
$list = [];
/** @var Account $account */
@@ -48,7 +50,7 @@ class AssetAccounts implements MapperInterface
$accountId = (int)$account->id;
$name = $account->name;
$iban = $account->iban ?? '';
- if (\strlen($iban) > 0) {
+ if ('' !== $iban) {
$name .= ' (' . $iban . ')';
}
diff --git a/app/Import/Mapper/OpposingAccountIbans.php b/app/Import/Mapper/OpposingAccountIbans.php
index 54fe60dd93..5a03f15b73 100644
--- a/app/Import/Mapper/OpposingAccountIbans.php
+++ b/app/Import/Mapper/OpposingAccountIbans.php
@@ -55,7 +55,7 @@ class OpposingAccountIbans implements MapperInterface
foreach ($set as $account) {
$iban = $account->iban ?? '';
$accountId = (int)$account->id;
- if (\strlen($iban) > 0) {
+ if ('' !== $iban) {
$name = $account->iban . ' (' . $account->name . ')';
// is a liability?
diff --git a/app/Import/Mapper/OpposingAccounts.php b/app/Import/Mapper/OpposingAccounts.php
index d47c74d8b7..82680bf6ad 100644
--- a/app/Import/Mapper/OpposingAccounts.php
+++ b/app/Import/Mapper/OpposingAccounts.php
@@ -55,7 +55,7 @@ class OpposingAccounts implements MapperInterface
$accountId = (int)$account->id;
$name = $account->name;
$iban = $account->iban ?? '';
- if (\strlen($iban) > 0) {
+ if ('' !== $iban) {
$name .= ' (' . $iban . ')';
}
// is a liability?
diff --git a/app/Import/Routine/BunqRoutine.php b/app/Import/Routine/BunqRoutine.php
index 625b2d7437..ec4dc6af79 100644
--- a/app/Import/Routine/BunqRoutine.php
+++ b/app/Import/Routine/BunqRoutine.php
@@ -98,8 +98,6 @@ class BunqRoutine implements RoutineInterface
}
-
-
/**
* Set the import job.
*
diff --git a/app/Import/Storage/ImportArrayStorage.php b/app/Import/Storage/ImportArrayStorage.php
index b916953344..761d659188 100644
--- a/app/Import/Storage/ImportArrayStorage.php
+++ b/app/Import/Storage/ImportArrayStorage.php
@@ -227,7 +227,7 @@ class ImportArrayStorage
throw new FireflyException('Could not encode import array. Please see the logs.');
// @codeCoverageIgnoreEnd
}
- $hash = hash('sha256', $json, false);
+ $hash = hash('sha256', $json);
Log::debug(sprintf('The hash is: %s', $hash));
return $hash;
@@ -338,7 +338,7 @@ class ImportArrayStorage
'description' => null,
'latitude' => null,
'longitude' => null,
- 'zoom_level' => null,
+ 'zoom_level' => null,
'tagMode' => 'nothing',
];
$tag = $repository->store($data);
diff --git a/app/Jobs/CreateRecurringTransactions.php b/app/Jobs/CreateRecurringTransactions.php
index 55e5bca7e0..36b72b12fb 100644
--- a/app/Jobs/CreateRecurringTransactions.php
+++ b/app/Jobs/CreateRecurringTransactions.php
@@ -185,7 +185,6 @@ class CreateRecurringTransactions implements ShouldQueue
/** @var Processor $processor */
$processor = app(Processor::class);
$processor->make($rule);
- /** @noinspection ExceptionsAnnotatingAndHandlingInspection */
$processor->handleTransactionJournal($journal);
if ($rule->stop_processing) {
return;
@@ -487,7 +486,7 @@ class CreateRecurringTransactions implements ShouldQueue
}
// has repeated X times.
- $journalCount = $this->repository->getJournalCount($recurrence, null, null);
+ $journalCount = $this->repository->getJournalCount($recurrence);
if (0 !== $recurrence->repetitions && $journalCount >= $recurrence->repetitions) {
Log::info(sprintf('Recurrence #%d has run %d times, so will run no longer.', $recurrence->id, $recurrence->repetitions));
diff --git a/app/Jobs/ExecuteRuleOnExistingTransactions.php b/app/Jobs/ExecuteRuleOnExistingTransactions.php
index 51c7943e8b..a9476a36aa 100644
--- a/app/Jobs/ExecuteRuleOnExistingTransactions.php
+++ b/app/Jobs/ExecuteRuleOnExistingTransactions.php
@@ -165,9 +165,9 @@ class ExecuteRuleOnExistingTransactions extends Job implements ShouldQueue
/** @var Processor $processor */
$processor = app(Processor::class);
$processor->make($this->rule, true);
- $hits = 0;
- $misses = 0;
- $total = 0;
+ $hits = 0;
+ $misses = 0;
+ $total = 0;
// Execute the rules for each transaction
foreach ($transactions as $transaction) {
++$total;
diff --git a/app/Models/Account.php b/app/Models/Account.php
index 125b4da2e6..839e105b79 100644
--- a/app/Models/Account.php
+++ b/app/Models/Account.php
@@ -23,10 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Carbon\Carbon;
-use Crypt;
-use FireflyIII\Exceptions\FireflyException;
use FireflyIII\User;
-use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@@ -34,7 +31,6 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Collection;
-use Log;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
diff --git a/app/Models/Budget.php b/app/Models/Budget.php
index 9c7893d3a1..018595217a 100644
--- a/app/Models/Budget.php
+++ b/app/Models/Budget.php
@@ -45,6 +45,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @property int $order
* @property Carbon created_at
* @property Carbon updated_at
+ * @property User $user
*/
class Budget extends Model
{
diff --git a/app/Models/BudgetLimit.php b/app/Models/BudgetLimit.php
index 508746ac7e..7acf1ccee9 100644
--- a/app/Models/BudgetLimit.php
+++ b/app/Models/BudgetLimit.php
@@ -30,16 +30,16 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* Class BudgetLimit.
*
- * @property Budget $budget
- * @property int $id
- * @property Carbon $created_at
- * @property Carbon $updated_at
- * @property Carbon $start_date
- * @property Carbon $end_date
- * @property string $amount
- * @property int $budget_id
- * @property string spent
- * @property int $transaction_currency_id
+ * @property Budget $budget
+ * @property int $id
+ * @property Carbon $created_at
+ * @property Carbon $updated_at
+ * @property Carbon $start_date
+ * @property Carbon $end_date
+ * @property string $amount
+ * @property int $budget_id
+ * @property string spent
+ * @property int $transaction_currency_id
* @property TransactionCurrency $transactionCurrency
*/
class BudgetLimit extends Model
diff --git a/app/Models/Category.php b/app/Models/Category.php
index b7d92b4313..d28edbfaa8 100644
--- a/app/Models/Category.php
+++ b/app/Models/Category.php
@@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Carbon\Carbon;
-use Crypt;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
diff --git a/app/Models/Preference.php b/app/Models/Preference.php
index 071800e3dd..6539762306 100644
--- a/app/Models/Preference.php
+++ b/app/Models/Preference.php
@@ -23,14 +23,9 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Carbon\Carbon;
-use Crypt;
-use Exception;
-use FireflyIII\Exceptions\FireflyException;
use FireflyIII\User;
-use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
-use Log;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
@@ -54,7 +49,7 @@ class Preference extends Model
= [
'created_at' => 'datetime',
'updated_at' => 'datetime',
- 'data' => 'array',
+ 'data' => 'array',
];
/** @var array Fields that can be filled */
diff --git a/app/Models/Tag.php b/app/Models/Tag.php
index 53405628f5..3496f67125 100644
--- a/app/Models/Tag.php
+++ b/app/Models/Tag.php
@@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Carbon\Carbon;
-use Crypt;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
diff --git a/app/Models/TransactionJournal.php b/app/Models/TransactionJournal.php
index 458b4c7c13..6e90acd9d1 100644
--- a/app/Models/TransactionJournal.php
+++ b/app/Models/TransactionJournal.php
@@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Carbon\Carbon;
-use Crypt;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
@@ -186,15 +185,6 @@ class TransactionJournal extends Model
return $this->belongsToMany(Category::class);
}
- /**
- * @codeCoverageIgnore
- * @return BelongsToMany
- */
- public function transactionGroups(): BelongsToMany
- {
- return $this->belongsToMany(Category::class);
- }
-
/**
* @return bool
*/
@@ -333,6 +323,15 @@ class TransactionJournal extends Model
return $this->belongsTo(TransactionCurrency::class);
}
+ /**
+ * @codeCoverageIgnore
+ * @return BelongsToMany
+ */
+ public function transactionGroups(): BelongsToMany
+ {
+ return $this->belongsToMany(Category::class);
+ }
+
/**
* @codeCoverageIgnore
* @return HasMany
diff --git a/app/Models/TransactionJournalLink.php b/app/Models/TransactionJournalLink.php
index bedf702a47..2a1e588b88 100644
--- a/app/Models/TransactionJournalLink.php
+++ b/app/Models/TransactionJournalLink.php
@@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Carbon\Carbon;
-use Crypt;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\MorphMany;
diff --git a/app/Providers/FireflyServiceProvider.php b/app/Providers/FireflyServiceProvider.php
index 07b9dc9ced..3750650cfd 100644
--- a/app/Providers/FireflyServiceProvider.php
+++ b/app/Providers/FireflyServiceProvider.php
@@ -22,6 +22,7 @@ declare(strict_types=1);
namespace FireflyIII\Providers;
+use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Export\ExpandedProcessor;
use FireflyIII\Export\ProcessorInterface;
use FireflyIII\Generator\Chart\Basic\ChartJsGenerator;
@@ -47,7 +48,6 @@ use FireflyIII\Helpers\Report\ReportHelperInterface;
use FireflyIII\Repositories\User\UserRepository;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\Services\Currency\ExchangeRateInterface;
-use FireflyIII\Services\Currency\FixerIOv2;
use FireflyIII\Services\IP\IpifyOrg;
use FireflyIII\Services\IP\IPRetrievalInterface;
use FireflyIII\Services\Password\PwndVerifierV2;
@@ -186,7 +186,7 @@ class FireflyServiceProvider extends ServiceProvider
$this->app->bind(BalanceReportHelperInterface::class, BalanceReportHelper::class);
$this->app->bind(BudgetReportHelperInterface::class, BudgetReportHelper::class);
$class = (string)config(sprintf('firefly.cer_providers.%s', (string)config('firefly.cer_provider')));
- if('' === $class) {
+ if ('' === $class) {
throw new FireflyException('Invalid currency exchange rate provider. Cannot continue.');
}
$this->app->bind(ExchangeRateInterface::class, $class);
diff --git a/app/Repositories/Account/AccountRepositoryInterface.php b/app/Repositories/Account/AccountRepositoryInterface.php
index 1f60fa2cec..00722f91ec 100644
--- a/app/Repositories/Account/AccountRepositoryInterface.php
+++ b/app/Repositories/Account/AccountRepositoryInterface.php
@@ -45,20 +45,6 @@ interface AccountRepositoryInterface
*/
public function count(array $types): int;
- /**
- * @param Account $account
- *
- * @return string
- */
- public function getAccountType(Account $account): string;
-
- /**
- * @param Account $account
- *
- * @return TransactionCurrency|null
- */
- public function getAccountCurrency(Account $account): ?TransactionCurrency;
-
/**
* Moved here from account CRUD.
*
@@ -102,6 +88,20 @@ interface AccountRepositoryInterface
*/
public function findNull(int $accountId): ?Account;
+ /**
+ * @param Account $account
+ *
+ * @return TransactionCurrency|null
+ */
+ public function getAccountCurrency(Account $account): ?TransactionCurrency;
+
+ /**
+ * @param Account $account
+ *
+ * @return string
+ */
+ public function getAccountType(Account $account): string;
+
/**
* Return account type or null if not found.
*
diff --git a/app/Repositories/Account/AccountTasker.php b/app/Repositories/Account/AccountTasker.php
index cbd0b9509f..3ea1993058 100644
--- a/app/Repositories/Account/AccountTasker.php
+++ b/app/Repositories/Account/AccountTasker.php
@@ -254,7 +254,7 @@ class AccountTasker implements AccountTaskerInterface
$keys = array_keys($expenses);
foreach ($keys as $key) {
$opposingId = $expenses[$key]['id'];
- if(1===$countAccounts[$opposingId]) {
+ if (1 === $countAccounts[$opposingId]) {
$expenses[$key]['name'] = $expenses[$key]['original'];
}
diff --git a/app/Repositories/Attachment/AttachmentRepository.php b/app/Repositories/Attachment/AttachmentRepository.php
index 65edf00f02..2050b408bf 100644
--- a/app/Repositories/Attachment/AttachmentRepository.php
+++ b/app/Repositories/Attachment/AttachmentRepository.php
@@ -33,8 +33,8 @@ use FireflyIII\Models\Note;
use FireflyIII\User;
use Illuminate\Contracts\Filesystem\FileNotFoundException;
use Illuminate\Support\Collection;
-use Log;
use Illuminate\Support\Facades\Storage;
+use Log;
/**
* Class AttachmentRepository.
@@ -231,7 +231,11 @@ class AttachmentRepository implements AttachmentRepositoryInterface
if ('' === $note) {
$dbNote = $attachment->notes()->first();
if (null !== $dbNote) {
- $dbNote->delete();
+ try {
+ $dbNote->delete();
+ } catch (Exception $e) {
+ Log::debug(sprintf('Could not delete note: %s', $e->getMessage()));
+ }
}
return true;