Various PSR12 code cleanup

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

View File

@@ -29,8 +29,9 @@ use FireflyIII\Models\TransactionCurrency;
use FireflyIII\User;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Support\Collection;
use JsonException;
use NumberFormatter;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
/**
* Class Amount.
@@ -113,8 +114,8 @@ class Amount
/**
* @return string
* @throws FireflyException
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function getCurrencyCode(): string
{

View File

@@ -44,8 +44,8 @@ class RemoteUserGuard implements Guard
/**
* Create a new authentication guard.
*
* @param UserProvider $provider
* @param Application $app
* @param UserProvider $provider
* @param Application $app
*/
public function __construct(UserProvider $provider, Application $app)
{
@@ -81,7 +81,7 @@ class RemoteUserGuard implements Guard
$header = config('auth.guard_email');
if (null !== $header) {
$emailAddress = (string) (request()->server($header) ?? apache_request_headers()[$header] ?? null);
$emailAddress = (string)(request()->server($header) ?? apache_request_headers()[$header] ?? null);
$preference = app('preferences')->getForUser($retrievedUser, 'remote_guard_alt_email');
if ('' !== $emailAddress && null === $preference && $emailAddress !== $userID) {

View File

@@ -1,4 +1,5 @@
<?php
/**
* AccountList.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -34,8 +35,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class AccountList implements BinderInterface
{
/**
* @param string $value
* @param Route $route
* @param string $value
* @param Route $route
*
* @return Collection
* @throws NotFoundHttpException

View File

@@ -1,4 +1,5 @@
<?php
/**
* BinderInterface.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -30,8 +31,8 @@ use Illuminate\Routing\Route;
interface BinderInterface
{
/**
* @param string $value
* @param Route $route
* @param string $value
* @param Route $route
*
* @return mixed
*/

View File

@@ -1,4 +1,5 @@
<?php
/**
* BudgetList.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -25,7 +26,6 @@ namespace FireflyIII\Support\Binder;
use FireflyIII\Models\Budget;
use Illuminate\Routing\Route;
use Illuminate\Support\Collection;
use Log;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
@@ -34,8 +34,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class BudgetList implements BinderInterface
{
/**
* @param string $value
* @param Route $route
* @param string $value
* @param Route $route
*
* @return Collection
* @throws NotFoundHttpException

View File

@@ -35,8 +35,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class CLIToken implements BinderInterface
{
/**
* @param string $value
* @param Route $route
* @param string $value
* @param Route $route
*
* @return mixed
* @throws FireflyException
@@ -48,7 +48,7 @@ class CLIToken implements BinderInterface
$users = $repository->all();
// check for static token
if ($value === config('firefly.static_cron_token') && 32 === strlen((string) config('firefly.static_cron_token'))) {
if ($value === config('firefly.static_cron_token') && 32 === strlen((string)config('firefly.static_cron_token'))) {
return $value;
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* CategoryList.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -33,8 +34,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class CategoryList implements BinderInterface
{
/**
* @param string $value
* @param Route $route
* @param string $value
* @param Route $route
*
* @return Collection
* @throws NotFoundHttpException

View File

@@ -1,4 +1,5 @@
<?php
/**
* CurrencyCode.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -32,8 +33,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class CurrencyCode implements BinderInterface
{
/**
* @param string $value
* @param Route $route
* @param string $value
* @param Route $route
*
* @return TransactionCurrency
* @throws NotFoundHttpException

View File

@@ -1,4 +1,5 @@
<?php
/**
* Date.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -35,8 +36,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class Date implements BinderInterface
{
/**
* @param string $value
* @param Route $route
* @param string $value
* @param Route $route
*
* @return Carbon
* @throws NotFoundHttpException

View File

@@ -40,8 +40,8 @@ class DynamicConfigKey
];
/**
* @param string $value
* @param Route $route
* @param string $value
* @param Route $route
*
* @return string
* @throws NotFoundHttpException

View File

@@ -57,8 +57,8 @@ class EitherConfigKey
];
/**
* @param string $value
* @param Route $route
* @param string $value
* @param Route $route
*
* @return string
* @throws NotFoundHttpException

View File

@@ -1,4 +1,5 @@
<?php
/**
* JournalList.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -33,8 +34,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class JournalList implements BinderInterface
{
/**
* @param string $value
* @param Route $route
* @param string $value
* @param Route $route
*
* @return array
*
@@ -62,7 +63,7 @@ class JournalList implements BinderInterface
}
/**
* @param string $value
* @param string $value
*
* @return array
*/

View File

@@ -1,4 +1,5 @@
<?php
/**
* TagList.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -35,8 +36,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class TagList implements BinderInterface
{
/**
* @param string $value
* @param Route $route
* @param string $value
* @param Route $route
*
* @return Collection
* @throws NotFoundHttpException
@@ -68,7 +69,7 @@ class TagList implements BinderInterface
if (in_array(strtolower($tag->tag), $list, true)) {
return true;
}
if (in_array((string) $tag->id, $list, true)) {
if (in_array((string)$tag->id, $list, true)) {
return true;
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* TagOrId.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -34,8 +35,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class TagOrId implements BinderInterface
{
/**
* @param string $value
* @param Route $route
* @param string $value
* @param Route $route
*
* @return Tag
*/
@@ -48,7 +49,7 @@ class TagOrId implements BinderInterface
$result = $repository->findByTag($value);
if (null === $result) {
$result = $repository->find((int) $value);
$result = $repository->find((int)$value);
}
if (null !== $result) {
return $result;

View File

@@ -1,4 +1,5 @@
<?php
/**
* CacheProperties.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -49,7 +50,7 @@ class CacheProperties
}
/**
* @param mixed $property
* @param mixed $property
*/
public function addProperty($property): void
{
@@ -95,14 +96,14 @@ class CacheProperties
$content .= json_encode($property, JSON_THROW_ON_ERROR);
} catch (JsonException $e) {
// @ignoreException
$content .= hash('sha256', (string) time());
$content .= hash('sha256', (string)time());
}
}
$this->hash = substr(hash('sha256', $content), 0, 16);
}
/**
* @param mixed $data
* @param mixed $data
*/
public function store($data): void
{

View File

@@ -1,4 +1,5 @@
<?php
/**
* FrontpageChartGenerator.php
* Copyright (c) 2020 james@firefly-iii.org
@@ -23,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Support\Chart\Budget;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Budget;
use FireflyIII\Models\BudgetLimit;
use FireflyIII\Repositories\Budget\BudgetLimitRepositoryInterface;
@@ -64,9 +66,9 @@ class FrontpageChartGenerator
{
$budgets = $this->budgetRepository->getActiveBudgets();
$data = [
['label' => (string) trans('firefly.spent_in_budget'), 'entries' => [], 'type' => 'bar'],
['label' => (string) trans('firefly.left_to_spend'), 'entries' => [], 'type' => 'bar'],
['label' => (string) trans('firefly.overspent'), 'entries' => [], 'type' => 'bar'],
['label' => (string)trans('firefly.spent_in_budget'), 'entries' => [], 'type' => 'bar'],
['label' => (string)trans('firefly.left_to_spend'), 'entries' => [], 'type' => 'bar'],
['label' => (string)trans('firefly.overspent'), 'entries' => [], 'type' => 'bar'],
];
// loop al budgets:
@@ -83,8 +85,8 @@ class FrontpageChartGenerator
* When no limits are present, the time range is used to collect information on money spent.
* If limits are present, each limit is processed individually.
*
* @param array $data
* @param Budget $budget
* @param array $data
* @param Budget $budget
*
* @return array
*/
@@ -105,8 +107,8 @@ class FrontpageChartGenerator
* When no limits are present, the expenses of the whole period are collected and grouped.
* This is grouped per currency. Because there is no limit set, "left to spend" and "overspent" are empty.
*
* @param array $data
* @param Budget $budget
* @param array $data
* @param Budget $budget
*
* @return array
*/
@@ -127,9 +129,9 @@ class FrontpageChartGenerator
/**
* If a budget has budget limit, each limit is processed individually.
*
* @param array $data
* @param Budget $budget
* @param Collection $limits
* @param array $data
* @param Budget $budget
* @param Collection $limits
*
* @return array
*/
@@ -146,9 +148,9 @@ class FrontpageChartGenerator
/**
* For each limit, the expenses from the time range of the limit are collected. Each row from the result is processed individually.
*
* @param array $data
* @param Budget $budget
* @param BudgetLimit $limit
* @param array $data
* @param Budget $budget
* @param BudgetLimit $limit
*
* @return array
*/
@@ -158,7 +160,7 @@ class FrontpageChartGenerator
/** @var array $entry */
foreach ($spent as $entry) {
// only spent the entry where the entry's currency matches the budget limit's currency
if ($entry['currency_id'] === (int) $limit->transaction_currency_id) {
if ($entry['currency_id'] === (int)$limit->transaction_currency_id) {
$data = $this->processRow($data, $budget, $limit, $entry);
}
}
@@ -172,10 +174,10 @@ class FrontpageChartGenerator
* Each one is added to the $data array. If the limit's date range is different from the global $start and $end dates,
* for example when a limit only partially falls into this month, the title is expanded to clarify.
*
* @param array $data
* @param Budget $budget
* @param BudgetLimit $limit
* @param array $entry
* @param array $data
* @param Budget $budget
* @param BudgetLimit $limit
* @param array $entry
*
* @return array
*/
@@ -201,7 +203,7 @@ class FrontpageChartGenerator
}
/**
* @param Carbon $end
* @param Carbon $end
*/
public function setEnd(Carbon $end): void
{
@@ -209,7 +211,7 @@ class FrontpageChartGenerator
}
/**
* @param Carbon $start
* @param Carbon $start
*/
public function setStart(Carbon $start): void
{
@@ -219,8 +221,8 @@ class FrontpageChartGenerator
/**
* A basic setter for the user. Also updates the repositories with the right user.
*
* @param User $user
* @throws \FireflyIII\Exceptions\FireflyException
* @param User $user
* @throws FireflyException
*/
public function setUser(User $user): void
{
@@ -230,6 +232,6 @@ class FrontpageChartGenerator
$this->opsRepository->setUser($user);
$locale = app('steam')->getLocale();
$this->monthAndDayFormat = (string) trans('config.month_and_day_js', [], $locale);
$this->monthAndDayFormat = (string)trans('config.month_and_day_js', [], $locale);
}
}

View File

@@ -52,8 +52,8 @@ class FrontpageChartGenerator
/**
* FrontpageChartGenerator constructor.
*
* @param Carbon $start
* @param Carbon $end
* @param Carbon $start
* @param Carbon $end
*/
public function __construct(Carbon $start, Carbon $end)
{
@@ -99,8 +99,8 @@ class FrontpageChartGenerator
}
/**
* @param Category $category
* @param Collection $accounts
* @param Category $category
* @param Collection $accounts
*
* @return array
*/
@@ -113,8 +113,8 @@ class FrontpageChartGenerator
$tempData[] = [
'name' => $category->name,
'sum' => $currency['sum'],
'sum_float' => round((float) $currency['sum'], $currency['currency_decimal_places']),
'currency_id' => (int) $currency['currency_id'],
'sum_float' => round((float)$currency['sum'], $currency['currency_decimal_places']),
'currency_id' => (int)$currency['currency_id'],
];
}
@@ -122,23 +122,23 @@ class FrontpageChartGenerator
}
/**
* @param array $currency
* @param array $currency
*/
private function addCurrency(array $currency): void
{
$currencyId = (int) $currency['currency_id'];
$currencyId = (int)$currency['currency_id'];
$this->currencies[$currencyId] = $this->currencies[$currencyId] ?? [
'currency_id' => $currencyId,
'currency_name' => $currency['currency_name'],
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
'currency_decimal_places' => $currency['currency_decimal_places'],
];
'currency_id' => $currencyId,
'currency_name' => $currency['currency_name'],
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
'currency_decimal_places' => $currency['currency_decimal_places'],
];
}
/**
* @param Collection $accounts
* @param Collection $accounts
*
* @return array
*/
@@ -151,8 +151,8 @@ class FrontpageChartGenerator
$tempData[] = [
'name' => trans('firefly.no_category'),
'sum' => $currency['sum'],
'sum_float' => round((float) $currency['sum'], $currency['currency_decimal_places'] ?? 2), // intentional float
'currency_id' => (int) $currency['currency_id'],
'sum_float' => round((float)$currency['sum'], $currency['currency_decimal_places'] ?? 2), // intentional float
'currency_id' => (int)$currency['currency_id'],
];
}
@@ -160,7 +160,7 @@ class FrontpageChartGenerator
}
/**
* @param array $data
* @param array $data
*
* @return array
*/
@@ -174,7 +174,7 @@ class FrontpageChartGenerator
foreach ($this->currencies as $currencyId => $currency) {
$key = sprintf('spent-%d', $currencyId);
$return[$key] = [
'label' => sprintf('%s (%s)', (string) trans('firefly.spent'), $currency['currency_name']),
'label' => sprintf('%s (%s)', (string)trans('firefly.spent'), $currency['currency_name']),
'type' => 'bar',
'currency_symbol' => $currency['currency_symbol'],
'entries' => $names,
@@ -185,8 +185,8 @@ class FrontpageChartGenerator
}
/**
* @param array $currencyData
* @param array $monetaryData
* @param array $currencyData
* @param array $monetaryData
*
* @return array
*/

View File

@@ -36,9 +36,9 @@ use Illuminate\Support\Collection;
class WholePeriodChartGenerator
{
/**
* @param Category $category
* @param Carbon $start
* @param Carbon $end
* @param Category $category
* @param Carbon $start
* @param Carbon $end
*
* @return array
*/
@@ -77,14 +77,14 @@ class WholePeriodChartGenerator
$code = $currency['currency_code'];
$name = $currency['currency_name'];
$chartData[sprintf('spent-in-%s', $code)] = [
'label' => (string) trans('firefly.box_spent_in_currency', ['currency' => $name]),
'label' => (string)trans('firefly.box_spent_in_currency', ['currency' => $name]),
'entries' => [],
'type' => 'bar',
'backgroundColor' => 'rgba(219, 68, 55, 0.5)', // red
];
$chartData[sprintf('earned-in-%s', $code)] = [
'label' => (string) trans('firefly.box_earned_in_currency', ['currency' => $name]),
'label' => (string)trans('firefly.box_earned_in_currency', ['currency' => $name]),
'entries' => [],
'type' => 'bar',
'backgroundColor' => 'rgba(0, 141, 76, 0.5)', // green
@@ -117,8 +117,8 @@ class WholePeriodChartGenerator
/**
* TODO this method is duplicated
*
* @param Carbon $start
* @param Carbon $end
* @param Carbon $start
* @param Carbon $end
*
* @return string
*/
@@ -143,7 +143,7 @@ class WholePeriodChartGenerator
* Loop array of spent/earned info, and extract which currencies are present.
* Key is the currency ID.
*
* @param array $array
* @param array $array
*
* @return array
*/
@@ -153,12 +153,12 @@ class WholePeriodChartGenerator
foreach ($array as $block) {
foreach ($block as $currencyId => $currencyRow) {
$return[$currencyId] = $return[$currencyId] ?? [
'currency_id' => $currencyId,
'currency_name' => $currencyRow['currency_name'],
'currency_symbol' => $currencyRow['currency_symbol'],
'currency_code' => $currencyRow['currency_code'],
'currency_decimal_places' => $currencyRow['currency_decimal_places'],
];
'currency_id' => $currencyId,
'currency_name' => $currencyRow['currency_name'],
'currency_symbol' => $currencyRow['currency_symbol'],
'currency_code' => $currencyRow['currency_code'],
'currency_decimal_places' => $currencyRow['currency_decimal_places'],
];
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* ChartColour.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -54,7 +55,7 @@ class ChartColour
];
/**
* @param int $index
* @param int $index
*
* @return string
*/

View File

@@ -59,7 +59,7 @@ abstract class AbstractCronjob
abstract public function fire(): void;
/**
* @param Carbon $date
* @param Carbon $date
*/
final public function setDate(Carbon $date): void
{
@@ -68,7 +68,7 @@ abstract class AbstractCronjob
}
/**
* @param bool $force
* @param bool $force
*/
final public function setForce(bool $force): void
{

View File

@@ -41,7 +41,7 @@ class AutoBudgetCronjob extends AbstractCronjob
{
/** @var Configuration $config */
$config = app('fireflyconfig')->get('last_ab_job', 0);
$lastTime = (int) $config->data;
$lastTime = (int)$config->data;
$diff = time() - $lastTime;
$diffForHumans = Carbon::now()->diffForHumans(Carbon::createFromTimestamp($lastTime), null, true);
if (0 === $lastTime) {
@@ -88,7 +88,7 @@ class AutoBudgetCronjob extends AbstractCronjob
$this->jobSucceeded = true;
$this->message = 'Auto-budget cron job fired successfully.';
app('fireflyconfig')->set('last_ab_job', (int) $this->date->format('U'));
app('fireflyconfig')->set('last_ab_job', (int)$this->date->format('U'));
Log::info('Done with auto budget cron job task.');
}
}

View File

@@ -28,6 +28,8 @@ use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Jobs\WarnAboutBills;
use FireflyIII\Models\Configuration;
use Log;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
/**
* Class BillWarningCronjob
@@ -36,15 +38,15 @@ class BillWarningCronjob extends AbstractCronjob
{
/**
* @throws FireflyException
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function fire(): void
{
Log::debug(sprintf('Now in %s', __METHOD__));
/** @var Configuration $config */
$config = app('fireflyconfig')->get('last_bw_job', 0);
$lastTime = (int) $config->data;
$lastTime = (int)$config->data;
$diff = time() - $lastTime;
$diffForHumans = Carbon::now()->diffForHumans(Carbon::createFromTimestamp($lastTime), null, true);
@@ -97,8 +99,8 @@ class BillWarningCronjob extends AbstractCronjob
$this->jobSucceeded = true;
$this->message = 'Bill warning cron job fired successfully.';
app('fireflyconfig')->set('last_bw_job', (int) $this->date->format('U'));
Log::info(sprintf('Marked the last time this job has run as "%s" (%d)', $this->date->format('Y-m-d H:i:s'), (int) $this->date->format('U')));
app('fireflyconfig')->set('last_bw_job', (int)$this->date->format('U'));
Log::info(sprintf('Marked the last time this job has run as "%s" (%d)', $this->date->format('Y-m-d H:i:s'), (int)$this->date->format('U')));
Log::info('Done with bill warning cron job task.');
}
}

View File

@@ -41,7 +41,7 @@ class ExchangeRatesCronjob extends AbstractCronjob
{
/** @var Configuration $config */
$config = app('fireflyconfig')->get('last_cer_job', 0);
$lastTime = (int) $config->data;
$lastTime = (int)$config->data;
$diff = time() - $lastTime;
$diffForHumans = Carbon::now()->diffForHumans(Carbon::createFromTimestamp($lastTime), null, true);
if (0 === $lastTime) {
@@ -88,7 +88,7 @@ class ExchangeRatesCronjob extends AbstractCronjob
$this->jobSucceeded = true;
$this->message = 'Exchange rates cron job fired successfully.';
app('fireflyconfig')->set('last_cer_job', (int) $this->date->format('U'));
app('fireflyconfig')->set('last_cer_job', (int)$this->date->format('U'));
Log::info('Done with exchange rates job task.');
}
}

View File

@@ -28,6 +28,8 @@ use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Jobs\CreateRecurringTransactions;
use FireflyIII\Models\Configuration;
use Log;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
/**
* Class RecurringCronjob
@@ -36,15 +38,15 @@ class RecurringCronjob extends AbstractCronjob
{
/**
* @throws FireflyException
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function fire(): void
{
Log::debug(sprintf('Now in %s', __METHOD__));
/** @var Configuration $config */
$config = app('fireflyconfig')->get('last_rt_job', 0);
$lastTime = (int) $config->data;
$lastTime = (int)$config->data;
$diff = time() - $lastTime;
$diffForHumans = Carbon::now()->diffForHumans(Carbon::createFromTimestamp($lastTime), null, true);
@@ -97,8 +99,8 @@ class RecurringCronjob extends AbstractCronjob
$this->jobSucceeded = true;
$this->message = 'Recurring transactions cron job fired successfully.';
app('fireflyconfig')->set('last_rt_job', (int) $this->date->format('U'));
Log::info(sprintf('Marked the last time this job has run as "%s" (%d)', $this->date->format('Y-m-d H:i:s'), (int) $this->date->format('U')));
app('fireflyconfig')->set('last_rt_job', (int)$this->date->format('U'));
Log::info(sprintf('Marked the last time this job has run as "%s" (%d)', $this->date->format('Y-m-d H:i:s'), (int)$this->date->format('U')));
Log::info('Done with recurring cron job task.');
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* Domain.php
* Copyright (c) 2019 james@firefly-iii.org

View File

@@ -1,4 +1,5 @@
<?php
/**
* ExpandedForm.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -42,9 +43,9 @@ class ExpandedForm
use FormSupport;
/**
* @param string $name
* @param mixed $value
* @param array|null $options
* @param string $name
* @param mixed $value
* @param array|null $options
*
* @return string
*/
@@ -74,10 +75,10 @@ class ExpandedForm
}
/**
* @param string $name
* @param int|null $value
* @param mixed $checked
* @param array|null $options
* @param string $name
* @param int|null $value
* @param mixed $checked
* @param array|null $options
*
* @return string
*/
@@ -110,9 +111,9 @@ class ExpandedForm
}
/**
* @param string $name
* @param mixed $value
* @param array|null $options
* @param string $name
* @param mixed $value
* @param array|null $options
*
* @return string
*/
@@ -135,8 +136,8 @@ class ExpandedForm
}
/**
* @param string $name
* @param array|null $options
* @param string $name
* @param array|null $options
*
* @return string
*/
@@ -158,9 +159,9 @@ class ExpandedForm
}
/**
* @param string $name
* @param mixed $value
* @param array|null $options
* @param string $name
* @param mixed $value
* @param array|null $options
*
* @return string
*/
@@ -184,9 +185,9 @@ class ExpandedForm
}
/**
* @param string $name
* @param mixed $value
* @param array|null $options
* @param string $name
* @param mixed $value
* @param array|null $options
*
* @return string
*/
@@ -209,7 +210,7 @@ class ExpandedForm
}
/**
* @param Collection $set
* @param Collection $set
*
* @return array
*
@@ -221,7 +222,7 @@ class ExpandedForm
$fields = ['title', 'name', 'description'];
/** @var Eloquent $entry */
foreach ($set as $entry) {
$entryId = (int) $entry->id;
$entryId = (int)$entry->id;
$current = $entry->toArray();
$title = null;
foreach ($fields as $field) {
@@ -236,9 +237,9 @@ class ExpandedForm
}
/**
* @param string $name
* @param mixed $value
* @param array|null $options
* @param string $name
* @param mixed $value
* @param array|null $options
*
* @return string
*/
@@ -268,9 +269,9 @@ class ExpandedForm
}
/**
* @param string $name
* @param mixed $value
* @param array|null $options
* @param string $name
* @param mixed $value
* @param array|null $options
*
* @return string
*/
@@ -294,8 +295,8 @@ class ExpandedForm
}
/**
* @param null $value
* @param array|null $options
* @param null $value
* @param array|null $options
*
* @return string
*/
@@ -324,8 +325,8 @@ class ExpandedForm
}
/**
* @param string $type
* @param string $name
* @param string $type
* @param string $name
*
* @return string
*
@@ -344,8 +345,8 @@ class ExpandedForm
}
/**
* @param string $name
* @param array|null $options
* @param string $name
* @param array|null $options
*
* @return string
*/
@@ -368,9 +369,9 @@ class ExpandedForm
/**
* Function to render a percentage.
*
* @param string $name
* @param mixed $value
* @param array|null $options
* @param string $name
* @param mixed $value
* @param array|null $options
*
* @return string
*/
@@ -394,9 +395,9 @@ class ExpandedForm
}
/**
* @param string $name
* @param mixed $value
* @param array|null $options
* @param string $name
* @param mixed $value
* @param array|null $options
*
* @return string
*/
@@ -417,9 +418,9 @@ class ExpandedForm
}
/**
* @param string $name
* @param mixed $value
* @param array|null $options
* @param string $name
* @param mixed $value
* @param array|null $options
*
* @return string
*/
@@ -441,9 +442,9 @@ class ExpandedForm
}
/**
* @param string $name
* @param mixed $value
* @param array|null $options
* @param string $name
* @param mixed $value
* @param array|null $options
*
* @return string
*/

View File

@@ -56,6 +56,8 @@ use Illuminate\Support\Collection;
use League\Csv\CannotInsertRecord;
use League\Csv\Exception;
use League\Csv\Writer;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
/**
* Class ExportDataGenerator
@@ -141,8 +143,25 @@ class ExportDataGenerator
*/
private function exportAccounts(): string
{
$header = ['user_id', 'account_id', 'created_at', 'updated_at', 'type', 'name', 'virtual_balance', 'iban', 'number', 'active', 'currency_code', 'role',
'cc_type', 'cc_payment_date', 'in_net_worth', 'interest', 'interest_period',];
$header = [
'user_id',
'account_id',
'created_at',
'updated_at',
'type',
'name',
'virtual_balance',
'iban',
'number',
'active',
'currency_code',
'role',
'cc_type',
'cc_payment_date',
'in_net_worth',
'interest',
'interest_period',
];
/** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class);
$repository->setUser($this->user);
@@ -194,6 +213,14 @@ class ExportDataGenerator
return $string;
}
/**
* @param User $user
*/
public function setUser(User $user): void
{
$this->user = $user;
}
/**
* @return string
* @throws FireflyException
@@ -204,8 +231,20 @@ class ExportDataGenerator
$repository = app(BillRepositoryInterface::class);
$repository->setUser($this->user);
$bills = $repository->getBills();
$header = ['user_id', 'bill_id', 'created_at', 'updated_at', 'currency_code', 'name', 'amount_min', 'amount_max', 'date', 'repeat_freq', 'skip',
'active',];
$header = [
'user_id',
'bill_id',
'created_at',
'updated_at',
'currency_code',
'name',
'amount_min',
'amount_max',
'date',
'repeat_freq',
'skip',
'active',
];
$records = [];
/** @var Bill $bill */
@@ -374,9 +413,22 @@ class ExportDataGenerator
$accountRepos = app(AccountRepositoryInterface::class);
$accountRepos->setUser($this->user);
$header = ['user_id', 'piggy_bank_id', 'created_at', 'updated_at', 'account_name', 'account_type', 'name',
'currency_code', 'target_amount', 'current_amount', 'start_date', 'target_date', 'order',
'active'];
$header = [
'user_id',
'piggy_bank_id',
'created_at',
'updated_at',
'account_name',
'account_type',
'name',
'currency_code',
'target_amount',
'current_amount',
'start_date',
'target_date',
'order',
'active',
];
$records = [];
$piggies = $piggyRepos->getPiggyBanks();
@@ -435,14 +487,39 @@ class ExportDataGenerator
$recurringRepos->setUser($this->user);
$header = [
// recurrence:
'user_id', 'recurrence_id', 'row_contains', 'created_at', 'updated_at', 'type', 'title', 'description', 'first_date', 'repeat_until',
'latest_date', 'repetitions', 'apply_rules', 'active',
'user_id',
'recurrence_id',
'row_contains',
'created_at',
'updated_at',
'type',
'title',
'description',
'first_date',
'repeat_until',
'latest_date',
'repetitions',
'apply_rules',
'active',
// repetition info:
'type', 'moment', 'skip', 'weekend',
'type',
'moment',
'skip',
'weekend',
// transactions + meta:
'currency_code', 'foreign_currency_code', 'source_name', 'source_type', 'destination_name', 'destination_type', 'amount', 'foreign_amount',
'category', 'budget', 'piggy_bank', 'tags',
'currency_code',
'foreign_currency_code',
'source_name',
'source_type',
'destination_name',
'destination_type',
'amount',
'foreign_amount',
'category',
'budget',
'piggy_bank',
'tags',
];
$records = [];
$recurrences = $recurringRepos->getAll();
@@ -471,10 +548,25 @@ class ExportDataGenerator
$records[] = [
// recurrence
$this->user->id,
$recurrence->id, 'repetition', null, null, null, null, null, null, null, null, null, null, null,
$recurrence->id,
'repetition',
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
// repetition:
$repetition->repetition_type, $repetition->repetition_moment, $repetition->repetition_skip, $repetition->weekend,
$repetition->repetition_type,
$repetition->repetition_moment,
$repetition->repetition_skip,
$repetition->weekend,
];
}
/** @var RecurrenceTransaction $transaction */
@@ -487,16 +579,39 @@ class ExportDataGenerator
$records[] = [
// recurrence
$this->user->id,
$recurrence->id, 'transaction', null, null, null, null, null, null, null, null, null, null, null,
$recurrence->id,
'transaction',
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
// repetition:
null, null, null, null,
null,
null,
null,
null,
// transaction:
$transaction->transactionCurrency->code, $transaction->foreignCurrency?->code,
$transaction->sourceAccount->name, $transaction->sourceAccount->accountType->type, $transaction->destinationAccount->name,
$transaction->destinationAccount->accountType->type, $transaction->amount, $transaction->foreign_amount,
$categoryName, $budgetId, $piggyBankId, implode(',', $tags),
$transaction->transactionCurrency->code,
$transaction->foreignCurrency?->code,
$transaction->sourceAccount->name,
$transaction->sourceAccount->accountType->type,
$transaction->destinationAccount->name,
$transaction->destinationAccount->accountType->type,
$transaction->amount,
$transaction->foreign_amount,
$categoryName,
$budgetId,
$piggyBankId,
implode(',', $tags),
];
}
}
@@ -528,9 +643,31 @@ class ExportDataGenerator
*/
private function exportRules(): string
{
$header = ['user_id', 'rule_id', 'row_contains', 'created_at', 'updated_at', 'group_id', 'group_name', 'title', 'description', 'order', 'active',
'stop_processing', 'strict', 'trigger_type', 'trigger_value', 'trigger_order', 'trigger_active', 'trigger_stop_processing', 'action_type',
'action_value', 'action_order', 'action_active', 'action_stop_processing',];
$header = [
'user_id',
'rule_id',
'row_contains',
'created_at',
'updated_at',
'group_id',
'group_name',
'title',
'description',
'order',
'active',
'stop_processing',
'strict',
'trigger_type',
'trigger_value',
'trigger_order',
'trigger_active',
'trigger_stop_processing',
'action_type',
'action_value',
'action_order',
'action_active',
'action_stop_processing',
];
$ruleRepos = app(RuleRepositoryInterface::class);
$ruleRepos->setUser($this->user);
$rules = $ruleRepos->getAll();
@@ -538,31 +675,70 @@ class ExportDataGenerator
/** @var Rule $rule */
foreach ($rules as $rule) {
$records[] = [
$this->user->id, $rule->id, 'rule',
$rule->created_at->toAtomString(), $rule->updated_at->toAtomString(),
$rule->ruleGroup->id, $rule->ruleGroup->title,
$rule->title, $rule->description, $rule->order, $rule->active, $rule->stop_processing, $rule->strict,
$this->user->id,
$rule->id,
'rule',
$rule->created_at->toAtomString(),
$rule->updated_at->toAtomString(),
$rule->ruleGroup->id,
$rule->ruleGroup->title,
$rule->title,
$rule->description,
$rule->order,
$rule->active,
$rule->stop_processing,
$rule->strict,
];
/** @var RuleTrigger $trigger */
foreach ($rule->ruleTriggers as $trigger) {
$records[] = [
$this->user->id, $rule->id, 'trigger',
null, null,
null, null,
null, null, null, null, null, null,
$trigger->trigger_type, $trigger->trigger_value, $trigger->order, $trigger->active, $trigger->stop_processing,
$this->user->id,
$rule->id,
'trigger',
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
$trigger->trigger_type,
$trigger->trigger_value,
$trigger->order,
$trigger->active,
$trigger->stop_processing,
];
}
/** @var RuleAction $action */
foreach ($rule->ruleActions as $action) {
$records[] = [
$this->user->id, $rule->id, 'action',
null, null,
null, null,
null, null, null, null, null, null,
null, null, null, null, null,
$action->action_type, $action->action_value, $action->order, $action->active, $action->stop_processing,
$this->user->id,
$rule->id,
'action',
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
$action->action_type,
$action->action_value,
$action->order,
$action->active,
$action->stop_processing,
];
}
}
@@ -592,8 +768,8 @@ class ExportDataGenerator
/**
* @return string
* @throws FireflyException
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
private function exportTags(): string
{
@@ -648,10 +824,33 @@ class ExportDataGenerator
private function exportTransactions(): string
{
// TODO better place for keys?
$header = ['user_id', 'group_id', 'journal_id', 'created_at', 'updated_at', 'group_title', 'type', 'amount', 'foreign_amount', 'currency_code',
'foreign_currency_code', 'description', 'date', 'source_name', 'source_iban', 'source_type', 'destination_name', 'destination_iban',
'destination_type', 'reconciled', 'category', 'budget', 'bill', 'tags', 'notes',
// all optional meta fields:
$header = [
'user_id',
'group_id',
'journal_id',
'created_at',
'updated_at',
'group_title',
'type',
'amount',
'foreign_amount',
'currency_code',
'foreign_currency_code',
'description',
'date',
'source_name',
'source_iban',
'source_type',
'destination_name',
'destination_iban',
'destination_type',
'reconciled',
'category',
'budget',
'bill',
'tags',
'notes',
// all optional meta fields:
];
$metaFields = config('firefly.journal_meta_fields');
@@ -761,7 +960,15 @@ class ExportDataGenerator
}
/**
* @param array $tags
* @param Collection $accounts
*/
public function setAccounts(Collection $accounts): void
{
$this->accounts = $accounts;
}
/**
* @param array $tags
*
* @return string
*/
@@ -779,15 +986,7 @@ class ExportDataGenerator
}
/**
* @param Collection $accounts
*/
public function setAccounts(Collection $accounts): void
{
$this->accounts = $accounts;
}
/**
* @param Carbon $end
* @param Carbon $end
*/
public function setEnd(Carbon $end): void
{
@@ -795,7 +994,7 @@ class ExportDataGenerator
}
/**
* @param bool $exportAccounts
* @param bool $exportAccounts
*/
public function setExportAccounts(bool $exportAccounts): void
{
@@ -803,7 +1002,7 @@ class ExportDataGenerator
}
/**
* @param bool $exportBills
* @param bool $exportBills
*/
public function setExportBills(bool $exportBills): void
{
@@ -811,7 +1010,7 @@ class ExportDataGenerator
}
/**
* @param bool $exportBudgets
* @param bool $exportBudgets
*/
public function setExportBudgets(bool $exportBudgets): void
{
@@ -819,7 +1018,7 @@ class ExportDataGenerator
}
/**
* @param bool $exportCategories
* @param bool $exportCategories
*/
public function setExportCategories(bool $exportCategories): void
{
@@ -827,7 +1026,7 @@ class ExportDataGenerator
}
/**
* @param bool $exportPiggies
* @param bool $exportPiggies
*/
public function setExportPiggies(bool $exportPiggies): void
{
@@ -835,7 +1034,7 @@ class ExportDataGenerator
}
/**
* @param bool $exportRecurring
* @param bool $exportRecurring
*/
public function setExportRecurring(bool $exportRecurring): void
{
@@ -843,7 +1042,7 @@ class ExportDataGenerator
}
/**
* @param bool $exportRules
* @param bool $exportRules
*/
public function setExportRules(bool $exportRules): void
{
@@ -851,7 +1050,7 @@ class ExportDataGenerator
}
/**
* @param bool $exportTags
* @param bool $exportTags
*/
public function setExportTags(bool $exportTags): void
{
@@ -859,7 +1058,7 @@ class ExportDataGenerator
}
/**
* @param bool $exportTransactions
* @param bool $exportTransactions
*/
public function setExportTransactions(bool $exportTransactions): void
{
@@ -867,18 +1066,10 @@ class ExportDataGenerator
}
/**
* @param Carbon $start
* @param Carbon $start
*/
public function setStart(Carbon $start): void
{
$this->start = $start;
}
/**
* @param User $user
*/
public function setUser(User $user): void
{
$this->user = $user;
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* AccountForm.php
* Copyright (c) 2019 james@firefly-iii.org

View File

@@ -1,4 +1,5 @@
<?php
/**
* Amount.php
* Copyright (c) 2019 james@firefly-iii.org

View File

@@ -1,4 +1,5 @@
<?php
/**
* CurrencyForm.php
* Copyright (c) 2019 james@firefly-iii.org

View File

@@ -1,4 +1,5 @@
<?php
/**
* ExpandedForm.php
* Copyright (c) 2019 james@firefly-iii.org

View File

@@ -1,4 +1,5 @@
<?php
/**
* FireflyConfig.php
* Copyright (c) 2019 james@firefly-iii.org

View File

@@ -1,4 +1,5 @@
<?php
/**
* Navigation.php
* Copyright (c) 2019 james@firefly-iii.org

View File

@@ -1,4 +1,5 @@
<?php
/**
* PiggyBankForm.php
* Copyright (c) 2019 james@firefly-iii.org

View File

@@ -1,4 +1,5 @@
<?php
/**
* Preferences.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -26,7 +27,6 @@ use FireflyIII\Models\Preference;
use FireflyIII\User;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Facade;
use Log;
/**
* @codeCoverageIgnore

View File

@@ -1,4 +1,5 @@
<?php
/**
* RuleForm.php
* Copyright (c) 2019 james@firefly-iii.org

View File

@@ -1,4 +1,5 @@
<?php
/**
* Steam.php
* Copyright (c) 2019 james@firefly-iii.org

View File

@@ -1,4 +1,5 @@
<?php
/**
* FireflyConfig.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -36,11 +37,11 @@ use Illuminate\Database\QueryException;
class FireflyConfig
{
/**
* @param string $name
* @param string $name
*/
public function delete(string $name): void
{
$fullName = 'ff-config-' . $name;
$fullName = 'ff-config-'.$name;
if (Cache::has($fullName)) {
Cache::forget($fullName);
}
@@ -52,15 +53,25 @@ class FireflyConfig
}
/**
* @param string $name
* @param bool|string|int|null $default
* @param string $name
*
* @return bool
*/
public function has(string $name): bool
{
return Configuration::where('name', $name)->count() === 1;
}
/**
* @param string $name
* @param bool|string|int|null $default
*
* @return Configuration|null
* @throws FireflyException
*/
public function get(string $name, $default = null): ?Configuration
{
$fullName = 'ff-config-' . $name;
$fullName = 'ff-config-'.$name;
if (Cache::has($fullName)) {
return Cache::get($fullName);
}
@@ -86,8 +97,8 @@ class FireflyConfig
}
/**
* @param string $name
* @param mixed $value
* @param string $name
* @param mixed $value
*
* @return Configuration
*/
@@ -108,20 +119,20 @@ class FireflyConfig
$item->name = $name;
$item->data = $value;
$item->save();
Cache::forget('ff-config-' . $name);
Cache::forget('ff-config-'.$name);
return $item;
}
$config->data = $value;
$config->save();
Cache::forget('ff-config-' . $name);
Cache::forget('ff-config-'.$name);
return $config;
}
/**
* @param string $name
* @param mixed $default
* @param string $name
* @param mixed $default
*
* @return Configuration|null
*/
@@ -140,18 +151,8 @@ class FireflyConfig
}
/**
* @param string $name
*
* @return bool
*/
public function has(string $name): bool
{
return Configuration::where('name', $name)->count() === 1;
}
/**
* @param string $name
* @param mixed $value
* @param string $name
* @param mixed $value
*
* @return Configuration
*/

View File

@@ -45,9 +45,9 @@ class AccountForm
/**
* Grouped dropdown list of all accounts that are valid as the destination of a withdrawal.
*
* @param string $name
* @param mixed $value
* @param array|null $options
* @param string $name
* @param mixed $value
* @param array|null $options
*
* @return string
*/
@@ -57,8 +57,8 @@ class AccountForm
$repository = $this->getAccountRepository();
$grouped = $this->getAccountsGrouped($types, $repository);
$cash = $repository->getCashAccount();
$key = (string) trans('firefly.cash_account_type');
$grouped[$key][$cash->id] = sprintf('(%s)', (string) trans('firefly.cash'));
$key = (string)trans('firefly.cash_account_type');
$grouped[$key][$cash->id] = sprintf('(%s)', (string)trans('firefly.cash'));
return $this->select($name, $grouped, $value, $options);
}
@@ -74,7 +74,7 @@ class AccountForm
/** @var Account $account */
foreach ($accountList as $account) {
$role = (string) $repository->getMetaValue($account, 'account_role');
$role = (string)$repository->getMetaValue($account, 'account_role');
if (in_array($account->accountType->type, $liabilityTypes, true)) {
$role = sprintf('l_%s', $account->accountType->type);
} elseif ('' === $role) {
@@ -86,7 +86,7 @@ class AccountForm
$role = 'no_account_type';
}
}
$key = (string) trans(sprintf('firefly.opt_group_%s', $role));
$key = (string)trans(sprintf('firefly.opt_group_%s', $role));
$grouped[$key][$account->id] = $account->name;
}
@@ -96,9 +96,9 @@ class AccountForm
/**
* Grouped dropdown list of all accounts that are valid as the destination of a withdrawal.
*
* @param string $name
* @param mixed $value
* @param array|null $options
* @param string $name
* @param mixed $value
* @param array|null $options
*
* @return string
*/
@@ -109,8 +109,8 @@ class AccountForm
$grouped = $this->getAccountsGrouped($types, $repository);
$cash = $repository->getCashAccount();
$key = (string) trans('firefly.cash_account_type');
$grouped[$key][$cash->id] = sprintf('(%s)', (string) trans('firefly.cash'));
$key = (string)trans('firefly.cash_account_type');
$grouped[$key][$cash->id] = sprintf('(%s)', (string)trans('firefly.cash'));
return $this->select($name, $grouped, $value, $options);
}
@@ -118,8 +118,8 @@ class AccountForm
/**
* Check list of asset accounts.
*
* @param string $name
* @param array|null $options
* @param string $name
* @param array|null $options
*
* @return string
*/
@@ -150,9 +150,9 @@ class AccountForm
/**
* Basic list of asset accounts.
*
* @param string $name
* @param mixed $value
* @param array|null $options
* @param string $name
* @param mixed $value
* @param array|null $options
*
* @return string
*/
@@ -167,9 +167,9 @@ class AccountForm
/**
* Same list but all liabilities as well.
*
* @param string $name
* @param mixed $value
* @param array|null $options
* @param string $name
* @param mixed $value
* @param array|null $options
*
* @return string
*/

View File

@@ -41,9 +41,9 @@ class CurrencyForm
use FormSupport;
/**
* @param string $name
* @param mixed $value
* @param array|null $options
* @param string $name
* @param mixed $value
* @param array|null $options
*
* @return string
*/
@@ -53,10 +53,10 @@ class CurrencyForm
}
/**
* @param string $name
* @param string $view
* @param mixed $value
* @param array|null $options
* @param string $name
* @param string $view
* @param mixed $value
* @param array|null $options
*
* @return string
*/
@@ -77,8 +77,8 @@ class CurrencyForm
if (!is_array($preFilled)) {
$preFilled = [];
}
$key = 'amount_currency_id_' . $name;
$sentCurrencyId = array_key_exists($key, $preFilled) ? (int) $preFilled[$key] : $defaultCurrency->id;
$key = 'amount_currency_id_'.$name;
$sentCurrencyId = array_key_exists($key, $preFilled) ? (int)$preFilled[$key] : $defaultCurrency->id;
Log::debug(sprintf('Sent currency ID is %d', $sentCurrencyId));
@@ -96,7 +96,7 @@ class CurrencyForm
$value = app('steam')->bcround($value, $defaultCurrency->decimal_places);
}
try {
$html = view('form.' . $view, compact('defaultCurrency', 'currencies', 'classes', 'name', 'label', 'value', 'options'))->render();
$html = view('form.'.$view, compact('defaultCurrency', 'currencies', 'classes', 'name', 'label', 'value', 'options'))->render();
} catch (Throwable $e) {
Log::debug(sprintf('Could not render currencyField(): %s', $e->getMessage()));
$html = 'Could not render currencyField.';
@@ -109,9 +109,9 @@ class CurrencyForm
/**
* TODO describe and cleanup.
*
* @param string $name
* @param mixed $value
* @param array|null $options
* @param string $name
* @param mixed $value
* @param array|null $options
*
* @return string
*/
@@ -123,10 +123,10 @@ class CurrencyForm
/**
* TODO describe and cleanup
*
* @param string $name
* @param string $view
* @param mixed $value
* @param array|null $options
* @param string $name
* @param string $view
* @param mixed $value
* @param array|null $options
*
* @return string
*/
@@ -147,8 +147,8 @@ class CurrencyForm
if (!is_array($preFilled)) {
$preFilled = [];
}
$key = 'amount_currency_id_' . $name;
$sentCurrencyId = array_key_exists($key, $preFilled) ? (int) $preFilled[$key] : $defaultCurrency->id;
$key = 'amount_currency_id_'.$name;
$sentCurrencyId = array_key_exists($key, $preFilled) ? (int)$preFilled[$key] : $defaultCurrency->id;
Log::debug(sprintf('Sent currency ID is %d', $sentCurrencyId));
@@ -166,7 +166,7 @@ class CurrencyForm
$value = app('steam')->bcround($value, $defaultCurrency->decimal_places);
}
try {
$html = view('form.' . $view, compact('defaultCurrency', 'currencies', 'classes', 'name', 'label', 'value', 'options'))->render();
$html = view('form.'.$view, compact('defaultCurrency', 'currencies', 'classes', 'name', 'label', 'value', 'options'))->render();
} catch (Throwable $e) {
Log::debug(sprintf('Could not render currencyField(): %s', $e->getMessage()));
$html = 'Could not render currencyField.';
@@ -179,9 +179,9 @@ class CurrencyForm
/**
* TODO cleanup and describe
*
* @param string $name
* @param mixed $value
* @param array|null $options
* @param string $name
* @param mixed $value
* @param array|null $options
*
* @return string
*/
@@ -195,7 +195,7 @@ class CurrencyForm
$array = [];
/** @var TransactionCurrency $currency */
foreach ($list as $currency) {
$array[$currency->id] = $currency->name . ' (' . $currency->symbol . ')';
$array[$currency->id] = $currency->name.' ('.$currency->symbol.')';
}
return $this->select($name, $array, $value, $options);
@@ -204,9 +204,9 @@ class CurrencyForm
/**
* TODO cleanup and describe
*
* @param string $name
* @param mixed $value
* @param array|null $options
* @param string $name
* @param mixed $value
* @param array|null $options
*
* @return string
*/
@@ -218,11 +218,11 @@ class CurrencyForm
// get all currencies:
$list = $currencyRepos->get();
$array = [
0 => (string) trans('firefly.no_currency'),
0 => (string)trans('firefly.no_currency'),
];
/** @var TransactionCurrency $currency */
foreach ($list as $currency) {
$array[$currency->id] = $currency->name . ' (' . $currency->symbol . ')';
$array[$currency->id] = $currency->name.' ('.$currency->symbol.')';
}
return $this->select($name, $array, $value, $options);

View File

@@ -37,10 +37,10 @@ use Throwable;
trait FormSupport
{
/**
* @param string $name
* @param array|null $list
* @param mixed $selected
* @param array|null $options
* @param string $name
* @param array|null $list
* @param mixed $selected
* @param array|null $options
*
* @return string
*/
@@ -63,8 +63,8 @@ trait FormSupport
}
/**
* @param string $name
* @param array|null $options
* @param string $name
* @param array|null $options
*
* @return string
*/
@@ -76,13 +76,13 @@ trait FormSupport
}
$name = str_replace('[]', '', $name);
return (string) trans('form.' . $name);
return (string)trans('form.'.$name);
}
/**
* @param string $name
* @param mixed $label
* @param array|null $options
* @param string $name
* @param mixed $label
* @param array|null $options
*
* @return array
*/
@@ -91,7 +91,7 @@ trait FormSupport
$options = $options ?? [];
$name = str_replace('[]', '', $name);
$options['class'] = 'form-control';
$options['id'] = 'ffInput_' . $name;
$options['id'] = 'ffInput_'.$name;
$options['autocomplete'] = 'off';
$options['placeholder'] = ucfirst($label);
@@ -99,7 +99,7 @@ trait FormSupport
}
/**
* @param string $name
* @param string $name
*
* @return string
*/
@@ -118,8 +118,8 @@ trait FormSupport
}
/**
* @param string $name
* @param mixed|null $value
* @param string $name
* @param mixed|null $value
*
* @return mixed
*/

View File

@@ -38,9 +38,9 @@ class PiggyBankForm
/**
* TODO cleanup and describe
*
* @param string $name
* @param mixed $value
* @param array|null $options
* @param string $name
* @param mixed $value
* @param array|null $options
*
* @return string
*/
@@ -50,7 +50,7 @@ class PiggyBankForm
/** @var PiggyBankRepositoryInterface $repository */
$repository = app(PiggyBankRepositoryInterface::class);
$piggyBanks = $repository->getPiggyBanksWithAmount();
$title = (string) trans('firefly.default_group_title_name');
$title = (string)trans('firefly.default_group_title_name');
$array = [];
$subList = [
0 => [
@@ -58,7 +58,7 @@ class PiggyBankForm
'title' => $title,
],
'piggies' => [
(string) trans('firefly.none_in_select_list'),
(string)trans('firefly.none_in_select_list'),
],
],
];
@@ -72,11 +72,11 @@ class PiggyBankForm
$groupOrder = $group->order;
}
$subList[$groupOrder] = $subList[$groupOrder] ?? [
'group' => [
'title' => $groupTitle,
],
'piggies' => [],
];
'group' => [
'title' => $groupTitle,
],
'piggies' => [],
];
$subList[$groupOrder]['piggies'][$piggy->id] = $piggy->name;
}
ksort($subList);

View File

@@ -37,9 +37,9 @@ class RuleForm
use FormSupport;
/**
* @param string $name
* @param mixed $value
* @param array|null $options
* @param string $name
* @param mixed $value
* @param array|null $options
*
* @return string
*/
@@ -60,9 +60,9 @@ class RuleForm
}
/**
* @param string $name
* @param null $value
* @param array|null $options
* @param string $name
* @param null $value
* @param array|null $options
*
* @return HtmlString
*/
@@ -76,11 +76,11 @@ class RuleForm
// get all currencies:
$list = $groupRepos->get();
$array = [
0 => (string) trans('firefly.none_in_select_list'),
0 => (string)trans('firefly.none_in_select_list'),
];
/** @var RuleGroup $group */
foreach ($list as $group) {
if (array_key_exists('hidden', $options) && (int) $options['hidden'] !== $group->id) {
if (array_key_exists('hidden', $options) && (int)$options['hidden'] !== $group->id) {
$array[$group->id] = $group->title;
}
}

View File

@@ -35,17 +35,27 @@ trait AccountFilter
/**
* All the available types.
*
* @param string $type
* @param string $type
*
* @return array
*/
protected function mapAccountTypes(string $type): array
{
$types = [
'all' => [AccountType::DEFAULT, AccountType::CASH,
AccountType::ASSET, AccountType::EXPENSE, AccountType::REVENUE,
AccountType::INITIAL_BALANCE, AccountType::BENEFICIARY, AccountType::IMPORT, AccountType::RECONCILIATION,
AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE],
'all' => [
AccountType::DEFAULT,
AccountType::CASH,
AccountType::ASSET,
AccountType::EXPENSE,
AccountType::REVENUE,
AccountType::INITIAL_BALANCE,
AccountType::BENEFICIARY,
AccountType::IMPORT,
AccountType::RECONCILIATION,
AccountType::LOAN,
AccountType::DEBT,
AccountType::MORTGAGE,
],
'asset' => [AccountType::DEFAULT, AccountType::ASSET,],
'cash' => [AccountType::CASH,],
'expense' => [AccountType::EXPENSE, AccountType::BENEFICIARY,],

View File

@@ -36,7 +36,7 @@ trait ApiSupport
/**
* Small helper function for the revenue and expense account charts.
*
* @param array $names
* @param array $names
*
* @return array
*/
@@ -53,7 +53,7 @@ trait ApiSupport
/**
* Small helper function for the revenue and expense account charts.
*
* @param Collection $accounts
* @param Collection $accounts
*
* @return array
*/

View File

@@ -37,10 +37,47 @@ trait ConvertsExchangeRates
{
private ?bool $enabled = null;
/**
* @param array $set
* @return array
*/
public function cerChartSet(array $set): array
{
if (null === $this->enabled) {
$this->getPreference();
}
// if not enabled, return the same array but without conversion:
if (false === $this->enabled) {
$set['converted'] = false;
return $set;
}
$set['converted'] = true;
/** @var TransactionCurrency $native */
$native = app('amount')->getDefaultCurrency();
$currency = $this->getCurrency((int)$set['currency_id']);
if ($native->id === $currency->id) {
$set['native_id'] = (string)$currency->id;
$set['native_code'] = $currency->code;
$set['native_symbol'] = $currency->symbol;
$set['native_decimal_places'] = $currency->decimal_places;
return $set;
}
foreach ($set['entries'] as $date => $entry) {
$carbon = Carbon::createFromFormat(DateTimeInterface::ATOM, $date);
$rate = $this->getRate($currency, $native, $carbon);
$rate = '0' === $rate ? '1' : $rate;
Log::debug(sprintf('bcmul("%s", "%s")', (string)$entry, $rate));
$set['entries'][$date] = (float)bcmul((string)$entry, $rate);
}
return $set;
}
/**
* For a sum of entries, get the exchange rate to the native currency of
* the user.
* @param array $entries
* @param array $entries
* @return array
*/
public function cerSum(array $entries): array
@@ -66,12 +103,12 @@ trait ConvertsExchangeRates
$return = [];
/** @var array $entry */
foreach ($entries as $entry) {
$currency = $this->getCurrency((int) $entry['id']);
$currency = $this->getCurrency((int)$entry['id']);
if ($currency->id !== $native->id) {
$amount = $this->convertAmount($entry['sum'], $currency, $native);
$entry['converted'] = true;
$entry['native_sum'] = $amount;
$entry['native_id'] = (string) $native->id;
$entry['native_id'] = (string)$native->id;
$entry['native_name'] = $native->name;
$entry['native_symbol'] = $native->symbol;
$entry['native_code'] = $native->code;
@@ -80,7 +117,7 @@ trait ConvertsExchangeRates
if ($currency->id === $native->id) {
$entry['converted'] = false;
$entry['native_sum'] = $entry['sum'];
$entry['native_id'] = (string) $native->id;
$entry['native_id'] = (string)$native->id;
$entry['native_name'] = $native->name;
$entry['native_symbol'] = $native->symbol;
$entry['native_code'] = $native->code;
@@ -92,44 +129,15 @@ trait ConvertsExchangeRates
}
/**
* @param array $set
* @return array
* @return void
*/
public function cerChartSet(array $set): array
private function getPreference(): void
{
if (null === $this->enabled) {
$this->getPreference();
}
// if not enabled, return the same array but without conversion:
if (false === $this->enabled) {
$set['converted'] = false;
return $set;
}
$set['converted'] = true;
/** @var TransactionCurrency $native */
$native = app('amount')->getDefaultCurrency();
$currency = $this->getCurrency((int) $set['currency_id']);
if ($native->id === $currency->id) {
$set['native_id'] = (string) $currency->id;
$set['native_code'] = $currency->code;
$set['native_symbol'] = $currency->symbol;
$set['native_decimal_places'] = $currency->decimal_places;
return $set;
}
foreach ($set['entries'] as $date => $entry) {
$carbon = Carbon::createFromFormat(DateTimeInterface::ATOM, $date);
$rate = $this->getRate($currency, $native, $carbon);
$rate = '0' === $rate ? '1' : $rate;
Log::debug(sprintf('bcmul("%s", "%s")', (string) $entry, $rate));
$set['entries'][$date] = (float) bcmul((string) $entry, $rate);
}
return $set;
$this->enabled = true;
}
/**
* @param int $currencyId
* @param int $currencyId
* @return TransactionCurrency
*/
private function getCurrency(int $currencyId): TransactionCurrency
@@ -142,9 +150,9 @@ trait ConvertsExchangeRates
}
/**
* @param string $amount
* @param TransactionCurrency $from
* @param TransactionCurrency $to
* @param string $amount
* @param TransactionCurrency $from
* @param TransactionCurrency $to
* @return string
*/
private function convertAmount(string $amount, TransactionCurrency $from, TransactionCurrency $to, ?Carbon $date = null): string
@@ -157,9 +165,9 @@ trait ConvertsExchangeRates
}
/**
* @param TransactionCurrency $from
* @param TransactionCurrency $to
* @param Carbon $date
* @param TransactionCurrency $from
* @param TransactionCurrency $to
* @param Carbon $date
* @return string
*/
private function getRate(TransactionCurrency $from, TransactionCurrency $to, Carbon $date): string
@@ -174,7 +182,7 @@ trait ConvertsExchangeRates
->orderBy('date', 'DESC')
->first();
if (null !== $result) {
$rate = (string) $result->rate;
$rate = (string)$result->rate;
Log::debug(sprintf('Rate is %s', $rate));
return $rate;
}
@@ -188,7 +196,7 @@ trait ConvertsExchangeRates
->orderBy('date', 'DESC')
->first();
if (null !== $result) {
$rate = bcdiv('1', (string) $result->rate);
$rate = bcdiv('1', (string)$result->rate);
Log::debug(sprintf('Reversed rate is %s', $rate));
return $rate;
}
@@ -213,8 +221,8 @@ trait ConvertsExchangeRates
}
/**
* @param TransactionCurrency $currency
* @param Carbon $date
* @param TransactionCurrency $currency
* @param Carbon $date
* @return string
*/
private function getEuroRate(TransactionCurrency $currency, Carbon $date): string
@@ -236,7 +244,7 @@ trait ConvertsExchangeRates
->orderBy('date', 'DESC')
->first();
if (null !== $result) {
$rate = (string) $result->rate;
$rate = (string)$result->rate;
Log::debug(sprintf('Rate for %s to EUR is %s.', $currency->code, $rate));
return $rate;
}
@@ -250,7 +258,7 @@ trait ConvertsExchangeRates
->orderBy('date', 'DESC')
->first();
if (null !== $result) {
$rate = bcdiv('1', (string) $result->rate);
$rate = bcdiv('1', (string)$result->rate);
Log::debug(sprintf('Inverted rate for %s to EUR is %s.', $currency->code, $rate));
return $rate;
}
@@ -258,12 +266,4 @@ trait ConvertsExchangeRates
Log::debug(sprintf('No rate for %s to EUR.', $currency->code));
return '0';
}
/**
* @return void
*/
private function getPreference(): void
{
$this->enabled = true;
}
}

View File

@@ -35,15 +35,20 @@ trait TransactionFilter
/**
* All the types you can request.
*
* @param string $type
* @param string $type
*
* @return array
*/
protected function mapTransactionTypes(string $type): array
{
$types = [
'all' => [TransactionType::WITHDRAWAL, TransactionType::DEPOSIT, TransactionType::TRANSFER, TransactionType::OPENING_BALANCE,
TransactionType::RECONCILIATION,],
'all' => [
TransactionType::WITHDRAWAL,
TransactionType::DEPOSIT,
TransactionType::TRANSFER,
TransactionType::OPENING_BALANCE,
TransactionType::RECONCILIATION,
],
'withdrawal' => [TransactionType::WITHDRAWAL,],
'withdrawals' => [TransactionType::WITHDRAWAL,],
'expense' => [TransactionType::WITHDRAWAL,],

View File

@@ -37,7 +37,6 @@ use FireflyIII\Repositories\Budget\OperationsRepositoryInterface;
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
use FireflyIII\Support\CacheProperties;
use Illuminate\Support\Collection;
use JsonException;
/**
* Trait AugumentData
@@ -48,7 +47,7 @@ trait AugumentData
/**
* Searches for the opposing account.
*
* @param Collection $accounts
* @param Collection $accounts
*
* @return array
*/
@@ -75,7 +74,7 @@ trait AugumentData
/**
* Small helper function for the revenue and expense account charts.
*
* @param array $names
* @param array $names
*
* @return array
*/
@@ -92,7 +91,7 @@ trait AugumentData
/**
* Small helper function for the revenue and expense account charts.
*
* @param Collection $accounts
* @param Collection $accounts
*
* @return array
*/
@@ -110,7 +109,7 @@ trait AugumentData
/**
* Get the account names belonging to a bunch of account ID's.
*
* @param array $accountIds
* @param array $accountIds
*
* @return array
*/
@@ -123,7 +122,7 @@ trait AugumentData
$return = [];
foreach ($accountIds as $combinedId) {
$parts = explode('-', $combinedId);
$accountId = (int) $parts[0];
$accountId = (int)$parts[0];
if (array_key_exists($accountId, $grouped)) {
$return[$accountId] = $grouped[$accountId][0]['name'];
}
@@ -136,7 +135,7 @@ trait AugumentData
/**
* Get the budget names from a set of budget ID's.
*
* @param array $budgetIds
* @param array $budgetIds
*
* @return array
*/
@@ -152,7 +151,7 @@ trait AugumentData
$return[$budgetId] = $grouped[$budgetId][0]['name'];
}
}
$return[0] = (string) trans('firefly.no_budget');
$return[0] = (string)trans('firefly.no_budget');
return $return;
}
@@ -160,7 +159,7 @@ trait AugumentData
/**
* Get the category names from a set of category ID's. Small helper function for some of the charts.
*
* @param array $categoryIds
* @param array $categoryIds
*
* @return array
*/
@@ -173,12 +172,12 @@ trait AugumentData
$return = [];
foreach ($categoryIds as $combinedId) {
$parts = explode('-', $combinedId);
$categoryId = (int) $parts[0];
$categoryId = (int)$parts[0];
if (array_key_exists($categoryId, $grouped)) {
$return[$categoryId] = $grouped[$categoryId][0]['name'];
}
}
$return[0] = (string) trans('firefly.no_category');
$return[0] = (string)trans('firefly.no_category');
return $return;
}
@@ -186,9 +185,9 @@ trait AugumentData
/**
* Gets all budget limits for a budget.
*
* @param Budget $budget
* @param Carbon $start
* @param Carbon $end
* @param Budget $budget
* @param Carbon $start
* @param Carbon $end
*
* @return Collection
*/
@@ -221,7 +220,7 @@ trait AugumentData
$currentStart = clone $entry->start_date;
$currentEnd = clone $entry->end_date;
$expenses = $opsRepository->sumExpenses($currentStart, $currentEnd, null, $budgetCollection, $currency);
$spent = $expenses[(int) $currency->id]['sum'] ?? '0';
$spent = $expenses[(int)$currency->id]['sum'] ?? '0';
$entry->spent = $spent;
$limits->push($entry);
@@ -234,7 +233,7 @@ trait AugumentData
/**
* Group set of transactions by name of opposing account.
*
* @param array $array
* @param array $array
*
* @return array
*/
@@ -262,10 +261,10 @@ trait AugumentData
/**
* Spent in a period.
*
* @param Collection $assets
* @param Collection $opposing
* @param Carbon $start
* @param Carbon $end
* @param Collection $assets
* @param Collection $opposing
* @param Carbon $start
* @param Carbon $end
*
* @return array
*/
@@ -283,7 +282,7 @@ trait AugumentData
];
// loop to support multi currency
foreach ($journals as $journal) {
$currencyId = (int) $journal['currency_id'];
$currencyId = (int)$journal['currency_id'];
// if not set, set to zero:
if (!array_key_exists($currencyId, $sum['per_currency'])) {

View File

@@ -34,8 +34,8 @@ trait BasicDataSupport
/**
* Find the ID in a given array. Return '0' if not there (amount).
*
* @param array $array
* @param int $entryId
* @param array $array
* @param int $entryId
*
* @return null|mixed
*/
@@ -47,8 +47,8 @@ trait BasicDataSupport
/**
* Find the ID in a given array. Return null if not there (amount).
*
* @param array $array
* @param int $entryId
* @param array $array
* @param int $entryId
*
* @return null|Carbon
*/

View File

@@ -42,9 +42,9 @@ trait ChartGeneration
/**
* Shows an overview of the account balances for a set of accounts.
*
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
*
* @return array
* @throws FireflyException
@@ -76,7 +76,7 @@ trait ChartGeneration
/** @var Account $account */
foreach ($accounts as $account) {
// TODO we can use getAccountCurrency instead.
$currency = $repository->find((int) $accountRepos->getMetaValue($account, 'currency_id'));
$currency = $repository->find((int)$accountRepos->getMetaValue($account, 'currency_id'));
if (null === $currency) {
$currency = $default;
}
@@ -91,7 +91,7 @@ trait ChartGeneration
$previous = array_values($range)[0];
while ($currentStart <= $end) {
$format = $currentStart->format('Y-m-d');
$label = trim($currentStart->isoFormat((string) trans('config.month_and_day_js', [], $locale)));
$label = trim($currentStart->isoFormat((string)trans('config.month_and_day_js', [], $locale)));
$balance = $range[$format] ?? $previous;
$previous = $balance;
$currentStart->addDay();

View File

@@ -42,8 +42,8 @@ trait CreateStuff
/**
* Creates an asset account.
*
* @param NewUserFormRequest $request
* @param TransactionCurrency $currency
* @param NewUserFormRequest $request
* @param TransactionCurrency $currency
*
* @return bool
*/
@@ -72,8 +72,8 @@ trait CreateStuff
/**
* Creates a cash wallet.
*
* @param TransactionCurrency $currency
* @param string $language
* @param TransactionCurrency $currency
* @param string $language
*
* @return bool
*/
@@ -82,7 +82,7 @@ trait CreateStuff
/** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class);
$assetAccount = [
'name' => (string) trans('firefly.cash_wallet', [], $language),
'name' => (string)trans('firefly.cash_wallet', [], $language),
'iban' => null,
'account_type_name' => 'asset',
'virtual_balance' => 0,
@@ -138,9 +138,9 @@ trait CreateStuff
/**
* Create a savings account.
*
* @param NewUserFormRequest $request
* @param TransactionCurrency $currency
* @param string $language
* @param NewUserFormRequest $request
* @param TransactionCurrency $currency
* @param string $language
*
* @return bool
*/
@@ -149,7 +149,7 @@ trait CreateStuff
/** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class);
$savingsAccount = [
'name' => (string) trans('firefly.new_savings_account', ['bank_name' => $request->get('bank_name')], $language),
'name' => (string)trans('firefly.new_savings_account', ['bank_name' => $request->get('bank_name')], $language),
'iban' => null,
'account_type_name' => 'asset',
'account_type_id' => null,
@@ -168,7 +168,7 @@ trait CreateStuff
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @param array $data
*
* @return User
*/

View File

@@ -34,8 +34,8 @@ use FireflyIII\Support\Cronjobs\RecurringCronjob;
trait CronRunner
{
/**
* @param bool $force
* @param Carbon $date
* @param bool $force
* @param Carbon $date
*
* @return array
*/
@@ -65,8 +65,8 @@ trait CronRunner
}
/**
* @param bool $force
* @param Carbon $date
* @param bool $force
* @param Carbon $date
*
* @return array
*/

View File

@@ -37,8 +37,8 @@ trait DateCalculation
*
* If both are in the past OR both are in the future, simply return the number of days in the period with a minimum of 1
*
* @param Carbon $start
* @param Carbon $end
* @param Carbon $start
* @param Carbon $end
*
* @return int
*/
@@ -59,8 +59,8 @@ trait DateCalculation
*
* If both are in the past OR both are in the future, simply return the period between them with a minimum of 1
*
* @param Carbon $start
* @param Carbon $end
* @param Carbon $start
* @param Carbon $end
*
* @return int
*/
@@ -77,8 +77,8 @@ trait DateCalculation
}
/**
* @param Carbon $start
* @param Carbon $end
* @param Carbon $start
* @param Carbon $end
*
* @return string
*/
@@ -103,8 +103,8 @@ trait DateCalculation
* Get a list of the periods that will occur after this date. For example,
* March 2018, April 2018, etc.
*
* @param Carbon $date
* @param string $range
* @param Carbon $date
* @param string $range
*
* @return array
*/
@@ -139,8 +139,8 @@ trait DateCalculation
* Get a list of the periods that occurred before the start date. For example,
* March 2018, February 2018, etc.
*
* @param Carbon $date
* @param string $range
* @param Carbon $date
* @param string $range
*
* @return array
*/

View File

@@ -26,6 +26,8 @@ namespace FireflyIII\Support\Http\Controllers;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use Log;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
/**
* Trait GetConfigurationData
@@ -36,7 +38,7 @@ trait GetConfigurationData
/**
* Some common combinations.
*
* @param int $value
* @param int $value
*
* @return string
*/
@@ -52,13 +54,13 @@ trait GetConfigurationData
E_COMPILE_ERROR | E_RECOVERABLE_ERROR | E_ERROR | E_CORE_ERROR => 'E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR',
];
return $array[$value] ?? (string) $value;
return $array[$value] ?? (string)$value;
}
/**
* Get the basic steps from config.
*
* @param string $route
* @param string $route
*
* @return array
*/
@@ -72,7 +74,7 @@ trait GetConfigurationData
$currentStep = $options;
// get the text:
$currentStep['intro'] = (string) trans('intro.' . $route . '_' . $key);
$currentStep['intro'] = (string)trans('intro.'.$route.'_'.$key);
// save in array:
$steps[] = $currentStep;
@@ -88,12 +90,12 @@ trait GetConfigurationData
*
* @return array
* @throws FireflyException
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
protected function getDateRangeConfig(): array // get configuration + get preferences.
{
$viewRange = (string) app('preferences')->get('viewRange', '1M')->data;
$viewRange = (string)app('preferences')->get('viewRange', '1M')->data;
/** @var Carbon $start */
$start = session('start');
/** @var Carbon $end */
@@ -134,41 +136,41 @@ trait GetConfigurationData
/** @var Carbon $todayEnd */
$todayEnd = app('navigation')->endOfPeriod($todayStart, $viewRange);
if ($todayStart->ne($start) || $todayEnd->ne($end)) {
$ranges[ucfirst((string) trans('firefly.today'))] = [$todayStart, $todayEnd];
$ranges[ucfirst((string)trans('firefly.today'))] = [$todayStart, $todayEnd];
}
// last seven days:
$seven = Carbon::now()->subDays(7);
$index = (string) trans('firefly.last_seven_days');
$index = (string)trans('firefly.last_seven_days');
$ranges[$index] = [$seven, new Carbon()];
// last 30 days:
$thirty = Carbon::now()->subDays(30);
$index = (string) trans('firefly.last_thirty_days');
$index = (string)trans('firefly.last_thirty_days');
$ranges[$index] = [$thirty, new Carbon()];
// month to date:
$monthBegin = Carbon::now()->startOfMonth();
$index = (string) trans('firefly.month_to_date');
$index = (string)trans('firefly.month_to_date');
$ranges[$index] = [$monthBegin, new Carbon()];
// year to date:
$yearBegin = Carbon::now()->startOfYear();
$index = (string) trans('firefly.year_to_date');
$index = (string)trans('firefly.year_to_date');
$ranges[$index] = [$yearBegin, new Carbon()];
// everything
$index = (string) trans('firefly.everything');
$index = (string)trans('firefly.everything');
$ranges[$index] = [$first, new Carbon()];
return [
'title' => $title,
'configuration' => [
'apply' => (string) trans('firefly.apply'),
'cancel' => (string) trans('firefly.cancel'),
'from' => (string) trans('firefly.from'),
'to' => (string) trans('firefly.to'),
'customRange' => (string) trans('firefly.customRange'),
'apply' => (string)trans('firefly.apply'),
'cancel' => (string)trans('firefly.cancel'),
'from' => (string)trans('firefly.from'),
'to' => (string)trans('firefly.to'),
'customRange' => (string)trans('firefly.customRange'),
'start' => $start->format('Y-m-d'),
'end' => $end->format('Y-m-d'),
'ranges' => $ranges,
@@ -179,8 +181,8 @@ trait GetConfigurationData
/**
* Get specific info for special routes.
*
* @param string $route
* @param string $specificPage
* @param string $route
* @param string $specificPage
*
* @return array
*
@@ -193,13 +195,13 @@ trait GetConfigurationData
// user is on page with specific instructions:
if ('' !== $specificPage) {
$routeKey = str_replace('.', '_', $route);
$elements = config(sprintf('intro.%s', $routeKey . '_' . $specificPage));
$elements = config(sprintf('intro.%s', $routeKey.'_'.$specificPage));
if (is_array($elements) && count($elements) > 0) {
foreach ($elements as $key => $options) {
$currentStep = $options;
// get the text:
$currentStep['intro'] = (string) trans('intro.' . $route . '_' . $specificPage . '_' . $key);
$currentStep['intro'] = (string)trans('intro.'.$route.'_'.$specificPage.'_'.$key);
// save in array:
$steps[] = $currentStep;
@@ -217,7 +219,7 @@ trait GetConfigurationData
protected function verifyRecurringCronJob(): void
{
$config = app('fireflyconfig')->get('last_rt_job', 0);
$lastTime = (int) $config->data;
$lastTime = (int)$config->data;
$now = time();
Log::debug(sprintf('verifyRecurringCronJob: last time is %d ("%s"), now is %d', $lastTime, $config->data, $now));
if (0 === $lastTime) {

View File

@@ -42,7 +42,7 @@ trait ModelInformation
/**
* Get actions based on a bill.
*
* @param Bill $bill
* @param Bill $bill
*
* @return array
*/
@@ -80,13 +80,13 @@ trait ModelInformation
/** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class);
// types of liability:
$debt = $repository->getAccountTypeByType(AccountType::DEBT);
$loan = $repository->getAccountTypeByType(AccountType::LOAN);
$mortgage = $repository->getAccountTypeByType(AccountType::MORTGAGE);
$debt = $repository->getAccountTypeByType(AccountType::DEBT);
$loan = $repository->getAccountTypeByType(AccountType::LOAN);
$mortgage = $repository->getAccountTypeByType(AccountType::MORTGAGE);
$liabilityTypes = [
$debt->id => (string) trans(sprintf('firefly.account_type_%s', AccountType::DEBT)),
$loan->id => (string) trans(sprintf('firefly.account_type_%s', AccountType::LOAN)),
$mortgage->id => (string) trans(sprintf('firefly.account_type_%s', AccountType::MORTGAGE)),
$debt->id => (string)trans(sprintf('firefly.account_type_%s', AccountType::DEBT)),
$loan->id => (string)trans(sprintf('firefly.account_type_%s', AccountType::LOAN)),
$mortgage->id => (string)trans(sprintf('firefly.account_type_%s', AccountType::MORTGAGE)),
];
asort($liabilityTypes);
@@ -101,7 +101,7 @@ trait ModelInformation
{
$roles = [];
foreach (config('firefly.accountRoles') as $role) {
$roles[$role] = (string) trans(sprintf('firefly.account_role_%s', $role));
$roles[$role] = (string)trans(sprintf('firefly.account_role_%s', $role));
}
return $roles;
@@ -110,7 +110,7 @@ trait ModelInformation
/**
* Create fake triggers to match the bill's properties
*
* @param Bill $bill
* @param Bill $bill
*
* @return array
*/
@@ -121,7 +121,7 @@ trait ModelInformation
$triggers = [];
foreach ($operators as $key => $operator) {
if ('user_action' !== $key && false === $operator['alias']) {
$triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key));
$triggers[$key] = (string)trans(sprintf('firefly.rule_trigger_%s_choice', $key));
}
}
asort($triggers);
@@ -161,7 +161,7 @@ trait ModelInformation
}
/**
* @param TransactionJournal $journal
* @param TransactionJournal $journal
*
* @return array
*/
@@ -172,7 +172,7 @@ trait ModelInformation
$triggers = [];
foreach ($operators as $key => $operator) {
if ('user_action' !== $key && false === $operator['alias']) {
$triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key));
$triggers[$key] = (string)trans(sprintf('firefly.rule_trigger_%s_choice', $key));
}
}
asort($triggers);

View File

@@ -33,8 +33,9 @@ use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Support\CacheProperties;
use Illuminate\Support\Collection;
use JsonException;
use Log;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
/**
* Trait PeriodOverview.
@@ -73,14 +74,14 @@ trait PeriodOverview
* and for each period, the amount of money spent and earned. This is a complex operation which is cached for
* performance reasons.
*
* @param Account $account
* @param Carbon $start
* @param Carbon $end
* @param Account $account
* @param Carbon $start
* @param Carbon $end
*
* @return array
* @throws FireflyException
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
protected function getAccountPeriodOverview(Account $account, Carbon $start, Carbon $end): array
{
@@ -152,9 +153,9 @@ trait PeriodOverview
/**
* Filter a list of journals by a set of dates, and then group them by currency.
*
* @param array $array
* @param Carbon $start
* @param Carbon $end
* @param array $array
* @param Carbon $start
* @param Carbon $end
*
* @return array
*/
@@ -174,8 +175,8 @@ trait PeriodOverview
/**
* Return only transactions where $account is the source.
*
* @param Account $account
* @param array $journals
* @param Account $account
* @param array $journals
*
* @return array
*/
@@ -184,7 +185,7 @@ trait PeriodOverview
$return = [];
/** @var array $journal */
foreach ($journals as $journal) {
if ($account->id === (int) $journal['source_account_id']) {
if ($account->id === (int)$journal['source_account_id']) {
$return[] = $journal;
}
}
@@ -195,8 +196,8 @@ trait PeriodOverview
/**
* Return only transactions where $account is the source.
*
* @param Account $account
* @param array $journals
* @param Account $account
* @param array $journals
*
* @return array
* @codeCoverageIgnore
@@ -206,7 +207,7 @@ trait PeriodOverview
$return = [];
/** @var array $journal */
foreach ($journals as $journal) {
if ($account->id === (int) $journal['destination_account_id']) {
if ($account->id === (int)$journal['destination_account_id']) {
$return[] = $journal;
}
}
@@ -215,7 +216,7 @@ trait PeriodOverview
}
/**
* @param array $journals
* @param array $journals
*
* @return array
* @codeCoverageIgnore
@@ -225,7 +226,7 @@ trait PeriodOverview
$return = [];
/** @var array $journal */
foreach ($journals as $journal) {
$currencyId = (int) $journal['currency_id'];
$currencyId = (int)$journal['currency_id'];
$foreignCurrencyId = $journal['foreign_currency_id'];
if (!array_key_exists($currencyId, $return)) {
$return[$currencyId] = [
@@ -246,7 +247,7 @@ trait PeriodOverview
$return[$foreignCurrencyId] = [
'amount' => '0',
'count' => 0,
'currency_id' => (int) $foreignCurrencyId,
'currency_id' => (int)$foreignCurrencyId,
'currency_name' => $journal['foreign_currency_name'],
'currency_code' => $journal['foreign_currency_code'],
'currency_symbol' => $journal['foreign_currency_symbol'],
@@ -264,14 +265,14 @@ trait PeriodOverview
/**
* Overview for single category. Has been refactored recently.
*
* @param Category $category
* @param Carbon $start
* @param Carbon $end
* @param Category $category
* @param Carbon $start
* @param Carbon $end
*
* @return array
* @throws FireflyException
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
protected function getCategoryPeriodOverview(Category $category, Carbon $start, Carbon $end): array
{
@@ -345,13 +346,13 @@ trait PeriodOverview
*
* This method has been refactored recently.
*
* @param Carbon $start
* @param Carbon $end
* @param Carbon $start
* @param Carbon $end
*
* @return array
* @throws FireflyException
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
protected function getNoBudgetPeriodOverview(Carbon $start, Carbon $end): array
{
@@ -401,12 +402,12 @@ trait PeriodOverview
*
* Show period overview for no category view.
*
* @param Carbon $theDate
* @param Carbon $theDate
*
* @return array
* @throws FireflyException
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
protected function getNoCategoryPeriodOverview(Carbon $theDate): array
{
@@ -471,14 +472,14 @@ trait PeriodOverview
/**
* This shows a period overview for a tag. It goes back in time and lists all relevant transactions and sums.
*
* @param Tag $tag
* @param Carbon $start
* @param Carbon $end
* @param Tag $tag
* @param Carbon $start
* @param Carbon $end
*
* @return array
* @throws FireflyException
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
protected function getTagPeriodOverview(Tag $tag, Carbon $start, Carbon $end): array // period overview for tags.
{
@@ -546,14 +547,14 @@ trait PeriodOverview
}
/**
* @param string $transactionType
* @param Carbon $start
* @param Carbon $end
* @param string $transactionType
* @param Carbon $start
* @param Carbon $end
*
* @return array
* @throws FireflyException
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
protected function getTransactionPeriodOverview(string $transactionType, Carbon $start, Carbon $end): array
{

View File

@@ -48,7 +48,7 @@ trait RenderPartialViews
/**
* View for transactions in a budget for an account.
*
* @param array $attributes
* @param array $attributes
*
* @return string
*/
@@ -59,10 +59,10 @@ trait RenderPartialViews
/** @var BudgetRepositoryInterface $budgetRepository */
$budgetRepository = app(BudgetRepositoryInterface::class);
$budget = $budgetRepository->find((int) $attributes['budgetId']);
$budget = $budgetRepository->find((int)$attributes['budgetId']);
$accountRepos = app(AccountRepositoryInterface::class);
$account = $accountRepos->find((int) $attributes['accountId']);
$account = $accountRepos->find((int)$attributes['accountId']);
$journals = $popupHelper->balanceForBudget($budget, $account, $attributes);
@@ -102,7 +102,7 @@ trait RenderPartialViews
/**
* View for spent in a single budget.
*
* @param array $attributes
* @param array $attributes
*
* @return string
*/
@@ -114,7 +114,7 @@ trait RenderPartialViews
/** @var PopupReportInterface $popupHelper */
$popupHelper = app(PopupReportInterface::class);
$budget = $budgetRepository->find((int) $attributes['budgetId']);
$budget = $budgetRepository->find((int)$attributes['budgetId']);
if (null === $budget) {
$budget = new Budget();
}
@@ -134,7 +134,7 @@ trait RenderPartialViews
/**
* View for transactions in a category.
*
* @param array $attributes
* @param array $attributes
*
* @return string
*/
@@ -145,7 +145,7 @@ trait RenderPartialViews
/** @var CategoryRepositoryInterface $categoryRepository */
$categoryRepository = app(CategoryRepositoryInterface::class);
$category = $categoryRepository->find((int) $attributes['categoryId']);
$category = $categoryRepository->find((int)$attributes['categoryId']);
$journals = $popupHelper->byCategory($category, $attributes);
try {
@@ -226,7 +226,7 @@ trait RenderPartialViews
/**
* Returns all the expenses that went to the given expense account.
*
* @param array $attributes
* @param array $attributes
*
* @return string
*/
@@ -238,7 +238,7 @@ trait RenderPartialViews
/** @var PopupReportInterface $popupHelper */
$popupHelper = app(PopupReportInterface::class);
$account = $accountRepository->find((int) $attributes['accountId']);
$account = $accountRepository->find((int)$attributes['accountId']);
if (null === $account) {
return 'This is an unknown account. Apologies.';
@@ -260,7 +260,7 @@ trait RenderPartialViews
/**
* Get current (from system) rule actions.
*
* @param Rule $rule
* @param Rule $rule
*
* @return array
*/
@@ -298,7 +298,7 @@ trait RenderPartialViews
/**
* Get current (from DB) rule triggers.
*
* @param Rule $rule
* @param Rule $rule
*
* @return array
*
@@ -310,7 +310,7 @@ trait RenderPartialViews
$triggers = [];
foreach ($operators as $key => $operator) {
if ('user_action' !== $key && false === $operator['alias']) {
$triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key));
$triggers[$key] = (string)trans(sprintf('firefly.rule_trigger_%s_choice', $key));
}
}
asort($triggers);
@@ -354,7 +354,7 @@ trait RenderPartialViews
/**
* Returns all the incomes that went to the given asset account.
*
* @param array $attributes
* @param array $attributes
*
* @return string
*/
@@ -365,7 +365,7 @@ trait RenderPartialViews
/** @var PopupReportInterface $popupHelper */
$popupHelper = app(PopupReportInterface::class);
$account = $accountRepository->find((int) $attributes['accountId']);
$account = $accountRepository->find((int)$attributes['accountId']);
if (null === $account) {
return 'This is an unknown category. Apologies.';

View File

@@ -37,6 +37,8 @@ use Illuminate\Routing\Route;
use Illuminate\Support\Facades\Validator;
use InvalidArgumentException;
use Log;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Route as RouteFacade;
/**
@@ -88,8 +90,8 @@ trait RequestInformation
*
* @return bool
* @throws FireflyException
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
final protected function hasSeenDemo(): bool // get request info + get preference
{

View File

@@ -37,7 +37,7 @@ use Throwable;
trait RuleManagement
{
/**
* @param Request $request
* @param Request $request
*
* @return array
* @codeCoverageIgnore
@@ -55,7 +55,7 @@ trait RuleManagement
[
'oldAction' => $oldAction['type'],
'oldValue' => $oldAction['value'],
'oldChecked' => 1 === (int) ($oldAction['stop_processing'] ?? '0'),
'oldChecked' => 1 === (int)($oldAction['stop_processing'] ?? '0'),
'count' => $index + 1,
]
)->render();
@@ -72,7 +72,7 @@ trait RuleManagement
}
/**
* @param Request $request
* @param Request $request
*
* @return array
* @codeCoverageIgnore
@@ -84,7 +84,7 @@ trait RuleManagement
$triggers = [];
foreach ($operators as $key => $operator) {
if ('user_action' !== $key && false === $operator['alias']) {
$triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key));
$triggers[$key] = (string)trans(sprintf('firefly.rule_trigger_%s_choice', $key));
}
}
asort($triggers);
@@ -100,8 +100,8 @@ trait RuleManagement
[
'oldTrigger' => OperatorQuerySearch::getRootOperator($oldTrigger['type']),
'oldValue' => $oldTrigger['value'],
'oldChecked' => 1 === (int) ($oldTrigger['stop_processing'] ?? '0'),
'oldProhibited' => 1 === (int) ($oldTrigger['prohibited'] ?? '0'),
'oldChecked' => 1 === (int)($oldTrigger['stop_processing'] ?? '0'),
'oldProhibited' => 1 === (int)($oldTrigger['prohibited'] ?? '0'),
'count' => $index + 1,
'triggers' => $triggers,
]
@@ -119,7 +119,7 @@ trait RuleManagement
}
/**
* @param array $submittedOperators
* @param array $submittedOperators
*
* @return array
*/
@@ -131,7 +131,7 @@ trait RuleManagement
$triggers = [];
foreach ($operators as $key => $operator) {
if ('user_action' !== $key && false === $operator['alias']) {
$triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key));
$triggers[$key] = (string)trans(sprintf('firefly.rule_trigger_%s_choice', $key));
}
}
asort($triggers);
@@ -169,8 +169,8 @@ trait RuleManagement
$repository = app(RuleGroupRepositoryInterface::class);
if (0 === $repository->count()) {
$data = [
'title' => (string) trans('firefly.default_rule_group_name'),
'description' => (string) trans('firefly.default_rule_group_description'),
'title' => (string)trans('firefly.default_rule_group_name'),
'description' => (string)trans('firefly.default_rule_group_description'),
'active' => true,
];

View File

@@ -37,10 +37,10 @@ trait TransactionCalculation
/**
* Get all expenses for a set of accounts.
*
* @param Collection $accounts
* @param Collection $opposing
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $opposing
* @param Carbon $start
* @param Carbon $end
*
* @return array
*/
@@ -61,10 +61,10 @@ trait TransactionCalculation
/**
* Get all expenses by tags.
*
* @param Collection $accounts
* @param Collection $tags
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $tags
* @param Carbon $start
* @param Carbon $end
*
* @return array
*
@@ -83,10 +83,10 @@ trait TransactionCalculation
/**
* Helper function that collects expenses for the given budgets.
*
* @param Collection $accounts
* @param Collection $budgets
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $budgets
* @param Carbon $start
* @param Carbon $end
*
* @return array
*/
@@ -103,10 +103,10 @@ trait TransactionCalculation
/**
* Get all expenses in a period for categories.
*
* @param Collection $accounts
* @param Collection $categories
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $categories
* @param Carbon $start
* @param Carbon $end
*
* @return array
*/
@@ -127,10 +127,10 @@ trait TransactionCalculation
/**
* Get all income for a period and a bunch of categories.
*
* @param Collection $accounts
* @param Collection $categories
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $categories
* @param Carbon $start
* @param Carbon $end
*
* @return array
*/
@@ -147,10 +147,10 @@ trait TransactionCalculation
/**
* Get the income for a set of accounts.
*
* @param Collection $accounts
* @param Collection $opposing
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $opposing
* @param Carbon $start
* @param Carbon $end
*
* @return array
*/
@@ -167,10 +167,10 @@ trait TransactionCalculation
/**
* Get all income by tag.
*
* @param Collection $accounts
* @param Collection $tags
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $tags
* @param Carbon $start
* @param Carbon $end
*
* @return array
*/

View File

@@ -46,14 +46,14 @@ trait UserNavigation
* will be returned.
* - If the remembered url contains "jscript/" the remembered url will not be returned but instead the index (/) will be returned.
*
* @param string $identifier
* @param string $identifier
*
* @return string
*/
final protected function getPreviousUrl(string $identifier): string
{
Log::debug(sprintf('Trying to retrieve URL stored under "%s"', $identifier));
$url = (string) session($identifier);
$url = (string)session($identifier);
Log::debug(sprintf('The URL is %s', $url));
return app('steam')->getSafeUrl($url, route('index'));
@@ -62,7 +62,7 @@ trait UserNavigation
/**
* Will return false if you cant edit this account type.
*
* @param Account $account
* @param Account $account
*
* @return bool
*/
@@ -75,7 +75,7 @@ trait UserNavigation
}
/**
* @param TransactionGroup $group
* @param TransactionGroup $group
*
* @return bool
*/
@@ -93,7 +93,7 @@ trait UserNavigation
}
/**
* @param Account $account
* @param Account $account
*
* @return RedirectResponse|Redirector
*/
@@ -128,7 +128,7 @@ trait UserNavigation
}
/**
* @param TransactionGroup $group
* @param TransactionGroup $group
*
* @return RedirectResponse|Redirector
*/
@@ -156,7 +156,7 @@ trait UserNavigation
}
/**
* @param string $identifier
* @param string $identifier
*
* @return string|null
*/

View File

@@ -38,7 +38,7 @@ class AuditLogger
/**
* Customize the given logger instance.
*
* @param Logger $logger
* @param Logger $logger
*
* @return void
*/

View File

@@ -32,7 +32,7 @@ namespace FireflyIII\Support\Logging;
class AuditProcessor
{
/**
* @param array $record
* @param array $record
*
* @return array
*/

View File

@@ -1,4 +1,5 @@
<?php
/**
* Navigation.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -33,9 +34,9 @@ use Log;
class Navigation
{
/**
* @param Carbon $theDate
* @param string $repeatFreq
* @param int $skip
* @param Carbon $theDate
* @param string $repeatFreq
* @param int $skip
*
* @return Carbon
*/
@@ -99,9 +100,9 @@ class Navigation
}
/**
* @param Carbon $start
* @param Carbon $end
* @param string $range
* @param Carbon $start
* @param Carbon $end
* @param string $range
*
* @return array
*
@@ -160,8 +161,8 @@ class Navigation
}
/**
* @param Carbon $theDate
* @param string $repeatFreq
* @param Carbon $theDate
* @param string $repeatFreq
*
* @return Carbon
*/
@@ -210,8 +211,8 @@ class Navigation
}
/**
* @param Carbon $end
* @param string $repeatFreq
* @param Carbon $end
* @param string $repeatFreq
*
* @return Carbon
*/
@@ -288,9 +289,9 @@ class Navigation
}
/**
* @param Carbon $theCurrentEnd
* @param string $repeatFreq
* @param Carbon|null $maxDate
* @param Carbon $theCurrentEnd
* @param string $repeatFreq
* @param Carbon|null $maxDate
*
* @return Carbon
*/
@@ -328,8 +329,8 @@ class Navigation
}
/**
* @param Carbon $start
* @param Carbon $end
* @param Carbon $start
* @param Carbon $end
*
* @return array
* @throws FireflyException
@@ -340,17 +341,17 @@ class Navigation
// define period to increment
$increment = 'addDay';
$format = $this->preferredCarbonFormat($start, $end);
$displayFormat = (string) trans('config.month_and_day_js', [], $locale);
$displayFormat = (string)trans('config.month_and_day_js', [], $locale);
// increment by month (for year)
if ($start->diffInMonths($end) > 1) {
$increment = 'addMonth';
$displayFormat = (string) trans('config.month_js');
$displayFormat = (string)trans('config.month_js');
}
// increment by year (for multi year)
if ($start->diffInMonths($end) > 12) {
$increment = 'addYear';
$displayFormat = (string) trans('config.year_js');
$displayFormat = (string)trans('config.year_js');
}
$begin = clone $start;
$entries = [];
@@ -368,8 +369,8 @@ class Navigation
* If the date difference between start and end is less than a month, method returns "Y-m-d". If the difference is less than a year,
* method returns "Y-m". If the date difference is larger, method returns "Y".
*
* @param Carbon $start
* @param Carbon $end
* @param Carbon $start
* @param Carbon $end
*
* @return string
*/
@@ -388,8 +389,8 @@ class Navigation
}
/**
* @param Carbon $theDate
* @param string $repeatFrequency
* @param Carbon $theDate
* @param string $repeatFrequency
*
* @return string
*/
@@ -397,23 +398,23 @@ class Navigation
{
$date = clone $theDate;
$formatMap = [
'1D' => (string) trans('config.specific_day_js'),
'daily' => (string) trans('config.specific_day_js'),
'custom' => (string) trans('config.specific_day_js'),
'1W' => (string) trans('config.week_in_year_js'),
'week' => (string) trans('config.week_in_year_js'),
'weekly' => (string) trans('config.week_in_year_js'),
'1M' => (string) trans('config.month_js'),
'month' => (string) trans('config.month_js'),
'monthly' => (string) trans('config.month_js'),
'1Y' => (string) trans('config.year_js'),
'year' => (string) trans('config.year_js'),
'yearly' => (string) trans('config.year_js'),
'6M' => (string) trans('config.half_year_js'),
'1D' => (string)trans('config.specific_day_js'),
'daily' => (string)trans('config.specific_day_js'),
'custom' => (string)trans('config.specific_day_js'),
'1W' => (string)trans('config.week_in_year_js'),
'week' => (string)trans('config.week_in_year_js'),
'weekly' => (string)trans('config.week_in_year_js'),
'1M' => (string)trans('config.month_js'),
'month' => (string)trans('config.month_js'),
'monthly' => (string)trans('config.month_js'),
'1Y' => (string)trans('config.year_js'),
'year' => (string)trans('config.year_js'),
'yearly' => (string)trans('config.year_js'),
'6M' => (string)trans('config.half_year_js'),
];
if (array_key_exists($repeatFrequency, $formatMap)) {
return $date->isoFormat((string) $formatMap[$repeatFrequency]);
return $date->isoFormat((string)$formatMap[$repeatFrequency]);
}
if ('3M' === $repeatFrequency || 'quarter' === $repeatFrequency) {
$quarter = ceil($theDate->month / 3);
@@ -431,8 +432,8 @@ class Navigation
* If the date difference between start and end is less than a month, method returns trans(config.month_and_day). If the difference is less than a year,
* method returns "config.month". If the date difference is larger, method returns "config.year".
*
* @param Carbon $start
* @param Carbon $end
* @param Carbon $start
* @param Carbon $end
*
* @return string
* @throws FireflyException
@@ -440,13 +441,13 @@ class Navigation
public function preferredCarbonLocalizedFormat(Carbon $start, Carbon $end): string
{
$locale = app('steam')->getLocale();
$format = (string) trans('config.month_and_day_js', [], $locale);
$format = (string)trans('config.month_and_day_js', [], $locale);
if ($start->diffInMonths($end) > 1) {
$format = (string) trans('config.month_js', [], $locale);
$format = (string)trans('config.month_js', [], $locale);
}
if ($start->diffInMonths($end) > 12) {
$format = (string) trans('config.year_js', [], $locale);
$format = (string)trans('config.year_js', [], $locale);
}
return $format;
@@ -456,8 +457,8 @@ class Navigation
* If the date difference between start and end is less than a month, method returns "endOfDay". If the difference is less than a year,
* method returns "endOfMonth". If the date difference is larger, method returns "endOfYear".
*
* @param Carbon $start
* @param Carbon $end
* @param Carbon $start
* @param Carbon $end
*
* @return string
*/
@@ -479,8 +480,8 @@ class Navigation
* If the date difference between start and end is less than a month, method returns "1D". If the difference is less than a year,
* method returns "1M". If the date difference is larger, method returns "1Y".
*
* @param Carbon $start
* @param Carbon $end
* @param Carbon $start
* @param Carbon $end
*
* @return string
*/
@@ -502,8 +503,8 @@ class Navigation
* If the date difference between start and end is less than a month, method returns "%Y-%m-%d". If the difference is less than a year,
* method returns "%Y-%m". If the date difference is larger, method returns "%Y".
*
* @param Carbon $start
* @param Carbon $end
* @param Carbon $start
* @param Carbon $end
*
* @return string
*/
@@ -522,9 +523,9 @@ class Navigation
}
/**
* @param Carbon $theDate
* @param string $repeatFreq
* @param int|null $subtract
* @param Carbon $theDate
* @param string $repeatFreq
* @param int|null $subtract
*
* @return Carbon
*
@@ -611,8 +612,8 @@ class Navigation
}
/**
* @param string $range
* @param Carbon $start
* @param string $range
* @param Carbon $start
*
* @return Carbon
*
@@ -670,8 +671,8 @@ class Navigation
}
/**
* @param string $range
* @param Carbon $start
* @param string $range
* @param Carbon $start
*
* @return Carbon
*

View File

@@ -37,8 +37,8 @@ class NullArrayObject extends ArrayObject
/**
* NullArrayObject constructor.
*
* @param array $array
* @param null $default
* @param array $array
* @param null $default
*/
public function __construct(array $array, $default = null)
{
@@ -47,7 +47,7 @@ class NullArrayObject extends ArrayObject
}
/**
* @param mixed $key
* @param mixed $key
*
* @return mixed|null
*/

View File

@@ -49,7 +49,7 @@ class ParseDateString
];
/**
* @param string $date
* @param string $date
*
* @return bool
*/
@@ -73,7 +73,7 @@ class ParseDateString
}
/**
* @param string $date
* @param string $date
*
* @return Carbon
* @throws FireflyException
@@ -114,7 +114,7 @@ class ParseDateString
return new Carbon('1984-09-17');
}
// maybe a year, nothing else?
if (4 === strlen($date) && is_numeric($date) && (int) $date > 1000 && (int) $date <= 3000) {
if (4 === strlen($date) && is_numeric($date) && (int)$date > 1000 && (int)$date <= 3000) {
return new Carbon(sprintf('%d-01-01', $date));
}
@@ -122,7 +122,7 @@ class ParseDateString
}
/**
* @param string $keyword
* @param string $keyword
*
* @return Carbon
*/
@@ -146,7 +146,7 @@ class ParseDateString
}
/**
* @param string $date
* @param string $date
*
* @return Carbon
*/
@@ -156,7 +156,7 @@ class ParseDateString
}
/**
* @param string $date
* @param string $date
*
* @return Carbon
*/
@@ -172,7 +172,8 @@ class ParseDateString
'm' => 'subMonths',
'q' => 'subQuarters',
'y' => 'subYears',
], [
],
[
'd' => 'addDays',
'w' => 'addWeeks',
'm' => 'addMonths',
@@ -194,7 +195,7 @@ class ParseDateString
}
$direction = str_starts_with($part, '+') ? 1 : 0;
$period = $part[strlen($part) - 1];
$number = (int) substr($part, 1, -1);
$number = (int)substr($part, 1, -1);
if (!array_key_exists($period, $functions[$direction])) {
Log::error(sprintf('No method for direction %d and period "%s".', $direction, $period));
continue;
@@ -209,7 +210,7 @@ class ParseDateString
}
/**
* @param string $date
* @param string $date
*
* @return array
*/
@@ -246,7 +247,7 @@ class ParseDateString
}
/**
* @param string $date
* @param string $date
*
* @return bool
*/
@@ -267,7 +268,7 @@ class ParseDateString
/**
* format of string is xxxx-xx-DD
*
* @param string $date
* @param string $date
*
* @return array
*/
@@ -281,7 +282,7 @@ class ParseDateString
}
/**
* @param string $date
* @param string $date
*
* @return bool
*/
@@ -302,7 +303,7 @@ class ParseDateString
/**
* format of string is xxxx-MM-xx
*
* @param string $date
* @param string $date
*
* @return array
*/
@@ -317,7 +318,7 @@ class ParseDateString
}
/**
* @param string $date
* @param string $date
*
* @return bool
*/
@@ -338,7 +339,7 @@ class ParseDateString
/**
* format of string is YYYY-xx-xx
*
* @param string $date
* @param string $date
*
* @return array
*/
@@ -353,7 +354,7 @@ class ParseDateString
}
/**
* @param string $date
* @param string $date
*
* @return bool
*/
@@ -374,7 +375,7 @@ class ParseDateString
/**
* format of string is xxxx-MM-DD
*
* @param string $date
* @param string $date
*
* @return array
*/
@@ -390,7 +391,7 @@ class ParseDateString
}
/**
* @param string $date
* @param string $date
*
* @return bool
*/
@@ -411,7 +412,7 @@ class ParseDateString
/**
* format of string is YYYY-xx-DD
*
* @param string $date
* @param string $date
*
* @return array
*/
@@ -427,7 +428,7 @@ class ParseDateString
}
/**
* @param string $date
* @param string $date
*
* @return bool
*/
@@ -448,7 +449,7 @@ class ParseDateString
/**
* format of string is YYYY-MM-xx
*
* @param string $date
* @param string $date
*
* @return array
*/

View File

@@ -1,4 +1,5 @@
<?php
/**
* Preferences.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -52,89 +53,13 @@ class Preferences
}
/**
* @param User $user
* @param string $search
*
* @return Collection
*/
public function beginsWith(User $user, string $search): Collection
{
return Preference::where('user_id', $user->id)->where('name', 'LIKE', $search . '%')->get();
}
/**
* @param string $name
*
* @return bool
* @throws FireflyException
*/
public function delete(string $name): bool
{
$fullName = sprintf('preference%s%s', auth()->user()->id, $name);
if (Cache::has($fullName)) {
Cache::forget($fullName);
}
try {
Preference::where('user_id', auth()->user()->id)->where('name', $name)->delete();
} catch (Exception $e) {
throw new FireflyException(sprintf('Could not delete preference: %s', $e->getMessage()), 0, $e);
}
return true;
}
/**
* @param string $name
*
* @return Collection
*/
public function findByName(string $name): Collection
{
return Preference::where('name', $name)->get();
}
/**
* @param User $user
* @param string $name
*/
public function forget(User $user, string $name): void
{
$key = sprintf('preference%s%s', $user->id, $name);
Cache::forget($key);
Cache::put($key, '', 5);
}
/**
* @param User $user
* @param array $list
*
* @return array
*/
public function getArrayForUser(User $user, array $list): array
{
$result = [];
$preferences = Preference::where('user_id', $user->id)->whereIn('name', $list)->get(['id', 'name', 'data']);
/** @var Preference $preference */
foreach ($preferences as $preference) {
$result[$preference->name] = $preference->data;
}
foreach ($list as $name) {
if (!array_key_exists($name, $result)) {
$result[$name] = null;
}
}
return $result;
}
/**
* @param string $name
* @param mixed $default
* @param string $name
* @param mixed $default
*
* @return Preference|null
* @throws FireflyException
*/
public function getFresh(string $name, $default = null): ?Preference
public function get(string $name, $default = null): ?Preference
{
/** @var User|null $user */
$user = auth()->user();
@@ -145,27 +70,13 @@ class Preferences
return $preference;
}
return $this->getFreshForUser($user, $name, $default);
}
/**
* @param User $user
* @param string $name
* @param null $default
*
* @return Preference|null
* TODO remove me.
* @throws FireflyException
*/
public function getFreshForUser(User $user, string $name, $default = null): ?Preference
{
return $this->getForUser($user, $name, $default);
}
/**
* @param User $user
* @param string $name
* @param null|string|int $default
* @param User $user
* @param string $name
* @param null|string|int $default
*
* @return Preference|null
* @throws FireflyException
@@ -195,9 +106,41 @@ class Preferences
}
/**
* @param User $user
* @param string $name
* @param mixed $value
* @param string $name
*
* @return bool
* @throws FireflyException
*/
public function delete(string $name): bool
{
$fullName = sprintf('preference%s%s', auth()->user()->id, $name);
if (Cache::has($fullName)) {
Cache::forget($fullName);
}
try {
Preference::where('user_id', auth()->user()->id)->where('name', $name)->delete();
} catch (Exception $e) {
throw new FireflyException(sprintf('Could not delete preference: %s', $e->getMessage()), 0, $e);
}
return true;
}
/**
* @param User $user
* @param string $name
*/
public function forget(User $user, string $name): void
{
$key = sprintf('preference%s%s', $user->id, $name);
Cache::forget($key);
Cache::put($key, '', 5);
}
/**
* @param User $user
* @param string $name
* @param mixed $value
*
* @return Preference
* @throws FireflyException
@@ -237,6 +180,85 @@ class Preferences
return $pref;
}
/**
* @param User $user
* @param string $search
*
* @return Collection
*/
public function beginsWith(User $user, string $search): Collection
{
return Preference::where('user_id', $user->id)->where('name', 'LIKE', $search.'%')->get();
}
/**
* @param string $name
*
* @return Collection
*/
public function findByName(string $name): Collection
{
return Preference::where('name', $name)->get();
}
/**
* @param User $user
* @param array $list
*
* @return array
*/
public function getArrayForUser(User $user, array $list): array
{
$result = [];
$preferences = Preference::where('user_id', $user->id)->whereIn('name', $list)->get(['id', 'name', 'data']);
/** @var Preference $preference */
foreach ($preferences as $preference) {
$result[$preference->name] = $preference->data;
}
foreach ($list as $name) {
if (!array_key_exists($name, $result)) {
$result[$name] = null;
}
}
return $result;
}
/**
* @param string $name
* @param mixed $default
*
* @return Preference|null
* @throws FireflyException
*/
public function getFresh(string $name, $default = null): ?Preference
{
/** @var User|null $user */
$user = auth()->user();
if (null === $user) {
$preference = new Preference();
$preference->data = $default;
return $preference;
}
return $this->getFreshForUser($user, $name, $default);
}
/**
* @param User $user
* @param string $name
* @param null $default
*
* @return Preference|null
* TODO remove me.
* @throws FireflyException
*/
public function getFreshForUser(User $user, string $name, $default = null): ?Preference
{
return $this->getForUser($user, $name, $default);
}
/**
* @return string
* @throws FireflyException
@@ -256,27 +278,6 @@ class Preferences
return hash('sha256', $lastActivity);
}
/**
* @param string $name
* @param mixed $default
*
* @return Preference|null
* @throws FireflyException
*/
public function get(string $name, $default = null): ?Preference
{
/** @var User|null $user */
$user = auth()->user();
if (null === $user) {
$preference = new Preference();
$preference->data = $default;
return $preference;
}
return $this->getForUser($user, $name, $default);
}
/**
*
*/
@@ -287,8 +288,8 @@ class Preferences
}
/**
* @param string $name
* @param mixed $value
* @param string $name
* @param mixed $value
*
* @return Preference
* @throws FireflyException

View File

@@ -1,4 +1,5 @@
<?php
/*
* BudgetReportGenerator.php
* Copyright (c) 2020 james@firefly-iii.org
@@ -23,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Support\Report\Budget;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Account;
use FireflyIII\Models\Budget;
use FireflyIII\Models\BudgetLimit;
@@ -33,6 +35,7 @@ use FireflyIII\Repositories\Budget\NoBudgetRepositoryInterface;
use FireflyIII\Repositories\Budget\OperationsRepositoryInterface;
use FireflyIII\User;
use Illuminate\Support\Collection;
use JsonException;
/**
* Class BudgetReportGenerator
@@ -75,11 +78,11 @@ class BudgetReportGenerator
foreach ($this->accounts as $account) {
$accountId = $account->id;
$this->report[$accountId] = $this->report[$accountId] ?? [
'name' => $account->name,
'id' => $account->id,
'iban' => $account->iban,
'currencies' => [],
];
'name' => $account->name,
'id' => $account->id,
'iban' => $account->iban,
'currencies' => [],
];
}
// loop expenses.
@@ -91,7 +94,7 @@ class BudgetReportGenerator
/**
* Process each row of expenses collected for the "Account per budget" partial
*
* @param array $expenses
* @param array $expenses
*/
private function processExpenses(array $expenses): void
{
@@ -103,24 +106,24 @@ class BudgetReportGenerator
/**
* Process each set of transactions for each row of expenses.
*
* @param array $expenses
* @param array $budget
* @param array $expenses
* @param array $budget
*/
private function processBudgetExpenses(array $expenses, array $budget): void
{
$budgetId = (int) $budget['id'];
$currencyId = (int) $expenses['currency_id'];
$budgetId = (int)$budget['id'];
$currencyId = (int)$expenses['currency_id'];
foreach ($budget['transaction_journals'] as $journal) {
$sourceAccountId = $journal['source_account_id'];
$this->report[$sourceAccountId]['currencies'][$currencyId]
= $this->report[$sourceAccountId]['currencies'][$currencyId] ?? [
'currency_id' => $expenses['currency_id'],
'currency_symbol' => $expenses['currency_symbol'],
'currency_name' => $expenses['currency_name'],
'currency_decimal_places' => $expenses['currency_decimal_places'],
'budgets' => [],
];
'currency_id' => $expenses['currency_id'],
'currency_symbol' => $expenses['currency_symbol'],
'currency_name' => $expenses['currency_name'],
'currency_decimal_places' => $expenses['currency_decimal_places'],
'budgets' => [],
];
$this->report[$sourceAccountId]['currencies'][$currencyId]['budgets'][$budgetId]
= $this->report[$sourceAccountId]['currencies'][$currencyId]['budgets'][$budgetId] ?? '0';
@@ -161,17 +164,17 @@ class BudgetReportGenerator
/**
* Process expenses etc. for a single budget for the budgets block on the default report.
*
* @param Budget $budget
* @param Budget $budget
*/
private function processBudget(Budget $budget): void
{
$budgetId = (int) $budget->id;
$budgetId = (int)$budget->id;
$this->report['budgets'][$budgetId] = $this->report['budgets'][$budgetId] ?? [
'budget_id' => $budgetId,
'budget_name' => $budget->name,
'no_budget' => false,
'budget_limits' => [],
];
'budget_id' => $budgetId,
'budget_name' => $budget->name,
'no_budget' => false,
'budget_limits' => [],
];
// get all budget limits for budget in period:
$limits = $this->blRepository->getBudgetLimits($budget, $this->start, $this->end);
@@ -184,50 +187,50 @@ class BudgetReportGenerator
/**
* Process a single budget limit for the budgets block on the default report.
*
* @param Budget $budget
* @param BudgetLimit $limit
* @param Budget $budget
* @param BudgetLimit $limit
*/
private function processLimit(Budget $budget, BudgetLimit $limit): void
{
$budgetId = (int) $budget->id;
$limitId = (int) $limit->id;
$budgetId = (int)$budget->id;
$limitId = (int)$limit->id;
$limitCurrency = $limit->transactionCurrency ?? $this->currency;
$currencyId = (int) $limitCurrency->id;
$currencyId = (int)$limitCurrency->id;
$expenses = $this->opsRepository->sumExpenses($limit->start_date, $limit->end_date, $this->accounts, new Collection([$budget]));
$spent = $expenses[$currencyId]['sum'] ?? '0';
$left = -1 === bccomp(bcadd($limit->amount, $spent), '0') ? '0' : bcadd($limit->amount, $spent);
$overspent = 1 === bccomp(bcmul($spent, '-1'), $limit->amount) ? bcadd($spent, $limit->amount) : '0';
$this->report['budgets'][$budgetId]['budget_limits'][$limitId] = $this->report['budgets'][$budgetId]['budget_limits'][$limitId] ?? [
'budget_limit_id' => $limitId,
'start_date' => $limit->start_date,
'end_date' => $limit->end_date,
'budgeted' => $limit->amount,
'budgeted_pct' => '0',
'spent' => $spent,
'spent_pct' => '0',
'left' => $left,
'overspent' => $overspent,
'currency_id' => $currencyId,
'currency_code' => $limitCurrency->code,
'currency_name' => $limitCurrency->name,
'currency_symbol' => $limitCurrency->symbol,
'currency_decimal_places' => $limitCurrency->decimal_places,
];
'budget_limit_id' => $limitId,
'start_date' => $limit->start_date,
'end_date' => $limit->end_date,
'budgeted' => $limit->amount,
'budgeted_pct' => '0',
'spent' => $spent,
'spent_pct' => '0',
'left' => $left,
'overspent' => $overspent,
'currency_id' => $currencyId,
'currency_code' => $limitCurrency->code,
'currency_name' => $limitCurrency->name,
'currency_symbol' => $limitCurrency->symbol,
'currency_decimal_places' => $limitCurrency->decimal_places,
];
// make sum information:
$this->report['sums'][$currencyId]
= $this->report['sums'][$currencyId] ?? [
'budgeted' => '0',
'spent' => '0',
'left' => '0',
'overspent' => '0',
'currency_id' => $currencyId,
'currency_code' => $limitCurrency->code,
'currency_name' => $limitCurrency->name,
'currency_symbol' => $limitCurrency->symbol,
'currency_decimal_places' => $limitCurrency->decimal_places,
];
'budgeted' => '0',
'spent' => '0',
'left' => '0',
'overspent' => '0',
'currency_id' => $currencyId,
'currency_code' => $limitCurrency->code,
'currency_name' => $limitCurrency->name,
'currency_symbol' => $limitCurrency->symbol,
'currency_decimal_places' => $limitCurrency->decimal_places,
];
$this->report['sums'][$currencyId]['budgeted'] = bcadd($this->report['sums'][$currencyId]['budgeted'], $limit->amount);
$this->report['sums'][$currencyId]['spent'] = bcadd($this->report['sums'][$currencyId]['spent'], $spent);
$this->report['sums'][$currencyId]['left'] = bcadd($this->report['sums'][$currencyId]['left'], bcadd($limit->amount, $spent));
@@ -250,7 +253,7 @@ class BudgetReportGenerator
$noBudget = $this->nbRepository->sumExpenses($this->start, $this->end, $this->accounts);
foreach ($noBudget as $noBudgetEntry) {
// currency information:
$nbCurrencyId = (int) ($noBudgetEntry['currency_id'] ?? $this->currency->id);
$nbCurrencyId = (int)($noBudgetEntry['currency_id'] ?? $this->currency->id);
$nbCurrencyCode = $noBudgetEntry['currency_code'] ?? $this->currency->code;
$nbCurrencyName = $noBudgetEntry['currency_name'] ?? $this->currency->name;
$nbCurrencySymbol = $noBudgetEntry['currency_symbol'] ?? $this->currency->symbol;
@@ -295,9 +298,9 @@ class BudgetReportGenerator
// make percentages based on total amount.
foreach ($this->report['budgets'] as $budgetId => $data) {
foreach ($data['budget_limits'] as $limitId => $entry) {
$budgetId = (int) $budgetId;
$limitId = (int) $limitId;
$currencyId = (int) $entry['currency_id'];
$budgetId = (int)$budgetId;
$limitId = (int)$limitId;
$currencyId = (int)$entry['currency_id'];
$spent = $entry['spent'];
$totalSpent = $this->report['sums'][$currencyId]['spent'] ?? '0';
$spentPct = '0';
@@ -306,10 +309,10 @@ class BudgetReportGenerator
$budgetedPct = '0';
if (0 !== bccomp($spent, '0') && 0 !== bccomp($totalSpent, '0')) {
$spentPct = round((float) bcmul(bcdiv($spent, $totalSpent), '100'));
$spentPct = round((float)bcmul(bcdiv($spent, $totalSpent), '100'));
}
if (0 !== bccomp($budgeted, '0') && 0 !== bccomp($totalBudgeted, '0')) {
$budgetedPct = round((float) bcmul(bcdiv($budgeted, $totalBudgeted), '100'));
$budgetedPct = round((float)bcmul(bcdiv($budgeted, $totalBudgeted), '100'));
}
$this->report['sums'][$currencyId]['budgeted'] = $this->report['sums'][$currencyId]['budgeted'] ?? '0';
$this->report['budgets'][$budgetId]['budget_limits'][$limitId]['spent_pct'] = $spentPct;
@@ -327,7 +330,7 @@ class BudgetReportGenerator
}
/**
* @param Collection $accounts
* @param Collection $accounts
*/
public function setAccounts(Collection $accounts): void
{
@@ -335,7 +338,7 @@ class BudgetReportGenerator
}
/**
* @param Collection $budgets
* @param Collection $budgets
*/
public function setBudgets(Collection $budgets): void
{
@@ -343,7 +346,7 @@ class BudgetReportGenerator
}
/**
* @param Carbon $end
* @param Carbon $end
*/
public function setEnd(Carbon $end): void
{
@@ -351,7 +354,7 @@ class BudgetReportGenerator
}
/**
* @param Carbon $start
* @param Carbon $start
*/
public function setStart(Carbon $start): void
{
@@ -359,9 +362,9 @@ class BudgetReportGenerator
}
/**
* @param User $user
* @throws \FireflyIII\Exceptions\FireflyException
* @throws \JsonException
* @param User $user
* @throws FireflyException
* @throws JsonException
*/
public function setUser(User $user): void
{

View File

@@ -88,12 +88,12 @@ class CategoryReportGenerator
/**
* Process one of the spent arrays from the operations method.
*
* @param array $data
* @param array $data
*/
private function processOpsArray(array $data): void
{
/**
* @var int $currencyId
* @var int $currencyId
* @var array $currencyRow
*/
foreach ($data as $currencyId => $currencyRow) {
@@ -102,24 +102,24 @@ class CategoryReportGenerator
}
/**
* @param int $currencyId
* @param array $currencyRow
* @param int $currencyId
* @param array $currencyRow
*/
private function processCurrencyArray(int $currencyId, array $currencyRow): void
{
$this->report['sums'][$currencyId] = $this->report['sums'][$currencyId] ?? [
'spent' => '0',
'earned' => '0',
'sum' => '0',
'currency_id' => $currencyRow['currency_id'],
'currency_symbol' => $currencyRow['currency_symbol'],
'currency_name' => $currencyRow['currency_name'],
'currency_code' => $currencyRow['currency_code'],
'currency_decimal_places' => $currencyRow['currency_decimal_places'],
];
'spent' => '0',
'earned' => '0',
'sum' => '0',
'currency_id' => $currencyRow['currency_id'],
'currency_symbol' => $currencyRow['currency_symbol'],
'currency_name' => $currencyRow['currency_name'],
'currency_code' => $currencyRow['currency_code'],
'currency_decimal_places' => $currencyRow['currency_decimal_places'],
];
/**
* @var int $categoryId
* @var int $categoryId
* @var array $categoryRow
*/
foreach ($currencyRow['categories'] as $categoryId => $categoryRow) {
@@ -128,26 +128,26 @@ class CategoryReportGenerator
}
/**
* @param int $currencyId
* @param array $currencyRow
* @param int $categoryId
* @param array $categoryRow
* @param int $currencyId
* @param array $currencyRow
* @param int $categoryId
* @param array $categoryRow
*/
private function processCategoryRow(int $currencyId, array $currencyRow, int $categoryId, array $categoryRow): void
{
$key = sprintf('%s-%s', $currencyId, $categoryId);
$this->report['categories'][$key] = $this->report['categories'][$key] ?? [
'id' => $categoryId,
'title' => $categoryRow['name'],
'currency_id' => $currencyRow['currency_id'],
'currency_symbol' => $currencyRow['currency_symbol'],
'currency_name' => $currencyRow['currency_name'],
'currency_code' => $currencyRow['currency_code'],
'currency_decimal_places' => $currencyRow['currency_decimal_places'],
'spent' => '0',
'earned' => '0',
'sum' => '0',
];
'id' => $categoryId,
'title' => $categoryRow['name'],
'currency_id' => $currencyRow['currency_id'],
'currency_symbol' => $currencyRow['currency_symbol'],
'currency_name' => $currencyRow['currency_name'],
'currency_code' => $currencyRow['currency_code'],
'currency_decimal_places' => $currencyRow['currency_decimal_places'],
'spent' => '0',
'earned' => '0',
'sum' => '0',
];
// loop journals:
foreach ($categoryRow['transaction_journals'] as $journal) {
// sum of sums
@@ -179,7 +179,7 @@ class CategoryReportGenerator
}
/**
* @param Collection $accounts
* @param Collection $accounts
*/
public function setAccounts(Collection $accounts): void
{
@@ -187,7 +187,7 @@ class CategoryReportGenerator
}
/**
* @param Carbon $end
* @param Carbon $end
*/
public function setEnd(Carbon $end): void
{
@@ -195,7 +195,7 @@ class CategoryReportGenerator
}
/**
* @param Carbon $start
* @param Carbon $start
*/
public function setStart(Carbon $start): void
{
@@ -203,7 +203,7 @@ class CategoryReportGenerator
}
/**
* @param User $user
* @param User $user
*/
public function setUser(User $user): void
{

View File

@@ -35,9 +35,9 @@ trait CalculateRangeOccurrences
/**
* Get the number of daily occurrences for a recurring transaction until date $end is reached. Will skip every $skipMod-1 occurrences.
*
* @param Carbon $start
* @param Carbon $end
* @param int $skipMod
* @param Carbon $start
* @param Carbon $end
* @param int $skipMod
*
* @return array
*/
@@ -59,10 +59,10 @@ trait CalculateRangeOccurrences
/**
* Get the number of daily occurrences for a recurring transaction until date $end is reached. Will skip every $skipMod-1 occurrences.
*
* @param Carbon $start
* @param Carbon $end
* @param int $skipMod
* @param string $moment
* @param Carbon $start
* @param Carbon $end
* @param int $skipMod
* @param string $moment
*
* @return array
*
@@ -71,7 +71,7 @@ trait CalculateRangeOccurrences
{
$return = [];
$attempts = 0;
$dayOfMonth = (int) $moment;
$dayOfMonth = (int)$moment;
if ($start->day > $dayOfMonth) {
// day has passed already, add a month.
$start->addMonth();
@@ -92,10 +92,10 @@ trait CalculateRangeOccurrences
/**
* Get the number of daily occurrences for a recurring transaction until date $end is reached. Will skip every $skipMod-1 occurrences.
*
* @param Carbon $start
* @param Carbon $end
* @param int $skipMod
* @param string $moment
* @param Carbon $start
* @param Carbon $end
* @param int $skipMod
* @param string $moment
*
* @return array
*/
@@ -124,10 +124,10 @@ trait CalculateRangeOccurrences
/**
* Get the number of daily occurrences for a recurring transaction until date $end is reached. Will skip every $skipMod-1 occurrences.
*
* @param Carbon $start
* @param Carbon $end
* @param int $skipMod
* @param string $moment
* @param Carbon $start
* @param Carbon $end
* @param int $skipMod
* @param string $moment
*
* @return array
*
@@ -139,7 +139,7 @@ trait CalculateRangeOccurrences
Log::debug('Rep is weekly.');
// monday = 1
// sunday = 7
$dayOfWeek = (int) $moment;
$dayOfWeek = (int)$moment;
Log::debug(sprintf('DoW in repetition is %d, in mutator is %d', $dayOfWeek, $start->dayOfWeekIso));
if ($start->dayOfWeekIso > $dayOfWeek) {
// day has already passed this week, add one week:
@@ -168,10 +168,10 @@ trait CalculateRangeOccurrences
/**
* Get the number of daily occurrences for a recurring transaction until date $end is reached. Will skip every $skipMod-1 occurrences.
*
* @param Carbon $start
* @param Carbon $end
* @param int $skipMod
* @param string $moment
* @param Carbon $start
* @param Carbon $end
* @param int $skipMod
* @param string $moment
*
* @return array
*

View File

@@ -35,9 +35,9 @@ trait CalculateXOccurrences
* Calculates the number of daily occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip
* over $skipMod -1 recurrences.
*
* @param Carbon $date
* @param int $count
* @param int $skipMod
* @param Carbon $date
* @param int $count
* @param int $skipMod
*
* @return array
*/
@@ -63,10 +63,10 @@ trait CalculateXOccurrences
* Calculates the number of monthly occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip
* over $skipMod -1 recurrences.
*
* @param Carbon $date
* @param int $count
* @param int $skipMod
* @param string $moment
* @param Carbon $date
* @param int $count
* @param int $skipMod
* @param string $moment
*
* @return array
*/
@@ -76,7 +76,7 @@ trait CalculateXOccurrences
$mutator = clone $date;
$total = 0;
$attempts = 0;
$dayOfMonth = (int) $moment;
$dayOfMonth = (int)$moment;
if ($mutator->day > $dayOfMonth) {
// day has passed already, add a month.
$mutator->addMonth();
@@ -100,10 +100,10 @@ trait CalculateXOccurrences
* Calculates the number of NDOM occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip
* over $skipMod -1 recurrences.
*
* @param Carbon $date
* @param int $count
* @param int $skipMod
* @param string $moment
* @param Carbon $date
* @param int $count
* @param int $skipMod
* @param string $moment
*
* @return array
*/
@@ -138,10 +138,10 @@ trait CalculateXOccurrences
* Calculates the number of weekly occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip
* over $skipMod -1 recurrences.
*
* @param Carbon $date
* @param int $count
* @param int $skipMod
* @param string $moment
* @param Carbon $date
* @param int $count
* @param int $skipMod
* @param string $moment
*
* @return array
*/
@@ -154,7 +154,7 @@ trait CalculateXOccurrences
// monday = 1
// sunday = 7
$mutator->addDay(); // always assume today has passed.
$dayOfWeek = (int) $moment;
$dayOfWeek = (int)$moment;
if ($mutator->dayOfWeekIso > $dayOfWeek) {
// day has already passed this week, add one week:
$mutator->addWeek();
@@ -180,10 +180,10 @@ trait CalculateXOccurrences
* Calculates the number of yearly occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip
* over $skipMod -1 recurrences.
*
* @param Carbon $date
* @param int $count
* @param int $skipMod
* @param string $moment
* @param Carbon $date
* @param int $count
* @param int $skipMod
* @param string $moment
*
* @return array
*/

View File

@@ -36,10 +36,10 @@ trait CalculateXOccurrencesSince
* Calculates the number of daily occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip
* over $skipMod -1 recurrences.
*
* @param Carbon $date
* @param Carbon $afterDate
* @param int $count
* @param int $skipMod
* @param Carbon $date
* @param Carbon $afterDate
* @param int $count
* @param int $skipMod
*
* @return array
*/
@@ -66,11 +66,11 @@ trait CalculateXOccurrencesSince
* Calculates the number of monthly occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip
* over $skipMod -1 recurrences.
*
* @param Carbon $date
* @param Carbon $afterDate
* @param int $count
* @param int $skipMod
* @param string $moment
* @param Carbon $date
* @param Carbon $afterDate
* @param int $count
* @param int $skipMod
* @param string $moment
*
* @return array
*/
@@ -81,7 +81,7 @@ trait CalculateXOccurrencesSince
$mutator = clone $date;
$total = 0;
$attempts = 0;
$dayOfMonth = (int) $moment;
$dayOfMonth = (int)$moment;
$dayOfMonth = 0 === $dayOfMonth ? 1 : $dayOfMonth;
if ($mutator->day > $dayOfMonth) {
Log::debug(sprintf('%d is after %d, add a month. Mutator is now', $mutator->day, $dayOfMonth));
@@ -109,11 +109,11 @@ trait CalculateXOccurrencesSince
* Calculates the number of NDOM occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip
* over $skipMod -1 recurrences.
*
* @param Carbon $date
* @param Carbon $afterDate
* @param int $count
* @param int $skipMod
* @param string $moment
* @param Carbon $date
* @param Carbon $afterDate
* @param int $count
* @param int $skipMod
* @param string $moment
*
* @return array
*/
@@ -149,11 +149,11 @@ trait CalculateXOccurrencesSince
* Calculates the number of weekly occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip
* over $skipMod -1 recurrences.
*
* @param Carbon $date
* @param Carbon $afterDate
* @param int $count
* @param int $skipMod
* @param string $moment
* @param Carbon $date
* @param Carbon $afterDate
* @param int $count
* @param int $skipMod
* @param string $moment
*
* @return array
*/
@@ -168,7 +168,7 @@ trait CalculateXOccurrencesSince
// sunday = 7
// Removed assumption today has passed, see issue https://github.com/firefly-iii/firefly-iii/issues/4798
//$mutator->addDay(); // always assume today has passed.
$dayOfWeek = (int) $moment;
$dayOfWeek = (int)$moment;
if ($mutator->dayOfWeekIso > $dayOfWeek) {
// day has already passed this week, add one week:
$mutator->addWeek();
@@ -194,11 +194,11 @@ trait CalculateXOccurrencesSince
* Calculates the number of yearly occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip
* over $skipMod -1 recurrences.
*
* @param Carbon $date
* @param Carbon $afterDate
* @param int $count
* @param int $skipMod
* @param string $moment
* @param Carbon $date
* @param Carbon $afterDate
* @param int $count
* @param int $skipMod
* @param string $moment
*
* @return array
*/

View File

@@ -37,8 +37,8 @@ trait FiltersWeekends
/**
* Filters out all weekend entries, if necessary.
*
* @param RecurrenceRepetition $repetition
* @param array $dates
* @param RecurrenceRepetition $repetition
* @param array $dates
*
* @return array
*
@@ -46,7 +46,7 @@ trait FiltersWeekends
protected function filterWeekends(RecurrenceRepetition $repetition, array $dates): array
{
Log::debug(sprintf('Now in %s', __METHOD__));
if ((int) $repetition->weekend === RecurrenceRepetition::WEEKEND_DO_NOTHING) {
if ((int)$repetition->weekend === RecurrenceRepetition::WEEKEND_DO_NOTHING) {
Log::debug('Repetition will not be filtered on weekend days.');
return $dates;

View File

@@ -42,9 +42,9 @@ trait AppendsLocationData
/**
* Read the submitted Request data and add new or updated Location data to the array.
*
* @param array $data
* @param array $data
*
* @param string|null $prefix
* @param string|null $prefix
*
* @return array
*/
@@ -100,8 +100,8 @@ trait AppendsLocationData
}
/**
* @param string|null $prefix
* @param string $key
* @param string|null $prefix
* @param string $key
*
* @return string
*/
@@ -115,7 +115,7 @@ trait AppendsLocationData
}
/**
* @param string|null $prefix
* @param string|null $prefix
*
* @return bool
*/
@@ -167,7 +167,7 @@ trait AppendsLocationData
/**
* Abstract method.
*
* @param mixed ...$patterns
* @param mixed ...$patterns
*
* @return mixed
*/
@@ -176,15 +176,15 @@ trait AppendsLocationData
/**
* Abstract method stolen from "InteractsWithInput".
*
* @param null $key
* @param bool $default
* @param null $key
* @param bool $default
*
* @return mixed
*/
abstract public function boolean($key = null, $default = false);
/**
* @param string|null $prefix
* @param string|null $prefix
*
* @return bool
*/
@@ -229,7 +229,7 @@ trait AppendsLocationData
}
/**
* @param string|null $prefix
* @param string|null $prefix
*
* @return bool
*/
@@ -245,7 +245,7 @@ trait AppendsLocationData
&& null === $this->get($zoomLevelKey))
&& (
'PUT' === $this->method()
|| ('POST' === $this->method() && $this->routeIs('*.update'))
|| ('POST' === $this->method() && $this->routeIs('*.update'))
);
}
}

View File

@@ -35,30 +35,30 @@ trait ConvertsDataTypes
/**
* Return integer value.
*
* @param string $field
* @param string $field
*
* @return int
*/
public function convertInteger(string $field): int
{
return (int) $this->get($field);
return (int)$this->get($field);
}
/**
* Return string value.
*
* @param string $field
* @param string $field
*
* @return string
*/
public function convertString(string $field): string
{
return $this->clearString((string) ($this->get($field) ?? ''), false);
return $this->clearString((string)($this->get($field) ?? ''), false);
}
/**
* @param string|null $string
* @param bool $keepNewlines
* @param string|null $string
* @param bool $keepNewlines
*
* @return string|null
*/
@@ -131,17 +131,17 @@ trait ConvertsDataTypes
/**
* Return string value with newlines.
*
* @param string $field
* @param string $field
*
* @return string
*/
public function stringWithNewlines(string $field): string
{
return $this->clearString((string) ($this->get($field) ?? ''));
return $this->clearString((string)($this->get($field) ?? ''));
}
/**
* @param mixed $array
* @param mixed $array
*
* @return array|null
*/
@@ -161,7 +161,7 @@ trait ConvertsDataTypes
}
/**
* @param string|null $value
* @param string|null $value
*
* @return bool
*/
@@ -187,7 +187,24 @@ trait ConvertsDataTypes
}
/**
* @param string|null $string
* Return floating value.
*
* @param string $field
*
* @return float|null
*/
protected function convertFloat(string $field): ?float
{
$res = $this->get($field);
if (null === $res) {
return null;
}
return (float)$res;
}
/**
* @param string|null $string
*
* @return Carbon|null
*/
@@ -215,28 +232,11 @@ trait ConvertsDataTypes
return $carbon;
}
/**
* Return floating value.
*
* @param string $field
*
* @return float|null
*/
protected function convertFloat(string $field): ?float
{
$res = $this->get($field);
if (null === $res) {
return null;
}
return (float) $res;
}
/**
* Returns all data in the request, or omits the field if not set,
* according to the config from the request. This is the way.
*
* @param array $fields
* @param array $fields
*
* @return array
*/
@@ -256,7 +256,7 @@ trait ConvertsDataTypes
/**
* Return date or NULL.
*
* @param string $field
* @param string $field
*
* @return Carbon|null
*/
@@ -278,7 +278,7 @@ trait ConvertsDataTypes
/**
* Parse to integer
*
* @param string|null $string
* @param string|null $string
*
* @return int|null
*/
@@ -291,13 +291,13 @@ trait ConvertsDataTypes
return null;
}
return (int) $string;
return (int)$string;
}
/**
* Return integer value, or NULL when it's not set.
*
* @param string $field
* @param string $field
*
* @return int|null
*/
@@ -307,11 +307,11 @@ trait ConvertsDataTypes
return null;
}
$value = (string) $this->get($field);
$value = (string)$this->get($field);
if ('' === $value) {
return null;
}
return (int) $value;
return (int)$value;
}
}

View File

@@ -29,7 +29,7 @@ namespace FireflyIII\Support\Request;
trait GetRecurrenceData
{
/**
* @param array $transaction
* @param array $transaction
*
* @return array
*/
@@ -42,7 +42,7 @@ trait GetRecurrenceData
$return['amount'] = $transaction['amount'];
}
if (array_key_exists('currency_id', $transaction)) {
$return['currency_id'] = (int) $transaction['currency_id'];
$return['currency_id'] = (int)$transaction['currency_id'];
}
if (array_key_exists('currency_code', $transaction)) {
$return['currency_code'] = $transaction['currency_code'];
@@ -53,17 +53,17 @@ trait GetRecurrenceData
$return['foreign_amount'] = $transaction['foreign_amount'];
}
if (array_key_exists('foreign_currency_id', $transaction)) {
$return['foreign_currency_id'] = (int) $transaction['foreign_currency_id'];
$return['foreign_currency_id'] = (int)$transaction['foreign_currency_id'];
}
if (array_key_exists('foreign_currency_code', $transaction)) {
$return['foreign_currency_code'] = $transaction['foreign_currency_code'];
}
// source + dest
if (array_key_exists('source_id', $transaction)) {
$return['source_id'] = (int) $transaction['source_id'];
$return['source_id'] = (int)$transaction['source_id'];
}
if (array_key_exists('destination_id', $transaction)) {
$return['destination_id'] = (int) $transaction['destination_id'];
$return['destination_id'] = (int)$transaction['destination_id'];
}
// description
if (array_key_exists('description', $transaction)) {
@@ -71,17 +71,17 @@ trait GetRecurrenceData
}
if (array_key_exists('piggy_bank_id', $transaction)) {
$return['piggy_bank_id'] = (int) $transaction['piggy_bank_id'];
$return['piggy_bank_id'] = (int)$transaction['piggy_bank_id'];
}
if (array_key_exists('tags', $transaction)) {
$return['tags'] = $transaction['tags'];
}
if (array_key_exists('budget_id', $transaction)) {
$return['budget_id'] = (int) $transaction['budget_id'];
$return['budget_id'] = (int)$transaction['budget_id'];
}
if (array_key_exists('category_id', $transaction)) {
$return['category_id'] = (int) $transaction['category_id'];
$return['category_id'] = (int)$transaction['category_id'];
}
return $return;

View File

@@ -27,7 +27,6 @@ namespace FireflyIII\Support\Search;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Collection;
use JsonException;
/**
* Class AccountSearch
@@ -85,7 +84,7 @@ class AccountSearch implements GenericSearchInterface
);
break;
case self::SEARCH_ID:
$searchQuery->where('accounts.id', '=', (int) $originalQuery);
$searchQuery->where('accounts.id', '=', (int)$originalQuery);
break;
case self::SEARCH_NAME:
$searchQuery->where('accounts.name', 'LIKE', $like);
@@ -109,7 +108,7 @@ class AccountSearch implements GenericSearchInterface
}
/**
* @param string $field
* @param string $field
*/
public function setField(string $field): void
{
@@ -117,7 +116,7 @@ class AccountSearch implements GenericSearchInterface
}
/**
* @param string $query
* @param string $query
*/
public function setQuery(string $query): void
{
@@ -125,7 +124,7 @@ class AccountSearch implements GenericSearchInterface
}
/**
* @param array $types
* @param array $types
*/
public function setTypes(array $types): void
{
@@ -133,7 +132,7 @@ class AccountSearch implements GenericSearchInterface
}
/**
* @param User $user
* @param User $user
*/
public function setUser(User $user): void
{

View File

@@ -74,11 +74,11 @@ class OperatorQuerySearch implements SearchInterface
private int $limit;
private Collection $operators;
private int $page;
private array $prohibitedWords;
private float $startTime;
private TagRepositoryInterface $tagRepository;
private array $validOperators;
private array $words;
private array $prohibitedWords;
/**
* OperatorQuerySearch constructor.
@@ -175,7 +175,7 @@ class OperatorQuerySearch implements SearchInterface
}
/**
* @param Node $searchNode
* @param Node $searchNode
*
* @throws FireflyException
*/
@@ -202,7 +202,7 @@ class OperatorQuerySearch implements SearchInterface
case Emoticon::class:
case Emoji::class:
case Mention::class:
$allWords = (string) $searchNode->getValue();
$allWords = (string)$searchNode->getValue();
Log::debug(sprintf('Add words "%s" to search string, because Node class is "%s"', $allWords, $class));
$this->words[] = $allWords;
break;
@@ -223,11 +223,11 @@ class OperatorQuerySearch implements SearchInterface
// must be valid operator:
if (
in_array($operator, $this->validOperators, true) &&
$this->updateCollector($operator, (string) $value, $prohibited)) {
$this->updateCollector($operator, (string)$value, $prohibited)) {
$this->operators->push(
[
'type' => self::getRootOperator($operator),
'value' => (string) $value,
'value' => (string)$value,
'prohibited' => $prohibited,
]
);
@@ -237,15 +237,15 @@ class OperatorQuerySearch implements SearchInterface
Log::debug(sprintf('Added INVALID operator type "%s"', $operator));
$this->invalidOperators[] = [
'type' => $operator,
'value' => (string) $value,
'value' => (string)$value,
];
}
}
}
/**
* @param string $operator
* @param string $value
* @param string $operator
* @param string $value
*
* @return bool
* @throws FireflyException
@@ -371,7 +371,7 @@ class OperatorQuerySearch implements SearchInterface
$this->searchAccount($value, 1, 3, true);
break;
case 'source_account_id':
$account = $this->accountRepository->find((int) $value);
$account = $this->accountRepository->find((int)$value);
if (null !== $account) {
$this->collector->setSourceAccounts(new Collection([$account]));
}
@@ -381,7 +381,7 @@ class OperatorQuerySearch implements SearchInterface
}
break;
case '-source_account_id':
$account = $this->accountRepository->find((int) $value);
$account = $this->accountRepository->find((int)$value);
if (null !== $account) {
$this->collector->excludeSourceAccounts(new Collection([$account]));
}
@@ -455,7 +455,7 @@ class OperatorQuerySearch implements SearchInterface
$this->searchAccount($value, 2, 3, true);
break;
case 'destination_account_id':
$account = $this->accountRepository->find((int) $value);
$account = $this->accountRepository->find((int)$value);
if (null !== $account) {
$this->collector->setDestinationAccounts(new Collection([$account]));
}
@@ -464,7 +464,7 @@ class OperatorQuerySearch implements SearchInterface
}
break;
case '-destination_account_id':
$account = $this->accountRepository->find((int) $value);
$account = $this->accountRepository->find((int)$value);
if (null !== $account) {
$this->collector->excludeDestinationAccounts(new Collection([$account]));
}
@@ -476,7 +476,7 @@ class OperatorQuerySearch implements SearchInterface
$parts = explode(',', $value);
$collection = new Collection();
foreach ($parts as $accountId) {
$account = $this->accountRepository->find((int) $accountId);
$account = $this->accountRepository->find((int)$accountId);
if (null !== $account) {
$collection->push($account);
}
@@ -492,7 +492,7 @@ class OperatorQuerySearch implements SearchInterface
$parts = explode(',', $value);
$collection = new Collection();
foreach ($parts as $accountId) {
$account = $this->accountRepository->find((int) $accountId);
$account = $this->accountRepository->find((int)$accountId);
if (null !== $account) {
$collection->push($account);
}
@@ -928,7 +928,7 @@ class OperatorQuerySearch implements SearchInterface
case 'amount_is':
// strip comma's, make dots.
Log::debug(sprintf('Original value "%s"', $value));
$value = str_replace(',', '.', (string) $value);
$value = str_replace(',', '.', (string)$value);
$amount = app('steam')->positive($value);
Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $amount));
$this->collector->amountIs($amount);
@@ -936,7 +936,7 @@ class OperatorQuerySearch implements SearchInterface
case '-amount_is':
// strip comma's, make dots.
Log::debug(sprintf('Original value "%s"', $value));
$value = str_replace(',', '.', (string) $value);
$value = str_replace(',', '.', (string)$value);
$amount = app('steam')->positive($value);
Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $amount));
$this->collector->amountIsNot($amount);
@@ -944,7 +944,7 @@ class OperatorQuerySearch implements SearchInterface
case 'foreign_amount_is':
// strip comma's, make dots.
$value = str_replace(',', '.', (string) $value);
$value = str_replace(',', '.', (string)$value);
$amount = app('steam')->positive($value);
Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $amount));
@@ -953,7 +953,7 @@ class OperatorQuerySearch implements SearchInterface
case '-foreign_amount_is':
// strip comma's, make dots.
$value = str_replace(',', '.', (string) $value);
$value = str_replace(',', '.', (string)$value);
$amount = app('steam')->positive($value);
Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $amount));
@@ -962,7 +962,7 @@ class OperatorQuerySearch implements SearchInterface
case '-amount_more':
case 'amount_less':
// strip comma's, make dots.
$value = str_replace(',', '.', (string) $value);
$value = str_replace(',', '.', (string)$value);
$amount = app('steam')->positive($value);
Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $amount));
@@ -971,7 +971,7 @@ class OperatorQuerySearch implements SearchInterface
case '-foreign_amount_more':
case 'foreign_amount_less':
// strip comma's, make dots.
$value = str_replace(',', '.', (string) $value);
$value = str_replace(',', '.', (string)$value);
$amount = app('steam')->positive($value);
Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $amount));
@@ -981,7 +981,7 @@ class OperatorQuerySearch implements SearchInterface
case 'amount_more':
Log::debug(sprintf('Now handling operator "%s"', $operator));
// strip comma's, make dots.
$value = str_replace(',', '.', (string) $value);
$value = str_replace(',', '.', (string)$value);
$amount = app('steam')->positive($value);
Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $amount));
$this->collector->amountMore($amount);
@@ -990,7 +990,7 @@ class OperatorQuerySearch implements SearchInterface
case 'foreign_amount_more':
Log::debug(sprintf('Now handling operator "%s"', $operator));
// strip comma's, make dots.
$value = str_replace(',', '.', (string) $value);
$value = str_replace(',', '.', (string)$value);
$amount = app('steam')->positive($value);
Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $amount));
$this->collector->foreignAmountMore($amount);
@@ -1325,7 +1325,7 @@ class OperatorQuerySearch implements SearchInterface
}
/**
* @param string $operator
* @param string $operator
*
* @return string
* @throws FireflyException
@@ -1361,10 +1361,10 @@ class OperatorQuerySearch implements SearchInterface
* searchDirection: 1 = source (default), 2 = destination, 3 = both
* stringPosition: 1 = start (default), 2 = end, 3 = contains, 4 = is
*
* @param string $value
* @param int $searchDirection
* @param int $stringPosition
* @param bool $prohibited
* @param string $value
* @param int $searchDirection
* @param int $stringPosition
* @param bool $prohibited
*/
private function searchAccount(string $value, int $searchDirection, int $stringPosition, bool $prohibited = false): void
{
@@ -1437,10 +1437,10 @@ class OperatorQuerySearch implements SearchInterface
* searchDirection: 1 = source (default), 2 = destination, 3 = both
* stringPosition: 1 = start (default), 2 = end, 3 = contains, 4 = is
*
* @param string $value
* @param int $searchDirection
* @param int $stringPosition
* @param bool $prohibited
* @param string $value
* @param int $searchDirection
* @param int $stringPosition
* @param bool $prohibited
*/
private function searchAccountNr(string $value, int $searchDirection, int $stringPosition, bool $prohibited = false): void
{
@@ -1500,7 +1500,7 @@ class OperatorQuerySearch implements SearchInterface
$filtered = $accounts->filter(
function (Account $account) use ($value, $stringMethod) {
// either IBAN or account number
$ibanMatch = $stringMethod(strtolower((string) $account->iban), strtolower((string) $value));
$ibanMatch = $stringMethod(strtolower((string)$account->iban), strtolower((string)$value));
$accountNrMatch = false;
/** @var AccountMeta $meta */
foreach ($account->accountMeta as $meta) {
@@ -1532,7 +1532,7 @@ class OperatorQuerySearch implements SearchInterface
}
/**
* @param string $value
* @param string $value
*
* @return TransactionCurrency|null
*/
@@ -1552,7 +1552,7 @@ class OperatorQuerySearch implements SearchInterface
}
/**
* @param string $value
* @param string $value
*
* @return array
* @throws FireflyException
@@ -1571,14 +1571,14 @@ class OperatorQuerySearch implements SearchInterface
}
/**
* @param array $range
* @param array $range
*
* @throws FireflyException
*/
private function setExactDateParams(array $range, bool $prohibited = false): void
{
/**
* @var string $key
* @var string $key
* @var Carbon|string $value
*/
foreach ($range as $key => $value) {
@@ -1630,14 +1630,14 @@ class OperatorQuerySearch implements SearchInterface
}
/**
* @param array $range
* @param array $range
*
* @throws FireflyException
*/
private function setDateBeforeParams(array $range, bool $prohibited = false): void
{
/**
* @var string $key
* @var string $key
* @var Carbon|string $value
*/
foreach ($range as $key => $value) {
@@ -1669,14 +1669,14 @@ class OperatorQuerySearch implements SearchInterface
}
/**
* @param array $range
* @param array $range
*
* @throws FireflyException
*/
private function setDateAfterParams(array $range, bool $prohibited = false)
{
/**
* @var string $key
* @var string $key
* @var Carbon|string $value
*/
foreach ($range as $key => $value) {
@@ -1708,8 +1708,8 @@ class OperatorQuerySearch implements SearchInterface
}
/**
* @param string $field
* @param array $range
* @param string $field
* @param array $range
* @return void
* @throws FireflyException
*/
@@ -1717,7 +1717,7 @@ class OperatorQuerySearch implements SearchInterface
{
Log::debug('Now in setExactMetaDateParams()');
/**
* @var string $key
* @var string $key
* @var Carbon|string $value
*/
foreach ($range as $key => $value) {
@@ -1770,15 +1770,15 @@ class OperatorQuerySearch implements SearchInterface
}
/**
* @param string $field
* @param array $range
* @param string $field
* @param array $range
* @return void
* @throws FireflyException
*/
private function setMetaDateBeforeParams(string $field, array $range, bool $prohibited = false): void
{
/**
* @var string $key
* @var string $key
* @var Carbon|string $value
*/
foreach ($range as $key => $value) {
@@ -1810,15 +1810,15 @@ class OperatorQuerySearch implements SearchInterface
}
/**
* @param string $field
* @param array $range
* @param string $field
* @param array $range
* @return void
* @throws FireflyException
*/
private function setMetaDateAfterParams(string $field, array $range, bool $prohibited = false): void
{
/**
* @var string $key
* @var string $key
* @var Carbon|string $value
*/
foreach ($range as $key => $value) {
@@ -1850,15 +1850,15 @@ class OperatorQuerySearch implements SearchInterface
}
/**
* @param string $field
* @param array $range
* @param string $field
* @param array $range
* @return void
* @throws FireflyException
*/
private function setExactObjectDateParams(string $field, array $range, bool $prohibited = false): void
{
/**
* @var string $key
* @var string $key
* @var Carbon|string $value
*/
foreach ($range as $key => $value) {
@@ -1911,15 +1911,15 @@ class OperatorQuerySearch implements SearchInterface
}
/**
* @param string $field
* @param array $range
* @param string $field
* @param array $range
*
* @throws FireflyException
*/
private function setObjectDateBeforeParams(string $field, array $range, bool $prohibited = false): void
{
/**
* @var string $key
* @var string $key
* @var Carbon|string $value
*/
foreach ($range as $key => $value) {
@@ -1951,15 +1951,15 @@ class OperatorQuerySearch implements SearchInterface
}
/**
* @param string $field
* @param array $range
* @param string $field
* @param array $range
*
* @throws FireflyException
*/
private function setObjectDateAfterParams(string $field, array $range, bool $prohibited = false): void
{
/**
* @var string $key
* @var string $key
* @var Carbon|string $value
*/
foreach ($range as $key => $value) {
@@ -2020,7 +2020,7 @@ class OperatorQuerySearch implements SearchInterface
}
/**
* @param Carbon $date
* @param Carbon $date
*/
public function setDate(Carbon $date): void
{
@@ -2052,11 +2052,11 @@ class OperatorQuerySearch implements SearchInterface
$this->collector->setUser($user);
$this->collector->withAccountInformation()->withCategoryInformation()->withBudgetInformation();
$this->setLimit((int) app('preferences')->getForUser($user, 'listPageSize', 50)->data);
$this->setLimit((int)app('preferences')->getForUser($user, 'listPageSize', 50)->data);
}
/**
* @param int $limit
* @param int $limit
*/
public function setLimit(int $limit): void
{

View File

@@ -1,4 +1,5 @@
<?php
/**
* SearchInterface.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -58,7 +59,7 @@ interface SearchInterface
public function hasModifiers(): bool;
/**
* @param string $query
* @param string $query
*/
public function parseQuery(string $query);
@@ -73,22 +74,22 @@ interface SearchInterface
public function searchTransactions(): LengthAwarePaginator;
/**
* @param Carbon $date
* @param Carbon $date
*/
public function setDate(Carbon $date): void;
/**
* @param int $limit
* @param int $limit
*/
public function setLimit(int $limit): void;
/**
* @param int $page
* @param int $page
*/
public function setPage(int $page): void;
/**
* @param User $user
* @param User $user
*/
public function setUser(User $user);
}

View File

@@ -33,6 +33,8 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use Illuminate\Support\Collection;
use JsonException;
use Log;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use stdClass;
use Str;
use ValueError;
@@ -95,38 +97,6 @@ class Steam
return $sum;
}
/**
* https://stackoverflow.com/questions/1642614/how-to-ceil-floor-and-round-bcmath-numbers
*
* @param null|string $number
* @param int $precision
* @return string
*/
public function bcround(?string $number, int $precision = 0): string
{
if (null === $number) {
return '0';
}
if ('' === trim($number)) {
return '0';
}
// if the number contains "E", it's in scientific notation, so we need to convert it to a normal number first.
if (false !== stripos($number, 'e')) {
$number = sprintf('%.24f', $number);
}
Log::debug(sprintf('Trying bcround("%s",%d)', $number, $precision));
if (str_contains($number, '.')) {
if ($number[0] !== '-') {
return bcadd($number, '0.'.str_repeat('0', $precision).'5', $precision);
}
return bcsub($number, '0.'.str_repeat('0', $precision).'5', $precision);
}
return $number;
}
/**
* Gets the balance for the given account during the whole range, using this format:.
*
@@ -182,11 +152,11 @@ class Steam
->whereNull('transaction_journals.deleted_at')
->get(
[
'transaction_journals.date',
'transactions.transaction_currency_id',
DB::raw('SUM(transactions.amount) AS modified'),
'transactions.foreign_currency_id',
DB::raw('SUM(transactions.foreign_amount) AS modified_foreign'),
'transaction_journals.date',
'transactions.transaction_currency_id',
DB::raw('SUM(transactions.amount) AS modified'),
'transactions.foreign_currency_id',
DB::raw('SUM(transactions.foreign_amount) AS modified_foreign'),
]
);
@@ -363,6 +333,38 @@ class Steam
return $return;
}
/**
* https://stackoverflow.com/questions/1642614/how-to-ceil-floor-and-round-bcmath-numbers
*
* @param null|string $number
* @param int $precision
* @return string
*/
public function bcround(?string $number, int $precision = 0): string
{
if (null === $number) {
return '0';
}
if ('' === trim($number)) {
return '0';
}
// if the number contains "E", it's in scientific notation, so we need to convert it to a normal number first.
if (false !== stripos($number, 'e')) {
$number = sprintf('%.24f', $number);
}
Log::debug(sprintf('Trying bcround("%s",%d)', $number, $precision));
if (str_contains($number, '.')) {
if ($number[0] !== '-') {
return bcadd($number, '0.'.str_repeat('0', $precision).'5', $precision);
}
return bcsub($number, '0.'.str_repeat('0', $precision).'5', $precision);
}
return $number;
}
/**
* @param string $string
*
@@ -453,8 +455,8 @@ class Steam
*
* @return string
* @throws FireflyException
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function getLocale(): string // get preference
{
@@ -476,8 +478,8 @@ class Steam
*
* @return string
* @throws FireflyException
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function getLanguage(): string // get preference
{

View File

@@ -53,7 +53,7 @@ trait GeneratesInstallationId
if (null === $config) {
$uuid4 = Uuid::uuid4();
$uniqueId = (string) $uuid4;
$uniqueId = (string)$uuid4;
Log::info(sprintf('Created Firefly III installation ID %s', $uniqueId));
app('fireflyconfig')->set('installation_id', $uniqueId);
}

View File

@@ -72,8 +72,8 @@ class OAuthKeys
// better check if keys are in the database:
if (app('fireflyconfig')->has(self::PRIVATE_KEY) && app('fireflyconfig')->has(self::PUBLIC_KEY)) {
try {
$privateKey = (string) app('fireflyconfig')->get(self::PRIVATE_KEY)?->data;
$publicKey = (string) app('fireflyconfig')->get(self::PUBLIC_KEY)?->data;
$privateKey = (string)app('fireflyconfig')->get(self::PRIVATE_KEY)?->data;
$publicKey = (string)app('fireflyconfig')->get(self::PUBLIC_KEY)?->data;
} catch (ContainerExceptionInterface|NotFoundExceptionInterface|FireflyException $e) {
Log::error(sprintf('Could not validate keysInDatabase(): %s', $e->getMessage()));
Log::error($e->getTraceAsString());
@@ -125,8 +125,8 @@ class OAuthKeys
*/
public static function restoreKeysFromDB(): bool
{
$privateKey = (string) app('fireflyconfig')->get(self::PRIVATE_KEY)?->data;
$publicKey = (string) app('fireflyconfig')->get(self::PUBLIC_KEY)?->data;
$privateKey = (string)app('fireflyconfig')->get(self::PRIVATE_KEY)?->data;
$publicKey = (string)app('fireflyconfig')->get(self::PUBLIC_KEY)?->data;
try {
$privateContent = Crypt::decrypt($privateKey);
$publicContent = Crypt::decrypt($publicKey);

View File

@@ -1,4 +1,5 @@
<?php
/**
* AmountFormat.php
* Copyright (c) 2019 james@firefly-iii.org

View File

@@ -1,4 +1,5 @@
<?php
/**
* General.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -85,15 +86,15 @@ class General extends AbstractExtension
static function (int $size): string {
// less than one GB, more than one MB
if ($size < (1024 * 1024 * 2014) && $size >= (1024 * 1024)) {
return round($size / (1024 * 1024), 2) . ' MB';
return round($size / (1024 * 1024), 2).' MB';
}
// less than one MB
if ($size < (1024 * 1024)) {
return round($size / 1024, 2) . ' KB';
return round($size / 1024, 2).' KB';
}
return $size . ' bytes';
return $size.' bytes';
}
);
}
@@ -192,7 +193,7 @@ class General extends AbstractExtension
]
);
return (string) $converter->convert($text);
return (string)$converter->convert($text);
},
['is_safe' => ['html']]
);
@@ -208,8 +209,8 @@ class General extends AbstractExtension
return new TwigFilter(
'phphost',
static function (string $string): string {
$proto = (string) parse_url($string, PHP_URL_SCHEME);
$host = (string) parse_url($string, PHP_URL_HOST);
$proto = (string)parse_url($string, PHP_URL_SCHEME);
$host = (string)parse_url($string, PHP_URL_HOST);
return e(sprintf('%s://%s', $proto, $host));
}
@@ -406,7 +407,7 @@ class General extends AbstractExtension
return new TwigFunction(
'getRootSearchOperator',
static function (string $operator): string {
$result = OperatorQuerySearch::getRootOperator($operator);
$result = OperatorQuerySearch::getRootOperator($operator);
return str_replace('-', 'not_', $result);
}
);

View File

@@ -1,4 +1,5 @@
<?php
/**
* Rule.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -52,8 +53,8 @@ class Rule extends AbstractExtension
'allJournalTriggers',
static function () {
return [
'store-journal' => (string) trans('firefly.rule_trigger_store_journal'),
'update-journal' => (string) trans('firefly.rule_trigger_update_journal'),
'store-journal' => (string)trans('firefly.rule_trigger_store_journal'),
'update-journal' => (string)trans('firefly.rule_trigger_update_journal'),
];
}
);
@@ -71,7 +72,7 @@ class Rule extends AbstractExtension
$possibleTriggers = [];
foreach ($ruleTriggers as $key) {
if ('user_action' !== $key) {
$possibleTriggers[$key] = (string) trans('firefly.rule_trigger_' . $key . '_choice');
$possibleTriggers[$key] = (string)trans('firefly.rule_trigger_'.$key.'_choice');
}
}
unset($ruleTriggers);
@@ -94,7 +95,7 @@ class Rule extends AbstractExtension
$ruleActions = array_keys(Config::get('firefly.rule-actions'));
$possibleActions = [];
foreach ($ruleActions as $key) {
$possibleActions[$key] = (string) trans('firefly.rule_action_' . $key . '_choice');
$possibleActions[$key] = (string)trans('firefly.rule_action_'.$key.'_choice');
}
unset($ruleActions);
asort($possibleActions);

View File

@@ -79,7 +79,7 @@ class TransactionGroupTwig extends AbstractExtension
/**
* Generate normal amount for transaction from a transaction group.
*
* @param array $array
* @param array $array
*
* @return string
*/
@@ -95,7 +95,7 @@ class TransactionGroupTwig extends AbstractExtension
$colored = false;
}
$result = app('amount')->formatFlat($array['currency_symbol'], (int) $array['currency_decimal_places'], $amount, $colored);
$result = app('amount')->formatFlat($array['currency_symbol'], (int)$array['currency_decimal_places'], $amount, $colored);
if ($type === TransactionType::TRANSFER) {
$result = sprintf('<span class="text-info">%s</span>', $result);
}
@@ -104,9 +104,9 @@ class TransactionGroupTwig extends AbstractExtension
}
/**
* @param string $amount
* @param string $transactionType
* @param string $sourceType
* @param string $amount
* @param string $transactionType
* @param string $sourceType
*
* @return string
*/
@@ -133,7 +133,7 @@ class TransactionGroupTwig extends AbstractExtension
/**
* Generate foreign amount for transaction from a transaction group.
*
* @param array $array
* @param array $array
*
* @return string
*/
@@ -149,7 +149,7 @@ class TransactionGroupTwig extends AbstractExtension
if ($type === TransactionType::TRANSFER) {
$colored = false;
}
$result = app('amount')->formatFlat($array['foreign_currency_symbol'], (int) $array['foreign_currency_decimal_places'], $amount, $colored);
$result = app('amount')->formatFlat($array['foreign_currency_symbol'], (int)$array['foreign_currency_decimal_places'], $amount, $colored);
if ($type === TransactionType::TRANSFER) {
$result = sprintf('<span class="text-info">%s</span>', $result);
}
@@ -183,7 +183,7 @@ class TransactionGroupTwig extends AbstractExtension
/**
* Generate normal amount for transaction from a transaction group.
*
* @param TransactionJournal $journal
* @param TransactionJournal $journal
*
* @return string
*/
@@ -201,7 +201,7 @@ class TransactionGroupTwig extends AbstractExtension
if ($type === TransactionType::TRANSFER) {
$colored = false;
}
$result = app('amount')->formatFlat($currency->symbol, (int) $currency->decimal_places, $amount, $colored);
$result = app('amount')->formatFlat($currency->symbol, (int)$currency->decimal_places, $amount, $colored);
if ($type === TransactionType::TRANSFER) {
$result = sprintf('<span class="text-info">%s</span>', $result);
}
@@ -210,7 +210,7 @@ class TransactionGroupTwig extends AbstractExtension
}
/**
* @param TransactionJournal $journal
* @param TransactionJournal $journal
*
* @return bool
*/
@@ -225,7 +225,7 @@ class TransactionGroupTwig extends AbstractExtension
/**
* Generate foreign amount for journal from a transaction group.
*
* @param TransactionJournal $journal
* @param TransactionJournal $journal
*
* @return string
*/
@@ -244,7 +244,7 @@ class TransactionGroupTwig extends AbstractExtension
if ($type === TransactionType::TRANSFER) {
$colored = false;
}
$result = app('amount')->formatFlat($currency->symbol, (int) $currency->decimal_places, $amount, $colored);
$result = app('amount')->formatFlat($currency->symbol, (int)$currency->decimal_places, $amount, $colored);
if ($type === TransactionType::TRANSFER) {
$result = sprintf('<span class="text-info">%s</span>', $result);
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* Translation.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -40,7 +41,7 @@ class Translation extends AbstractExtension
new TwigFilter(
'_',
static function ($name) {
return (string) trans(sprintf('firefly.%s', $name));
return (string)trans(sprintf('firefly.%s', $name));
},
['is_safe' => ['html']]
),