Various code fixes.

This commit is contained in:
James Cole
2022-11-04 05:11:05 +01:00
parent 8d8f81c27d
commit f16b679049
48 changed files with 226 additions and 246 deletions

View File

@@ -17,6 +17,7 @@ parameters:
- ../app/Console/Commands/Correction/FixAccountTypes.php - ../app/Console/Commands/Correction/FixAccountTypes.php
- ../app/Console/Commands/Upgrade/OtherCurrenciesCorrections.php - ../app/Console/Commands/Upgrade/OtherCurrenciesCorrections.php
- ../app/Exceptions/GracefulNotFoundHandler.php - ../app/Exceptions/GracefulNotFoundHandler.php
- ../app/Generator/Webhook/StandardMessageGenerator.php
- -
message: '#Function compact\(\) should not be used#' message: '#Function compact\(\) should not be used#'
paths: paths:
@@ -28,6 +29,9 @@ parameters:
- ../app/Generator/Report/Standard/MultiYearReportGenerator.php - ../app/Generator/Report/Standard/MultiYearReportGenerator.php
- ../app/Generator/Report/Standard/YearReportGenerator.php - ../app/Generator/Report/Standard/YearReportGenerator.php
- ../app/Generator/Report/Tag/MonthReportGenerator.php - ../app/Generator/Report/Tag/MonthReportGenerator.php
- ../app/Http/Controllers/Account/*.php
- ../app/Http/Controllers/Admin/*.php
- ../app/Http/Controllers/*.php
paths: paths:
- ../app - ../app

View File

@@ -156,7 +156,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
return [ return [
'journals' => $journals, 'journals' => $journals,
'currency' => $currency, 'currency' => $currency,
'exists' => !empty($journals), 'exists' => 0 !== count($journals),
'end' => $this->end->isoFormat((string) trans('config.month_and_day_moment_js', [], $locale)), 'end' => $this->end->isoFormat((string) trans('config.month_and_day_moment_js', [], $locale)),
'endBalance' => app('steam')->balance($account, $this->end), 'endBalance' => app('steam')->balance($account, $this->end),
'dayBefore' => $date->isoFormat((string) trans('config.month_and_day_moment_js', [], $locale)), 'dayBefore' => $date->isoFormat((string) trans('config.month_and_day_moment_js', [], $locale)),

View File

@@ -180,7 +180,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
*/ */
protected function getExpenses(): array protected function getExpenses(): array
{ {
if (!empty($this->expenses)) { if (0 !== count($this->expenses)) {
Log::debug('Return previous set of expenses.'); Log::debug('Return previous set of expenses.');
return $this->expenses; return $this->expenses;

View File

@@ -188,7 +188,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
*/ */
protected function getExpenses(): array protected function getExpenses(): array
{ {
if (!empty($this->expenses)) { if (0 !== count($this->expenses)) {
Log::debug('Return previous set of expenses.'); Log::debug('Return previous set of expenses.');
return $this->expenses; return $this->expenses;
@@ -213,7 +213,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
*/ */
protected function getIncome(): array protected function getIncome(): array
{ {
if (!empty($this->income)) { if (0 !== count($this->income)) {
return $this->income; return $this->income;
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
/** /**
* UserEventHandler.php * UserEventHandler.php
* Copyright (c) 2019 james@firefly-iii.org * Copyright (c) 2019 james@firefly-iii.org
@@ -149,6 +150,8 @@ class UserEventHandler
$groupExists = true; $groupExists = true;
$groupTitle = $user->email; $groupTitle = $user->email;
$index = 1; $index = 1;
/** @var UserGroup $group */
$group = null;
// create a new group. // create a new group.
while (true === $groupExists) { while (true === $groupExists) {
@@ -163,6 +166,7 @@ class UserEventHandler
throw new FireflyException('Email address can no longer be used for registrations.'); throw new FireflyException('Email address can no longer be used for registrations.');
} }
} }
/** @var UserRole $role */
$role = UserRole::where('title', UserRole::OWNER)->first(); $role = UserRole::where('title', UserRole::OWNER)->first();
if (null === $role) { if (null === $role) {
throw new FireflyException('The user role is unexpectedly empty. Did you run all migrations?'); throw new FireflyException('The user role is unexpectedly empty. Did you run all migrations?');

View File

@@ -372,7 +372,7 @@ class GroupCollector implements GroupCollectorInterface
*/ */
public function excludeJournalIds(array $journalIds): GroupCollectorInterface public function excludeJournalIds(array $journalIds): GroupCollectorInterface
{ {
if (!empty($journalIds)) { if (0 !== count($journalIds)) {
// make all integers. // make all integers.
$integerIDs = array_map('intval', $journalIds); $integerIDs = array_map('intval', $journalIds);
@@ -894,7 +894,7 @@ class GroupCollector implements GroupCollectorInterface
*/ */
public function setJournalIds(array $journalIds): GroupCollectorInterface public function setJournalIds(array $journalIds): GroupCollectorInterface
{ {
if (!empty($journalIds)) { if (0 !== count($journalIds)) {
// make all integers. // make all integers.
$integerIDs = array_map('intval', $journalIds); $integerIDs = array_map('intval', $journalIds);

View File

@@ -75,13 +75,12 @@ class CreateController extends Controller
* Create a new account. * Create a new account.
* *
* @param Request $request * @param Request $request
* @param string|null $objectType * @param string $objectType
* *
* @return Factory|View * @return Factory|View
*/ */
public function create(Request $request, string $objectType = null) public function create(Request $request, string $objectType)
{ {
$objectType = $objectType ?? 'asset';
$defaultCurrency = app('amount')->getDefaultCurrency(); $defaultCurrency = app('amount')->getDefaultCurrency();
$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $objectType)); $subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $objectType));
$subTitle = (string)trans(sprintf('firefly.make_new_%s_account', $objectType)); $subTitle = (string)trans(sprintf('firefly.make_new_%s_account', $objectType));

View File

@@ -79,7 +79,6 @@ class IndexController extends Controller
*/ */
public function inactive(Request $request, string $objectType) public function inactive(Request $request, string $objectType)
{ {
$objectType = $objectType ?? 'asset';
$inactivePage = true; $inactivePage = true;
$subTitle = (string) trans(sprintf('firefly.%s_accounts_inactive', $objectType)); $subTitle = (string) trans(sprintf('firefly.%s_accounts_inactive', $objectType));
$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $objectType)); $subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $objectType));
@@ -137,7 +136,6 @@ class IndexController extends Controller
public function index(Request $request, string $objectType) public function index(Request $request, string $objectType)
{ {
Log::debug(sprintf('Now at %s', __METHOD__)); Log::debug(sprintf('Now at %s', __METHOD__));
$objectType = $objectType ?? 'asset';
$subTitle = (string) trans(sprintf('firefly.%s_accounts', $objectType)); $subTitle = (string) trans(sprintf('firefly.%s_accounts', $objectType));
$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $objectType)); $subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $objectType));
$types = config(sprintf('firefly.accountTypesByIdentifier.%s', $objectType)); $types = config(sprintf('firefly.accountTypesByIdentifier.%s', $objectType));

View File

@@ -90,7 +90,7 @@ class ReconcileController extends Controller
* @throws \Psr\Container\ContainerExceptionInterface * @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface * @throws \Psr\Container\NotFoundExceptionInterface
*/ */
public function reconcile(Account $account, Carbon $start = null, Carbon $end = null) public function reconcile(Account $account, Carbon $start = null, Carbon $end = null) // @phpstan-ignore-line
{ {
if (!$this->isEditableAccount($account)) { if (!$this->isEditableAccount($account)) {
return $this->redirectAccountToAccount($account); return $this->redirectAccountToAccount($account);

View File

@@ -88,7 +88,7 @@ class ShowController extends Controller
* @throws \Psr\Container\ContainerExceptionInterface * @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface * @throws \Psr\Container\NotFoundExceptionInterface
*/ */
public function show(Request $request, Account $account, Carbon $start = null, Carbon $end = null) public function show(Request $request, Account $account, Carbon $start = null, Carbon $end = null) // @phpstan-ignore-line
{ {
$objectType = config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type)); $objectType = config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type));

View File

@@ -81,8 +81,6 @@ class LoginController extends Controller
* *
* @param Request $request * @param Request $request
* *
* @return JsonResponse|RedirectResponse
*
* @throws ValidationException * @throws ValidationException
*/ */
public function login(Request $request) public function login(Request $request)

View File

@@ -126,7 +126,7 @@ class ResetPasswordController extends Controller
* @throws \Psr\Container\ContainerExceptionInterface * @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface * @throws \Psr\Container\NotFoundExceptionInterface
*/ */
public function showResetForm(Request $request, $token = null) public function showResetForm(Request $request, $token = null) // @phpstan-ignore-line
{ {
$loginProvider = config('firefly.login_provider'); $loginProvider = config('firefly.login_provider');
if ('eloquent' !== $loginProvider) { if ('eloquent' !== $loginProvider) {

View File

@@ -96,7 +96,7 @@ class IndexController extends Controller
* @throws \Psr\Container\ContainerExceptionInterface * @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface * @throws \Psr\Container\NotFoundExceptionInterface
*/ */
public function index(Request $request, Carbon $start = null, Carbon $end = null) public function index(Request $request, Carbon $start = null, Carbon $end = null) // @phpstan-ignore-line
{ {
Log::debug('Start of IndexController::index()'); Log::debug('Start of IndexController::index()');
@@ -122,7 +122,7 @@ class IndexController extends Controller
$sums = $this->getSums($budgets); $sums = $this->getSums($budgets);
// get budgeted for default currency: // get budgeted for default currency:
if (empty($availableBudgets)) { if (0 === count($availableBudgets)) {
$budgeted = $this->blRepository->budgeted($start, $end, $defaultCurrency, ); $budgeted = $this->blRepository->budgeted($start, $end, $defaultCurrency, );
$spentArr = $this->opsRepository->sumExpenses($start, $end, null, null, $defaultCurrency); $spentArr = $this->opsRepository->sumExpenses($start, $end, null, null, $defaultCurrency);
$spent = $spentArr[$defaultCurrency->id]['sum'] ?? '0'; $spent = $spentArr[$defaultCurrency->id]['sum'] ?? '0';

View File

@@ -84,7 +84,7 @@ class ShowController extends Controller
* @throws \Psr\Container\ContainerExceptionInterface * @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface * @throws \Psr\Container\NotFoundExceptionInterface
*/ */
public function noBudget(Request $request, Carbon $start = null, Carbon $end = null) public function noBudget(Request $request, Carbon $start = null, Carbon $end = null)// @phpstan-ignore-line
{ {
/** @var Carbon $start */ /** @var Carbon $start */
$start = $start ?? session('start'); $start = $start ?? session('start');

View File

@@ -80,7 +80,7 @@ class NoCategoryController extends Controller
* @throws \Psr\Container\ContainerExceptionInterface * @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface * @throws \Psr\Container\NotFoundExceptionInterface
*/ */
public function show(Request $request, Carbon $start = null, Carbon $end = null) public function show(Request $request, Carbon $start = null, Carbon $end = null)// @phpstan-ignore-line
{ {
Log::debug('Start of noCategory()'); Log::debug('Start of noCategory()');
/** @var Carbon $start */ /** @var Carbon $start */

View File

@@ -82,7 +82,7 @@ class ShowController extends Controller
* @throws \Psr\Container\ContainerExceptionInterface * @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface * @throws \Psr\Container\NotFoundExceptionInterface
*/ */
public function show(Request $request, Category $category, Carbon $start = null, Carbon $end = null) public function show(Request $request, Category $category, Carbon $start = null, Carbon $end = null) // @phpstan-ignore-line
{ {
/** @var Carbon $start */ /** @var Carbon $start */
$start = $start ?? session('start', Carbon::now()->startOfMonth()); $start = $start ?? session('start', Carbon::now()->startOfMonth());

View File

@@ -1,4 +1,5 @@
<?php <?php
/** /**
* AccountController.php * AccountController.php
* Copyright (c) 2019 james@firefly-iii.org * Copyright (c) 2019 james@firefly-iii.org
@@ -337,7 +338,7 @@ class AccountController extends Controller
Log::debug('Default set is ', $defaultSet); Log::debug('Default set is ', $defaultSet);
$frontPage = app('preferences')->get('frontPageAccounts', $defaultSet); $frontPage = app('preferences')->get('frontPageAccounts', $defaultSet);
Log::debug('Frontpage preference set is ', $frontPage->data); Log::debug('Frontpage preference set is ', $frontPage->data);
if (empty($frontPage->data)) { if (0 === count($frontPage->data)) {
app('preferences')->set('frontPageAccounts', $defaultSet); app('preferences')->set('frontPageAccounts', $defaultSet);
Log::debug('frontpage set is empty!'); Log::debug('frontpage set is empty!');
} }
@@ -478,14 +479,11 @@ class AccountController extends Controller
'label' => sprintf('%s (%s)', $account->name, $currency->symbol), 'label' => sprintf('%s (%s)', $account->name, $currency->symbol),
'currency_symbol' => $currency->symbol, 'currency_symbol' => $currency->symbol,
'currency_code' => $currency->code, 'currency_code' => $currency->code,
'entries' => [],
]; ];
$entries = []; $entries = [];
$current = clone $start; $current = clone $start;
switch ($step) {
default: if ('1D' === $step) {
break;
case '1D':
// per day the entire period, balance for every day. // per day the entire period, balance for every day.
$format = (string)trans('config.month_and_day_js', [], $locale); $format = (string)trans('config.month_and_day_js', [], $locale);
$range = app('steam')->balanceInRange($account, $start, $end, $currency); $range = app('steam')->balanceInRange($account, $start, $end, $currency);
@@ -498,18 +496,14 @@ class AccountController extends Controller
$previous = $balance; $previous = $balance;
$current->addDay(); $current->addDay();
} }
break; }
if ('1W' === $step || '1M' === $step || '1Y' === $step) {
case '1W':
case '1M':
case '1Y':
while ($end >= $current) { while ($end >= $current) {
$balance = (float)app('steam')->balance($account, $current, $currency); $balance = (float)app('steam')->balance($account, $current, $currency);
$label = app('navigation')->periodShow($current, $step); $label = app('navigation')->periodShow($current, $step);
$entries[$label] = $balance; $entries[$label] = $balance;
$current = app('navigation')->addPeriod($current, $step, 0); $current = app('navigation')->addPeriod($current, $step, 0);
} }
break;
} }
$result['entries'] = $entries; $result['entries'] = $entries;

View File

@@ -205,7 +205,7 @@ class BudgetController extends Controller
* *
* @return JsonResponse * @return JsonResponse
*/ */
public function expenseAsset(Budget $budget, ?BudgetLimit $budgetLimit = null): JsonResponse public function expenseAsset(Budget $budget, ?BudgetLimit $budgetLimit = null): JsonResponse // @phpstan-ignore-line
{ {
/** @var GroupCollectorInterface $collector */ /** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);
@@ -273,7 +273,7 @@ class BudgetController extends Controller
* *
* @return JsonResponse * @return JsonResponse
*/ */
public function expenseCategory(Budget $budget, ?BudgetLimit $budgetLimit = null): JsonResponse public function expenseCategory(Budget $budget, ?BudgetLimit $budgetLimit = null): JsonResponse // @phpstan-ignore-line
{ {
/** @var GroupCollectorInterface $collector */ /** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);
@@ -337,7 +337,7 @@ class BudgetController extends Controller
* *
* @return JsonResponse * @return JsonResponse
*/ */
public function expenseExpense(Budget $budget, ?BudgetLimit $budgetLimit = null): JsonResponse public function expenseExpense(Budget $budget, ?BudgetLimit $budgetLimit = null): JsonResponse // @phpstan-ignore-line
{ {
/** @var GroupCollectorInterface $collector */ /** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);

View File

@@ -1,4 +1,5 @@
<?php <?php
/** /**
* CategoryController.php * CategoryController.php
* Copyright (c) 2019 james@firefly-iii.org * Copyright (c) 2019 james@firefly-iii.org
@@ -23,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Chart; namespace FireflyIII\Http\Controllers\Chart;
use Carbon\Carbon; use Carbon\Carbon;
use Exception;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Generator\Chart\Basic\GeneratorInterface; use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Controllers\Controller;
@@ -39,7 +39,6 @@ use FireflyIII\Support\Http\Controllers\ChartGeneration;
use FireflyIII\Support\Http\Controllers\DateCalculation; use FireflyIII\Support\Http\Controllers\DateCalculation;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use JsonException;
/** /**
* Class CategoryController. * Class CategoryController.
@@ -106,14 +105,7 @@ class CategoryController extends Controller
*/ */
private function getDate(): Carbon private function getDate(): Carbon
{ {
$carbon = null; return today(config('app.timezone'));
try {
$carbon = today(config('app.timezone'));
} catch (Exception $e) {
// @ignoreException
}
return $carbon;
} }
/** /**

View File

@@ -318,7 +318,7 @@ class DoubleReportController extends Controller
$journalId = $journal['transaction_journal_id']; $journalId = $journal['transaction_journal_id'];
// no tags? also deserves a sport // no tags? also deserves a sport
if (empty($journal['tags'])) { if (0 === count($journal['tags'])) {
$includedJournals[] = $journalId; $includedJournals[] = $journalId;
// do something // do something
$tagName = trans('firefly.no_tags'); $tagName = trans('firefly.no_tags');
@@ -378,7 +378,7 @@ class DoubleReportController extends Controller
$journalId = $journal['transaction_journal_id']; $journalId = $journal['transaction_journal_id'];
// no tags? also deserves a sport // no tags? also deserves a sport
if (empty($journal['tags'])) { if (0 === count($journal['tags'])) {
$includedJournals[] = $journalId; $includedJournals[] = $journalId;
// do something // do something
$tagName = trans('firefly.no_tags'); $tagName = trans('firefly.no_tags');

View File

@@ -189,7 +189,7 @@ class ExpenseReportController extends Controller
$newSet[$key] = $entry; $newSet[$key] = $entry;
} }
} }
if (empty($newSet)) { if (0 === count($newSet)) {
$newSet = $chartData; $newSet = $chartData;
} }
$data = $this->generator->multiSet($newSet); $data = $this->generator->multiSet($newSet);

View File

@@ -115,20 +115,17 @@ class TransactionController extends Controller
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);
$collector->setRange($start, $end); $collector->setRange($start, $end);
$collector->withCategoryInformation(); $collector->withCategoryInformation();
switch ($objectType) {
default: if ('withdrawal' === $objectType) {
throw new FireflyException(sprintf('Cant handle "%s"', $objectType));
case 'withdrawal':
$collector->setTypes([TransactionType::WITHDRAWAL]); $collector->setTypes([TransactionType::WITHDRAWAL]);
break;
case 'deposit':
$collector->setTypes([TransactionType::DEPOSIT]);
break;
case 'transfers':
case 'transfer':
$collector->setTypes([TransactionType::TRANSFER]);
break;
} }
if ('deposit' === $objectType) {
$collector->setTypes([TransactionType::DEPOSIT]);
}
if ('transfer' === $objectType || 'transfers' === $objectType) {
$collector->setTypes([TransactionType::TRANSFER]);
}
$result = $collector->getExtractedJournals(); $result = $collector->getExtractedJournals();
$data = []; $data = [];
@@ -172,20 +169,17 @@ class TransactionController extends Controller
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);
$collector->setRange($start, $end); $collector->setRange($start, $end);
$collector->withAccountInformation(); $collector->withAccountInformation();
switch ($objectType) {
default: if ('withdrawal' === $objectType) {
throw new FireflyException(sprintf('Cant handle "%s"', $objectType));
case 'withdrawal':
$collector->setTypes([TransactionType::WITHDRAWAL]); $collector->setTypes([TransactionType::WITHDRAWAL]);
break;
case 'deposit':
$collector->setTypes([TransactionType::DEPOSIT]);
break;
case 'transfers':
case 'transfer':
$collector->setTypes([TransactionType::TRANSFER]);
break;
} }
if ('deposit' === $objectType) {
$collector->setTypes([TransactionType::DEPOSIT]);
}
if ('transfer' === $objectType || 'transfers' === $objectType) {
$collector->setTypes([TransactionType::TRANSFER]);
}
$result = $collector->getExtractedJournals(); $result = $collector->getExtractedJournals();
$data = []; $data = [];
@@ -229,20 +223,17 @@ class TransactionController extends Controller
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);
$collector->setRange($start, $end); $collector->setRange($start, $end);
$collector->withAccountInformation(); $collector->withAccountInformation();
switch ($objectType) {
default: if ('withdrawal' === $objectType) {
throw new FireflyException(sprintf('Cant handle "%s"', $objectType));
case 'withdrawal':
$collector->setTypes([TransactionType::WITHDRAWAL]); $collector->setTypes([TransactionType::WITHDRAWAL]);
break;
case 'deposit':
$collector->setTypes([TransactionType::DEPOSIT]);
break;
case 'transfers':
case 'transfer':
$collector->setTypes([TransactionType::TRANSFER]);
break;
} }
if ('deposit' === $objectType) {
$collector->setTypes([TransactionType::DEPOSIT]);
}
if ('transfer' === $objectType || 'transfers' === $objectType) {
$collector->setTypes([TransactionType::TRANSFER]);
}
$result = $collector->getExtractedJournals(); $result = $collector->getExtractedJournals();
$data = []; $data = [];

View File

@@ -98,7 +98,7 @@ class DebugController extends Controller
Log::debug('Call twig:clean...'); Log::debug('Call twig:clean...');
try { try {
Artisan::call('twig:clean'); Artisan::call('twig:clean');
} catch (Exception $e) { } catch (Exception $e) { // @phpstan-ignore-line
// @ignoreException // @ignoreException
} }
@@ -188,7 +188,7 @@ class DebugController extends Controller
if (null !== $logFile) { if (null !== $logFile) {
try { try {
$logContent = file_get_contents($logFile); $logContent = file_get_contents($logFile);
} catch (Exception $e) { } catch (Exception $e) { // @phpstan-ignore-line
// @ignoreException // @ignoreException
} }
} }

View File

@@ -190,7 +190,7 @@ class BoxController extends Controller
$incomes[$currencyId] = app('amount')->formatAnything($currency, $incomes[$currencyId] ?? '0', false); $incomes[$currencyId] = app('amount')->formatAnything($currency, $incomes[$currencyId] ?? '0', false);
$expenses[$currencyId] = app('amount')->formatAnything($currency, $expenses[$currencyId] ?? '0', false); $expenses[$currencyId] = app('amount')->formatAnything($currency, $expenses[$currencyId] ?? '0', false);
} }
if (empty($sums)) { if (0 === count($sums)) {
$currency = app('amount')->getDefaultCurrency(); $currency = app('amount')->getDefaultCurrency();
$sums[$currency->id] = app('amount')->formatAnything($currency, '0', false); $sums[$currency->id] = app('amount')->formatAnything($currency, '0', false);
$incomes[$currency->id] = app('amount')->formatAnything($currency, '0', false); $incomes[$currency->id] = app('amount')->formatAnything($currency, '0', false);

View File

@@ -68,7 +68,7 @@ class FrontpageController extends Controller
} }
} }
$html = ''; $html = '';
if (!empty($info)) { if (0 !== count($info)) {
try { try {
$html = view('json.piggy-banks', compact('info'))->render(); $html = view('json.piggy-banks', compact('info'))->render();
} catch (Throwable $e) { } catch (Throwable $e) {

View File

@@ -43,13 +43,13 @@ class IntroController extends Controller
* *
* @return JsonResponse * @return JsonResponse
*/ */
public function getIntroSteps(string $route, string $specificPage = null): JsonResponse public function getIntroSteps(string $route, string $specificPage = null): JsonResponse // @phpstan-ignore-line
{ {
Log::debug(sprintf('getIntroSteps for route "%s" and page "%s"', $route, $specificPage)); Log::debug(sprintf('getIntroSteps for route "%s" and page "%s"', $route, $specificPage));
$specificPage = $specificPage ?? ''; $specificPage = $specificPage ?? '';
$steps = $this->getBasicSteps($route); $steps = $this->getBasicSteps($route);
$specificSteps = $this->getSpecificSteps($route, $specificPage); $specificSteps = $this->getSpecificSteps($route, $specificPage);
if (empty($specificSteps)) { if (0 === count($specificSteps)) {
Log::debug(sprintf('No specific steps for route "%s" and page "%s"', $route, $specificPage)); Log::debug(sprintf('No specific steps for route "%s" and page "%s"', $route, $specificPage));
return response()->json($steps); return response()->json($steps);
@@ -104,7 +104,7 @@ class IntroController extends Controller
* @return JsonResponse * @return JsonResponse
* @throws FireflyException * @throws FireflyException
*/ */
public function postEnable(string $route, string $specialPage = null): JsonResponse public function postEnable(string $route, string $specialPage = null): JsonResponse // @phpstan-ignore-line
{ {
$specialPage = $specialPage ?? ''; $specialPage = $specialPage ?? '';
$route = str_replace('.', '_', $route); $route = str_replace('.', '_', $route);
@@ -128,7 +128,7 @@ class IntroController extends Controller
* @return JsonResponse * @return JsonResponse
* @throws FireflyException * @throws FireflyException
*/ */
public function postFinished(string $route, string $specialPage = null): JsonResponse public function postFinished(string $route, string $specialPage = null): JsonResponse // @phpstan-ignore-line
{ {
$specialPage = $specialPage ?? ''; $specialPage = $specialPage ?? '';
$key = 'shown_demo_' . $route; $key = 'shown_demo_' . $route;

View File

@@ -85,7 +85,7 @@ class ReconcileController extends Controller
* @throws FireflyException * @throws FireflyException
* @throws JsonException * @throws JsonException
*/ */
public function overview(Request $request, Account $account = null, Carbon $start = null, Carbon $end = null): JsonResponse public function overview(Request $request, Account $account = null, Carbon $start = null, Carbon $end = null): JsonResponse // @phpstan-ignore-line
{ {
$startBalance = $request->get('startBalance'); $startBalance = $request->get('startBalance');
$endBalance = $request->get('endBalance'); $endBalance = $request->get('endBalance');
@@ -226,7 +226,7 @@ class ReconcileController extends Controller
* @throws FireflyException * @throws FireflyException
* @throws JsonException * @throws JsonException
*/ */
public function transactions(Account $account, Carbon $start = null, Carbon $end = null) public function transactions(Account $account, Carbon $start = null, Carbon $end = null) // @phpstan-ignore-line
{ {
if (null === $start || null === $end) { if (null === $start || null === $end) {
throw new FireflyException('Invalid dates submitted.'); throw new FireflyException('Invalid dates submitted.');

View File

@@ -127,7 +127,7 @@ class PreferencesController extends Controller
$locales = ['equal' => (string) trans('firefly.equal_to_language')] + $locales; $locales = ['equal' => (string) trans('firefly.equal_to_language')] + $locales;
// an important fallback is that the frontPageAccount array gets refilled automatically // an important fallback is that the frontPageAccount array gets refilled automatically
// when it turns up empty. // when it turns up empty.
if (empty($frontPageAccounts->data)) { if (0 === count($frontPageAccounts->data)) {
$frontPageAccounts = $accountIds; $frontPageAccounts = $accountIds;
} }

View File

@@ -728,7 +728,7 @@ class CategoryController extends Controller
} catch (Throwable $e) { } catch (Throwable $e) {
Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage())); Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage()));
$result = sprintf('Could not render view: %s', $e->getMessage()); $result = sprintf('Could not render view: %s', $e->getMessage());
throw new FireflyException($result, 0, $e); throw new FireflyException($e->getMessage(), 0, $e);
} }
return $result; return $result;
@@ -778,7 +778,7 @@ class CategoryController extends Controller
} catch (Throwable $e) { } catch (Throwable $e) {
Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage())); Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage()));
$result = sprintf('Could not render view: %s', $e->getMessage()); $result = sprintf('Could not render view: %s', $e->getMessage());
throw new FireflyException($result, 0, $e); throw new FireflyException($e->getMessage(), 0, $e);
} }
return $result; return $result;

View File

@@ -115,7 +115,7 @@ class DoubleController extends Controller
} catch (Throwable $e) { } catch (Throwable $e) {
Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage())); Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage()));
$result = sprintf('Could not render view: %s', $e->getMessage()); $result = sprintf('Could not render view: %s', $e->getMessage());
throw new FireflyException($result, 0, $e); throw new FireflyException($e->getMessage(), 0, $e);
} }
return $result; return $result;
@@ -167,7 +167,7 @@ class DoubleController extends Controller
} catch (Throwable $e) { } catch (Throwable $e) {
Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage())); Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage()));
$result = sprintf('Could not render view: %s', $e->getMessage()); $result = sprintf('Could not render view: %s', $e->getMessage());
throw new FireflyException($result, 0, $e); throw new FireflyException($e->getMessage(), 0, $e);
} }
return $result; return $result;
@@ -461,7 +461,7 @@ class DoubleController extends Controller
} catch (Throwable $e) { } catch (Throwable $e) {
Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage())); Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage()));
$result = sprintf('Could not render view: %s', $e->getMessage()); $result = sprintf('Could not render view: %s', $e->getMessage());
throw new FireflyException($result, 0, $e); throw new FireflyException($e->getMessage(), 0, $e);
} }
return $result; return $result;
@@ -511,7 +511,7 @@ class DoubleController extends Controller
} catch (Throwable $e) { } catch (Throwable $e) {
Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage())); Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage()));
$result = sprintf('Could not render view: %s', $e->getMessage()); $result = sprintf('Could not render view: %s', $e->getMessage());
throw new FireflyException($result, 0, $e); throw new FireflyException($e->getMessage(), 0, $e);
} }
return $result; return $result;

View File

@@ -145,7 +145,7 @@ class SelectController extends Controller
$textTriggers = $this->getValidTriggerList($request); $textTriggers = $this->getValidTriggerList($request);
// warn if nothing. // warn if nothing.
if (empty($textTriggers)) { if (0 === count($textTriggers)) {
return response()->json(['html' => '', 'warning' => (string) trans('firefly.warning_no_valid_triggers')]); return response()->json(['html' => '', 'warning' => (string) trans('firefly.warning_no_valid_triggers')]);
} }
@@ -169,7 +169,7 @@ class SelectController extends Controller
// Warn the user if only a subset of transactions is returned // Warn the user if only a subset of transactions is returned
$warning = ''; $warning = '';
if (empty($collection)) { if (0 === count($collection)) {
$warning = (string) trans('firefly.warning_no_matching_transactions'); $warning = (string) trans('firefly.warning_no_matching_transactions');
} }
@@ -200,7 +200,7 @@ class SelectController extends Controller
{ {
$triggers = $rule->ruleTriggers; $triggers = $rule->ruleTriggers;
if (empty($triggers)) { if (0 === count($triggers)) {
return response()->json(['html' => '', 'warning' => (string) trans('firefly.warning_no_valid_triggers')]); return response()->json(['html' => '', 'warning' => (string) trans('firefly.warning_no_valid_triggers')]);
} }
// create new rule engine: // create new rule engine:
@@ -212,7 +212,7 @@ class SelectController extends Controller
$collection = $collection->slice(0, 20); $collection = $collection->slice(0, 20);
$warning = ''; $warning = '';
if (empty($collection)) { if (0 === count($collection)) {
$warning = (string) trans('firefly.warning_no_matching_transactions'); $warning = (string) trans('firefly.warning_no_matching_transactions');
} }

View File

@@ -87,7 +87,7 @@ class Authenticate
*/ */
protected function authenticate($request, array $guards) protected function authenticate($request, array $guards)
{ {
if (empty($guards)) { if (0 === count($guards)) {
try { try {
// go for default guard: // go for default guard:
if ($this->auth->check()) { if ($this->auth->check()) {

View File

@@ -296,7 +296,7 @@ class TransactionJournal extends Model
if (!self::isJoined($query, 'transaction_types')) { if (!self::isJoined($query, 'transaction_types')) {
$query->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id'); $query->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id');
} }
if (!empty($types)) { if (0 !== count($types)) {
$query->whereIn('transaction_types.type', $types); $query->whereIn('transaction_types.type', $types);
} }
} }

View File

@@ -142,7 +142,7 @@ class AccountRepository implements AccountRepositoryInterface
} }
); );
if (!empty($types)) { if (0 !== count($types)) {
$dbQuery->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id'); $dbQuery->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
$dbQuery->whereIn('account_types.type', $types); $dbQuery->whereIn('account_types.type', $types);
} }
@@ -160,7 +160,7 @@ class AccountRepository implements AccountRepositoryInterface
{ {
$query = $this->user->accounts()->where('iban', '!=', '')->whereNotNull('iban'); $query = $this->user->accounts()->where('iban', '!=', '')->whereNotNull('iban');
if (!empty($types)) { if (0 !== count($types)) {
$query->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id'); $query->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
$query->whereIn('account_types.type', $types); $query->whereIn('account_types.type', $types);
} }
@@ -178,7 +178,7 @@ class AccountRepository implements AccountRepositoryInterface
{ {
$query = $this->user->accounts(); $query = $this->user->accounts();
if (!empty($types)) { if (0 !== count($types)) {
$query->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id'); $query->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
$query->whereIn('account_types.type', $types); $query->whereIn('account_types.type', $types);
} }
@@ -218,7 +218,7 @@ class AccountRepository implements AccountRepositoryInterface
{ {
$query = $this->user->accounts(); $query = $this->user->accounts();
if (!empty($accountIds)) { if (0 !== count($accountIds)) {
$query->whereIn('accounts.id', $accountIds); $query->whereIn('accounts.id', $accountIds);
} }
$query->orderBy('accounts.order', 'ASC'); $query->orderBy('accounts.order', 'ASC');
@@ -240,7 +240,7 @@ class AccountRepository implements AccountRepositoryInterface
$query->where('name', 'account_role'); $query->where('name', 'account_role');
}, 'attachments'] }, 'attachments']
); );
if (!empty($types)) { if (0 !== count($types)) {
$query->accountTypeIn($types); $query->accountTypeIn($types);
} }
$query->where('active', true); $query->where('active', true);
@@ -316,7 +316,7 @@ class AccountRepository implements AccountRepositoryInterface
$query->where('name', 'account_role'); $query->where('name', 'account_role');
}] }]
); );
if (!empty($types)) { if (0 !== count($types)) {
$query->accountTypeIn($types); $query->accountTypeIn($types);
} }
$query->where('active', 0); $query->where('active', 0);
@@ -585,19 +585,19 @@ class AccountRepository implements AccountRepositoryInterface
{ {
$res = array_intersect([AccountType::ASSET, AccountType::MORTGAGE, AccountType::LOAN, AccountType::DEBT], $types); $res = array_intersect([AccountType::ASSET, AccountType::MORTGAGE, AccountType::LOAN, AccountType::DEBT], $types);
$query = $this->user->accounts(); $query = $this->user->accounts();
if (!empty($types)) { if (0 !== count($types)) {
$query->accountTypeIn($types); $query->accountTypeIn($types);
} }
// add sort parameters. At this point they're filtered to allowed fields to sort by: // add sort parameters. At this point they're filtered to allowed fields to sort by:
if (!empty($sort)) { if (0 !== count($sort)) {
foreach ($sort as $param) { foreach ($sort as $param) {
$query->orderBy($param[0], $param[1]); $query->orderBy($param[0], $param[1]);
} }
} }
if (empty($sort)) { if (0 === count($sort)) {
if (!empty($res)) { if (0 !== count($res)) {
$query->orderBy('accounts.order', 'ASC'); $query->orderBy('accounts.order', 'ASC');
} }
$query->orderBy('accounts.active', 'DESC'); $query->orderBy('accounts.active', 'DESC');
@@ -698,7 +698,7 @@ class AccountRepository implements AccountRepositoryInterface
$dbQuery->where('name', 'LIKE', $search); $dbQuery->where('name', 'LIKE', $search);
} }
} }
if (!empty($types)) { if (0 !== count($types)) {
$dbQuery->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id'); $dbQuery->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
$dbQuery->whereIn('account_types.type', $types); $dbQuery->whereIn('account_types.type', $types);
} }
@@ -736,7 +736,7 @@ class AccountRepository implements AccountRepositoryInterface
); );
} }
} }
if (!empty($types)) { if (0 !== count($types)) {
$dbQuery->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id'); $dbQuery->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
$dbQuery->whereIn('account_types.type', $types); $dbQuery->whereIn('account_types.type', $types);
} }

View File

@@ -332,7 +332,7 @@ class RecurringRepository implements RecurringRepositoryInterface
foreach ($journalMeta as $journalId) { foreach ($journalMeta as $journalId) {
$search[] = (int) $journalId; $search[] = (int) $journalId;
} }
if (empty($search)) { if (0 === count($search)) {
return new Collection(); return new Collection();
} }

View File

@@ -68,7 +68,7 @@ class CreditRecalculateService
// work based on account. // work based on account.
$this->processAccount(); $this->processAccount();
} }
if (empty($this->work)) { if (0 === count($this->work)) {
Log::debug('No work accounts, do not do CreditRecalculationService'); Log::debug('No work accounts, do not do CreditRecalculationService');
return; return;
@@ -84,7 +84,7 @@ class CreditRecalculateService
{ {
/** @var TransactionJournal $journal */ /** @var TransactionJournal $journal */
foreach ($this->group->transactionJournals as $journal) { foreach ($this->group->transactionJournals as $journal) {
if (empty($this->work)) { if (0 === count($this->work)) {
try { try {
$this->findByJournal($journal); $this->findByJournal($journal);
} catch (FireflyException $e) { } catch (FireflyException $e) {

View File

@@ -339,7 +339,7 @@ trait RecurringTransactionTrait
*/ */
protected function updateTags(RecurrenceTransaction $transaction, array $tags): void protected function updateTags(RecurrenceTransaction $transaction, array $tags): void
{ {
if (!empty($tags)) { if (0 !== count($tags)) {
/** @var RecurrenceMeta|null $entry */ /** @var RecurrenceMeta|null $entry */
$entry = $transaction->recurrenceTransactionMeta()->where('name', 'tags')->first(); $entry = $transaction->recurrenceTransactionMeta()->where('name', 'tags')->first();
if (null === $entry) { if (null === $entry) {
@@ -348,7 +348,7 @@ trait RecurringTransactionTrait
$entry->value = json_encode($tags); $entry->value = json_encode($tags);
$entry->save(); $entry->save();
} }
if (empty($tags)) { if (0 === count($tags)) {
// delete if present // delete if present
$transaction->recurrenceTransactionMeta()->where('name', 'tags')->delete(); $transaction->recurrenceTransactionMeta()->where('name', 'tags')->delete();
} }

View File

@@ -60,7 +60,7 @@ class GroupUpdateService
} }
if (empty($transactions)) { if (0 === count($transactions)) {
Log::debug('No transactions submitted, do nothing.'); Log::debug('No transactions submitted, do nothing.');
return $transactionGroup; return $transactionGroup;
@@ -119,7 +119,7 @@ class GroupUpdateService
private function updateTransactionJournal(TransactionGroup $transactionGroup, TransactionJournal $journal, array $data): void private function updateTransactionJournal(TransactionGroup $transactionGroup, TransactionJournal $journal, array $data): void
{ {
Log::debug(sprintf('Now in %s', __METHOD__)); Log::debug(sprintf('Now in %s', __METHOD__));
if (empty($data)) { if (0 === count($data)) {
return; return;
} }
if (1 === count($data) && array_key_exists('transaction_journal_id', $data)) { if (1 === count($data) && array_key_exists('transaction_journal_id', $data)) {

View File

@@ -150,7 +150,7 @@ class RecurrenceUpdateService
private function updateRepetitions(Recurrence $recurrence, array $repetitions): void private function updateRepetitions(Recurrence $recurrence, array $repetitions): void
{ {
$originalCount = $recurrence->recurrenceRepetitions()->count(); $originalCount = $recurrence->recurrenceRepetitions()->count();
if (empty($repetitions)) { if (0 === count($repetitions)) {
// wont drop repetition, rather avoid. // wont drop repetition, rather avoid.
return; return;
} }
@@ -228,7 +228,7 @@ class RecurrenceUpdateService
private function updateTransactions(Recurrence $recurrence, array $transactions): void private function updateTransactions(Recurrence $recurrence, array $transactions): void
{ {
$originalCount = $recurrence->recurrenceTransactions()->count(); $originalCount = $recurrence->recurrenceTransactions()->count();
if (empty($transactions)) { if (0 === count($transactions)) {
// wont drop transactions, rather avoid. // wont drop transactions, rather avoid.
return; return;
} }

View File

@@ -54,7 +54,7 @@ class BudgetList implements BinderInterface
$list = array_unique(array_map('\intval', explode(',', $value))); $list = array_unique(array_map('\intval', explode(',', $value)));
if (empty($list)) { if (0 === count($list)) {
app('log')->warning('Budget list count is zero, return 404.'); app('log')->warning('Budget list count is zero, return 404.');
throw new NotFoundHttpException(); throw new NotFoundHttpException();
} }

View File

@@ -50,7 +50,7 @@ class CategoryList implements BinderInterface
} }
$list = array_unique(array_map('\intval', explode(',', $value))); $list = array_unique(array_map('\intval', explode(',', $value)));
if (empty($list)) { if (0 === count($list)) {
throw new NotFoundHttpException(); throw new NotFoundHttpException();
} }

View File

@@ -52,7 +52,7 @@ class JournalList implements BinderInterface
$collector->withCategoryInformation()->withBudgetInformation()->withTagInformation()->withAccountInformation(); $collector->withCategoryInformation()->withBudgetInformation()->withTagInformation()->withAccountInformation();
$collector->setJournalIds($list); $collector->setJournalIds($list);
$result = $collector->getExtractedJournals(); $result = $collector->getExtractedJournals();
if (empty($result)) { if (0 === count($result)) {
throw new NotFoundHttpException(); throw new NotFoundHttpException();
} }
@@ -69,7 +69,7 @@ class JournalList implements BinderInterface
protected static function parseList(string $value): array protected static function parseList(string $value): array
{ {
$list = array_unique(array_map('\intval', explode(',', $value))); $list = array_unique(array_map('\intval', explode(',', $value)));
if (empty($list)) { if (0 === count($list)) {
throw new NotFoundHttpException(); throw new NotFoundHttpException();
} }

View File

@@ -52,7 +52,7 @@ class TagList implements BinderInterface
$list = array_unique(array_map('\strtolower', explode(',', $value))); $list = array_unique(array_map('\strtolower', explode(',', $value)));
Log::debug('List of tags is', $list); Log::debug('List of tags is', $list);
if (empty($list)) { if (0 === count($list)) {
Log::error('Tag list is empty.'); Log::error('Tag list is empty.');
throw new NotFoundHttpException(); throw new NotFoundHttpException();
} }

View File

@@ -767,7 +767,7 @@ class ExportDataGenerator
*/ */
private function mergeTags(array $tags): string private function mergeTags(array $tags): string
{ {
if (empty($tags)) { if (0 === count($tags)) {
return ''; return '';
} }
$smol = []; $smol = [];

View File

@@ -1993,7 +1993,7 @@ class OperatorQuerySearch implements SearchInterface
*/ */
public function searchTransactions(): LengthAwarePaginator public function searchTransactions(): LengthAwarePaginator
{ {
if (empty($this->getWords()) && empty($this->getOperators())) { if (0 === count($this->getWords()) && 0 === count($this->getOperators())) {
return new LengthAwarePaginator([], 0, 5, 1); return new LengthAwarePaginator([], 0, 5, 1);
} }

View File

@@ -92,7 +92,7 @@ class ActionFactory
*/ */
protected static function getActionTypes(): array protected static function getActionTypes(): array
{ {
if (empty(self::$actionTypes)) { if (0 === count(self::$actionTypes)) {
self::$actionTypes = Domain::getRuleActions(); self::$actionTypes = Domain::getRuleActions();
} }

View File

@@ -126,7 +126,7 @@ trait RecurrenceValidation
$data = $validator->getData(); $data = $validator->getData();
$repetitions = $data['repetitions'] ?? []; $repetitions = $data['repetitions'] ?? [];
// need at least one transaction // need at least one transaction
if (!is_countable($repetitions) || empty($repetitions)) { if (!is_countable($repetitions) || 0 === count($repetitions)) {
$validator->errors()->add('repetitions', (string) trans('validation.at_least_one_repetition')); $validator->errors()->add('repetitions', (string) trans('validation.at_least_one_repetition'));
} }
} }
@@ -144,7 +144,7 @@ trait RecurrenceValidation
return; return;
} }
// need at least one transaction // need at least one transaction
if (empty($repetitions)) { if (0 === count($repetitions)) {
$validator->errors()->add('repetitions', (string) trans('validation.at_least_one_repetition')); $validator->errors()->add('repetitions', (string) trans('validation.at_least_one_repetition'));
} }
} }

View File

@@ -312,7 +312,7 @@ trait TransactionValidation
$transactions = $this->getTransactionsArray($validator); $transactions = $this->getTransactionsArray($validator);
// need at least one transaction // need at least one transaction
if (empty($transactions)) { if (0 === count($transactions)) {
$validator->errors()->add('transactions', (string) trans('validation.at_least_one_transaction')); $validator->errors()->add('transactions', (string) trans('validation.at_least_one_transaction'));
} }
} }
@@ -327,7 +327,7 @@ trait TransactionValidation
Log::debug('Now in validateOneTransaction()'); Log::debug('Now in validateOneTransaction()');
$transactions = $this->getTransactionsArray($validator); $transactions = $this->getTransactionsArray($validator);
// need at least one transaction // need at least one transaction
if (empty($transactions)) { if (0 === count($transactions)) {
$validator->errors()->add('transactions.0.description', (string) trans('validation.at_least_one_transaction')); $validator->errors()->add('transactions.0.description', (string) trans('validation.at_least_one_transaction'));
Log::debug('Added error: at_least_one_transaction.'); Log::debug('Added error: at_least_one_transaction.');