mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-11-22 08:56:39 -06:00
Fix various phpstan things
This commit is contained in:
parent
1c3cb85a46
commit
b9feb0aa71
@ -106,12 +106,11 @@ class BudgetLimitController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param BudgetLimit $budgetLimit
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
*/
|
||||
public function delete(Request $request, BudgetLimit $budgetLimit)
|
||||
public function delete(BudgetLimit $budgetLimit)
|
||||
{
|
||||
$this->blRepository->destroyBudgetLimit($budgetLimit);
|
||||
session()->flash('success', trans('firefly.deleted_bl'));
|
||||
|
@ -87,8 +87,6 @@ class IndexController extends Controller
|
||||
/**
|
||||
* Show all budgets.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
*
|
||||
@ -98,7 +96,7 @@ class IndexController extends Controller
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function index(Request $request, Carbon $start = null, Carbon $end = null)
|
||||
public function index(Carbon $start = null, Carbon $end = null)
|
||||
{
|
||||
$this->abRepository->cleanup();
|
||||
app('log')->debug(sprintf('Start of IndexController::index("%s", "%s")', $start?->format('Y-m-d'), $end?->format('Y-m-d')));
|
||||
@ -137,7 +135,7 @@ class IndexController extends Controller
|
||||
|
||||
// get budgeted for default currency:
|
||||
if (0 === count($availableBudgets)) {
|
||||
$budgeted = $this->blRepository->budgeted($start, $end, $defaultCurrency, );
|
||||
$budgeted = $this->blRepository->budgeted($start, $end, $defaultCurrency,);
|
||||
$spentArr = $this->opsRepository->sumExpenses($start, $end, null, null, $defaultCurrency);
|
||||
$spent = $spentArr[$defaultCurrency->id]['sum'] ?? '0';
|
||||
unset($spentArr);
|
||||
@ -196,7 +194,7 @@ class IndexController extends Controller
|
||||
$array['spent'] = $spentArr[$entry->transaction_currency_id]['sum'] ?? '0';
|
||||
|
||||
// budgeted in period:
|
||||
$budgeted = $this->blRepository->budgeted($entry->start_date, $entry->end_date, $entry->transactionCurrency, );
|
||||
$budgeted = $this->blRepository->budgeted($entry->start_date, $entry->end_date, $entry->transactionCurrency,);
|
||||
$array['budgeted'] = $budgeted;
|
||||
$availableBudgets[] = $array;
|
||||
unset($spentArr);
|
||||
@ -321,9 +319,8 @@ class IndexController extends Controller
|
||||
// final calculation for 'left':
|
||||
/**
|
||||
* @var int $currencyId
|
||||
* @var array $info
|
||||
*/
|
||||
foreach ($sums['budgeted'] as $currencyId => $info) {
|
||||
foreach (array_keys($sums['budgeted']) as $currencyId) {
|
||||
$spent = $sums['spent'][$currencyId]['amount'] ?? '0';
|
||||
$budgeted = $sums['budgeted'][$currencyId]['amount'] ?? '0';
|
||||
$sums['left'][$currencyId]['amount'] = bcadd($spent, $budgeted);
|
||||
|
@ -115,12 +115,10 @@ class DebugController extends Controller
|
||||
/**
|
||||
* Show debug info.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Factory|View
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function index(Request $request)
|
||||
public function index()
|
||||
{
|
||||
$table = $this->generateTable();
|
||||
$table = str_replace(["\n", "\t", ' '], '', $table);
|
||||
|
@ -48,13 +48,12 @@ class JavascriptController extends Controller
|
||||
* Show info about accounts.
|
||||
*
|
||||
* @param AccountRepositoryInterface $repository
|
||||
* @param CurrencyRepositoryInterface $currencyRepository
|
||||
*
|
||||
* @return Response
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function accounts(AccountRepositoryInterface $repository, CurrencyRepositoryInterface $currencyRepository): Response
|
||||
public function accounts(AccountRepositoryInterface $repository): Response
|
||||
{
|
||||
$accounts = $repository->getAccountsByType(
|
||||
[AccountType::DEFAULT, AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::CREDITCARD]
|
||||
@ -104,7 +103,6 @@ class JavascriptController extends Controller
|
||||
*
|
||||
* @param Request $request
|
||||
* @param AccountRepositoryInterface $repository
|
||||
* @param CurrencyRepositoryInterface $currencyRepository
|
||||
*
|
||||
* @return Response
|
||||
* @throws FireflyException
|
||||
@ -112,7 +110,7 @@ class JavascriptController extends Controller
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function variables(Request $request, AccountRepositoryInterface $repository, CurrencyRepositoryInterface $currencyRepository): Response
|
||||
public function variables(Request $request, AccountRepositoryInterface $repository): Response
|
||||
{
|
||||
$account = $repository->find((int)$request->get('account'));
|
||||
$currency = app('amount')->getDefaultCurrency();
|
||||
@ -147,11 +145,9 @@ class JavascriptController extends Controller
|
||||
/**
|
||||
* Bit of a hack but OK.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function variablesV2(Request $request): Response
|
||||
public function variablesV2(): Response
|
||||
{
|
||||
/** @var Carbon $start */
|
||||
$start = clone session('start', today(config('app.timezone'))->startOfMonth());
|
||||
|
@ -74,13 +74,11 @@ class IndexController extends Controller
|
||||
*
|
||||
* TODO very complicated function.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Factory|View
|
||||
* @throws FireflyException
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function index(Request $request)
|
||||
public function index()
|
||||
{
|
||||
$this->cleanupObjectGroups();
|
||||
$this->piggyRepos->resetOrder();
|
||||
|
@ -76,13 +76,12 @@ class ShowController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param TransactionGroup $transactionGroup
|
||||
*
|
||||
* @return Factory|View
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function show(Request $request, TransactionGroup $transactionGroup)
|
||||
public function show( TransactionGroup $transactionGroup)
|
||||
{
|
||||
/** @var TransactionJournal|null $first */
|
||||
$first = $transactionGroup->transactionJournals()->first(['transaction_journals.*']);
|
||||
@ -105,7 +104,7 @@ class ShowController extends Controller
|
||||
$amounts = $this->getAmounts($groupArray);
|
||||
$accounts = $this->getAccounts($groupArray);
|
||||
|
||||
foreach ($groupArray['transactions'] as $index => $transaction) {
|
||||
foreach (array_keys($groupArray['transactions']) as $index) {
|
||||
$groupArray['transactions'][$index]['tags'] = $this->repository->getTagObjects(
|
||||
$groupArray['transactions'][$index]['transaction_journal_id']
|
||||
);
|
||||
|
@ -53,13 +53,9 @@ class IndexController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Show debug info.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Factory|View
|
||||
*/
|
||||
public function index(Request $request)
|
||||
public function index()
|
||||
{
|
||||
return view('webhooks.index');
|
||||
}
|
||||
|
@ -83,6 +83,7 @@ class Authenticate
|
||||
* @return mixed
|
||||
* @throws FireflyException
|
||||
* @throws AuthenticationException
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
protected function authenticate($request, array $guards)
|
||||
{
|
||||
|
@ -324,21 +324,4 @@ class OperationsRepository implements OperationsRepositoryInterface
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* For now, simply refer to whichever repository holds this function.
|
||||
* TODO perhaps better in the future.
|
||||
*
|
||||
* @param Budget $budget
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
private function getBudgetLimits(Budget $budget, Carbon $start = null, Carbon $end = null): Collection
|
||||
{
|
||||
/** @var BudgetLimitRepositoryInterface $blRepository */
|
||||
$blRepository = app(BudgetLimitRepositoryInterface::class);
|
||||
|
||||
return $blRepository->getBudgetLimits($budget, $start, $end);
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ trait ValidatesUserGroupTrait
|
||||
$user = auth()->user();
|
||||
if (!$request->has('user_group_id')) {
|
||||
$group = $user->userGroup;
|
||||
app('log')->debug(sprintf('validateUserGroup: no user group submitted, return default group #%d.', $group->id));
|
||||
app('log')->debug(sprintf('validateUserGroup: no user group submitted, return default group #%d.', $group?->id));
|
||||
return $group;
|
||||
}
|
||||
$groupId = (int)$request->get('user_group_id');
|
||||
|
@ -36,6 +36,7 @@ use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use FireflyIII\Repositories\Budget\OperationsRepositoryInterface;
|
||||
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use FireflyIII\Support\Facades\Amount;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
@ -216,9 +217,20 @@ trait AugumentData
|
||||
/** @var BudgetLimit $entry */
|
||||
foreach ($set as $entry) {
|
||||
$currency = $entry->transactionCurrency;
|
||||
|
||||
if(null === $currency) {
|
||||
$currency = app('amount')->getDefaultCurrency();
|
||||
}
|
||||
|
||||
// clone because these objects change each other.
|
||||
$currentStart = clone $entry->start_date;
|
||||
$currentEnd = clone $entry->end_date;
|
||||
$currentEnd = null === $entry->end_date ? null : clone $entry->end_date;
|
||||
|
||||
if(null === $currentEnd) {
|
||||
$currentEnd = clone $currentStart;
|
||||
$currentEnd->addMonth();
|
||||
}
|
||||
|
||||
$expenses = $opsRepository->sumExpenses($currentStart, $currentEnd, null, $budgetCollection, $currency);
|
||||
$spent = $expenses[$currency->id]['sum'] ?? '0';
|
||||
$entry->spent = $spent;
|
||||
|
@ -220,9 +220,9 @@ trait GetConfigurationData
|
||||
protected function verifyRecurringCronJob(): void
|
||||
{
|
||||
$config = app('fireflyconfig')->get('last_rt_job', 0);
|
||||
$lastTime = (int)$config->data;
|
||||
$lastTime = (int)$config?->data;
|
||||
$now = time();
|
||||
app('log')->debug(sprintf('verifyRecurringCronJob: last time is %d ("%s"), now is %d', $lastTime, $config->data, $now));
|
||||
app('log')->debug(sprintf('verifyRecurringCronJob: last time is %d ("%s"), now is %d', $lastTime, $config?->data, $now));
|
||||
if (0 === $lastTime) {
|
||||
request()->session()->flash('info', trans('firefly.recurring_never_cron'));
|
||||
|
||||
|
@ -79,6 +79,7 @@ trait ModelInformation
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
$repository = app(AccountRepositoryInterface::class);
|
||||
// types of liability:
|
||||
/** @var AccountType $debt */
|
||||
$debt = $repository->getAccountTypeByType(AccountType::DEBT);
|
||||
$loan = $repository->getAccountTypeByType(AccountType::LOAN);
|
||||
$mortgage = $repository->getAccountTypeByType(AccountType::MORTGAGE);
|
||||
|
@ -64,6 +64,10 @@ trait RenderPartialViews
|
||||
$accountRepos = app(AccountRepositoryInterface::class);
|
||||
$account = $accountRepos->find((int)$attributes['accountId']);
|
||||
|
||||
if(null === $budget || null === $account) {
|
||||
throw new FireflyException('Could not render popup.report.balance-amount because budget or account is null.');
|
||||
}
|
||||
|
||||
$journals = $popupHelper->balanceForBudget($budget, $account, $attributes);
|
||||
|
||||
try {
|
||||
@ -330,7 +334,7 @@ trait RenderPartialViews
|
||||
if ('user_action' !== $entry->trigger_type) {
|
||||
$count = ($index + 1);
|
||||
try {
|
||||
$rootOperator = OperatorQuerySearch::getRootOperator($entry->trigger_type);
|
||||
$rootOperator = OperatorQuerySearch::getRootOperator((string) $entry->trigger_type);
|
||||
if (str_starts_with($rootOperator, '-')) {
|
||||
$rootOperator = substr($rootOperator, 1);
|
||||
}
|
||||
@ -340,7 +344,7 @@ trait RenderPartialViews
|
||||
'oldTrigger' => $rootOperator,
|
||||
'oldValue' => $entry->trigger_value,
|
||||
'oldChecked' => $entry->stop_processing,
|
||||
'oldProhibited' => str_starts_with($entry->trigger_type, '-'),
|
||||
'oldProhibited' => str_starts_with((string) $entry->trigger_type, '-'),
|
||||
'count' => $count,
|
||||
'triggers' => $triggers,
|
||||
]
|
||||
|
@ -63,11 +63,15 @@ trait UserGroupTrait
|
||||
* @param Authenticatable|User|null $user
|
||||
*
|
||||
* @return void
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function setUser(Authenticatable | User | null $user): void
|
||||
{
|
||||
if ($user instanceof User) {
|
||||
$this->user = $user;
|
||||
if(null === $user->userGroup) {
|
||||
throw new FireflyException(sprintf('User #%d has no user group.', $user->id));
|
||||
}
|
||||
$this->userGroup = $user->userGroup;
|
||||
}
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ trait ChecksLogin
|
||||
$user = auth()->user();
|
||||
app('log')->debug('Now in getUserGroup()');
|
||||
/** @var UserGroup|null $userGroup */
|
||||
$userGroup = $this->route()->parameter('userGroup');
|
||||
$userGroup = $this->route()?->parameter('userGroup');
|
||||
if (null === $userGroup) {
|
||||
app('log')->debug('Request class has no userGroup parameter, but perhaps there is a parameter.');
|
||||
$userGroupId = (int)$this->get('user_group_id');
|
||||
|
@ -70,7 +70,7 @@ trait ConvertsDataTypes
|
||||
if (!is_scalar($entry)) {
|
||||
return '';
|
||||
}
|
||||
return $this->clearString((string)$entry, false);
|
||||
return (string) $this->clearString((string)$entry, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -199,7 +199,7 @@ trait ConvertsDataTypes
|
||||
*/
|
||||
public function stringWithNewlines(string $field): string
|
||||
{
|
||||
return $this->clearString((string)($this->get($field) ?? ''));
|
||||
return (string) $this->clearString((string)($this->get($field) ?? ''));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -255,7 +255,7 @@ trait ConvertsDataTypes
|
||||
*/
|
||||
protected function convertDateTime(?string $string): ?Carbon
|
||||
{
|
||||
$value = $this->get($string);
|
||||
$value = $this->get((string)$string);
|
||||
if (null === $value) {
|
||||
return null;
|
||||
}
|
||||
|
@ -36,7 +36,6 @@ use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
||||
use FireflyIII\Services\Password\Verifier;
|
||||
use FireflyIII\Support\Facades\Preferences;
|
||||
use FireflyIII\Support\ParseDateString;
|
||||
use FireflyIII\TransactionRules\Triggers\TriggerInterface;
|
||||
use FireflyIII\User;
|
||||
@ -49,6 +48,7 @@ use ValueError;
|
||||
|
||||
/**
|
||||
* Class FireflyValidator.
|
||||
* TODO all of these validations must become separate classes.
|
||||
*/
|
||||
class FireflyValidator extends Validator
|
||||
{
|
||||
@ -60,6 +60,7 @@ class FireflyValidator extends Validator
|
||||
* @throws IncompatibleWithGoogleAuthenticatorException
|
||||
* @throws InvalidCharactersException
|
||||
* @throws SecretKeyTooShortException
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function validate2faCode($attribute, $value): bool
|
||||
{
|
||||
@ -73,18 +74,18 @@ class FireflyValidator extends Validator
|
||||
}
|
||||
$secretPreference = app('preferences')->get('temp-mfa-secret');
|
||||
$secret = $secretPreference?->data ?? '';
|
||||
if(is_array($secret)) {
|
||||
if (is_array($secret)) {
|
||||
$secret = '';
|
||||
}
|
||||
|
||||
return (bool) Google2FA::verifyKey((string) $secret, $value);
|
||||
return (bool)Google2FA::verifyKey((string)$secret, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $attribute
|
||||
* @param mixed $value
|
||||
* @param mixed $parameters
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
* @return bool
|
||||
*/
|
||||
public function validateBelongsToUser($attribute, $value, $parameters): bool
|
||||
@ -102,7 +103,7 @@ class FireflyValidator extends Validator
|
||||
/**
|
||||
* @param mixed $attribute
|
||||
* @param mixed $value
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
* @return bool
|
||||
*/
|
||||
public function validateBic($attribute, $value): bool
|
||||
@ -122,7 +123,7 @@ class FireflyValidator extends Validator
|
||||
/**
|
||||
* @param mixed $attribute
|
||||
* @param mixed $value
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
* @return bool
|
||||
*/
|
||||
public function validateIban(mixed $attribute, mixed $value): bool
|
||||
@ -186,7 +187,7 @@ class FireflyValidator extends Validator
|
||||
$value = strtoupper($value);
|
||||
|
||||
// replace characters outside of ASCI range.
|
||||
$value = (string) iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $value);
|
||||
$value = (string)iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $value);
|
||||
$search = [' ', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
|
||||
$replace = [
|
||||
'',
|
||||
@ -228,7 +229,8 @@ class FireflyValidator extends Validator
|
||||
}
|
||||
try {
|
||||
$checksum = bcmod($iban, '97');
|
||||
} catch (ValueError $e) { /** @phpstan-ignore-line */
|
||||
} catch (ValueError $e) {
|
||||
/** @phpstan-ignore-line */
|
||||
$message = sprintf('Could not validate IBAN check value "%s" (IBAN "%s")', $iban, $value);
|
||||
app('log')->error($message);
|
||||
app('log')->error($e->getTraceAsString());
|
||||
@ -243,7 +245,7 @@ class FireflyValidator extends Validator
|
||||
* @param mixed $attribute
|
||||
* @param mixed $value
|
||||
* @param mixed $parameters
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
* @return bool
|
||||
*/
|
||||
public function validateLess($attribute, $value, $parameters): bool
|
||||
@ -258,7 +260,7 @@ class FireflyValidator extends Validator
|
||||
* @param mixed $attribute
|
||||
* @param mixed $value
|
||||
* @param mixed $parameters
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
* @return bool
|
||||
*/
|
||||
public function validateMore($attribute, $value, $parameters): bool
|
||||
@ -273,7 +275,7 @@ class FireflyValidator extends Validator
|
||||
* @param mixed $attribute
|
||||
* @param mixed $value
|
||||
* @param mixed $parameters
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
* @return bool
|
||||
*/
|
||||
public function validateMustExist($attribute, $value, $parameters): bool
|
||||
@ -444,7 +446,7 @@ class FireflyValidator extends Validator
|
||||
/**
|
||||
* @param mixed $attribute
|
||||
* @param mixed $value
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
* @return bool
|
||||
*/
|
||||
public function validateSecurePassword($attribute, $value): bool
|
||||
@ -467,6 +469,7 @@ class FireflyValidator extends Validator
|
||||
* @param mixed $attribute
|
||||
* @param mixed $value
|
||||
* @param mixed $parameters
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@ -624,6 +627,7 @@ class FireflyValidator extends Validator
|
||||
* @param mixed $attribute
|
||||
* @param mixed $value
|
||||
* @param mixed $parameters
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@ -676,10 +680,11 @@ class FireflyValidator extends Validator
|
||||
/**
|
||||
* @param string|null $attribute
|
||||
* @param string|null $value
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function validateUniqueCurrencyCode(string|null $attribute, string|null $value): bool
|
||||
public function validateUniqueCurrencyCode(string | null $attribute, string | null $value): bool
|
||||
{
|
||||
return $this->validateUniqueCurrency('code', (string)$attribute, (string)$value);
|
||||
}
|
||||
@ -688,6 +693,7 @@ class FireflyValidator extends Validator
|
||||
* @param string $field
|
||||
* @param string $attribute
|
||||
* @param string $value
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@ -702,7 +708,7 @@ class FireflyValidator extends Validator
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function validateUniqueCurrencyName(string|null $attribute, string|null $value): bool
|
||||
public function validateUniqueCurrencyName(string | null $attribute, string | null $value): bool
|
||||
{
|
||||
return $this->validateUniqueCurrency('name', (string)$attribute, (string)$value);
|
||||
}
|
||||
@ -713,7 +719,7 @@ class FireflyValidator extends Validator
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function validateUniqueCurrencySymbol(string|null $attribute, string|null $value): bool
|
||||
public function validateUniqueCurrencySymbol(string | null $attribute, string | null $value): bool
|
||||
{
|
||||
return $this->validateUniqueCurrency('symbol', (string)$attribute, (string)$value);
|
||||
}
|
||||
@ -722,6 +728,7 @@ class FireflyValidator extends Validator
|
||||
* @param mixed $value
|
||||
* @param mixed $parameters
|
||||
* @param mixed $something
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@ -777,6 +784,7 @@ class FireflyValidator extends Validator
|
||||
* @param mixed $attribute
|
||||
* @param mixed $value
|
||||
* @param mixed $parameters
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@ -809,6 +817,7 @@ class FireflyValidator extends Validator
|
||||
* @param mixed $attribute
|
||||
* @param mixed $value
|
||||
* @param mixed $parameters
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@ -830,6 +839,7 @@ class FireflyValidator extends Validator
|
||||
* @param mixed $attribute
|
||||
* @param mixed $value
|
||||
* @param mixed $parameters
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@ -849,6 +859,7 @@ class FireflyValidator extends Validator
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @param mixed $parameters
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
|
@ -488,7 +488,7 @@ trait TransactionValidation
|
||||
*/
|
||||
private function getTransactionType(TransactionGroup $group, array $transactions): string
|
||||
{
|
||||
return $transactions[0]['type'] ?? strtolower($group->transactionJournals()->first()->transactionType->type);
|
||||
return $transactions[0]['type'] ?? strtolower((string) $group->transactionJournals()->first()?->transactionType->type);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -502,13 +502,13 @@ trait TransactionValidation
|
||||
if (1 === $transactionGroup->transactionJournals->count()) {
|
||||
$journal = $transactionGroup->transactionJournals->first();
|
||||
|
||||
return $journal->transactions()->where('amount', '<', 0)->first()->account;
|
||||
return $journal?->transactions()->where('amount', '<', 0)->first()?->account;
|
||||
}
|
||||
/** @var TransactionJournal $journal */
|
||||
foreach ($transactionGroup->transactionJournals as $journal) {
|
||||
$journalId = (int)($transaction['transaction_journal_id'] ?? 0);
|
||||
if ($journal->id === $journalId) {
|
||||
return $journal->transactions()->where('amount', '<', 0)->first()->account;
|
||||
return $journal->transactions()->where('amount', '<', 0)->first()?->account;
|
||||
}
|
||||
}
|
||||
|
||||
@ -785,7 +785,7 @@ trait TransactionValidation
|
||||
}
|
||||
/** @var Transaction|null $destination */
|
||||
$destination = Transaction::where('transaction_journal_id', $journalId)->where('amount', '>', 0)->with(['account'])->first();
|
||||
if (null !== $source) {
|
||||
if (null !== $destination) {
|
||||
$return['destination_id'] = $destination->account_id;
|
||||
$return['destination_name'] = $destination->account->name;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user