Clean up code.

This commit is contained in:
James Cole
2023-12-10 06:45:59 +01:00
parent 9a807fc215
commit c2b22a2bac
157 changed files with 648 additions and 669 deletions

View File

@@ -36,13 +36,15 @@ $finder = PhpCsFixer\Finder::create()
$config = new PhpCsFixer\Config();
return $config->setRules([
'@PHP83Migration' => true,
'@PhpCsFixer:risky' => true,
'@PSR12:risky' => true,
'declare_strict_types' => true,
'strict_param' => true,
'comment_to_phpdoc' => false, // breaks phpstan lines in combination with PHPStorm.
'array_syntax' => ['syntax' => 'short'],
'native_function_invocation' => false, // annoying
'php_unit_data_provider_name' => false, // bloody annoying long test names
'static_lambda' => false, // breaks the Response macro for API's.
'static_lambda' => false, // breaks the Response macro for API's.
])
->setFinder($finder);

View File

@@ -226,16 +226,16 @@
},
{
"name": "friendsofphp/php-cs-fixer",
"version": "v3.40.1",
"version": "v3.41.0",
"source": {
"type": "git",
"url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git",
"reference": "7002f09c9593f515625a9f9717b10c2ab64dd3d5"
"reference": "7d8d18e19095a939b8a3b8046f57108feaad6134"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/7002f09c9593f515625a9f9717b10c2ab64dd3d5",
"reference": "7002f09c9593f515625a9f9717b10c2ab64dd3d5",
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/7d8d18e19095a939b8a3b8046f57108feaad6134",
"reference": "7d8d18e19095a939b8a3b8046f57108feaad6134",
"shasum": ""
},
"require": {
@@ -265,8 +265,6 @@
"php-cs-fixer/accessible-object": "^1.1",
"php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.4",
"php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.4",
"phpspec/prophecy": "^1.17",
"phpspec/prophecy-phpunit": "^2.0",
"phpunit/phpunit": "^9.6",
"symfony/phpunit-bridge": "^6.3.8 || ^7.0",
"symfony/yaml": "^5.4 || ^6.0 || ^7.0"
@@ -307,7 +305,7 @@
],
"support": {
"issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues",
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.40.1"
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.41.0"
},
"funding": [
{
@@ -315,7 +313,7 @@
"type": "github"
}
],
"time": "2023-12-02T23:18:26+00:00"
"time": "2023-12-08T22:54:33+00:00"
},
{
"name": "psr/container",

View File

@@ -92,8 +92,8 @@ class AccountController extends Controller
// user's preferences
$defaultSet = $this->repository->getAccountsByType([AccountType::ASSET])->pluck('id')->toArray();
/** @var Preference $frontPage */
$frontPage = app('preferences')->get('frontPageAccounts', $defaultSet);
$default = app('amount')->getDefaultCurrency();
$frontPage = app('preferences')->get('frontPageAccounts', $defaultSet);
$default = app('amount')->getDefaultCurrency();
if (!(is_array($frontPage->data) && count($frontPage->data) > 0)) {
$frontPage->data = $defaultSet;

View File

@@ -229,7 +229,7 @@ class ExportController extends Controller
* @throws ContainerExceptionInterface
* @throws FireflyException
* @throws NotFoundExceptionInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function tags(ExportRequest $request): LaravelResponse
{

View File

@@ -92,7 +92,7 @@ class BillController extends Controller
$foreignKey = sprintf('%d-%d', $billId, $foreignCurrencyId);
if (0 !== $currencyId) {
$response[$key] = $response[$key] ?? [
$response[$key] ??= [
'id' => (string)$billId,
'name' => $journal['bill_name'],
'difference' => '0',
@@ -104,7 +104,7 @@ class BillController extends Controller
$response[$key]['difference_float'] = (float)$response[$key]['difference']; // intentional float
}
if (0 !== $foreignCurrencyId) {
$response[$foreignKey] = $response[$foreignKey] ?? [
$response[$foreignKey] ??= [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$foreignCurrencyId,
@@ -147,7 +147,7 @@ class BillController extends Controller
$foreignCurrencyId = (int)$journal['foreign_currency_id'];
if (0 !== $currencyId) {
$response[$currencyId] = $response[$currencyId] ?? [
$response[$currencyId] ??= [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$currencyId,
@@ -157,7 +157,7 @@ class BillController extends Controller
$response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference']; // intentional float
}
if (0 !== $foreignCurrencyId) {
$response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [
$response[$foreignCurrencyId] ??= [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$foreignCurrencyId,

View File

@@ -58,7 +58,7 @@ class PeriodController extends Controller
$foreignCurrencyId = (int)$journal['foreign_currency_id'];
if (0 !== $currencyId) {
$response[$currencyId] = $response[$currencyId] ?? [
$response[$currencyId] ??= [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$currencyId,
@@ -68,7 +68,7 @@ class PeriodController extends Controller
$response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference']; // intentional float
}
if (0 !== $foreignCurrencyId) {
$response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [
$response[$foreignCurrencyId] ??= [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$foreignCurrencyId,

View File

@@ -83,7 +83,7 @@ class TagController extends Controller
$foreignCurrencyId = (int)$journal['foreign_currency_id'];
if (0 !== $currencyId) {
$response[$currencyId] = $response[$currencyId] ?? [
$response[$currencyId] ??= [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$currencyId,
@@ -93,7 +93,7 @@ class TagController extends Controller
$response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference']; // float but on purpose.
}
if (0 !== $foreignCurrencyId) {
$response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [
$response[$foreignCurrencyId] ??= [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$foreignCurrencyId,
@@ -148,7 +148,7 @@ class TagController extends Controller
// on currency ID
if (0 !== $currencyId) {
$response[$key] = $response[$key] ?? [
$response[$key] ??= [
'id' => (string)$tagId,
'name' => $tag['name'],
'difference' => '0',

View File

@@ -58,7 +58,7 @@ class PeriodController extends Controller
$foreignCurrencyId = (int)$journal['foreign_currency_id'];
if (0 !== $currencyId) {
$response[$currencyId] = $response[$currencyId] ?? [
$response[$currencyId] ??= [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$currencyId,
@@ -68,7 +68,7 @@ class PeriodController extends Controller
$response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference']; // float but on purpose.
}
if (0 !== $foreignCurrencyId) {
$response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [
$response[$foreignCurrencyId] ??= [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$foreignCurrencyId,

View File

@@ -84,7 +84,7 @@ class TagController extends Controller
$foreignCurrencyId = (int)$journal['foreign_currency_id'];
if (0 !== $currencyId) {
$response[$currencyId] = $response[$currencyId] ?? [
$response[$currencyId] ??= [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$currencyId,
@@ -94,7 +94,7 @@ class TagController extends Controller
$response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference'];
}
if (0 !== $foreignCurrencyId) {
$response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [
$response[$foreignCurrencyId] ??= [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$foreignCurrencyId,
@@ -152,7 +152,7 @@ class TagController extends Controller
// on currency ID
if (0 !== $currencyId) {
$response[$key] = $response[$key] ?? [
$response[$key] ??= [
'id' => (string)$tagId,
'name' => $tag['name'],
'difference' => '0',

View File

@@ -58,7 +58,7 @@ class PeriodController extends Controller
$foreignCurrencyId = (int)$journal['foreign_currency_id'];
if (0 !== $currencyId) {
$response[$currencyId] = $response[$currencyId] ?? [
$response[$currencyId] ??= [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$currencyId,
@@ -68,7 +68,7 @@ class PeriodController extends Controller
$response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference'];
}
if (0 !== $foreignCurrencyId) {
$response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [
$response[$foreignCurrencyId] ??= [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$foreignCurrencyId,

View File

@@ -81,7 +81,7 @@ class TagController extends Controller
$foreignCurrencyId = (int)$journal['foreign_currency_id'];
if (0 !== $currencyId) {
$response[$currencyId] = $response[$currencyId] ?? [
$response[$currencyId] ??= [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$currencyId,
@@ -91,7 +91,7 @@ class TagController extends Controller
$response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference'];
}
if (0 !== $foreignCurrencyId) {
$response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [
$response[$foreignCurrencyId] ??= [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$foreignCurrencyId,
@@ -149,7 +149,7 @@ class TagController extends Controller
// on currency ID
if (0 !== $currencyId) {
$response[$key] = $response[$key] ?? [
$response[$key] ??= [
'id' => (string)$tagId,
'name' => $tag['name'],
'difference' => '0',

View File

@@ -33,7 +33,6 @@ use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Transformers\BudgetLimitTransformer;
use FireflyIII\User;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
use League\Fractal\Resource\Collection as FractalCollection;

View File

@@ -24,13 +24,11 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Controllers\Models\ObjectGroup;
use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\ObjectGroup;
use FireflyIII\Repositories\ObjectGroup\ObjectGroupRepositoryInterface;
use FireflyIII\Transformers\ObjectGroupTransformer;
use FireflyIII\User;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
use League\Fractal\Resource\Collection as FractalCollection;

View File

@@ -148,12 +148,12 @@ class BasicController extends Controller
/** @var array $transactionJournal */
foreach ($set as $transactionJournal) {
$currencyId = (int)$transactionJournal['currency_id'];
$incomes[$currencyId] = $incomes[$currencyId] ?? '0';
$incomes[$currencyId] ??= '0';
$incomes[$currencyId] = bcadd(
$incomes[$currencyId],
bcmul($transactionJournal['amount'], '-1')
);
$sums[$currencyId] = $sums[$currencyId] ?? '0';
$sums[$currencyId] ??= '0';
$sums[$currencyId] = bcadd($sums[$currencyId], bcmul($transactionJournal['amount'], '-1'));
}
@@ -171,9 +171,9 @@ class BasicController extends Controller
/** @var array $transactionJournal */
foreach ($set as $transactionJournal) {
$currencyId = (int)$transactionJournal['currency_id'];
$expenses[$currencyId] = $expenses[$currencyId] ?? '0';
$expenses[$currencyId] ??= '0';
$expenses[$currencyId] = bcadd($expenses[$currencyId], $transactionJournal['amount']);
$sums[$currencyId] = $sums[$currencyId] ?? '0';
$sums[$currencyId] ??= '0';
$sums[$currencyId] = bcadd($sums[$currencyId], $transactionJournal['amount']);
}

View File

@@ -102,7 +102,7 @@ class AccountController extends Controller
$nameWithBalance = sprintf('%s (%s)', $account->name, app('amount')->formatAnything($currency, $balance, false));
}
$type = (string)trans(sprintf('firefly.%s', $account->accountType->type));
$groupedResult[$type] = $groupedResult[$type] ?? [
$groupedResult[$type] ??= [
'group ' => $type,
'items' => [],
];
@@ -124,8 +124,8 @@ class AccountController extends Controller
usort(
$allItems,
static function (array $left, array $right): int {
$order = [AccountType::ASSET, AccountType::REVENUE, AccountType::EXPENSE];
$posLeft = (int)array_search($left['type'], $order, true);
$order = [AccountType::ASSET, AccountType::REVENUE, AccountType::EXPENSE];
$posLeft = (int)array_search($left['type'], $order, true);
$posRight = (int)array_search($right['type'], $order, true);
return $posLeft - $posRight;

View File

@@ -27,7 +27,6 @@ namespace FireflyIII\Api\V2\Controllers\Chart;
use Carbon\Carbon;
use FireflyIII\Api\V2\Controllers\Controller;
use FireflyIII\Api\V2\Request\Chart\DashboardChartRequest;
use FireflyIII\Api\V2\Request\Generic\DateRequest;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
@@ -100,7 +99,7 @@ class AccountController extends Controller
$default = app('amount')->getDefaultCurrency();
$params = $request->getAll();
/** @var Collection $accounts */
$accounts = $params['accounts'];
$accounts = $params['accounts'];
$chartData = [];
// user's preferences
@@ -117,13 +116,13 @@ class AccountController extends Controller
}
// both options are overruled by "preselected"
if('all' === $params['preselected']) {
if ('all' === $params['preselected']) {
$accounts = $this->repository->getAccountsByType([AccountType::ASSET, AccountType::DEFAULT, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]);
}
if('assets' === $params['preselected']) {
if ('assets' === $params['preselected']) {
$accounts = $this->repository->getAccountsByType([AccountType::ASSET, AccountType::DEFAULT]);
}
if('liabilities' === $params['preselected']) {
if ('liabilities' === $params['preselected']) {
$accounts = $this->repository->getAccountsByType([AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]);
}

View File

@@ -121,7 +121,7 @@ class BalanceController extends Controller
$currencies[$currencyId] = $currency; // may just re-assign itself, don't mind.
// set the array with monetary info, if it does not exist.
$data[$currencyId] = $data[$currencyId] ?? [
$data[$currencyId] ??= [
'currency_id' => (string)$currencyId,
'currency_symbol' => $journal['currency_symbol'],
'currency_code' => $journal['currency_code'],
@@ -135,7 +135,7 @@ class BalanceController extends Controller
];
// set the array (in monetary info) with spent/earned in this $period, if it does not exist.
$data[$currencyId][$period] = $data[$currencyId][$period] ?? [
$data[$currencyId][$period] ??= [
'period' => $period,
'spent' => '0',
'earned' => '0',

View File

@@ -198,8 +198,8 @@ class BudgetController extends Controller
* @var array $block
*/
foreach ($array as $currencyId => $block) {
$this->currencies[$currencyId] = $this->currencies[$currencyId] ?? TransactionCurrency::find($currencyId);
$return[$currencyId] = $return[$currencyId] ?? [
$this->currencies[$currencyId] ??= TransactionCurrency::find($currencyId);
$return[$currencyId] ??= [
'currency_id' => (string)$currencyId,
'currency_code' => $block['currency_code'],
'currency_name' => $block['currency_name'],

View File

@@ -109,7 +109,7 @@ class CategoryController extends Controller
$nativeAmount = app('steam')->positive($journal['foreign_amount']);
}
// create arrays
$return[$key] = $return[$key] ?? [
$return[$key] ??= [
'label' => $categoryName,
'currency_id' => (string)$currency->id,
'currency_code' => $currency->code,

View File

@@ -28,7 +28,6 @@ use FireflyIII\Api\V2\Controllers\Controller;
use FireflyIII\Models\Account;
use FireflyIII\Transformers\V2\AccountTransformer;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
/**
* Show = show a single account.

View File

@@ -30,7 +30,6 @@ use FireflyIII\Repositories\UserGroups\Bill\BillRepositoryInterface;
use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait;
use FireflyIII\Transformers\V2\BillTransformer;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
/**

View File

@@ -31,7 +31,6 @@ use FireflyIII\Repositories\UserGroups\Bill\BillRepositoryInterface;
use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait;
use FireflyIII\Transformers\V2\BillTransformer;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
/**
* Class ShowController

View File

@@ -28,7 +28,6 @@ use FireflyIII\Api\V2\Controllers\Controller;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Transformers\V2\BudgetTransformer;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
/**

View File

@@ -25,8 +25,6 @@ declare(strict_types=1);
namespace FireflyIII\Api\V2\Controllers\Model\BudgetLimit;
use FireflyIII\Api\V2\Controllers\Controller;
use FireflyIII\Api\V2\Request\Generic\DateRequest;
use FireflyIII\Models\Budget;
use Illuminate\Http\JsonResponse;
/**

View File

@@ -30,7 +30,6 @@ use FireflyIII\Repositories\UserGroups\PiggyBank\PiggyBankRepositoryInterface;
use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait;
use FireflyIII\Transformers\V2\PiggyBankTransformer;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
/**

View File

@@ -169,10 +169,10 @@ class BasicController extends Controller
$nativeAmount = $transactionJournal['foreign_amount'];
}
// prep the arrays
$incomes[$currencyId] = $incomes[$currencyId] ?? '0';
$incomes['native'] = $incomes['native'] ?? '0';
$sums[$currencyId] = $sums[$currencyId] ?? '0';
$sums['native'] = $sums['native'] ?? '0';
$incomes[$currencyId] ??= '0';
$incomes['native'] ??= '0';
$sums[$currencyId] ??= '0';
$sums['native'] ??= '0';
// add values:
$incomes[$currencyId] = bcadd($incomes[$currencyId], $amount);
@@ -208,10 +208,10 @@ class BasicController extends Controller
}
// prep arrays
$expenses[$currencyId] = $expenses[$currencyId] ?? '0';
$expenses['native'] = $expenses['native'] ?? '0';
$sums[$currencyId] = $sums[$currencyId] ?? '0';
$sums['native'] = $sums['native'] ?? '0';
$expenses[$currencyId] ??= '0';
$expenses['native'] ??= '0';
$sums[$currencyId] ??= '0';
$sums['native'] ??= '0';
// add values
$expenses[$currencyId] = bcadd($expenses[$currencyId], $amount);

View File

@@ -31,7 +31,6 @@ use FireflyIII\Models\UserGroup;
use FireflyIII\Repositories\UserGroup\UserGroupRepositoryInterface;
use FireflyIII\User;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**

View File

@@ -30,7 +30,6 @@ use FireflyIII\Models\UserGroup;
use FireflyIII\Repositories\UserGroup\UserGroupRepositoryInterface;
use FireflyIII\Transformers\V2\UserGroupTransformer;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;

View File

@@ -27,7 +27,6 @@ use FireflyIII\Enums\UserRoleEnum;
use FireflyIII\Models\AccountType;
use FireflyIII\Support\Request\ChecksLogin;
use FireflyIII\Support\Request\ConvertsDataTypes;
use FireflyIII\User;
use Illuminate\Foundation\Http\FormRequest;
/**

View File

@@ -55,7 +55,7 @@ class AutoSum
/** @var string $amount */
$amount = $getSum($object);
$return[$currency->id] = $return[$currency->id] ?? [
$return[$currency->id] ??= [
'id' => (string)$currency->id,
'name' => $currency->name,
'symbol' => $currency->symbol,

View File

@@ -59,9 +59,10 @@ class DeleteEmptyJournals extends Command
*/
private function deleteUnevenJournals(): void
{
$set = Transaction::whereNull('deleted_at')
->groupBy('transactions.transaction_journal_id')
->get([DB::raw('COUNT(transactions.transaction_journal_id) as the_count'), 'transaction_journal_id']); /** @phpstan-ignore-line */
$set = Transaction::whereNull('deleted_at')
->groupBy('transactions.transaction_journal_id')
->get([DB::raw('COUNT(transactions.transaction_journal_id) as the_count'), 'transaction_journal_id']);
/** @phpstan-ignore-line */
$total = 0;
/** @var Transaction $row */
foreach ($set as $row) {

View File

@@ -43,8 +43,8 @@ class FixAccountTypes extends Command
{
use ShowsFriendlyMessages;
protected $description = 'Make sure all journals have the correct from/to account types.';
protected $signature = 'firefly-iii:fix-account-types';
protected $description = 'Make sure all journals have the correct from/to account types.';
protected $signature = 'firefly-iii:fix-account-types';
private int $count;
private array $expected;
private AccountFactory $factory;

View File

@@ -28,7 +28,6 @@ use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\Preference;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Support\Facades\Preferences;
use FireflyIII\User;
use Illuminate\Console\Command;

View File

@@ -37,8 +37,8 @@ class FixIbans extends Command
{
use ShowsFriendlyMessages;
protected $description = 'Removes spaces from IBANs';
protected $signature = 'firefly-iii:fix-ibans';
protected $description = 'Removes spaces from IBANs';
protected $signature = 'firefly-iii:fix-ibans';
private int $count = 0;
/**
@@ -91,7 +91,7 @@ class FixIbans extends Command
/** @var Account $account */
foreach ($accounts as $account) {
$userId = $account->user_id;
$set[$userId] = $set[$userId] ?? [];
$set[$userId] ??= [];
$iban = (string)$account->iban;
if ('' === $iban) {
continue;

View File

@@ -40,8 +40,8 @@ class FixRecurringTransactions extends Command
{
use ShowsFriendlyMessages;
protected $description = 'Fixes recurring transactions with the wrong transaction type.';
protected $signature = 'firefly-iii:fix-recurring-transactions';
protected $description = 'Fixes recurring transactions with the wrong transaction type.';
protected $signature = 'firefly-iii:fix-recurring-transactions';
private int $count = 0;
private RecurringRepositoryInterface $recurringRepos;
private UserRepositoryInterface $userRepos;

View File

@@ -54,8 +54,8 @@ class CreateDatabase extends Command
return 0;
}
// try to set up a raw connection:
$exists = false;
$dsn = sprintf('mysql:host=%s;port=%d;charset=utf8mb4', env('DB_HOST', 'localhost'), env('DB_PORT', '3306'));
$exists = false;
$dsn = sprintf('mysql:host=%s;port=%d;charset=utf8mb4', env('DB_HOST', 'localhost'), env('DB_PORT', '3306'));
if ('' !== env('DB_SOCKET', '')) {
$dsn = sprintf('mysql:unix_socket=%s;charset=utf8mb4', env('DB_SOCKET', ''));
@@ -79,7 +79,7 @@ class CreateDatabase extends Command
// only continue when no error.
// with PDO, try to list DB's (
/** @var array $stmt */
$stmt = $pdo->query('SHOW DATABASES;');
$stmt = $pdo->query('SHOW DATABASES;');
// slightly more complex but less error-prone.
foreach ($stmt as $row) {
$name = $row['Database'] ?? false;

View File

@@ -42,7 +42,7 @@ class CreateFirstUser extends Command
protected $description = 'Creates a new user and gives admin rights. Outputs the password on the command line. Strictly for testing.';
protected $signature = 'firefly-iii:create-first-user {email}';
protected $signature = 'firefly-iii:create-first-user {email}';
private UserRepositoryInterface $repository;
/**

View File

@@ -53,8 +53,8 @@ class ForceDecimalSize extends Command
{
use ShowsFriendlyMessages;
protected $description = 'This command resizes DECIMAL columns in MySQL or PostgreSQL and correct amounts (only MySQL).';
protected $signature = 'firefly-iii:force-decimal-size';
protected $description = 'This command resizes DECIMAL columns in MySQL or PostgreSQL and correct amounts (only MySQL).';
protected $signature = 'firefly-iii:force-decimal-size';
private string $cast;
private array $classes
= [
@@ -260,7 +260,7 @@ class ForceDecimalSize extends Command
continue;
}
// fix $field by rounding it down correctly.
$pow = 10** $currency->decimal_places;
$pow = 10 ** $currency->decimal_places;
$correct = bcdiv((string)round($value * $pow), (string)$pow, 12);
$this->friendlyInfo(sprintf('Account #%d has %s with value "%s", this has been corrected to "%s".', $account->id, $field, $value, $correct));
Account::find($account->id)->update([$field => $correct]);
@@ -313,7 +313,7 @@ class ForceDecimalSize extends Command
continue;
}
// fix $field by rounding it down correctly.
$pow = 10** $currency->decimal_places;
$pow = 10 ** $currency->decimal_places;
$correct = bcdiv((string)round($value * $pow), (string)$pow, 12);
$this->friendlyWarning(sprintf('%s #%d has %s with value "%s", this has been corrected to "%s".', $table, $item->id, $field, $value, $correct));
$class::find($item->id)->update([$field => $correct]);
@@ -366,7 +366,7 @@ class ForceDecimalSize extends Command
continue;
}
// fix $field by rounding it down correctly.
$pow = 10** $currency->decimal_places;
$pow = 10 ** $currency->decimal_places;
$correct = bcdiv((string)round($value * $pow), (string)$pow, 12);
$this->friendlyWarning(
sprintf('Piggy bank event #%d has %s with value "%s", this has been corrected to "%s".', $item->id, $field, $value, $correct)
@@ -421,7 +421,7 @@ class ForceDecimalSize extends Command
continue;
}
// fix $field by rounding it down correctly.
$pow = 10** $currency->decimal_places;
$pow = 10 ** $currency->decimal_places;
$correct = bcdiv((string)round($value * $pow), (string)$pow, 12);
$this->friendlyWarning(
sprintf('Piggy bank repetition #%d has %s with value "%s", this has been corrected to "%s".', $item->id, $field, $value, $correct)
@@ -475,7 +475,7 @@ class ForceDecimalSize extends Command
continue;
}
// fix $field by rounding it down correctly.
$pow = 10** $currency->decimal_places;
$pow = 10 ** $currency->decimal_places;
$correct = bcdiv((string)round($value * $pow), (string)$pow, 12);
$this->friendlyWarning(sprintf('Piggy bank #%d has %s with value "%s", this has been corrected to "%s".', $item->id, $field, $value, $correct));
PiggyBank::find($item->id)->update([$field => $correct]);
@@ -512,7 +512,7 @@ class ForceDecimalSize extends Command
continue;
}
// fix $field by rounding it down correctly.
$pow = (float)10** $currency->decimal_places;
$pow = (float)10 ** $currency->decimal_places;
$correct = bcdiv((string)round((float)$value * $pow), (string)$pow, 12);
$this->friendlyWarning(sprintf('Transaction #%d has amount with value "%s", this has been corrected to "%s".', $item->id, $value, $correct));
Transaction::find($item->id)->update(['amount' => $correct]);
@@ -539,7 +539,7 @@ class ForceDecimalSize extends Command
continue;
}
// fix $field by rounding it down correctly.
$pow = (float)10** $currency->decimal_places;
$pow = (float)10 ** $currency->decimal_places;
$correct = bcdiv((string)round((float)$value * $pow), (string)$pow, 12);
$this->friendlyWarning(
sprintf('Transaction #%d has foreign amount with value "%s", this has been corrected to "%s".', $item->id, $value, $correct)

View File

@@ -67,13 +67,13 @@ class ScanAttachments extends Command
$decryptedContent = $encryptedContent;
}
$tempFileName = tempnam(sys_get_temp_dir(), 'FireflyIII');
if(false === $tempFileName) {
if (false === $tempFileName) {
app('log')->error(sprintf('Could not create temporary file for attachment #%d', $attachment->id));
exit(1);
}
file_put_contents($tempFileName, $decryptedContent);
$attachment->md5 = (string) md5_file($tempFileName);
$attachment->mime = (string) mime_content_type($tempFileName);
$attachment->md5 = (string)md5_file($tempFileName);
$attachment->mime = (string)mime_content_type($tempFileName);
$attachment->save();
$this->friendlyInfo(sprintf('Fixed attachment #%d', $attachment->id));
}

View File

@@ -61,15 +61,15 @@ class UpgradeFireflyInstructions extends Command
*/
private function updateInstructions(): void
{
$version = (string) config('firefly.version');
$version = (string)config('firefly.version');
/** @var array $config */
$config = config('upgrade.text.upgrade');
$text = '';
$config = config('upgrade.text.upgrade');
$text = '';
/** @var string $compare */
foreach (array_keys($config) as $compare) {
// if string starts with:
if (str_starts_with($version, $compare)) {
$text = (string) $config[$compare];
$text = (string)$config[$compare];
}
}
@@ -175,15 +175,15 @@ class UpgradeFireflyInstructions extends Command
*/
private function installInstructions(): void
{
$version = (string) config('firefly.version');
$version = (string)config('firefly.version');
/** @var array $config */
$config = config('upgrade.text.install');
$text = '';
$config = config('upgrade.text.install');
$text = '';
/** @var string $compare */
foreach (array_keys($config) as $compare) {
// if string starts with:
if (str_starts_with($version, $compare)) {
$text = (string) $config[$compare];
$text = (string)$config[$compare];
}
}
$this->newLine();

View File

@@ -27,9 +27,7 @@ namespace FireflyIII\Console\Commands\System;
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use Illuminate\Console\Command;
use Illuminate\Database\QueryException;
use Illuminate\Filesystem\FilesystemAdapter;
use League\Flysystem\FilesystemException;
use League\Flysystem\FilesystemReader;
use Storage;
/**

View File

@@ -50,7 +50,7 @@ class ApplyRules extends Command
protected $description = 'This command will apply your rules and rule groups on a selection of your transactions.';
protected $signature
protected $signature
= 'firefly-iii:apply-rules
{--user=1 : The user ID.}
{--token= : The user\'s access token.}
@@ -297,7 +297,7 @@ class ApplyRules extends Command
if (null !== $endString && '' !== $endString) {
$inputEnd = Carbon::createFromFormat('Y-m-d', $endString);
}
if(false === $inputEnd || false === $inputStart) {
if (false === $inputEnd || false === $inputStart) {
Log::error('Could not parse start or end date in verifyInputDate().');
return;
}

View File

@@ -66,7 +66,7 @@ class Cron extends Command
} catch (InvalidArgumentException $e) {
$this->friendlyError(sprintf('"%s" is not a valid date', $this->option('date')));
}
$force = (bool) $this->option('force'); // @phpstan-ignore-line
$force = (bool)$this->option('force'); // @phpstan-ignore-line
/*
* Fire exchange rates cron job.

View File

@@ -46,8 +46,8 @@ class AccountCurrencies extends Command
public const string CONFIG_NAME = '480_account_currencies';
protected $description = 'Give all accounts proper currency info.';
protected $signature = 'firefly-iii:account-currencies {--F|force : Force the execution of this command.}';
protected $description = 'Give all accounts proper currency info.';
protected $signature = 'firefly-iii:account-currencies {--F|force : Force the execution of this command.}';
private AccountRepositoryInterface $accountRepos;
private int $count;
private UserRepositoryInterface $userRepos;
@@ -109,14 +109,14 @@ class AccountCurrencies extends Command
*/
private function updateAccountCurrencies(): void
{
$users = $this->userRepos->all();
$users = $this->userRepos->all();
foreach ($users as $user) {
$this->updateCurrenciesForUser($user);
}
}
/**
* @param User $user
* @param User $user
*
* @throws FireflyException
*/

View File

@@ -51,8 +51,8 @@ class MigrateToGroups extends Command
use ShowsFriendlyMessages;
public const string CONFIG_NAME = '480_migrated_to_groups';
protected $description = 'Migrates a pre-4.7.8 transaction structure to the 4.7.8+ transaction structure.';
protected $signature = 'firefly-iii:migrate-to-groups {--F|force : Force the migration, even if it fired before.}';
protected $description = 'Migrates a pre-4.7.8 transaction structure to the 4.7.8+ transaction structure.';
protected $signature = 'firefly-iii:migrate-to-groups {--F|force : Force the migration, even if it fired before.}';
private JournalCLIRepositoryInterface $cliRepository;
private int $count;
private TransactionGroupFactory $groupFactory;

View File

@@ -169,7 +169,7 @@ class MigrateToRules extends Command
if ('MIGRATED_TO_RULES' === $bill->match) {
return;
}
$languageString = null !== $language->data && !is_array($language->data) ? (string)$language->data : 'en_US';
$languageString = null !== $language->data && !is_array($language->data) ? (string)$language->data : 'en_US';
// get match thing:
$match = implode(' ', explode(',', $bill->match));

View File

@@ -45,8 +45,8 @@ class OtherCurrenciesCorrections extends Command
use ShowsFriendlyMessages;
public const string CONFIG_NAME = '480_other_currencies';
protected $description = 'Update all journal currency information.';
protected $signature = 'firefly-iii:other-currencies {--F|force : Force the execution of this command.}';
protected $description = 'Update all journal currency information.';
protected $signature = 'firefly-iii:other-currencies {--F|force : Force the execution of this command.}';
private array $accountCurrencies;
private AccountRepositoryInterface $accountRepos;
private JournalCLIRepositoryInterface $cliRepos;

View File

@@ -42,8 +42,8 @@ class TransactionIdentifier extends Command
use ShowsFriendlyMessages;
public const string CONFIG_NAME = '480_transaction_identifier';
protected $description = 'Fixes transaction identifiers.';
protected $signature = 'firefly-iii:transaction-identifiers {--F|force : Force the execution of this command.}';
protected $description = 'Fixes transaction identifiers.';
protected $signature = 'firefly-iii:transaction-identifiers {--F|force : Force the execution of this command.}';
private JournalCLIRepositoryInterface $cliRepository;
private int $count;

View File

@@ -43,8 +43,8 @@ class TransferCurrenciesCorrections extends Command
use ShowsFriendlyMessages;
public const string CONFIG_NAME = '480_transfer_currencies';
protected $description = 'Updates transfer currency information.';
protected $signature = 'firefly-iii:transfer-currencies {--F|force : Force the execution of this command.}';
protected $description = 'Updates transfer currency information.';
protected $signature = 'firefly-iii:transfer-currencies {--F|force : Force the execution of this command.}';
private array $accountCurrencies;
private AccountRepositoryInterface $accountRepos;
private JournalCLIRepositoryInterface $cliRepos;

View File

@@ -33,7 +33,8 @@ class DestroyedTransactionLink extends Event
{
use SerializesModels;
private TransactionJournalLink $link; /** @phpstan-ignore-line */
private TransactionJournalLink $link;
/** @phpstan-ignore-line */
/**
* DestroyedTransactionLink constructor.

View File

@@ -140,9 +140,9 @@ class GracefulNotFoundHandler extends ExceptionHandler
{
app('log')->debug('404 page is probably a deleted account. Redirect to overview of account types.');
/** @var User $user */
$user = auth()->user();
$route = $request->route();
$param = $route->parameter('account');
$user = auth()->user();
$route = $request->route();
$param = $route->parameter('account');
$accountId = 0;
if ($param instanceof Account) {
$accountId = $param->id;

View File

@@ -26,15 +26,12 @@ namespace FireflyIII\Exceptions;
use ErrorException;
use FireflyIII\Jobs\MailError;
use FireflyIII\Models\ObjectGroup;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Database\QueryException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Routing\Redirector;
use Illuminate\Session\TokenMismatchException;
use Illuminate\Support\Arr;
use Illuminate\Validation\ValidationException as LaravelValidationException;
@@ -127,7 +124,7 @@ class Handler extends ExceptionHandler
$errorCode = 500;
$errorCode = $e instanceof MethodNotAllowedHttpException ? 405 : $errorCode;
$isDebug = (bool) config('app.debug', false);
$isDebug = (bool)config('app.debug', false);
if ($isDebug) {
app('log')->debug(sprintf('Return JSON %s with debug.', get_class($e)));
return response()->json(
@@ -186,7 +183,7 @@ class Handler extends ExceptionHandler
*/
public function report(Throwable $e)
{
$doMailError = (bool) config('firefly.send_error_message');
$doMailError = (bool)config('firefly.send_error_message');
if ($this->shouldntReportLocal($e) || !$doMailError) {
parent::report($e);
@@ -250,7 +247,7 @@ class Handler extends ExceptionHandler
*
* @return JsonResponse| RedirectResponse |\Illuminate\Http\Response
*/
protected function invalid($request, LaravelValidationException $exception): JsonResponse| RedirectResponse |\Illuminate\Http\Response
protected function invalid($request, LaravelValidationException $exception): JsonResponse | RedirectResponse | \Illuminate\Http\Response
{
// protect against open redirect when submitting invalid forms.
$previous = app('steam')->getSafePreviousUrl();

View File

@@ -59,7 +59,8 @@ final class IntervalException extends Exception
array $intervals,
int $code = 0,
?Throwable $previous = null
): self {
): self
{
$message = sprintf(
'The periodicity %s is unknown. Choose one of available periodicity: %s',
$periodicity->name,

View File

@@ -93,7 +93,7 @@ class TagFactory
'zoomLevel' => null,
];
/** @var Tag|null $tag */
$tag = Tag::create($array);
$tag = Tag::create($array);
if (null !== $tag && null !== $latitude && null !== $longitude) {
// create location object.
$location = new Location();

View File

@@ -29,7 +29,6 @@ use Exception;
use FireflyIII\Exceptions\DuplicateTransactionException;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Account;
use FireflyIII\Models\Preference;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Models\TransactionJournal;

View File

@@ -56,9 +56,9 @@ trait AttachmentCollection
/** @var array $attachment */
foreach ($transaction['attachments'] as $attachment) {
$result = str_contains(strtolower($attachment['filename']), strtolower($name)) || str_contains(
strtolower($attachment['title']),
strtolower($name)
);
strtolower($attachment['title']),
strtolower($name)
);
if (true === $result) {
return true;
}
@@ -142,9 +142,9 @@ trait AttachmentCollection
/** @var array $attachment */
foreach ($transaction['attachments'] as $attachment) {
$result = !str_contains(strtolower($attachment['filename']), strtolower($name)) && !str_contains(
strtolower($attachment['title']),
strtolower($name)
);
strtolower($attachment['title']),
strtolower($name)
);
if (true === $result) {
return true;
}
@@ -179,9 +179,9 @@ trait AttachmentCollection
/** @var array $attachment */
foreach ($transaction['attachments'] as $attachment) {
$result = !str_ends_with(strtolower($attachment['filename']), strtolower($name)) && !str_ends_with(
strtolower($attachment['title']),
strtolower($name)
);
strtolower($attachment['title']),
strtolower($name)
);
if (true === $result) {
return true;
}
@@ -216,9 +216,9 @@ trait AttachmentCollection
/** @var array $attachment */
foreach ($transaction['attachments'] as $attachment) {
$result = !str_starts_with(strtolower($attachment['filename']), strtolower($name)) && !str_starts_with(
strtolower($attachment['title']),
strtolower($name)
);
strtolower($attachment['title']),
strtolower($name)
);
if (true === $result) {
return true;
}
@@ -246,9 +246,9 @@ trait AttachmentCollection
/** @var array $attachment */
foreach ($transaction['attachments'] as $attachment) {
$result = str_ends_with(strtolower($attachment['filename']), strtolower($name)) || str_ends_with(
strtolower($attachment['title']),
strtolower($name)
);
strtolower($attachment['title']),
strtolower($name)
);
if (true === $result) {
return true;
}
@@ -330,9 +330,9 @@ trait AttachmentCollection
/** @var array $attachment */
foreach ($transaction['attachments'] as $attachment) {
$result = str_starts_with(strtolower($attachment['filename']), strtolower($name)) || str_starts_with(
strtolower($attachment['title']),
strtolower($name)
);
strtolower($attachment['title']),
strtolower($name)
);
if (true === $result) {
return true;
}

View File

@@ -121,7 +121,7 @@ class NetWorth implements NetWorthInterface
$nativeVirtualBalance = $converter->convert($default, $currency, $account->created_at, $virtualBalance);
$nativeBalance = bcsub($nativeBalance, $nativeVirtualBalance);
}
$netWorth[$currencyId] = $netWorth[$currencyId] ?? [
$netWorth[$currencyId] ??= [
'balance' => '0',
'native_balance' => '0',
'currency_id' => $currencyId,
@@ -208,7 +208,7 @@ class NetWorth implements NetWorthInterface
$balance = bcsub($balance, $virtualBalance);
}
$return[$currency->id] = $return[$currency->id] ?? [
$return[$currency->id] ??= [
'id' => (string)$currency->id,
'name' => $currency->name,
'symbol' => $currency->symbol,

View File

@@ -97,9 +97,9 @@ class ShowController extends Controller
}
/** @var Carbon $start */
$start = $start ?? session('start');
$start ??= session('start');
/** @var Carbon $end */
$end = $end ?? session('end');
$end ??= session('end');
if ($end < $start) {
[$start, $end] = [$end, $start];

View File

@@ -109,7 +109,7 @@ class IndexController extends Controller
$array = $transformer->transform($bill);
$groupOrder = (int)$array['object_group_order'];
// make group array if necessary:
$bills[$groupOrder] = $bills[$groupOrder] ?? [
$bills[$groupOrder] ??= [
'object_group_id' => $array['object_group_id'],
'object_group_title' => $array['object_group_title'],
'bills' => [],
@@ -159,7 +159,7 @@ class IndexController extends Controller
}
$currencyId = $bill['currency_id'];
$sums[$groupOrder][$currencyId] = $sums[$groupOrder][$currencyId] ?? [
$sums[$groupOrder][$currencyId] ??= [
'currency_id' => $currencyId,
'currency_code' => $bill['currency_code'],
'currency_name' => $bill['currency_name'],
@@ -249,7 +249,7 @@ class IndexController extends Controller
* @var array $entry
*/
foreach ($array as $currencyId => $entry) {
$totals[$currencyId] = $totals[$currencyId] ?? [
$totals[$currencyId] ??= [
'currency_id' => $currencyId,
'currency_code' => $entry['currency_code'],
'currency_name' => $entry['currency_name'],

View File

@@ -105,14 +105,14 @@ class IndexController extends Controller
$range = app('navigation')->getViewRange(true);
$isCustomRange = session('is_custom_range', false);
if (false === $isCustomRange) {
$start = $start ?? session('start', today(config('app.timezone'))->startOfMonth());
$end = $end ?? app('navigation')->endOfPeriod($start, $range);
$start ??= session('start', today(config('app.timezone'))->startOfMonth());
$end ??= app('navigation')->endOfPeriod($start, $range);
}
// overrule start and end if necessary:
if (true === $isCustomRange) {
$start = $start ?? session('start', today(config('app.timezone'))->startOfMonth());
$end = $end ?? session('end', today(config('app.timezone'))->endOfMonth());
$start ??= session('start', today(config('app.timezone'))->startOfMonth());
$end ??= session('end', today(config('app.timezone'))->endOfMonth());
}
@@ -135,7 +135,7 @@ class IndexController extends Controller
// get budgeted for default currency:
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);
$spent = $spentArr[$defaultCurrency->id]['sum'] ?? '0';
unset($spentArr);
@@ -194,7 +194,7 @@ class IndexController extends Controller
$array['spent'] = $spentArr[$entry->transaction_currency_id]['sum'] ?? '0';
// budgeted in period:
$budgeted = $this->blRepository->budgeted($entry->start_date, $entry->end_date, $entry->transactionCurrency,);
$budgeted = $this->blRepository->budgeted($entry->start_date, $entry->end_date, $entry->transactionCurrency, );
$array['budgeted'] = $budgeted;
$availableBudgets[] = $array;
unset($spentArr);
@@ -283,8 +283,8 @@ class IndexController extends Controller
foreach ($budget['spent'] as $spent) {
$currencyId = $spent['currency_id'];
$sums['spent'][$currencyId]
= $sums['spent'][$currencyId]
?? [
??=
[
'amount' => '0',
'currency_id' => $spent['currency_id'],
'currency_symbol' => $spent['currency_symbol'],
@@ -297,8 +297,8 @@ class IndexController extends Controller
foreach ($budget['budgeted'] as $budgeted) {
$currencyId = $budgeted['currency_id'];
$sums['budgeted'][$currencyId]
= $sums['budgeted'][$currencyId]
?? [
??=
[
'amount' => '0',
'currency_id' => $budgeted['currency_id'],
'currency_symbol' => $budgeted['currency_symbol'],
@@ -307,8 +307,8 @@ class IndexController extends Controller
$sums['budgeted'][$currencyId]['amount'] = bcadd($sums['budgeted'][$currencyId]['amount'], $budgeted['amount']);
// also calculate how much left from budgeted:
$sums['left'][$currencyId] = $sums['left'][$currencyId]
?? [
$sums['left'][$currencyId] ??=
[
'amount' => '0',
'currency_id' => $budgeted['currency_id'],
'currency_symbol' => $budgeted['currency_symbol'],

View File

@@ -88,9 +88,9 @@ class ShowController extends Controller
public function noBudget(Request $request, Carbon $start = null, Carbon $end = null)
{
/** @var Carbon $start */
$start = $start ?? session('start');
$start ??= session('start');
/** @var Carbon $end */
$end = $end ?? session('end');
$end ??= session('end');
$subTitle = trans(
'firefly.without_budget_between',
['start' => $start->isoFormat($this->monthAndDayFormat), 'end' => $end->isoFormat($this->monthAndDayFormat)]

View File

@@ -84,9 +84,9 @@ class NoCategoryController extends Controller
{
app('log')->debug('Start of noCategory()');
/** @var Carbon $start */
$start = $start ?? session('start');
$start ??= session('start');
/** @var Carbon $end */
$end = $end ?? session('end');
$end ??= session('end');
$page = (int)$request->get('page');
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
$subTitle = trans(

View File

@@ -86,9 +86,9 @@ class ShowController extends Controller
public function show(Request $request, Category $category, Carbon $start = null, Carbon $end = null)
{
/** @var Carbon $start */
$start = $start ?? session('start', today(config('app.timezone'))->startOfMonth());
$start ??= session('start', today(config('app.timezone'))->startOfMonth());
/** @var Carbon $end */
$end = $end ?? session('end', today(config('app.timezone'))->endOfMonth());
$end ??= session('end', today(config('app.timezone'))->endOfMonth());
$subTitleIcon = 'fa-bookmark';
$page = (int)$request->get('page');
$attachments = $this->repository->getAttachments($category);

View File

@@ -125,7 +125,7 @@ class AccountController extends Controller
// grab the difference and find the currency.
$startAmount = (string)($startBalances[$accountId][$currencyId] ?? '0');
$diff = bcsub((string)$endAmount, $startAmount);
$currencies[$currencyId] = $currencies[$currencyId] ?? $this->currencyRepository->find($currencyId);
$currencies[$currencyId] ??= $this->currencyRepository->find($currencyId);
if (0 !== bccomp($diff, '0')) {
// store the values in a temporary array.
$tempData[] = [
@@ -585,7 +585,7 @@ class AccountController extends Controller
// grab the difference and find the currency.
$startAmount = (string)($startBalances[$accountId][$currencyId] ?? '0');
$diff = bcsub((string)$endAmount, $startAmount);
$currencies[$currencyId] = $currencies[$currencyId] ?? $this->currencyRepository->find($currencyId);
$currencies[$currencyId] ??= $this->currencyRepository->find($currencyId);
if (0 !== bccomp($diff, '0')) {
// store the values in a temporary array.
$tempData[] = [

View File

@@ -117,7 +117,7 @@ class BudgetController extends Controller
foreach ($spent as $row) {
$currencyId = $row['currency_id'];
$currencies[$currencyId] = $currencies[$currencyId] ?? $row; // don't mind the field 'sum'
$currencies[$currencyId] ??= $row; // don't mind the field 'sum'
// also store this day's sum:
$currencies[$currencyId]['spent'][$label] = $row['sum'];
}
@@ -237,7 +237,7 @@ class BudgetController extends Controller
// group by asset account ID:
foreach ($journals as $journal) {
$key = sprintf('%d-%d', (int)$journal['source_account_id'], $journal['currency_id']);
$result[$key] = $result[$key] ?? [
$result[$key] ??= [
'amount' => '0',
'currency_symbol' => $journal['currency_symbol'],
'currency_code' => $journal['currency_code'],
@@ -302,7 +302,7 @@ class BudgetController extends Controller
$chartData = [];
foreach ($journals as $journal) {
$key = sprintf('%d-%d', $journal['category_id'], $journal['currency_id']);
$result[$key] = $result[$key] ?? [
$result[$key] ??= [
'amount' => '0',
'currency_symbol' => $journal['currency_symbol'],
'currency_code' => $journal['currency_code'],
@@ -367,7 +367,7 @@ class BudgetController extends Controller
/** @var array $journal */
foreach ($journals as $journal) {
$key = sprintf('%d-%d', $journal['destination_account_id'], $journal['currency_id']);
$result[$key] = $result[$key] ?? [
$result[$key] ??= [
'amount' => '0',
'currency_symbol' => $journal['currency_symbol'],
'currency_code' => $journal['currency_code'],

View File

@@ -87,7 +87,7 @@ class BudgetReportController extends Controller
foreach ($spent as $currency) {
foreach ($currency['budgets'] as $budget) {
$title = sprintf('%s (%s)', $budget['name'], $currency['currency_name']);
$result[$title] = $result[$title] ?? [
$result[$title] ??= [
'amount' => '0',
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
@@ -124,7 +124,7 @@ class BudgetReportController extends Controller
foreach ($budget['transaction_journals'] as $journal) {
$categoryName = $journal['category_name'] ?? trans('firefly.no_category');
$title = sprintf('%s (%s)', $categoryName, $currency['currency_name']);
$result[$title] = $result[$title] ?? [
$result[$title] ??= [
'amount' => '0',
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
@@ -161,7 +161,7 @@ class BudgetReportController extends Controller
foreach ($currency['budgets'] as $budget) {
foreach ($budget['transaction_journals'] as $journal) {
$title = sprintf('%s (%s)', $journal['destination_account_name'], $currency['currency_name']);
$result[$title] = $result[$title] ?? [
$result[$title] ??= [
'amount' => '0',
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
@@ -198,7 +198,7 @@ class BudgetReportController extends Controller
foreach ($spent as $currency) {
// add things to chart Data for each currency:
$spentKey = sprintf('%d-spent', $currency['currency_id']);
$chartData[$spentKey] = $chartData[$spentKey] ?? [
$chartData[$spentKey] ??= [
'label' => sprintf(
'%s (%s)',
(string)trans('firefly.spent_in_specific_budget', ['budget' => $budget->name]),
@@ -215,7 +215,7 @@ class BudgetReportController extends Controller
foreach ($currentBudget['transaction_journals'] as $journal) {
$key = $journal['date']->isoFormat($format);
$amount = app('steam')->positive($journal['amount']);
$chartData[$spentKey]['entries'][$key] = $chartData[$spentKey]['entries'][$key] ?? '0';
$chartData[$spentKey]['entries'][$key] ??= '0';
$chartData[$spentKey]['entries'][$key] = bcadd($chartData[$spentKey]['entries'][$key], $amount);
}
}
@@ -269,7 +269,7 @@ class BudgetReportController extends Controller
foreach ($currency['budgets'] as $budget) {
foreach ($budget['transaction_journals'] as $journal) {
$title = sprintf('%s (%s)', $journal['source_account_name'], $currency['currency_name']);
$result[$title] = $result[$title] ?? [
$result[$title] ??= [
'amount' => '0',
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],

View File

@@ -235,7 +235,7 @@ class CategoryController extends Controller
foreach ($outSet['transaction_journals'] as $journal) {
$amount = app('steam')->positive($journal['amount']);
$date = $journal['date']->isoFormat($format);
$chartData[$outKey]['entries'][$date] = $chartData[$outKey]['entries'][$date] ?? '0';
$chartData[$outKey]['entries'][$date] ??= '0';
$chartData[$outKey]['entries'][$date] = bcadd($amount, $chartData[$outKey]['entries'][$date]);
}
@@ -244,7 +244,7 @@ class CategoryController extends Controller
foreach ($inSet['transaction_journals'] as $journal) {
$amount = app('steam')->positive($journal['amount']);
$date = $journal['date']->isoFormat($format);
$chartData[$inKey]['entries'][$date] = $chartData[$inKey]['entries'][$date] ?? '0';
$chartData[$inKey]['entries'][$date] ??= '0';
$chartData[$inKey]['entries'][$date] = bcadd($amount, $chartData[$inKey]['entries'][$date]);
}
}

View File

@@ -86,7 +86,7 @@ class CategoryReportController extends Controller
foreach ($category['transaction_journals'] as $journal) {
$objectName = $journal['budget_name'] ?? trans('firefly.no_budget');
$title = sprintf('%s (%s)', $objectName, $currency['currency_name']);
$result[$title] = $result[$title] ?? [
$result[$title] ??= [
'amount' => '0',
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
@@ -120,7 +120,7 @@ class CategoryReportController extends Controller
/** @var array $category */
foreach ($currency['categories'] as $category) {
$title = sprintf('%s (%s)', $category['name'], $currency['currency_name']);
$result[$title] = $result[$title] ?? [
$result[$title] ??= [
'amount' => '0',
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
@@ -155,7 +155,7 @@ class CategoryReportController extends Controller
/** @var array $category */
foreach ($currency['categories'] as $category) {
$title = sprintf('%s (%s)', $category['name'], $currency['currency_name']);
$result[$title] = $result[$title] ?? [
$result[$title] ??= [
'amount' => '0',
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
@@ -192,7 +192,7 @@ class CategoryReportController extends Controller
foreach ($category['transaction_journals'] as $journal) {
$objectName = $journal['destination_account_name'] ?? trans('firefly.empty');
$title = sprintf('%s (%s)', $objectName, $currency['currency_name']);
$result[$title] = $result[$title] ?? [
$result[$title] ??= [
'amount' => '0',
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
@@ -228,7 +228,7 @@ class CategoryReportController extends Controller
foreach ($category['transaction_journals'] as $journal) {
$objectName = $journal['destination_account_name'] ?? trans('firefly.empty');
$title = sprintf('%s (%s)', $objectName, $currency['currency_name']);
$result[$title] = $result[$title] ?? [
$result[$title] ??= [
'amount' => '0',
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
@@ -264,7 +264,7 @@ class CategoryReportController extends Controller
foreach ($spent as $currency) {
// add things to chart Data for each currency:
$spentKey = sprintf('%d-spent', $currency['currency_id']);
$chartData[$spentKey] = $chartData[$spentKey] ?? [
$chartData[$spentKey] ??= [
'label' => sprintf(
'%s (%s)',
(string)trans('firefly.spent_in_specific_category', ['category' => $category->name]),
@@ -281,7 +281,7 @@ class CategoryReportController extends Controller
foreach ($currentCategory['transaction_journals'] as $journal) {
$key = $journal['date']->isoFormat($format);
$amount = app('steam')->positive($journal['amount']);
$chartData[$spentKey]['entries'][$key] = $chartData[$spentKey]['entries'][$key] ?? '0';
$chartData[$spentKey]['entries'][$key] ??= '0';
$chartData[$spentKey]['entries'][$key] = bcadd($chartData[$spentKey]['entries'][$key], $amount);
}
}
@@ -291,7 +291,7 @@ class CategoryReportController extends Controller
foreach ($earned as $currency) {
// add things to chart Data for each currency:
$spentKey = sprintf('%d-earned', $currency['currency_id']);
$chartData[$spentKey] = $chartData[$spentKey] ?? [
$chartData[$spentKey] ??= [
'label' => sprintf(
'%s (%s)',
(string)trans('firefly.earned_in_specific_category', ['category' => $category->name]),
@@ -308,7 +308,7 @@ class CategoryReportController extends Controller
foreach ($currentCategory['transaction_journals'] as $journal) {
$key = $journal['date']->isoFormat($format);
$amount = app('steam')->positive($journal['amount']);
$chartData[$spentKey]['entries'][$key] = $chartData[$spentKey]['entries'][$key] ?? '0';
$chartData[$spentKey]['entries'][$key] ??= '0';
$chartData[$spentKey]['entries'][$key] = bcadd($chartData[$spentKey]['entries'][$key], $amount);
}
}
@@ -364,7 +364,7 @@ class CategoryReportController extends Controller
foreach ($category['transaction_journals'] as $journal) {
$objectName = $journal['source_account_name'] ?? trans('firefly.empty');
$title = sprintf('%s (%s)', $objectName, $currency['currency_name']);
$result[$title] = $result[$title] ?? [
$result[$title] ??= [
'amount' => '0',
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
@@ -400,7 +400,7 @@ class CategoryReportController extends Controller
foreach ($category['transaction_journals'] as $journal) {
$objectName = $journal['source_account_name'] ?? trans('firefly.empty');
$title = sprintf('%s (%s)', $objectName, $currency['currency_name']);
$result[$title] = $result[$title] ?? [
$result[$title] ??= [
'amount' => '0',
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],

View File

@@ -85,7 +85,7 @@ class DoubleReportController extends Controller
foreach ($currency['transaction_journals'] as $journal) {
$categoryName = $journal['budget_name'] ?? trans('firefly.no_budget');
$title = sprintf('%s (%s)', $categoryName, $currency['currency_name']);
$result[$title] = $result[$title] ?? [
$result[$title] ??= [
'amount' => '0',
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
@@ -120,7 +120,7 @@ class DoubleReportController extends Controller
foreach ($currency['transaction_journals'] as $journal) {
$categoryName = $journal['category_name'] ?? trans('firefly.no_category');
$title = sprintf('%s (%s)', $categoryName, $currency['currency_name']);
$result[$title] = $result[$title] ?? [
$result[$title] ??= [
'amount' => '0',
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
@@ -155,7 +155,7 @@ class DoubleReportController extends Controller
foreach ($currency['transaction_journals'] as $journal) {
$categoryName = $journal['category_name'] ?? trans('firefly.no_category');
$title = sprintf('%s (%s)', $categoryName, $currency['currency_name']);
$result[$title] = $result[$title] ?? [
$result[$title] ??= [
'amount' => '0',
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
@@ -195,7 +195,7 @@ class DoubleReportController extends Controller
$spentKey = sprintf('%d-spent', $currency['currency_id']);
$name = $this->getCounterpartName($accounts, $account->id, $account->name, $account->iban);
$chartData[$spentKey] = $chartData[$spentKey] ?? [
$chartData[$spentKey] ??= [
'label' => sprintf(
'%s (%s)',
(string)trans('firefly.spent_in_specific_double', ['account' => $name]),
@@ -211,7 +211,7 @@ class DoubleReportController extends Controller
foreach ($currency['transaction_journals'] as $journal) {
$key = $journal['date']->isoFormat($format);
$amount = app('steam')->positive($journal['amount']);
$chartData[$spentKey]['entries'][$key] = $chartData[$spentKey]['entries'][$key] ?? '0';
$chartData[$spentKey]['entries'][$key] ??= '0';
$chartData[$spentKey]['entries'][$key] = bcadd($chartData[$spentKey]['entries'][$key], $amount);
}
}
@@ -221,7 +221,7 @@ class DoubleReportController extends Controller
$earnedKey = sprintf('%d-earned', $currency['currency_id']);
$name = $this->getCounterpartName($accounts, $account->id, $account->name, $account->iban);
$chartData[$earnedKey] = $chartData[$earnedKey] ?? [
$chartData[$earnedKey] ??= [
'label' => sprintf(
'%s (%s)',
(string)trans('firefly.earned_in_specific_double', ['account' => $name]),
@@ -237,7 +237,7 @@ class DoubleReportController extends Controller
foreach ($currency['transaction_journals'] as $journal) {
$key = $journal['date']->isoFormat($format);
$amount = app('steam')->positive($journal['amount']);
$chartData[$earnedKey]['entries'][$key] = $chartData[$earnedKey]['entries'][$key] ?? '0';
$chartData[$earnedKey]['entries'][$key] ??= '0';
$chartData[$earnedKey]['entries'][$key] = bcadd($chartData[$earnedKey]['entries'][$key], $amount);
}
}
@@ -323,7 +323,7 @@ class DoubleReportController extends Controller
// do something
$tagName = trans('firefly.no_tags');
$title = sprintf('%s (%s)', $tagName, $currency['currency_name']);
$result[$title] = $result[$title] ?? [
$result[$title] ??= [
'amount' => '0',
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
@@ -341,7 +341,7 @@ class DoubleReportController extends Controller
// do something
$tagName = $tag['name'];
$title = sprintf('%s (%s)', $tagName, $currency['currency_name']);
$result[$title] = $result[$title] ?? [
$result[$title] ??= [
'amount' => '0',
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
@@ -383,7 +383,7 @@ class DoubleReportController extends Controller
// do something
$tagName = trans('firefly.no_tags');
$title = sprintf('%s (%s)', $tagName, $currency['currency_name']);
$result[$title] = $result[$title] ?? [
$result[$title] ??= [
'amount' => '0',
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
@@ -401,7 +401,7 @@ class DoubleReportController extends Controller
// do something
$tagName = $tag['name'];
$title = sprintf('%s (%s)', $tagName, $currency['currency_name']);
$result[$title] = $result[$title] ?? [
$result[$title] ??= [
'amount' => '0',
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],

View File

@@ -166,8 +166,8 @@ class ExpenseReportController extends Controller
$currentExpense = $expenses[$name] ?? '0';
// add to sum:
$sumOfIncome[$exp->id] = $sumOfIncome[$exp->id] ?? '0';
$sumOfExpense[$exp->id] = $sumOfExpense[$exp->id] ?? '0';
$sumOfIncome[$exp->id] ??= '0';
$sumOfExpense[$exp->id] ??= '0';
$sumOfIncome[$exp->id] = bcadd($sumOfIncome[$exp->id], $currentIncome);
$sumOfExpense[$exp->id] = bcadd($sumOfExpense[$exp->id], $currentExpense);

View File

@@ -182,14 +182,14 @@ class ReportController extends Controller
foreach ($journals as $journal) {
$period = $journal['date']->format($format);
$currencyId = (int)$journal['currency_id'];
$data[$currencyId] = $data[$currencyId] ?? [
$data[$currencyId] ??= [
'currency_id' => $currencyId,
'currency_symbol' => $journal['currency_symbol'],
'currency_code' => $journal['currency_code'],
'currency_name' => $journal['currency_name'],
'currency_decimal_places' => (int)$journal['currency_decimal_places'],
];
$data[$currencyId][$period] = $data[$currencyId][$period] ?? [
$data[$currencyId][$period] ??= [
'period' => $period,
'spent' => '0',
'earned' => '0',

View File

@@ -87,7 +87,7 @@ class TagReportController extends Controller
foreach ($tag['transaction_journals'] as $journal) {
$objectName = $journal['budget_name'] ?? trans('firefly.no_budget');
$title = sprintf('%s (%s)', $objectName, $currency['currency_name']);
$result[$title] = $result[$title] ?? [
$result[$title] ??= [
'amount' => '0',
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
@@ -123,7 +123,7 @@ class TagReportController extends Controller
foreach ($tag['transaction_journals'] as $journal) {
$objectName = $journal['category_name'] ?? trans('firefly.no_category');
$title = sprintf('%s (%s)', $objectName, $currency['currency_name']);
$result[$title] = $result[$title] ?? [
$result[$title] ??= [
'amount' => '0',
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
@@ -159,7 +159,7 @@ class TagReportController extends Controller
foreach ($tag['transaction_journals'] as $journal) {
$objectName = $journal['category_name'] ?? trans('firefly.no_category');
$title = sprintf('%s (%s)', $objectName, $currency['currency_name']);
$result[$title] = $result[$title] ?? [
$result[$title] ??= [
'amount' => '0',
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
@@ -195,7 +195,7 @@ class TagReportController extends Controller
foreach ($tag['transaction_journals'] as $journal) {
$objectName = $journal['destination_account_name'] ?? trans('firefly.empty');
$title = sprintf('%s (%s)', $objectName, $currency['currency_name']);
$result[$title] = $result[$title] ?? [
$result[$title] ??= [
'amount' => '0',
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
@@ -231,7 +231,7 @@ class TagReportController extends Controller
foreach ($tag['transaction_journals'] as $journal) {
$objectName = $journal['destination_account_name'] ?? trans('firefly.empty');
$title = sprintf('%s (%s)', $objectName, $currency['currency_name']);
$result[$title] = $result[$title] ?? [
$result[$title] ??= [
'amount' => '0',
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
@@ -269,7 +269,7 @@ class TagReportController extends Controller
foreach ($spent as $currency) {
// add things to chart Data for each currency:
$spentKey = sprintf('%d-spent', $currency['currency_id']);
$chartData[$spentKey] = $chartData[$spentKey] ?? [
$chartData[$spentKey] ??= [
'label' => sprintf(
'%s (%s)',
(string)trans('firefly.spent_in_specific_tag', ['tag' => $tag->tag]),
@@ -286,7 +286,7 @@ class TagReportController extends Controller
foreach ($currentTag['transaction_journals'] as $journal) {
$key = $journal['date']->isoFormat($format);
$amount = app('steam')->positive($journal['amount']);
$chartData[$spentKey]['entries'][$key] = $chartData[$spentKey]['entries'][$key] ?? '0';
$chartData[$spentKey]['entries'][$key] ??= '0';
$chartData[$spentKey]['entries'][$key] = bcadd($chartData[$spentKey]['entries'][$key], $amount);
}
}
@@ -296,7 +296,7 @@ class TagReportController extends Controller
foreach ($earned as $currency) {
// add things to chart Data for each currency:
$spentKey = sprintf('%d-earned', $currency['currency_id']);
$chartData[$spentKey] = $chartData[$spentKey] ?? [
$chartData[$spentKey] ??= [
'label' => sprintf(
'%s (%s)',
(string)trans('firefly.earned_in_specific_tag', ['tag' => $tag->tag]),
@@ -313,7 +313,7 @@ class TagReportController extends Controller
foreach ($currentTag['transaction_journals'] as $journal) {
$key = $journal['date']->isoFormat($format);
$amount = app('steam')->positive($journal['amount']);
$chartData[$spentKey]['entries'][$key] = $chartData[$spentKey]['entries'][$key] ?? '0';
$chartData[$spentKey]['entries'][$key] ??= '0';
$chartData[$spentKey]['entries'][$key] = bcadd($chartData[$spentKey]['entries'][$key], $amount);
}
}
@@ -369,7 +369,7 @@ class TagReportController extends Controller
foreach ($tag['transaction_journals'] as $journal) {
$objectName = $journal['source_account_name'] ?? trans('firefly.empty');
$title = sprintf('%s (%s)', $objectName, $currency['currency_name']);
$result[$title] = $result[$title] ?? [
$result[$title] ??= [
'amount' => '0',
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
@@ -405,7 +405,7 @@ class TagReportController extends Controller
foreach ($tag['transaction_journals'] as $journal) {
$objectName = $journal['source_account_name'] ?? trans('firefly.empty');
$title = sprintf('%s (%s)', $objectName, $currency['currency_name']);
$result[$title] = $result[$title] ?? [
$result[$title] ??= [
'amount' => '0',
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
@@ -439,7 +439,7 @@ class TagReportController extends Controller
/** @var array $tag */
foreach ($currency['tags'] as $tag) {
$title = sprintf('%s (%s)', $tag['name'], $currency['currency_name']);
$result[$title] = $result[$title] ?? [
$result[$title] ??= [
'amount' => '0',
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
@@ -473,7 +473,7 @@ class TagReportController extends Controller
/** @var array $tag */
foreach ($currency['tags'] as $tag) {
$title = sprintf('%s (%s)', $tag['name'], $currency['currency_name']);
$result[$title] = $result[$title] ?? [
$result[$title] ??= [
'amount' => '0',
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],

View File

@@ -78,7 +78,7 @@ class TransactionController extends Controller
foreach ($result as $journal) {
$budget = $journal['budget_name'] ?? (string)trans('firefly.no_budget');
$title = sprintf('%s (%s)', $budget, $journal['currency_symbol']);
$data[$title] = $data[$title] ?? [
$data[$title] ??= [
'amount' => '0',
'currency_symbol' => $journal['currency_symbol'],
'currency_code' => $journal['currency_code'],
@@ -131,7 +131,7 @@ class TransactionController extends Controller
foreach ($result as $journal) {
$category = $journal['category_name'] ?? (string)trans('firefly.no_category');
$title = sprintf('%s (%s)', $category, $journal['currency_symbol']);
$data[$title] = $data[$title] ?? [
$data[$title] ??= [
'amount' => '0',
'currency_symbol' => $journal['currency_symbol'],
'currency_code' => $journal['currency_code'],
@@ -184,7 +184,7 @@ class TransactionController extends Controller
foreach ($result as $journal) {
$name = $journal['destination_account_name'];
$title = sprintf('%s (%s)', $name, $journal['currency_symbol']);
$data[$title] = $data[$title] ?? [
$data[$title] ??= [
'amount' => '0',
'currency_symbol' => $journal['currency_symbol'],
'currency_code' => $journal['currency_code'],
@@ -237,7 +237,7 @@ class TransactionController extends Controller
foreach ($result as $journal) {
$name = $journal['source_account_name'];
$title = sprintf('%s (%s)', $name, $journal['currency_symbol']);
$data[$title] = $data[$title] ?? [
$data[$title] ??= [
'amount' => '0',
'currency_symbol' => $journal['currency_symbol'],
'currency_code' => $journal['currency_code'],

View File

@@ -179,9 +179,9 @@ class BoxController extends Controller
foreach ($set as $journal) {
$currencyId = (int)$journal['currency_id'];
$amount = $journal['amount'] ?? '0';
$incomes[$currencyId] = $incomes[$currencyId] ?? '0';
$incomes[$currencyId] ??= '0';
$incomes[$currencyId] = bcadd($incomes[$currencyId], app('steam')->positive($amount));
$sums[$currencyId] = $sums[$currencyId] ?? '0';
$sums[$currencyId] ??= '0';
$sums[$currencyId] = bcadd($sums[$currencyId], app('steam')->positive($amount));
}
@@ -194,9 +194,9 @@ class BoxController extends Controller
/** @var array $journal */
foreach ($set as $journal) {
$currencyId = (int)$journal['currency_id'];
$expenses[$currencyId] = $expenses[$currencyId] ?? '0';
$expenses[$currencyId] ??= '0';
$expenses[$currencyId] = bcadd($expenses[$currencyId], $journal['amount'] ?? '0');
$sums[$currencyId] = $sums[$currencyId] ?? '0';
$sums[$currencyId] ??= '0';
$sums[$currencyId] = bcadd($sums[$currencyId], $journal['amount']);
}

View File

@@ -46,7 +46,7 @@ class IntroController extends Controller
public function getIntroSteps(string $route, string $specificPage = null): JsonResponse
{
app('log')->debug(sprintf('getIntroSteps for route "%s" and page "%s"', $route, $specificPage));
$specificPage = $specificPage ?? '';
$specificPage ??= '';
$steps = $this->getBasicSteps($route);
$specificSteps = $this->getSpecificSteps($route, $specificPage);
if (0 === count($specificSteps)) {
@@ -106,7 +106,7 @@ class IntroController extends Controller
*/
public function postEnable(string $route, string $specialPage = null): JsonResponse
{
$specialPage = $specialPage ?? '';
$specialPage ??= '';
$route = str_replace('.', '_', $route);
$key = 'shown_demo_' . $route;
if ('' !== $specialPage) {
@@ -130,7 +130,7 @@ class IntroController extends Controller
*/
public function postFinished(string $route, string $specialPage = null): JsonResponse
{
$specialPage = $specialPage ?? '';
$specialPage ??= '';
$key = 'shown_demo_' . $route;
if ('' !== $specialPage) {
$key .= '_' . $specialPage;

View File

@@ -106,7 +106,7 @@ class IndexController extends Controller
$array = $transformer->transform($piggy);
$groupOrder = (int)$array['object_group_order'];
// make group array if necessary:
$piggyBanks[$groupOrder] = $piggyBanks[$groupOrder] ?? [
$piggyBanks[$groupOrder] ??= [
'object_group_id' => $array['object_group_id'] ?? 0,
'object_group_title' => $array['object_group_title'] ?? trans('firefly.default_group_title_name'),
'piggy_banks' => [],
@@ -154,7 +154,7 @@ class IndexController extends Controller
$groupId = $group['object_group_id'];
foreach ($group['piggy_banks'] as $piggy) {
$currencyId = $piggy['currency_id'];
$sums[$groupId][$currencyId] = $sums[$groupId][$currencyId] ?? [
$sums[$groupId][$currencyId] ??= [
'target' => '0',
'saved' => '0',
'left_to_save' => '0',

View File

@@ -104,7 +104,7 @@ class BalanceController extends Controller
foreach ($journals as $journal) {
$sourceAccount = $journal['source_account_id'];
$currencyId = $journal['currency_id'];
$spent[$sourceAccount] = $spent[$sourceAccount] ?? [
$spent[$sourceAccount] ??= [
'source_account_id' => $sourceAccount,
'currency_id' => $journal['currency_id'],
'currency_code' => $journal['currency_code'],
@@ -116,7 +116,7 @@ class BalanceController extends Controller
$spent[$sourceAccount]['spent'] = bcadd($spent[$sourceAccount]['spent'], $journal['amount']);
// also fix sum:
$report['sums'][$budgetId][$currencyId] = $report['sums'][$budgetId][$currencyId] ?? [
$report['sums'][$budgetId][$currencyId] ??= [
'sum' => '0',
'currency_id' => $journal['currency_id'],
'currency_code' => $journal['currency_code'],

View File

@@ -109,7 +109,7 @@ class BudgetController extends Controller
/** @var Account $account */
foreach ($accounts as $account) {
$accountId = $account->id;
$report[$accountId] = $report[$accountId] ?? [
$report[$accountId] ??= [
'name' => $account->name,
'id' => $account->id,
'iban' => $account->iban,
@@ -120,7 +120,7 @@ class BudgetController extends Controller
// loop expenses.
foreach ($spent as $currency) {
$currencyId = $currency['currency_id'];
$sums[$currencyId] = $sums[$currencyId] ?? [
$sums[$currencyId] ??= [
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
@@ -130,7 +130,7 @@ class BudgetController extends Controller
foreach ($currency['budgets'] as $budget) {
foreach ($budget['transaction_journals'] as $journal) {
$sourceAccountId = $journal['source_account_id'];
$report[$sourceAccountId]['currencies'][$currencyId] = $report[$sourceAccountId]['currencies'][$currencyId] ?? [
$report[$sourceAccountId]['currencies'][$currencyId] ??= [
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
@@ -167,7 +167,7 @@ class BudgetController extends Controller
foreach ($budget['transaction_journals'] as $journal) {
$destinationId = $journal['destination_account_id'];
$key = sprintf('%d-%d', $destinationId, $currency['currency_id']);
$result[$key] = $result[$key] ?? [
$result[$key] ??= [
'transactions' => 0,
'sum' => '0',
'avg' => '0',
@@ -219,7 +219,7 @@ class BudgetController extends Controller
/** @var Budget $budget */
foreach ($budgets as $budget) {
$budgetId = $budget->id;
$report[$budgetId] = $report[$budgetId] ?? [
$report[$budgetId] ??= [
'name' => $budget->name,
'id' => $budget->id,
'currencies' => [],
@@ -227,7 +227,7 @@ class BudgetController extends Controller
}
foreach ($spent as $currency) {
$currencyId = $currency['currency_id'];
$sums[$currencyId] = $sums[$currencyId] ?? [
$sums[$currencyId] ??= [
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
@@ -240,7 +240,7 @@ class BudgetController extends Controller
foreach ($budget['transaction_journals'] as $journal) {
// add currency info to report array:
$report[$budgetId]['currencies'][$currencyId] = $report[$budgetId]['currencies'][$currencyId] ?? [
$report[$budgetId]['currencies'][$currencyId] ??= [
'sum' => '0',
'sum_pct' => '0',
'currency_id' => $currency['currency_id'],
@@ -332,7 +332,7 @@ class BudgetController extends Controller
$count++;
$key = sprintf('%d-%d', $budget['id'], $currency['currency_id']);
$dateKey = $journal['date']->format($keyFormat);
$report[$key] = $report[$key] ?? [
$report[$key] ??= [
'id' => $budget['id'],
'name' => sprintf('%s (%s)', $budget['name'], $currency['currency_name']),
'sum' => '0',
@@ -343,7 +343,7 @@ class BudgetController extends Controller
'currency_decimal_places' => $currency['currency_decimal_places'],
'entries' => [],
];
$report[$key]['entries'][$dateKey] = $report[$key] ['entries'][$dateKey] ?? '0';
$report[$key]['entries'][$dateKey] ??= '0';
$report[$key]['entries'][$dateKey] = bcadd($journal['amount'], $report[$key] ['entries'][$dateKey]);
$report[$key]['sum'] = bcadd($report[$key] ['sum'], $journal['amount']);
$report[$key]['avg'] = bcdiv($report[$key]['sum'], (string)count($periods));

View File

@@ -82,7 +82,7 @@ class CategoryController extends Controller
/** @var Account $account */
foreach ($accounts as $account) {
$accountId = $account->id;
$report[$accountId] = $report[$accountId] ?? [
$report[$accountId] ??= [
'name' => $account->name,
'id' => $account->id,
'iban' => $account->iban,
@@ -98,7 +98,7 @@ class CategoryController extends Controller
foreach ($currency['categories'] as $category) {
foreach ($category['transaction_journals'] as $journal) {
$sourceAccountId = $journal['source_account_id'];
$report[$sourceAccountId]['currencies'][$currencyId] = $report[$sourceAccountId]['currencies'][$currencyId] ?? [
$report[$sourceAccountId]['currencies'][$currencyId] ??= [
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
@@ -107,8 +107,8 @@ class CategoryController extends Controller
];
$report[$sourceAccountId]['currencies'][$currencyId]['categories'][$category['id']]
= $report[$sourceAccountId]['currencies'][$currencyId]['categories'][$category['id']]
??
??=
[
'spent' => '0',
'earned' => '0',
@@ -134,8 +134,8 @@ class CategoryController extends Controller
foreach ($category['transaction_journals'] as $journal) {
$destinationId = $journal['destination_account_id'];
$report[$destinationId]['currencies'][$currencyId]
= $report[$destinationId]['currencies'][$currencyId]
?? [
??=
[
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
@@ -143,8 +143,8 @@ class CategoryController extends Controller
'categories' => [],
];
$report[$destinationId]['currencies'][$currencyId]['categories'][$category['id']]
= $report[$destinationId]['currencies'][$currencyId]['categories'][$category['id']]
??
??=
[
'spent' => '0',
'earned' => '0',
@@ -182,7 +182,7 @@ class CategoryController extends Controller
/** @var Account $account */
foreach ($accounts as $account) {
$accountId = $account->id;
$report[$accountId] = $report[$accountId] ?? [
$report[$accountId] ??= [
'name' => $account->name,
'id' => $account->id,
'iban' => $account->iban,
@@ -193,7 +193,7 @@ class CategoryController extends Controller
// loop expenses.
foreach ($spent as $currency) {
$currencyId = $currency['currency_id'];
$sums[$currencyId] = $sums[$currencyId] ?? [
$sums[$currencyId] ??= [
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
@@ -205,7 +205,7 @@ class CategoryController extends Controller
foreach ($currency['categories'] as $category) {
foreach ($category['transaction_journals'] as $journal) {
$sourceAccountId = $journal['source_account_id'];
$report[$sourceAccountId]['currencies'][$currencyId] = $report[$sourceAccountId]['currencies'][$currencyId] ?? [
$report[$sourceAccountId]['currencies'][$currencyId] ??= [
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
@@ -231,7 +231,7 @@ class CategoryController extends Controller
// loop income.
foreach ($earned as $currency) {
$currencyId = $currency['currency_id'];
$sums[$currencyId] = $sums[$currencyId] ?? [
$sums[$currencyId] ??= [
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
@@ -243,7 +243,7 @@ class CategoryController extends Controller
foreach ($currency['categories'] as $category) {
foreach ($category['transaction_journals'] as $journal) {
$destinationAccountId = $journal['destination_account_id'];
$report[$destinationAccountId]['currencies'][$currencyId] = $report[$destinationAccountId]['currencies'][$currencyId] ?? [
$report[$destinationAccountId]['currencies'][$currencyId] ??= [
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
@@ -287,7 +287,7 @@ class CategoryController extends Controller
foreach ($category['transaction_journals'] as $journal) {
$destinationId = $journal['destination_account_id'];
$key = sprintf('%d-%d', $destinationId, $currency['currency_id']);
$result[$key] = $result[$key] ?? [
$result[$key] ??= [
'transactions' => 0,
'sum' => '0',
'avg' => '0',
@@ -340,7 +340,7 @@ class CategoryController extends Controller
foreach ($category['transaction_journals'] as $journal) {
$sourceId = $journal['source_account_id'];
$key = sprintf('%d-%d', $sourceId, $currency['currency_id']);
$result[$key] = $result[$key] ?? [
$result[$key] ??= [
'transactions' => 0,
'sum' => '0',
'avg' => '0',
@@ -392,7 +392,7 @@ class CategoryController extends Controller
/** @var Category $category */
foreach ($categories as $category) {
$categoryId = $category->id;
$report[$categoryId] = $report[$categoryId] ?? [
$report[$categoryId] ??= [
'name' => $category->name,
'id' => $category->id,
'currencies' => [],
@@ -400,7 +400,7 @@ class CategoryController extends Controller
}
foreach ($spent as $currency) {
$currencyId = $currency['currency_id'];
$sums[$currencyId] = $sums[$currencyId] ?? [
$sums[$currencyId] ??= [
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
@@ -415,7 +415,7 @@ class CategoryController extends Controller
foreach ($category['transaction_journals'] as $journal) {
// add currency info to report array:
$report[$categoryId]['currencies'][$currencyId] = $report[$categoryId]['currencies'][$currencyId] ?? [
$report[$categoryId]['currencies'][$currencyId] ??= [
'spent' => '0',
'earned' => '0',
'sum' => '0',
@@ -441,7 +441,7 @@ class CategoryController extends Controller
foreach ($earned as $currency) {
$currencyId = $currency['currency_id'];
$sums[$currencyId] = $sums[$currencyId] ?? [
$sums[$currencyId] ??= [
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
@@ -456,7 +456,7 @@ class CategoryController extends Controller
foreach ($category['transaction_journals'] as $journal) {
// add currency info to report array:
$report[$categoryId]['currencies'][$currencyId] = $report[$categoryId]['currencies'][$currencyId] ?? [
$report[$categoryId]['currencies'][$currencyId] ??= [
'spent' => '0',
'earned' => '0',
'sum' => '0',
@@ -523,7 +523,7 @@ class CategoryController extends Controller
foreach ($set as $currencyId => $currencyRow) {
foreach ($currencyRow['categories'] as $categoryId => $categoryRow) {
$key = sprintf('%d-%d', $currencyId, $categoryId);
$data[$key] = $data[$key] ?? [
$data[$key] ??= [
'id' => $categoryRow['id'],
'title' => sprintf('%s (%s)', $categoryRow['name'], $currencyRow['currency_name']),
'currency_id' => $currencyRow['currency_id'],
@@ -537,7 +537,7 @@ class CategoryController extends Controller
];
foreach ($categoryRow['transaction_journals'] as $journal) {
$date = $journal['date']->format($format);
$data[$key]['entries'][$date] = $data[$key]['entries'][$date] ?? '0';
$data[$key]['entries'][$date] ??= '0';
$data[$key]['entries'][$date] = bcadd($data[$key]['entries'][$date], $journal['amount']);
$data[$key]['sum'] = bcadd($data[$key]['sum'], $journal['amount']);
}
@@ -604,7 +604,7 @@ class CategoryController extends Controller
foreach ($set as $currencyId => $currencyRow) {
foreach ($currencyRow['categories'] as $categoryId => $categoryRow) {
$key = sprintf('%d-%d', $currencyId, $categoryId);
$data[$key] = $data[$key] ?? [
$data[$key] ??= [
'id' => $categoryRow['id'],
'title' => sprintf('%s (%s)', $categoryRow['name'], $currencyRow['currency_name']),
'currency_id' => $currencyRow['currency_id'],
@@ -618,7 +618,7 @@ class CategoryController extends Controller
];
foreach ($categoryRow['transaction_journals'] as $journal) {
$date = $journal['date']->format($format);
$data[$key]['entries'][$date] = $data[$key]['entries'][$date] ?? '0';
$data[$key]['entries'][$date] ??= '0';
$data[$key]['entries'][$date] = bcadd($data[$key]['entries'][$date], $journal['amount']);
$data[$key]['sum'] = bcadd($data[$key]['sum'], $journal['amount']);
}

View File

@@ -88,7 +88,7 @@ class DoubleController extends Controller
foreach ($currency['transaction_journals'] as $journal) {
$sourceId = $journal['source_account_id'];
$key = sprintf('%d-%d', $sourceId, $currency['currency_id']);
$result[$key] = $result[$key] ?? [
$result[$key] ??= [
'transactions' => 0,
'sum' => '0',
'avg' => '0',
@@ -141,7 +141,7 @@ class DoubleController extends Controller
foreach ($currency['transaction_journals'] as $journal) {
$destinationId = $journal['destination_account_id'];
$key = sprintf('%d-%d', $destinationId, $currency['currency_id']);
$result[$key] = $result[$key] ?? [
$result[$key] ??= [
'transactions' => 0,
'sum' => '0',
'avg' => '0',
@@ -198,7 +198,7 @@ class DoubleController extends Controller
foreach ($spent as $currency) {
$currencyId = $currency['currency_id'];
$sums[$currencyId] = $sums[$currencyId] ?? [
$sums[$currencyId] ??= [
'spent' => '0',
'earned' => '0',
'sum' => '0',
@@ -216,7 +216,7 @@ class DoubleController extends Controller
$destIban = $journal['destination_account_iban'];
$genericName = $this->getCounterpartName($withCounterpart, $destId, $destName, $destIban);
$objectName = sprintf('%s (%s)', $genericName, $currency['currency_name']);
$report[$objectName] = $report[$objectName] ?? [
$report[$objectName] ??= [
'dest_name' => '',
'dest_iban' => '',
'source_name' => '',
@@ -246,7 +246,7 @@ class DoubleController extends Controller
foreach ($earned as $currency) {
$currencyId = $currency['currency_id'];
$sums[$currencyId] = $sums[$currencyId] ?? [
$sums[$currencyId] ??= [
'spent' => '0',
'earned' => '0',
'sum' => '0',
@@ -264,7 +264,7 @@ class DoubleController extends Controller
$sourceIban = $journal['source_account_iban'];
$genericName = $this->getCounterpartName($withCounterpart, $sourceId, $sourceName, $sourceIban);
$objectName = sprintf('%s (%s)', $genericName, $currency['currency_name']);
$report[$objectName] = $report[$objectName] ?? [
$report[$objectName] ??= [
'dest_name' => '',
'dest_iban' => '',
'source_name' => '',
@@ -342,7 +342,7 @@ class DoubleController extends Controller
foreach ($spent as $currency) {
$currencyId = $currency['currency_id'];
$sums[$currencyId] = $sums[$currencyId] ?? [
$sums[$currencyId] ??= [
'spent' => '0',
'earned' => '0',
'sum' => '0',
@@ -356,7 +356,7 @@ class DoubleController extends Controller
/** @var array $journal */
foreach ($currency['transaction_journals'] as $journal) {
$objectName = sprintf('%s (%s)', $journal['source_account_name'], $currency['currency_name']);
$report[$objectName] = $report[$objectName] ?? [
$report[$objectName] ??= [
'account_id' => $journal['source_account_id'],
'account_name' => $objectName,
'currency_id' => $currency['currency_id'],
@@ -381,7 +381,7 @@ class DoubleController extends Controller
foreach ($earned as $currency) {
$currencyId = $currency['currency_id'];
$sums[$currencyId] = $sums[$currencyId] ?? [
$sums[$currencyId] ??= [
'spent' => '0',
'earned' => '0',
'sum' => '0',
@@ -395,7 +395,7 @@ class DoubleController extends Controller
/** @var array $journal */
foreach ($currency['transaction_journals'] as $journal) {
$objectName = sprintf('%s (%s)', $journal['destination_account_name'], $currency['currency_name']);
$report[$objectName] = $report[$objectName] ?? [
$report[$objectName] ??= [
'account_id' => $journal['destination_account_id'],
'account_name' => $objectName,
'currency_id' => $currency['currency_id'],

View File

@@ -162,7 +162,7 @@ class OperationsController extends Controller
/** @var int $currencyId */
foreach ($keys as $currencyId) {
$currencyInfo = $incomes['sums'][$currencyId] ?? $expenses['sums'][$currencyId];
$sums[$currencyId] = $sums[$currencyId] ?? [
$sums[$currencyId] ??= [
'currency_id' => $currencyId,
'currency_name' => $currencyInfo['currency_name'],
'currency_code' => $currencyInfo['currency_code'],

View File

@@ -75,7 +75,7 @@ class TagController extends Controller
/** @var Account $account */
foreach ($accounts as $account) {
$accountId = $account->id;
$report[$accountId] = $report[$accountId] ?? [
$report[$accountId] ??= [
'name' => $account->name,
'id' => $account->id,
'iban' => $account->iban,
@@ -91,7 +91,7 @@ class TagController extends Controller
foreach ($currency['tags'] as $tag) {
foreach ($tag['transaction_journals'] as $journal) {
$sourceAccountId = $journal['source_account_id'];
$report[$sourceAccountId]['currencies'][$currencyId] = $report[$sourceAccountId]['currencies'][$currencyId] ?? [
$report[$sourceAccountId]['currencies'][$currencyId] ??= [
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
@@ -100,8 +100,8 @@ class TagController extends Controller
];
$report[$sourceAccountId]['currencies'][$currencyId]['tags'][$tag['id']]
= $report[$sourceAccountId]['currencies'][$currencyId]['tags'][$tag['id']]
??
??=
[
'spent' => '0',
'earned' => '0',
@@ -127,8 +127,8 @@ class TagController extends Controller
foreach ($tag['transaction_journals'] as $journal) {
$destinationId = $journal['destination_account_id'];
$report[$destinationId]['currencies'][$currencyId]
= $report[$destinationId]['currencies'][$currencyId]
?? [
??=
[
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
@@ -136,8 +136,8 @@ class TagController extends Controller
'tags' => [],
];
$report[$destinationId]['currencies'][$currencyId]['tags'][$tag['id']]
= $report[$destinationId]['currencies'][$currencyId]['tags'][$tag['id']]
??
??=
[
'spent' => '0',
'earned' => '0',
@@ -175,7 +175,7 @@ class TagController extends Controller
/** @var Account $account */
foreach ($accounts as $account) {
$accountId = $account->id;
$report[$accountId] = $report[$accountId] ?? [
$report[$accountId] ??= [
'name' => $account->name,
'id' => $account->id,
'iban' => $account->iban,
@@ -186,7 +186,7 @@ class TagController extends Controller
// loop expenses.
foreach ($spent as $currency) {
$currencyId = $currency['currency_id'];
$sums[$currencyId] = $sums[$currencyId] ?? [
$sums[$currencyId] ??= [
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
@@ -198,7 +198,7 @@ class TagController extends Controller
foreach ($currency['tags'] as $tag) {
foreach ($tag['transaction_journals'] as $journal) {
$sourceAccountId = $journal['source_account_id'];
$report[$sourceAccountId]['currencies'][$currencyId] = $report[$sourceAccountId]['currencies'][$currencyId] ?? [
$report[$sourceAccountId]['currencies'][$currencyId] ??= [
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
@@ -224,7 +224,7 @@ class TagController extends Controller
// loop income.
foreach ($earned as $currency) {
$currencyId = $currency['currency_id'];
$sums[$currencyId] = $sums[$currencyId] ?? [
$sums[$currencyId] ??= [
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
@@ -236,7 +236,7 @@ class TagController extends Controller
foreach ($currency['tags'] as $tag) {
foreach ($tag['transaction_journals'] as $journal) {
$destinationAccountId = $journal['destination_account_id'];
$report[$destinationAccountId]['currencies'][$currencyId] = $report[$destinationAccountId]['currencies'][$currencyId] ?? [
$report[$destinationAccountId]['currencies'][$currencyId] ??= [
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
@@ -280,7 +280,7 @@ class TagController extends Controller
foreach ($tag['transaction_journals'] as $journal) {
$destinationId = $journal['destination_account_id'];
$key = sprintf('%d-%d', $destinationId, $currency['currency_id']);
$result[$key] = $result[$key] ?? [
$result[$key] ??= [
'transactions' => 0,
'sum' => '0',
'avg' => '0',
@@ -333,7 +333,7 @@ class TagController extends Controller
foreach ($tag['transaction_journals'] as $journal) {
$sourceId = $journal['source_account_id'];
$key = sprintf('%d-%d', $sourceId, $currency['currency_id']);
$result[$key] = $result[$key] ?? [
$result[$key] ??= [
'transactions' => 0,
'sum' => '0',
'avg' => '0',
@@ -385,7 +385,7 @@ class TagController extends Controller
/** @var Tag $tag */
foreach ($tags as $tag) {
$tagId = $tag->id;
$report[$tagId] = $report[$tagId] ?? [
$report[$tagId] ??= [
'name' => $tag->tag,
'id' => $tag->id,
'currencies' => [],
@@ -393,7 +393,7 @@ class TagController extends Controller
}
foreach ($spent as $currency) {
$currencyId = $currency['currency_id'];
$sums[$currencyId] = $sums[$currencyId] ?? [
$sums[$currencyId] ??= [
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
@@ -408,7 +408,7 @@ class TagController extends Controller
foreach ($tag['transaction_journals'] as $journal) {
// add currency info to report array:
$report[$tagId]['currencies'][$currencyId] = $report[$tagId]['currencies'][$currencyId] ?? [
$report[$tagId]['currencies'][$currencyId] ??= [
'spent' => '0',
'earned' => '0',
'sum' => '0',
@@ -434,7 +434,7 @@ class TagController extends Controller
foreach ($earned as $currency) {
$currencyId = $currency['currency_id'];
$sums[$currencyId] = $sums[$currencyId] ?? [
$sums[$currencyId] ??= [
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
@@ -449,7 +449,7 @@ class TagController extends Controller
foreach ($tag['transaction_journals'] as $journal) {
// add currency info to report array:
$report[$tagId]['currencies'][$currencyId] = $report[$tagId]['currencies'][$currencyId] ?? [
$report[$tagId]['currencies'][$currencyId] ??= [
'spent' => '0',
'earned' => '0',
'sum' => '0',

View File

@@ -100,7 +100,7 @@ class CreateController extends Controller
session()->flash('warning', trans('firefly.rule_from_search_words', ['string' => $words]));
$operators[] = [
'type' => 'description_contains',
'value' => $words
'value' => $words,
];
}
$oldTriggers = $this->parseFromOperators($operators);

View File

@@ -243,8 +243,8 @@ class TagController extends Controller
$subTitleIcon = 'fa-tag';
$page = (int)$request->get('page');
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
$start = $start ?? session('start');
$end = $end ?? session('end');
$start ??= session('start');
$end ??= session('end');
$location = $this->repository->getLocation($tag);
$attachments = $this->repository->getAttachments($tag);
$subTitle = trans(
@@ -257,7 +257,7 @@ class TagController extends Controller
);
$startPeriod = $this->repository->firstUseDate($tag);
$startPeriod = $startPeriod ?? today(config('app.timezone'));
$startPeriod ??= today(config('app.timezone'));
$endPeriod = clone $end;
$periods = $this->getTagPeriodOverview($tag, $startPeriod, $endPeriod);
$path = route('tags.show', [$tag->id, $start->format('Y-m-d'), $end->format('Y-m-d')]);

View File

@@ -162,9 +162,9 @@ class ShowController extends Controller
$amounts[$symbol]['amount'] = bcadd($amounts[$symbol]['amount'], $transaction['amount']);
if (null !== $transaction['foreign_amount'] && '' !== $transaction['foreign_amount']
&& bccomp(
'0',
$transaction['foreign_amount']
) !== 0) {
'0',
$transaction['foreign_amount']
) !== 0) {
// same for foreign currency:
$foreignSymbol = $transaction['foreign_currency_symbol'];
if (!array_key_exists($foreignSymbol, $amounts)) {

View File

@@ -127,7 +127,7 @@ class Account extends Model
protected $fillable = ['user_id', 'user_group_id', 'account_type_id', 'name', 'active', 'virtual_balance', 'iban'];
protected $hidden = ['encrypted'];
protected $hidden = ['encrypted'];
private bool $joinedAccountTypes = false;
/**

View File

@@ -84,7 +84,7 @@ class TransactionCurrency extends Model
public ?bool $userDefault;
public ?bool $userEnabled;
protected $casts
protected $casts
= [
'created_at' => 'datetime',
'updated_at' => 'datetime',

View File

@@ -95,7 +95,7 @@ class TransactionJournalMeta extends Model
{
$data = json_encode($value);
$this->attributes['data'] = $data;
$this->attributes['hash'] = hash('sha256',(string) $data);
$this->attributes['hash'] = hash('sha256', (string) $data);
}
/**

View File

@@ -71,7 +71,7 @@ class AccountTasker implements AccountTaskerInterface
foreach ($accounts as $account) {
$id = $account->id;
$currency = $repository->getAccountCurrency($account) ?? $defaultCurrency;
$return['sums'][$currency->id] = $return['sums'][$currency->id] ?? [
$return['sums'][$currency->id] ??= [
'start' => '0',
'end' => '0',
'difference' => '0',
@@ -174,8 +174,8 @@ class AccountTasker implements AccountTaskerInterface
$sourceId = (int)$journal['destination_account_id'];
$currencyId = (int)$journal['currency_id'];
$key = sprintf('%s-%s', $sourceId, $currencyId);
$currencies[$currencyId] = $currencies[$currencyId] ?? $currencyRepos->find($currencyId);
$report['accounts'][$key] = $report['accounts'][$key] ?? [
$currencies[$currencyId] ??= $currencyRepos->find($currencyId);
$report['accounts'][$key] ??= [
'id' => $sourceId,
'name' => $journal['destination_account_name'],
'sum' => '0',
@@ -200,7 +200,7 @@ class AccountTasker implements AccountTaskerInterface
$report['accounts'][$key]['average'] = bcdiv($report['accounts'][$key]['sum'], (string)$report['accounts'][$key]['count']);
}
$currencyId = $report['accounts'][$key]['currency_id'];
$report['sums'][$currencyId] = $report['sums'][$currencyId] ?? [
$report['sums'][$currencyId] ??= [
'sum' => '0',
'currency_id' => $report['accounts'][$key]['currency_id'],
'currency_name' => $report['accounts'][$key]['currency_name'],
@@ -272,7 +272,7 @@ class AccountTasker implements AccountTaskerInterface
$currencyId = (int)$journal['currency_id'];
$key = sprintf('%s-%s', $sourceId, $currencyId);
if (!array_key_exists($key, $report['accounts'])) {
$currencies[$currencyId] = $currencies[$currencyId] ?? $currencyRepos->find($currencyId);
$currencies[$currencyId] ??= $currencyRepos->find($currencyId);
$report['accounts'][$key] = [
'id' => $sourceId,
'name' => $journal['source_account_name'],
@@ -296,7 +296,7 @@ class AccountTasker implements AccountTaskerInterface
$report['accounts'][$key]['average'] = bcdiv($report['accounts'][$key]['sum'], (string)$report['accounts'][$key]['count']);
}
$currencyId = $report['accounts'][$key]['currency_id'];
$report['sums'][$currencyId] = $report['sums'][$currencyId] ?? [
$report['sums'][$currencyId] ??= [
'sum' => '0',
'currency_id' => $report['accounts'][$key]['currency_id'],
'currency_name' => $report['accounts'][$key]['currency_name'],

View File

@@ -100,7 +100,7 @@ class OperationsRepository implements OperationsRepositoryInterface
foreach ($journals as $journal) {
$currencyId = (int)$journal['currency_id'];
$journalId = (int)$journal['transaction_journal_id'];
$array[$currencyId] = $array[$currencyId] ?? [
$array[$currencyId] ??= [
'currency_id' => $journal['currency_id'],
'currency_name' => $journal['currency_name'],
@@ -264,7 +264,7 @@ class OperationsRepository implements OperationsRepositoryInterface
foreach ($journals as $journal) {
$currencyId = (int)$journal['currency_id'];
$array[$currencyId] = $array[$currencyId] ?? [
$array[$currencyId] ??= [
'sum' => '0',
'currency_id' => $currencyId,
'currency_name' => $journal['currency_name'],
@@ -277,7 +277,7 @@ class OperationsRepository implements OperationsRepositoryInterface
// also do foreign amount:
$foreignId = (int)$journal['foreign_currency_id'];
if (0 !== $foreignId) {
$array[$foreignId] = $array[$foreignId] ?? [
$array[$foreignId] ??= [
'sum' => '0',
'currency_id' => $foreignId,
'currency_name' => $journal['foreign_currency_name'],
@@ -324,7 +324,7 @@ class OperationsRepository implements OperationsRepositoryInterface
foreach ($journals as $journal) {
$key = sprintf('%s-%s', $journal[$idKey], $journal['currency_id']);
$array[$key] = $array[$key] ?? [
$array[$key] ??= [
'id' => $journal[$idKey],
'name' => $journal[$nameKey],
'sum' => '0',
@@ -339,7 +339,7 @@ class OperationsRepository implements OperationsRepositoryInterface
// also do foreign amount:
if (0 !== (int)$journal['foreign_currency_id']) {
$key = sprintf('%s-%s', $journal[$idKey], $journal['foreign_currency_id']);
$array[$key] = $array[$key] ?? [
$array[$key] ??= [
'id' => $journal[$idKey],
'name' => $journal[$nameKey],
'sum' => '0',
@@ -473,7 +473,7 @@ class OperationsRepository implements OperationsRepositoryInterface
$amount = app('steam')->positive($journal['amount']);
// source first
$return[$sourceKey] = $return[$sourceKey] ?? [
$return[$sourceKey] ??= [
'id' => (string)$sourceId,
'name' => $journal['source_account_name'],
'difference' => '0',
@@ -487,7 +487,7 @@ class OperationsRepository implements OperationsRepositoryInterface
];
// dest next:
$return[$destKey] = $return[$destKey] ?? [
$return[$destKey] ??= [
'id' => (string)$destinationId,
'name' => $journal['destination_account_name'],
'difference' => '0',
@@ -517,7 +517,7 @@ class OperationsRepository implements OperationsRepositoryInterface
// same as above:
// source first
$return[$sourceKey] = $return[$sourceKey] ?? [
$return[$sourceKey] ??= [
'id' => (string)$sourceId,
'name' => $journal['source_account_name'],
'difference' => '0',
@@ -531,7 +531,7 @@ class OperationsRepository implements OperationsRepositoryInterface
];
// dest next:
$return[$destKey] = $return[$destKey] ?? [
$return[$destKey] ??= [
'id' => (string)$destinationId,
'name' => $journal['destination_account_name'],
'difference' => '0',

View File

@@ -311,7 +311,7 @@ class BillRepository implements BillRepositoryInterface
$transaction = $journal->transactions()->where('amount', '<', 0)->first();
$currencyId = (int)$journal->transaction_currency_id;
$currency = $journal->transactionCurrency;
$result[$currencyId] = $result[$currencyId] ?? [
$result[$currencyId] ??= [
'sum' => '0',
'count' => 0,
'avg' => '0',
@@ -373,12 +373,12 @@ class BillRepository implements BillRepositoryInterface
return $bill->transactionJournals()
->before($end)->after($start)->get(
[
[
'transaction_journals.id',
'transaction_journals.date',
'transaction_journals.transaction_group_id',
]
);
);
}
/**
@@ -416,7 +416,7 @@ class BillRepository implements BillRepositoryInterface
$array = [];
/** @var Rule $rule */
foreach ($rules as $rule) {
$array[$rule->action_value] = $array[$rule->action_value] ?? [];
$array[$rule->action_value] ??= [];
$array[$rule->action_value][] = ['id' => $rule->id, 'title' => $rule->title, 'active' => $rule->active];
}
$return = [];
@@ -456,7 +456,7 @@ class BillRepository implements BillRepositoryInterface
}
$currencyId = (int)$journal->transaction_currency_id;
$currency = $journal->transactionCurrency;
$result[$currencyId] = $result[$currencyId] ?? [
$result[$currencyId] ??= [
'sum' => '0',
'count' => 0,
'avg' => '0',
@@ -619,7 +619,7 @@ class BillRepository implements BillRepositoryInterface
$set = $bill->transactionJournals()->after($start)->before($end)->get(['transaction_journals.*']);
$currency = $bill->transactionCurrency;
$return[$currency->id] = $return[$currency->id] ?? [
$return[$currency->id] ??= [
'id' => (string)$currency->id,
'name' => $currency->name,
'symbol' => $currency->symbol,
@@ -676,7 +676,7 @@ class BillRepository implements BillRepositoryInterface
if ($total > 0) {
$currency = $bill->transactionCurrency;
$average = bcdiv(bcadd($bill->amount_max, $bill->amount_min), '2');
$return[$currency->id] = $return[$currency->id] ?? [
$return[$currency->id] ??= [
'id' => (string)$currency->id,
'name' => $currency->name,
'symbol' => $currency->symbol,

View File

@@ -104,7 +104,7 @@ class BudgetRepository implements BudgetRepositoryInterface
foreach ($limits as $limit) {
app('log')->debug(sprintf('Budget limit #%d', $limit->id));
$currency = $limit->transactionCurrency;
$return[$currency->id] = $return[$currency->id] ?? [
$return[$currency->id] ??= [
'id' => (string)$currency->id,
'name' => $currency->name,
'symbol' => $currency->symbol,
@@ -220,7 +220,7 @@ class BudgetRepository implements BudgetRepositoryInterface
foreach ($limits as $limit) {
app('log')->debug(sprintf('Budget limit #%d', $limit->id));
$currency = $limit->transactionCurrency;
$return[$currency->id] = $return[$currency->id] ?? [
$return[$currency->id] ??= [
'id' => (string)$currency->id,
'name' => $currency->name,
'symbol' => $currency->symbol,
@@ -694,7 +694,7 @@ class BudgetRepository implements BudgetRepositoryInterface
foreach ($journals as $journal) {
$currencyId = (int)$journal['currency_id'];
$array[$currencyId] = $array[$currencyId] ?? [
$array[$currencyId] ??= [
'id' => (string)$currencyId,
'name' => $journal['currency_name'],
'symbol' => $journal['currency_symbol'],
@@ -707,7 +707,7 @@ class BudgetRepository implements BudgetRepositoryInterface
// also do foreign amount:
$foreignId = (int)$journal['foreign_currency_id'];
if (0 !== $foreignId) {
$array[$foreignId] = $array[$foreignId] ?? [
$array[$foreignId] ??= [
'id' => (string)$foreignId,
'name' => $journal['foreign_currency_name'],
'symbol' => $journal['foreign_currency_symbol'],
@@ -757,7 +757,7 @@ class BudgetRepository implements BudgetRepositoryInterface
foreach ($journals as $journal) {
$currencyId = (int)$journal['currency_id'];
$array[$currencyId] = $array[$currencyId] ?? [
$array[$currencyId] ??= [
'id' => (string)$currencyId,
'name' => $journal['currency_name'],
'symbol' => $journal['currency_symbol'],
@@ -770,7 +770,7 @@ class BudgetRepository implements BudgetRepositoryInterface
// also do foreign amount:
$foreignId = (int)$journal['foreign_currency_id'];
if (0 !== $foreignId) {
$array[$foreignId] = $array[$foreignId] ?? [
$array[$foreignId] ??= [
'id' => (string)$foreignId,
'name' => $journal['foreign_currency_name'],
'symbol' => $journal['foreign_currency_symbol'],

View File

@@ -64,7 +64,7 @@ class NoBudgetRepository implements NoBudgetRepositoryInterface
foreach ($journals as $journal) {
$currencyId = (int)$journal['currency_id'];
$data[$currencyId] = $data[$currencyId] ?? [
$data[$currencyId] ??= [
'id' => 0,
'name' => sprintf('%s (%s)', trans('firefly.no_budget'), $journal['currency_name']),
'sum' => '0',
@@ -178,7 +178,7 @@ class NoBudgetRepository implements NoBudgetRepositoryInterface
foreach ($journals as $journal) {
$currencyId = (int)$journal['currency_id'];
$array[$currencyId] = $array[$currencyId] ?? [
$array[$currencyId] ??= [
'sum' => '0',
'currency_id' => $currencyId,
'currency_name' => $journal['currency_name'],

View File

@@ -105,7 +105,7 @@ class OperationsRepository implements OperationsRepositoryInterface
$currencyId = (int)$journal['currency_id'];
$key = sprintf('%d-%d', $budgetId, $currencyId);
$data[$key] = $data[$key] ?? [
$data[$key] ??= [
'id' => $budgetId,
'name' => sprintf('%s (%s)', $budgetName, $journal['currency_name']),
'sum' => '0',
@@ -164,7 +164,7 @@ class OperationsRepository implements OperationsRepositoryInterface
}
// info about the currency:
$array[$currencyId] = $array[$currencyId] ?? [
$array[$currencyId] ??= [
'budgets' => [],
'currency_id' => $currencyId,
'currency_name' => $journal['currency_name'],
@@ -174,7 +174,7 @@ class OperationsRepository implements OperationsRepositoryInterface
];
// info about the categories:
$array[$currencyId]['budgets'][$budgetId] = $array[$currencyId]['budgets'][$budgetId] ?? [
$array[$currencyId]['budgets'][$budgetId] ??= [
'id' => $budgetId,
'name' => $budgetName,
'transaction_journals' => [],
@@ -298,7 +298,7 @@ class OperationsRepository implements OperationsRepositoryInterface
foreach ($journals as $journal) {
$currencyId = (int)$journal['currency_id'];
$array[$currencyId] = $array[$currencyId] ?? [
$array[$currencyId] ??= [
'sum' => '0',
'currency_id' => $currencyId,
'currency_name' => $journal['currency_name'],
@@ -311,7 +311,7 @@ class OperationsRepository implements OperationsRepositoryInterface
// also do foreign amount:
$foreignId = (int)$journal['foreign_currency_id'];
if (0 !== $foreignId) {
$array[$foreignId] = $array[$foreignId] ?? [
$array[$foreignId] ??= [
'sum' => '0',
'currency_id' => $foreignId,
'currency_name' => $journal['foreign_currency_name'],

View File

@@ -62,7 +62,7 @@ class NoCategoryRepository implements NoCategoryRepositoryInterface
foreach ($journals as $journal) {
$currencyId = (int)$journal['currency_id'];
$array[$currencyId] = $array[$currencyId] ?? [
$array[$currencyId] ??= [
'categories' => [],
'currency_id' => $currencyId,
'currency_name' => $journal['currency_name'],
@@ -71,7 +71,7 @@ class NoCategoryRepository implements NoCategoryRepositoryInterface
'currency_decimal_places' => $journal['currency_decimal_places'],
];
// info about the non-existent category:
$array[$currencyId]['categories'][0] = $array[$currencyId]['categories'][0] ?? [
$array[$currencyId]['categories'][0] ??= [
'id' => 0,
'name' => (string)trans('firefly.noCategory'),
'transaction_journals' => [],
@@ -124,7 +124,7 @@ class NoCategoryRepository implements NoCategoryRepositoryInterface
foreach ($journals as $journal) {
$currencyId = (int)$journal['currency_id'];
$array[$currencyId] = $array[$currencyId] ?? [
$array[$currencyId] ??= [
'categories' => [],
'currency_id' => $currencyId,
'currency_name' => $journal['currency_name'],
@@ -134,7 +134,7 @@ class NoCategoryRepository implements NoCategoryRepositoryInterface
];
// info about the non-existent category:
$array[$currencyId]['categories'][0] = $array[$currencyId]['categories'][0] ?? [
$array[$currencyId]['categories'][0] ??= [
'id' => 0,
'name' => (string)trans('firefly.noCategory'),
'transaction_journals' => [],
@@ -175,7 +175,7 @@ class NoCategoryRepository implements NoCategoryRepositoryInterface
foreach ($journals as $journal) {
$currencyId = (int)$journal['currency_id'];
$array[$currencyId] = $array[$currencyId] ?? [
$array[$currencyId] ??= [
'sum' => '0',
'currency_id' => $currencyId,
'currency_name' => $journal['currency_name'],
@@ -212,7 +212,7 @@ class NoCategoryRepository implements NoCategoryRepositoryInterface
foreach ($journals as $journal) {
$currencyId = (int)$journal['currency_id'];
$array[$currencyId] = $array[$currencyId] ?? [
$array[$currencyId] ??= [
'sum' => '0',
'currency_id' => $currencyId,
'currency_name' => $journal['currency_name'],
@@ -243,7 +243,7 @@ class NoCategoryRepository implements NoCategoryRepositoryInterface
foreach ($journals as $journal) {
$currencyId = (int)$journal['currency_id'];
$array[$currencyId] = $array[$currencyId] ?? [
$array[$currencyId] ??= [
'sum' => '0',
'currency_id' => $currencyId,
'currency_name' => $journal['currency_name'],

View File

@@ -81,7 +81,7 @@ class OperationsRepository implements OperationsRepositoryInterface
}
// info about the currency:
$array[$currencyId] = $array[$currencyId] ?? [
$array[$currencyId] ??= [
'categories' => [],
'currency_id' => (string)$currencyId,
'currency_name' => $journal['currency_name'],
@@ -91,7 +91,7 @@ class OperationsRepository implements OperationsRepositoryInterface
];
// info about the categories:
$array[$currencyId]['categories'][$categoryId] = $array[$currencyId]['categories'][$categoryId] ?? [
$array[$currencyId]['categories'][$categoryId] ??= [
'id' => (string)$categoryId,
'name' => $categoryName,
'transaction_journals' => [],
@@ -177,7 +177,7 @@ class OperationsRepository implements OperationsRepositoryInterface
}
// info about the currency:
$array[$currencyId] = $array[$currencyId] ?? [
$array[$currencyId] ??= [
'categories' => [],
'currency_id' => (string)$currencyId,
'currency_name' => $journal['currency_name'],
@@ -187,7 +187,7 @@ class OperationsRepository implements OperationsRepositoryInterface
];
// info about the categories:
$array[$currencyId]['categories'][$categoryId] = $array[$currencyId]['categories'][$categoryId] ?? [
$array[$currencyId]['categories'][$categoryId] ??= [
'id' => (string)$categoryId,
'name' => $categoryName,
'transaction_journals' => [],
@@ -241,7 +241,7 @@ class OperationsRepository implements OperationsRepositoryInterface
}
// info about the currency:
$array[$currencyId] = $array[$currencyId] ?? [
$array[$currencyId] ??= [
'categories' => [],
'currency_id' => (string)$currencyId,
'currency_name' => $journal['currency_name'],
@@ -251,7 +251,7 @@ class OperationsRepository implements OperationsRepositoryInterface
];
// info about the categories:
$array[$currencyId]['categories'][$categoryId] = $array[$currencyId]['categories'][$categoryId] ?? [
$array[$currencyId]['categories'][$categoryId] ??= [
'id' => (string)$categoryId,
'name' => $categoryName,
'transaction_journals' => [],
@@ -306,7 +306,7 @@ class OperationsRepository implements OperationsRepositoryInterface
}
// info about the currency:
$array[$currencyId] = $array[$currencyId] ?? [
$array[$currencyId] ??= [
'categories' => [],
'currency_id' => (string)$currencyId,
'currency_name' => $journal['currency_name'],
@@ -316,7 +316,7 @@ class OperationsRepository implements OperationsRepositoryInterface
];
// info about the categories:
$array[$currencyId]['categories'][$categoryId] = $array[$currencyId]['categories'][$categoryId] ?? [
$array[$currencyId]['categories'][$categoryId] ??= [
'id' => (string)$categoryId,
'name' => $categoryName,
'transaction_journals' => [],
@@ -371,7 +371,7 @@ class OperationsRepository implements OperationsRepositoryInterface
foreach ($journals as $journal) {
$currencyId = (int)$journal['currency_id'];
$array[$currencyId] = $array[$currencyId] ?? [
$array[$currencyId] ??= [
'sum' => '0',
'currency_id' => (string)$currencyId,
'currency_name' => $journal['currency_name'],
@@ -414,7 +414,7 @@ class OperationsRepository implements OperationsRepositoryInterface
foreach ($journals as $journal) {
$currencyId = (int)$journal['currency_id'];
$array[$currencyId] = $array[$currencyId] ?? [
$array[$currencyId] ??= [
'sum' => '0',
'currency_id' => (string)$currencyId,
'currency_name' => $journal['currency_name'],
@@ -457,7 +457,7 @@ class OperationsRepository implements OperationsRepositoryInterface
foreach ($journals as $journal) {
$currencyId = (int)$journal['currency_id'];
$array[$currencyId] = $array[$currencyId] ?? [
$array[$currencyId] ??= [
'sum' => '0',
'currency_id' => (string)$currencyId,
'currency_name' => $journal['currency_name'],

View File

@@ -76,7 +76,7 @@ class OperationsRepository implements OperationsRepositoryInterface
$listedJournals = [];
foreach ($journals as $journal) {
$currencyId = (int)$journal['currency_id'];
$array[$currencyId] = $array[$currencyId] ?? [
$array[$currencyId] ??= [
'tags' => [],
'currency_id' => $currencyId,
'currency_name' => $journal['currency_name'],
@@ -95,7 +95,7 @@ class OperationsRepository implements OperationsRepositoryInterface
continue;
}
$listedJournals[] = $journalId;
$array[$currencyId]['tags'][$tagId] = $array[$currencyId]['tags'][$tagId] ?? [
$array[$currencyId]['tags'][$tagId] ??= [
'id' => $tagId,
'name' => $tagName,
'transaction_journals' => [],
@@ -176,7 +176,7 @@ class OperationsRepository implements OperationsRepositoryInterface
foreach ($journals as $journal) {
$currencyId = (int)$journal['currency_id'];
$array[$currencyId] = $array[$currencyId] ?? [
$array[$currencyId] ??= [
'tags' => [],
'currency_id' => $currencyId,
'currency_name' => $journal['currency_name'],
@@ -196,7 +196,7 @@ class OperationsRepository implements OperationsRepositoryInterface
}
$listedJournals[] = $journalId;
$array[$currencyId]['tags'][$tagId] = $array[$currencyId]['tags'][$tagId] ?? [
$array[$currencyId]['tags'][$tagId] ??= [
'id' => $tagId,
'name' => $tagName,
'transaction_journals' => [],

View File

@@ -329,7 +329,7 @@ class TagRepository implements TagRepositoryInterface
/** @var array $journal */
foreach ($journals as $journal) {
$currencyId = (int)$journal['currency_id'];
$sums[$currencyId] = $sums[$currencyId] ?? [
$sums[$currencyId] ??= [
'currency_id' => $currencyId,
'currency_name' => $journal['currency_name'],
'currency_symbol' => $journal['currency_symbol'],
@@ -351,7 +351,7 @@ class TagRepository implements TagRepositoryInterface
$foreignCurrencyId = $journal['foreign_currency_id'];
if (null !== $foreignCurrencyId && 0 !== $foreignCurrencyId) {
$sums[$foreignCurrencyId] = $sums[$foreignCurrencyId] ?? [
$sums[$foreignCurrencyId] ??= [
'currency_id' => $foreignCurrencyId,
'currency_name' => $journal['foreign_currency_name'],
'currency_symbol' => $journal['foreign_currency_symbol'],

View File

@@ -176,7 +176,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
/** @var Attachment $attachment */
foreach ($set as $attachment) {
$journalId = $attachment->attachable_id;
$result[$journalId] = $result[$journalId] ?? [];
$result[$journalId] ??= [];
$current = $attachment->toArray();
$current['file_exists'] = true;
$current['notes'] = $repository->getNoteText($attachment);
@@ -241,7 +241,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
/** @var TransactionJournalLink $entry */
foreach ($set as $entry) {
$journalId = in_array($entry->source_id, $journals, true) ? $entry->source_id : $entry->destination_id;
$return[$journalId] = $return[$journalId] ?? [];
$return[$journalId] ??= [];
// phpstan: the editable field is provided by the query.
@@ -418,7 +418,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
$currency = TransactionCurrency::where('id', $currencyPreference->data)->first();
}
$journalId = $row->transaction_journal_id;
$return[$journalId] = $return[$journalId] ?? [];
$return[$journalId] ??= [];
$return[$journalId][] = [
'piggy' => $row->piggyBank->name,

View File

@@ -45,7 +45,7 @@ class TransactionTypeRepository implements TransactionTypeRepositoryInterface
return $type;
}
$typeString = $typeString ?? TransactionType::WITHDRAWAL;
$typeString ??= TransactionType::WITHDRAWAL;
$search = $this->findByType($typeString);
if (null === $search) {
$search = $this->findByType(TransactionType::WITHDRAWAL);

Some files were not shown because too many files have changed in this diff Show More