Fix various phpstan issues.

This commit is contained in:
James Cole 2025-01-03 14:56:06 +01:00
parent a8ae496fda
commit 394d0eabef
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80
42 changed files with 133 additions and 181 deletions

View File

@ -126,7 +126,7 @@ class ApplyRules extends Command
$ruleEngine->addOperator(['type' => 'account_id', 'value' => $list]);
// add the date as a filter:
$ruleEngine->addOperator(['type' => 'date_after', 'value' => $this->start_date->format('Y-m-d')]);
$ruleEngine->addOperator(['type' => 'date_after', 'value' => $this->startDate->format('Y-m-d')]);
$ruleEngine->addOperator(['type' => 'date_before', 'value' => $this->endDate->format('Y-m-d')]);
// start running rules.
@ -227,7 +227,7 @@ class ApplyRules extends Command
foreach ($ruleGroupList as $ruleGroupId) {
$ruleGroup = $this->ruleGroupRepository->find((int) $ruleGroupId);
if ($ruleGroup->active) {
if (true === $ruleGroup->active) {
$this->ruleGroupSelection[] = $ruleGroup->id;
}
if (false === $ruleGroup->active) {
@ -249,7 +249,7 @@ class ApplyRules extends Command
foreach ($ruleList as $ruleId) {
$rule = $this->ruleRepository->find((int) $ruleId);
if (null !== $rule && $rule->active) {
if (null !== $rule && true === $rule->active) {
$this->ruleSelection[] = $rule->id;
}
}
@ -294,7 +294,7 @@ class ApplyRules extends Command
[$inputEnd, $inputStart] = [$inputStart, $inputEnd];
}
$this->start_date = $inputStart;
$this->startDate = $inputStart;
$this->endDate = $inputEnd;
}

View File

@ -43,7 +43,7 @@ class RepairsAccountBalances extends Command
return 0;
}
if (config('firefly.feature_flags.running_balance_column')) {
if (true === config('firefly.feature_flags.running_balance_column')) {
$this->friendlyInfo('Will recalculate account balances. This may take a LONG time. Please be patient.');
$this->markAsExecuted();
$this->correctBalanceAmounts();

View File

@ -95,7 +95,7 @@ class UpgradesCurrencyPreferences extends Command
/** @var TransactionCurrency $currency */
foreach ($currencies as $currency) {
if ($currency->enabled) {
if (true === $currency->enabled) {
$enabled->push($currency);
}
}
@ -109,7 +109,7 @@ class UpgradesCurrencyPreferences extends Command
/** @var TransactionCurrency $currency */
foreach ($currencies as $currency) {
if ($currency->enabled) {
if (true === $currency->enabled) {
$enabled->push($currency);
}
}

View File

@ -87,17 +87,6 @@ class Handler extends ExceptionHandler
app('log')->debug('Now in Handler::render()');
if ($e instanceof JsonApiException) {
// ignore it: controller will handle it.
app('log')->debug(sprintf(
'Return to parent to handle JsonApiException(%d)',
$e->getCode()
));
return parent::render($request, $e);
}
if ($e instanceof LaravelValidationException && $expectsJson) {
// ignore it: controller will handle it.

View File

@ -174,7 +174,7 @@ class TransactionJournalFactory
// 2024-11-19, overrule timezone with UTC and store it as UTC.
if (FireflyConfig::get('utc', false)->data) {
if (true === FireflyConfig::get('utc', false)->data) {
$carbon->setTimezone('UTC');
}
// $carbon->setTimezone('UTC');

View File

@ -40,7 +40,7 @@ class TransactionObserver
{
Log::debug('Observe "created" of a transaction.');
if (config('firefly.feature_flags.running_balance_column')) {
if (1 === bccomp($transaction->amount, '0') && self::$recalculate) {
if (1 === bccomp($transaction->amount, '0') && true === self::$recalculate) {
Log::debug('Trigger recalculateForJournal');
AccountBalanceCalculator::recalculateForJournal($transaction->transactionJournal);
}
@ -57,7 +57,7 @@ class TransactionObserver
public function updated(Transaction $transaction): void
{
// Log::debug('Observe "updated" of a transaction.');
if (config('firefly.feature_flags.running_balance_column') && self::$recalculate) {
if (config('firefly.feature_flags.running_balance_column') && true === self::$recalculate) {
if (1 === bccomp($transaction->amount, '0')) {
Log::debug('Trigger recalculateForJournal');
AccountBalanceCalculator::recalculateForJournal($transaction->transactionJournal);

View File

@ -88,7 +88,7 @@ class LinkController extends Controller
*/
public function delete(Request $request, LinkType $linkType)
{
if (!$linkType->editable) {
if (false === $linkType->editable) {
$request->session()->flash('error', (string) trans('firefly.cannot_edit_link_type', ['name' => e($linkType->name)]));
return redirect(route('admin.links.index'));
@ -139,7 +139,7 @@ class LinkController extends Controller
*/
public function edit(Request $request, LinkType $linkType)
{
if (!$linkType->editable) {
if (false === $linkType->editable) {
$request->session()->flash('error', (string) trans('firefly.cannot_edit_link_type', ['name' => e($linkType->name)]));
return redirect(route('admin.links.index'));
@ -231,7 +231,7 @@ class LinkController extends Controller
*/
public function update(LinkTypeFormRequest $request, LinkType $linkType)
{
if (!$linkType->editable) {
if (false === $linkType->editable) {
$request->session()->flash('error', (string) trans('firefly.cannot_edit_link_type', ['name' => e($linkType->name)]));
return redirect(route('admin.links.index'));

View File

@ -57,7 +57,7 @@ class NotificationController extends Controller
// admin notification settings:
$notifications = [];
foreach (config('notifications.notifications.owner') as $key => $info) {
if ($info['enabled']) {
if (true === $info['enabled']) {
$notifications[$key] = app('fireflyconfig')->get(sprintf('notification_%s', $key), true)->data;
}
}

View File

@ -85,7 +85,7 @@ class UserController extends Controller
public function deleteInvite(InvitedUser $invitedUser): JsonResponse
{
app('log')->debug('Will now delete invitation');
if ($invitedUser->redeemed) {
if (true === $invitedUser->redeemed) {
app('log')->debug('Is already redeemed.');
session()->flash('error', trans('firefly.invite_is_already_redeemed', ['address' => $invitedUser->email]));

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Budget;
use FireflyIII\Enums\AutoBudgetType;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
use FireflyIII\Http\Controllers\Controller;
@ -74,9 +75,9 @@ class CreateController extends Controller
// auto budget types
$autoBudgetTypes = [
0 => (string) trans('firefly.auto_budget_none'),
AutoBudget::AUTO_BUDGET_RESET => (string) trans('firefly.auto_budget_reset'),
AutoBudget::AUTO_BUDGET_ROLLOVER => (string) trans('firefly.auto_budget_rollover'),
AutoBudget::AUTO_BUDGET_ADJUSTED => (string) trans('firefly.auto_budget_adjusted'),
AutoBudgetType::AUTO_BUDGET_RESET->value => (string) trans('firefly.auto_budget_reset'),
AutoBudgetType::AUTO_BUDGET_ROLLOVER->value => (string) trans('firefly.auto_budget_rollover'),
AutoBudgetType::AUTO_BUDGET_ADJUSTED->value => (string) trans('firefly.auto_budget_adjusted'),
];
$autoBudgetPeriods = [
'daily' => (string) trans('firefly.auto_budget_period_daily'),

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Budget;
use FireflyIII\Enums\AutoBudgetType;
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Requests\BudgetFormUpdateRequest;
@ -76,9 +77,9 @@ class EditController extends Controller
// auto budget types
$autoBudgetTypes = [
0 => (string) trans('firefly.auto_budget_none'),
AutoBudget::AUTO_BUDGET_RESET => (string) trans('firefly.auto_budget_reset'),
AutoBudget::AUTO_BUDGET_ROLLOVER => (string) trans('firefly.auto_budget_rollover'),
AutoBudget::AUTO_BUDGET_ADJUSTED => (string) trans('firefly.auto_budget_adjusted'),
AutoBudgetType::AUTO_BUDGET_RESET->value => (string) trans('firefly.auto_budget_reset'),
AutoBudgetType::AUTO_BUDGET_ROLLOVER->value => (string) trans('firefly.auto_budget_rollover'),
AutoBudgetType::AUTO_BUDGET_ADJUSTED->value => (string) trans('firefly.auto_budget_adjusted'),
];
$autoBudgetPeriods = [
'daily' => (string) trans('firefly.auto_budget_period_daily'),

View File

@ -247,7 +247,7 @@ class DebugController extends Controller
private function getBuildInfo(): array
{
$return = [
'is_docker' => env('IS_DOCKER', false),
'is_docker' => env('IS_DOCKER', false), // @phpstan-ignore-line
'build' => '(unknown)',
'build_date' => '(unknown)',
'base_build' => '(unknown)',
@ -272,11 +272,11 @@ class DebugController extends Controller
app('log')->debug('Could not check build date, but thats ok.');
app('log')->warning($e->getMessage());
}
if ('' !== (string) env('BASE_IMAGE_BUILD')) {
$return['base_build'] = env('BASE_IMAGE_BUILD');
if ('' !== (string) env('BASE_IMAGE_BUILD')) { // @phpstan-ignore-line
$return['base_build'] = env('BASE_IMAGE_BUILD'); // @phpstan-ignore-line
}
if ('' !== (string) env('BASE_IMAGE_DATE')) {
$return['base_build_date'] = env('BASE_IMAGE_DATE');
if ('' !== (string) env('BASE_IMAGE_DATE')) { // @phpstan-ignore-line
$return['base_build_date'] = env('BASE_IMAGE_DATE'); // @phpstan-ignore-line
}
return $return;

View File

@ -47,7 +47,7 @@ class IndexController extends Controller
return $next($request);
}
);
if (!config('cer.enabled')) {
if (false === config('cer.enabled')) {
throw new NotFoundHttpException();
}
}

View File

@ -124,10 +124,10 @@ class ReconcileController extends Controller
Log::debug(sprintf('End balance: "%s"', $endBalance));
Log::debug(sprintf('Cleared amount: "%s"', $clearedAmount));
Log::debug(sprintf('Amount: "%s"', $amount));
$difference = bcadd(bcadd(bcsub($startBalance ?? '0', $endBalance ?? '0'), $clearedAmount ?? '0'), $amount);
$difference = bcadd(bcadd(bcsub($startBalance ?? '0', $endBalance ?? '0'), $clearedAmount), $amount);
$diffCompare = bccomp($difference, '0');
$countCleared = count($clearedJournals);
$reconSum = bcadd(bcadd($startBalance ?? '0', $amount ?? '0'), $clearedAmount ?? '0');
$reconSum = bcadd(bcadd($startBalance ?? '0', $amount), $clearedAmount);
try {
$view = view('accounts.reconcile.overview', compact('account', 'start', 'diffCompare', 'difference', 'end', 'clearedAmount', 'startBalance', 'endBalance', 'amount', 'route', 'countCleared', 'reconSum', 'selectedIds'))->render();

View File

@ -72,7 +72,7 @@ class PreferencesController extends Controller
public function index(AccountRepositoryInterface $repository)
{
$accounts = $repository->getAccountsByType([AccountTypeEnum::DEFAULT->value, AccountTypeEnum::ASSET->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value]);
$isDocker = env('IS_DOCKER', false);
$isDocker = env('IS_DOCKER', false); // @phpstan-ignore-line
$groupedAccounts = [];
/** @var Account $account */
@ -129,10 +129,10 @@ class PreferencesController extends Controller
// notification preferences
$notifications = [];
foreach (config('notifications.notifications.user') as $key => $info) {
if ($info['enabled']) {
if (true === $info['enabled']) {
$notifications[$key]
= [
'enabled' => app('preferences')->get(sprintf('notification_%s', $key), true)->data,
'enabled' => true === app('preferences')->get(sprintf('notification_%s', $key), true)->data,
'configurable' => $info['configurable'],
];
}

View File

@ -215,7 +215,7 @@ class MfaController extends Controller
$domain = $this->getDomain();
$secret = \Google2FA::generateSecretKey();
$image = \Google2FA::getQRCodeInline($domain, auth()->user()->email, (string) $secret);
$image = \Google2FA::getQRCodeInline($domain, auth()->user()->email, $secret);
app('preferences')->set('temp-mfa-secret', $secret);

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Recurring;
use FireflyIII\Enums\RecurrenceRepetitionWeekend;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
use FireflyIII\Http\Controllers\Controller;
@ -100,10 +101,10 @@ class CreateController extends Controller
'times' => (string) trans('firefly.repeat_times'),
];
$weekendResponses = [
RecurrenceRepetition::WEEKEND_DO_NOTHING => (string) trans('firefly.do_nothing'),
RecurrenceRepetition::WEEKEND_SKIP_CREATION => (string) trans('firefly.skip_transaction'),
RecurrenceRepetition::WEEKEND_TO_FRIDAY => (string) trans('firefly.jump_to_friday'),
RecurrenceRepetition::WEEKEND_TO_MONDAY => (string) trans('firefly.jump_to_monday'),
RecurrenceRepetitionWeekend::WEEKEND_DO_NOTHING->value => (string) trans('firefly.do_nothing'),
RecurrenceRepetitionWeekend::WEEKEND_SKIP_CREATION->value => (string) trans('firefly.skip_transaction'),
RecurrenceRepetitionWeekend::WEEKEND_TO_FRIDAY->value => (string) trans('firefly.jump_to_friday'),
RecurrenceRepetitionWeekend::WEEKEND_TO_MONDAY->value => (string) trans('firefly.jump_to_monday'),
];
$hasOldInput = null !== $request->old('_token'); // flash some data
$preFilled = [
@ -145,10 +146,10 @@ class CreateController extends Controller
'times' => (string) trans('firefly.repeat_times'),
];
$weekendResponses = [
RecurrenceRepetition::WEEKEND_DO_NOTHING => (string) trans('firefly.do_nothing'),
RecurrenceRepetition::WEEKEND_SKIP_CREATION => (string) trans('firefly.skip_transaction'),
RecurrenceRepetition::WEEKEND_TO_FRIDAY => (string) trans('firefly.jump_to_friday'),
RecurrenceRepetition::WEEKEND_TO_MONDAY => (string) trans('firefly.jump_to_monday'),
RecurrenceRepetitionWeekend::WEEKEND_DO_NOTHING->value => (string) trans('firefly.do_nothing'),
RecurrenceRepetitionWeekend::WEEKEND_SKIP_CREATION->value => (string) trans('firefly.skip_transaction'),
RecurrenceRepetitionWeekend::WEEKEND_TO_FRIDAY->value => (string) trans('firefly.jump_to_friday'),
RecurrenceRepetitionWeekend::WEEKEND_TO_MONDAY->value => (string) trans('firefly.jump_to_monday'),
];
// fill prefilled with journal info

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Recurring;
use FireflyIII\Enums\RecurrenceRepetitionWeekend;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
use FireflyIII\Http\Controllers\Controller;
@ -126,10 +127,10 @@ class EditController extends Controller
}
$weekendResponses = [
RecurrenceRepetition::WEEKEND_DO_NOTHING => (string) trans('firefly.do_nothing'),
RecurrenceRepetition::WEEKEND_SKIP_CREATION => (string) trans('firefly.skip_transaction'),
RecurrenceRepetition::WEEKEND_TO_FRIDAY => (string) trans('firefly.jump_to_friday'),
RecurrenceRepetition::WEEKEND_TO_MONDAY => (string) trans('firefly.jump_to_monday'),
RecurrenceRepetitionWeekend::WEEKEND_DO_NOTHING->value => (string) trans('firefly.do_nothing'),
RecurrenceRepetitionWeekend::WEEKEND_SKIP_CREATION->value => (string) trans('firefly.skip_transaction'),
RecurrenceRepetitionWeekend::WEEKEND_TO_FRIDAY->value => (string) trans('firefly.jump_to_friday'),
RecurrenceRepetitionWeekend::WEEKEND_TO_MONDAY->value => (string) trans('firefly.jump_to_monday'),
];
$hasOldInput = null !== $request->old('_token');

View File

@ -65,7 +65,7 @@ class SecureHeaders
];
// overrule in development mode
if (true === env('IS_LOCAL_DEV')) {
if (true === env('IS_LOCAL_DEV')) { // @phpstan-ignore-line
$csp = [
"default-src 'none'",
"object-src 'none'",

View File

@ -25,6 +25,7 @@ declare(strict_types=1);
namespace FireflyIII\Jobs;
use Carbon\Carbon;
use FireflyIII\Enums\AutoBudgetType;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\AutoBudget;
use FireflyIII\Models\Budget;
@ -126,7 +127,7 @@ class CreateAutoBudgetLimits implements ShouldQueue
// find budget limit:
$budgetLimit = $this->findBudgetLimit($autoBudget->budget, $start, $end);
if (null === $budgetLimit && AutoBudget::AUTO_BUDGET_RESET === (int) $autoBudget->auto_budget_type) {
if (null === $budgetLimit && AutoBudgetType::AUTO_BUDGET_RESET->value === (int) $autoBudget->auto_budget_type) {
// that's easy: create one.
// do nothing else.
$this->createBudgetLimit($autoBudget, $start, $end);
@ -135,14 +136,14 @@ class CreateAutoBudgetLimits implements ShouldQueue
return;
}
if (null === $budgetLimit && AutoBudget::AUTO_BUDGET_ROLLOVER === (int) $autoBudget->auto_budget_type) {
if (null === $budgetLimit && AutoBudgetType::AUTO_BUDGET_ROLLOVER->value === (int) $autoBudget->auto_budget_type) {
// budget limit exists already,
$this->createRollover($autoBudget);
app('log')->debug(sprintf('Done with auto budget #%d', $autoBudget->id));
return;
}
if (null === $budgetLimit && AutoBudget::AUTO_BUDGET_ADJUSTED === (int) $autoBudget->auto_budget_type) {
if (null === $budgetLimit && AutoBudgetType::AUTO_BUDGET_ADJUSTED->value === (int) $autoBudget->auto_budget_type) {
// budget limit exists already,
$this->createAdjustedLimit($autoBudget);
app('log')->debug(sprintf('Done with auto budget #%d', $autoBudget->id));

View File

@ -37,17 +37,17 @@ class PiggyBankEvent extends Model
use ReturnsIntegerIdTrait;
protected $casts
= [
'created_at' => 'datetime',
'updated_at' => 'datetime',
'date' => SeparateTimezoneCaster::class,
'amount' => 'string',
'amount' => 'native_string',
= [
'created_at' => 'datetime',
'updated_at' => 'datetime',
'date' => SeparateTimezoneCaster::class,
'amount' => 'string',
'native_amount' => 'string',
];
protected $fillable = ['piggy_bank_id', 'transaction_journal_id', 'date', 'date_tz', 'amount', 'native_amount'];
protected $hidden = ['amount_encrypted'];
protected $hidden = ['amount_encrypted'];
public function piggyBank(): BelongsTo
{
@ -73,14 +73,14 @@ class PiggyBankEvent extends Model
protected function amount(): Attribute
{
return Attribute::make(
get: static fn ($value) => (string) $value,
get: static fn($value) => (string) $value,
);
}
protected function piggyBankId(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int) $value,
get: static fn($value) => (int) $value,
);
}
}

View File

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
@ -86,22 +87,22 @@ class TransactionType extends Model
public function isDeposit(): bool
{
return self::DEPOSIT === $this->type;
return TransactionTypeEnum::DEPOSIT->value === $this->type;
}
public function isOpeningBalance(): bool
{
return self::OPENING_BALANCE === $this->type;
return TransactionTypeEnum::OPENING_BALANCE->value === $this->type;
}
public function isTransfer(): bool
{
return self::TRANSFER === $this->type;
return TransactionTypeEnum::TRANSFER->value === $this->type;
}
public function isWithdrawal(): bool
{
return self::WITHDRAWAL === $this->type;
return TransactionTypeEnum::WITHDRAWAL->value === $this->type;
}
public function transactionJournals(): HasMany

View File

@ -69,7 +69,7 @@ class ReturnsSettings
config(['ntfy-notification-channel.server' => $settings['ntfy_server']]);
config(['ntfy-notification-channel.topic' => $settings['ntfy_topic']]);
if ($settings['ntfy_auth']) {
if (true === $settings['ntfy_auth']) {
// overrule auth as well.
config(['ntfy-notification-channel.authentication.enabled' => true]);
config(['ntfy-notification-channel.authentication.username' => $settings['ntfy_user']]);

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Repositories\Budget;
use Carbon\Carbon;
use FireflyIII\Enums\AutoBudgetType;
use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
@ -760,13 +761,13 @@ class BudgetRepository implements BudgetRepositoryInterface
}
if ('reset' === $type) {
$type = AutoBudget::AUTO_BUDGET_RESET;
$type = AutoBudgetType::AUTO_BUDGET_RESET->value;
}
if ('rollover' === $type) {
$type = AutoBudget::AUTO_BUDGET_ROLLOVER;
$type = AutoBudgetType::AUTO_BUDGET_ROLLOVER->value;
}
if ('adjusted' === $type) {
$type = AutoBudget::AUTO_BUDGET_ADJUSTED;
$type = AutoBudgetType::AUTO_BUDGET_ADJUSTED->value;
}
/** @var CurrencyRepositoryInterface $repos */

View File

@ -492,7 +492,7 @@ class JournalUpdateService
$value->setTimezone(config('app.timezone'));
// 2024-11-22, overrule timezone with UTC and store it as UTC.
if (FireflyConfig::get('utc', false)->data) {
if (true === FireflyConfig::get('utc', false)->data) {
$value->setTimezone('UTC');
}
@ -770,6 +770,4 @@ class JournalUpdateService
$this->sourceTransaction->refresh();
$this->destinationTransaction->refresh();
}
private function collectCurrency(): TransactionCurrency {}
}

View File

@ -71,11 +71,11 @@ class Amount
public function convertToNative(?User $user = null): bool
{
if (null === $user) {
return Preferences::get('convert_to_native', false)->data && config('cer.enabled');
return true === Preferences::get('convert_to_native', false)->data && true === config('cer.enabled');
// Log::debug(sprintf('convertToNative [a]: %s', var_export($result, true)));
}
return Preferences::getForUser($user, 'convert_to_native', false)->data && config('cer.enabled');
return true === Preferences::getForUser($user, 'convert_to_native', false)->data && true === config('cer.enabled');
// Log::debug(sprintf('convertToNative [b]: %s', var_export($result, true)));
}

View File

@ -27,6 +27,7 @@ namespace FireflyIII\Support\Chart\Category;
use Carbon\Carbon;
use FireflyIII\Enums\AccountTypeEnum;
use FireflyIII\Models\Category;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
use FireflyIII\Repositories\Category\NoCategoryRepositoryInterface;
@ -48,6 +49,8 @@ class FrontpageChartGenerator
private NoCategoryRepositoryInterface $noCatRepos;
private OperationsRepositoryInterface $opsRepos;
private CategoryRepositoryInterface $repository;
public bool $convertToNative = false;
public TransactionCurrency $defaultCurrency;
private Carbon $start;
/**

View File

@ -40,11 +40,10 @@ trait GetConfigurationData
{
$array = [
-1 => 'ALL errors',
E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED => 'E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED',
E_ALL & ~E_NOTICE & ~E_DEPRECATED => 'E_ALL & ~E_NOTICE & ~E_DEPRECATED',
E_ALL => 'E_ALL',
E_ALL & ~E_DEPRECATED & ~E_STRICT => 'E_ALL & ~E_DEPRECATED & ~E_STRICT',
E_ALL & ~E_DEPRECATED => 'E_ALL & ~E_DEPRECATED ',
E_ALL & ~E_NOTICE => 'E_ALL & ~E_NOTICE',
E_ALL & ~E_NOTICE & ~E_STRICT => 'E_ALL & ~E_NOTICE & ~E_STRICT',
E_COMPILE_ERROR | E_RECOVERABLE_ERROR | E_ERROR | E_CORE_ERROR => 'E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR',
];

View File

@ -96,7 +96,13 @@ class TransactionSummarizer
'currency_code' => $currencyCode,
'currency_decimal_places' => $currencyDecimalPlaces,
];
$array[$currencyId]['sum'] = bcadd($array[$currencyId]['sum'], app('steam')->{$method}($amount));
if('positive' === $method) {
$array[$currencyId]['sum'] = bcadd($array[$currencyId]['sum'], app('steam')->positive($amount));
}
if('negative' === $method) {
$array[$currencyId]['sum'] = bcadd($array[$currencyId]['sum'], app('steam')->negative($amount));
}
// $array[$currencyId]['sum'] = bcadd($array[$currencyId]['sum'], app('steam')->{$method}($amount));
// Log::debug(sprintf('Journal #%d adds amount %s %s', $journal['transaction_journal_id'], $currencyCode, $amount));
}
Log::debug('End of sumExpenses.', $array);

View File

@ -25,6 +25,7 @@ declare(strict_types=1);
namespace FireflyIII\Support\Repositories\Recurring;
use Carbon\Carbon;
use FireflyIII\Enums\RecurrenceRepetitionWeekend;
use FireflyIII\Models\RecurrenceRepetition;
use Illuminate\Support\Collection;
@ -39,7 +40,7 @@ trait FiltersWeekends
protected function filterWeekends(RecurrenceRepetition $repetition, array $dates): array
{
app('log')->debug(sprintf('Now in %s', __METHOD__));
if (RecurrenceRepetition::WEEKEND_DO_NOTHING === $repetition->weekend) {
if (RecurrenceRepetitionWeekend::WEEKEND_DO_NOTHING->value === $repetition->weekend) {
app('log')->debug('Repetition will not be filtered on weekend days.');
return $dates;
@ -57,7 +58,7 @@ trait FiltersWeekends
}
// is weekend and must set back to Friday?
if (RecurrenceRepetition::WEEKEND_TO_FRIDAY === $repetition->weekend) {
if (RecurrenceRepetitionWeekend::WEEKEND_TO_FRIDAY->value === $repetition->weekend) {
$clone = clone $date;
$clone->addDays(5 - $date->dayOfWeekIso);
app('log')->debug(
@ -69,7 +70,7 @@ trait FiltersWeekends
}
// postpone to Monday?
if (RecurrenceRepetition::WEEKEND_TO_MONDAY === $repetition->weekend) {
if (RecurrenceRepetitionWeekend::WEEKEND_TO_MONDAY->value === $repetition->weekend) {
$clone = clone $date;
$clone->addDays(8 - $date->dayOfWeekIso);
app('log')->debug(

View File

@ -235,7 +235,7 @@ class UpdatePiggybank implements ActionInterface
return true;
}
}
Log::debug(sprintf('Piggy bank is not connected to account #%d "%s"', $account->id, $account->name));
Log::debug(sprintf('Piggy bank is not connected to account #%d "%s"', $link?->id, $link?->name));
return false;
}

View File

@ -277,7 +277,7 @@ class SearchRuleEngine implements RuleEngineInterface
app('log')->debug(sprintf('Total collection is now %d transactions', $total->count()));
++$count;
// if trigger says stop processing, do so.
if ($ruleTrigger->stop_processing && $result->count() > 0) {
if (true === $ruleTrigger->stop_processing && $result->count() > 0) {
app('log')->debug('The trigger says to stop processing, so stop processing other triggers.');
break;
@ -319,10 +319,10 @@ class SearchRuleEngine implements RuleEngineInterface
/** @var Rule $rule */
foreach ($this->rules as $rule) {
$result = $this->fireRule($rule);
if (true === $result && $rule->stop_processing) {
if (true === $result && true === $rule->stop_processing) {
app('log')->debug(sprintf('Rule #%d has triggered and executed, but calls to stop processing. Since not in the context of a group, do not stop.', $rule->id));
}
if (false === $result && $rule->stop_processing) {
if (false === $result && true === $rule->stop_processing) {
app('log')->debug(sprintf('Rule #%d has triggered and changed nothing, but calls to stop processing. Do not stop.', $rule->id));
}
}
@ -461,12 +461,12 @@ class SearchRuleEngine implements RuleEngineInterface
}
// pick up from the action if it actually acted or not:
if ($ruleAction->stop_processing && true === $result) {
if (true === $ruleAction->stop_processing && true === $result) {
app('log')->debug(sprintf('Rule action "%s" reports changes AND asks to break, so break!', $ruleAction->action_type));
return true;
}
if ($ruleAction->stop_processing && false === $result) {
if (true === $ruleAction->stop_processing && false === $result) {
app('log')->debug(sprintf('Rule action "%s" reports NO changes AND asks to break, but we wont break!', $ruleAction->action_type));
}

View File

@ -59,7 +59,7 @@ class BillTransformer extends AbstractTransformer
*/
public function transform(Bill $bill): array
{
$defaultCurrency = $this->parameters->get('defaultCurrency') ?? Amount::getDefaultCurrency();
$defaultCurrency = $this->parameters->get('defaultCurrency') ?? app('amount')->getDefaultCurrency();
$paidData = $this->paidData($bill);
$lastPaidDate = $this->getLastPaidDate($paidData);

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Transformers;
use FireflyIII\Enums\AutoBudgetType;
use FireflyIII\Models\AutoBudget;
use FireflyIII\Models\Budget;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
@ -71,9 +72,9 @@ class BudgetTransformer extends AbstractTransformer
$notes = $this->repository->getNoteText($budget);
$types = [
AutoBudget::AUTO_BUDGET_RESET => 'reset',
AutoBudget::AUTO_BUDGET_ROLLOVER => 'rollover',
AutoBudget::AUTO_BUDGET_ADJUSTED => 'adjusted',
AutoBudgetType::AUTO_BUDGET_RESET->value => 'reset',
AutoBudgetType::AUTO_BUDGET_ROLLOVER->value => 'rollover',
AutoBudgetType::AUTO_BUDGET_ADJUSTED->value => 'adjusted',
];
if (null !== $autoBudget) {

View File

@ -48,6 +48,7 @@ class AccountTransformer extends AbstractTransformer
private array $fullTypes;
private array $lastActivity;
private array $objectGroups;
private array $balances;
/**
* This method collects meta-data for one or all accounts in the transformer's collection.
@ -55,6 +56,7 @@ class AccountTransformer extends AbstractTransformer
public function collectMetaData(Collection $objects): Collection
{
$this->currencies = [];
$this->balances = [];
$this->accountMeta = [];
$this->accountTypes = [];
$this->fullTypes = [];

View File

@ -56,10 +56,10 @@ class TransactionGroupTransformer extends AbstractTransformer
// private array $currencies = [];
// private array $transactionTypes = [];
// private array $meta = [];
// private array $notes = [];
private array $meta = [];
private array $notes = [];
// private array $locations = [];
// private array $tags = [];
private array $tags = [];
// private array $amounts = [];
// private array $foreignAmounts = [];
// private array $journalCurrencies = [];

View File

@ -77,7 +77,7 @@ class FireflyValidator extends Validator
}
$secret = (string) $secret;
return (bool) \Google2FA::verifyKey((string) $secret, $value);
return (bool) \Google2FA::verifyKey($secret, $value);
}
/**
@ -823,7 +823,7 @@ class FireflyValidator extends Validator
}
$query->where('piggy_banks.name', $value);
return 0 === $query->get(['piggy_banks.*'])->count();
return 0 === $query->count(['piggy_banks.*']);
}
/**

View File

@ -43,7 +43,7 @@ if (!function_exists('envNonEmpty')) {
*/
function envNonEmpty(string $key, string | int | bool | null $default = null)
{
$result = env($key, $default);
$result = env($key, $default); // @phpstan-ignore-line
if ('' === $result) {
$result = $default;
}

View File

@ -1,56 +0,0 @@
<?php
/*
* jsonapi.php
* Copyright (c) 2025 james@firefly-iii.org.
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*/
declare(strict_types=1);
use FireflyIII\JsonApi\V2\Server;
return [
/*
|--------------------------------------------------------------------------
| Root Namespace
|--------------------------------------------------------------------------
|
| The root JSON:API namespace, within your application's namespace.
| This is used when generating any class that does not sit *within*
| a server's namespace. For example, new servers and filters.
|
| By default this is set to `JsonApi` which means the root namespace
| will be `\App\JsonApi`, if your application's namespace is `App`.
*/
'namespace' => 'JsonApi',
/*
|--------------------------------------------------------------------------
| Servers
|--------------------------------------------------------------------------
|
| A list of the JSON:API compliant APIs in your application, referred to
| as "servers". They must be listed below, with the array key being the
| unique name for each server, and the value being the fully-qualified
| class name of the server class.
*/
'servers' => [
'v2' => Server::class,
],
];

View File

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace Database\Seeders;
use FireflyIII\Enums\AccountTypeEnum;
use FireflyIII\Models\AccountType;
use Illuminate\Database\Seeder;
@ -34,19 +35,19 @@ class AccountTypeSeeder extends Seeder
public function run(): void
{
$types = [
AccountType::DEFAULT,
AccountType::CASH,
AccountType::ASSET,
AccountType::EXPENSE,
AccountType::REVENUE,
AccountType::INITIAL_BALANCE,
AccountType::BENEFICIARY,
AccountType::IMPORT,
AccountType::LOAN,
AccountType::RECONCILIATION,
AccountType::DEBT,
AccountType::MORTGAGE,
AccountType::LIABILITY_CREDIT,
AccountTypeEnum::DEFAULT->value,
AccountTypeEnum::CASH->value,
AccountTypeEnum::ASSET->value,
AccountTypeEnum::EXPENSE->value,
AccountTypeEnum::REVENUE->value,
AccountTypeEnum::INITIAL_BALANCE->value,
AccountTypeEnum::BENEFICIARY->value,
AccountTypeEnum::IMPORT->value,
AccountTypeEnum::LOAN->value,
AccountTypeEnum::RECONCILIATION->value,
AccountTypeEnum::DEBT->value,
AccountTypeEnum::MORTGAGE->value,
AccountTypeEnum::LIABILITY_CREDIT->value,
];
foreach ($types as $type) {
if (null === AccountType::where('type', $type)->first()) {

View File

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace Database\Seeders;
use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Models\TransactionType;
use Illuminate\Database\Seeder;
@ -34,13 +35,13 @@ class TransactionTypeSeeder extends Seeder
public function run(): void
{
$types = [
TransactionType::WITHDRAWAL,
TransactionTypeEnum::WITHDRAWAL->value,
TransactionTypeEnum::DEPOSIT->value,
TransactionType::TRANSFER,
TransactionType::OPENING_BALANCE,
TransactionType::RECONCILIATION,
TransactionType::INVALID,
TransactionType::LIABILITY_CREDIT,
TransactionTypeEnum::TRANSFER->value,
TransactionTypeEnum::OPENING_BALANCE->value,
TransactionTypeEnum::RECONCILIATION->value,
TransactionTypeEnum::INVALID->value,
TransactionTypeEnum::LIABILITY_CREDIT->value,
];
foreach ($types as $type) {

View File

@ -40,7 +40,7 @@ Route::group(
// the rest
$guard = config('passport.guard', null);
Route::middleware(['web', $guard ? 'auth:'.$guard : 'auth'])->group(function (): void {
Route::middleware(['web', null !== $guard ? 'auth:'.$guard : 'auth'])->group(function (): void {
Route::post('/token/refresh', ['uses' => 'TransientTokenController@refresh', 'as' => 'token.refresh']);
Route::post('/authorize', ['uses' => 'ApproveAuthorizationController@approve', 'as' => 'authorizations.approve']);
Route::delete('/authorize', ['uses' => 'DenyAuthorizationController@deny', 'as' => 'authorizations.deny']);