mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-30 02:26:58 +00:00
Final set of php8.4 changes.
This commit is contained in:
@@ -193,7 +193,7 @@ class BudgetController extends Controller
|
||||
// var_dump($return);
|
||||
/** @var array $journal */
|
||||
foreach ($currentBudgetArray['transaction_journals'] as $journal) {
|
||||
$return[$currencyId]['spent'] = bcadd($return[$currencyId]['spent'], $journal['amount']);
|
||||
$return[$currencyId]['spent'] = bcadd($return[$currencyId]['spent'], (string) $journal['amount']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,13 +245,13 @@ class BudgetController extends Controller
|
||||
}
|
||||
$result = $this->processExpenses($budget->id, $filtered, $limit->start_date, $end);
|
||||
if (1 === count($result)) {
|
||||
$compare = bccomp($limit->amount, app('steam')->positive($result[$limitCurrencyId]['spent']));
|
||||
$compare = bccomp($limit->amount, (string) app('steam')->positive($result[$limitCurrencyId]['spent']));
|
||||
if (1 === $compare) {
|
||||
// convert this amount into the native currency:
|
||||
$result[$limitCurrencyId]['left'] = bcadd($limit->amount, $result[$limitCurrencyId]['spent']);
|
||||
$result[$limitCurrencyId]['left'] = bcadd($limit->amount, (string) $result[$limitCurrencyId]['spent']);
|
||||
}
|
||||
if ($compare <= 0) {
|
||||
$result[$limitCurrencyId]['overspent'] = app('steam')->positive(bcadd($limit->amount, $result[$limitCurrencyId]['spent']));
|
||||
$result[$limitCurrencyId]['overspent'] = app('steam')->positive(bcadd($limit->amount, (string) $result[$limitCurrencyId]['spent']));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -96,7 +96,7 @@ class CategoryController extends Controller
|
||||
$currencyId = (int) $journal['currency_id'];
|
||||
$currency = $currencies[$currencyId] ?? $this->currencyRepos->find($currencyId);
|
||||
$currencies[$currencyId] = $currency;
|
||||
$categoryName = null === $journal['category_name'] ? (string) trans('firefly.no_category') : $journal['category_name'];
|
||||
$categoryName = $journal['category_name'] ?? (string) trans('firefly.no_category');
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$key = sprintf('%s-%s', $categoryName, $currency->code);
|
||||
// create arrays
|
||||
@@ -114,7 +114,7 @@ class CategoryController extends Controller
|
||||
];
|
||||
|
||||
// add monies
|
||||
$return[$key]['amount'] = bcadd($return[$key]['amount'], $amount);
|
||||
$return[$key]['amount'] = bcadd($return[$key]['amount'], (string) $amount);
|
||||
}
|
||||
$return = array_values($return);
|
||||
|
||||
|
@@ -89,7 +89,7 @@ class ExportController extends Controller
|
||||
->header('Expires', '0')
|
||||
->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0')
|
||||
->header('Pragma', 'public')
|
||||
->header('Content-Length', (string) strlen($data[$key]))
|
||||
->header('Content-Length', (string) strlen((string) $data[$key]))
|
||||
;
|
||||
|
||||
return $response;
|
||||
|
@@ -160,7 +160,7 @@ class TagController extends Controller
|
||||
'currency_id' => (string) $currencyId,
|
||||
'currency_code' => $journal['currency_code'],
|
||||
];
|
||||
$response[$key]['difference'] = bcadd($response[$key]['difference'], $journal['amount']);
|
||||
$response[$key]['difference'] = bcadd((string) $response[$key]['difference'], (string) $journal['amount']);
|
||||
$response[$key]['difference_float'] = (float) $response[$key]['difference']; // float but on purpose.
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ class TagController extends Controller
|
||||
'currency_id' => (string) $foreignCurrencyId,
|
||||
'currency_code' => $journal['foreign_currency_code'],
|
||||
];
|
||||
$response[$foreignKey]['difference'] = bcadd($response[$foreignKey]['difference'], $journal['foreign_amount']);
|
||||
$response[$foreignKey]['difference'] = bcadd((string) $response[$foreignKey]['difference'], (string) $journal['foreign_amount']);
|
||||
$response[$foreignKey]['difference_float'] = (float) $response[$foreignKey]['difference']; // float but on purpose.
|
||||
}
|
||||
}
|
||||
|
@@ -75,7 +75,7 @@ class PeriodController extends Controller
|
||||
'currency_id' => (string) $currencyId,
|
||||
'currency_code' => $currencyCode,
|
||||
];
|
||||
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], app('steam')->positive($journal[$field]));
|
||||
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], (string) app('steam')->positive($journal[$field]));
|
||||
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference']; // float but on purpose.
|
||||
}
|
||||
|
||||
|
@@ -100,7 +100,7 @@ class TagController extends Controller
|
||||
'currency_id' => (string) $currencyId,
|
||||
'currency_code' => $currencyCode,
|
||||
];
|
||||
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], app('steam')->positive($journal[$field]));
|
||||
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], (string) app('steam')->positive($journal[$field]));
|
||||
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];
|
||||
|
||||
}
|
||||
@@ -154,7 +154,7 @@ class TagController extends Controller
|
||||
'currency_id' => (string) $currencyId,
|
||||
'currency_code' => $journal['currency_code'],
|
||||
];
|
||||
$response[$key]['difference'] = bcadd($response[$key]['difference'], app('steam')->positive($journal['amount']));
|
||||
$response[$key]['difference'] = bcadd((string) $response[$key]['difference'], (string) app('steam')->positive($journal['amount']));
|
||||
$response[$key]['difference_float'] = (float) $response[$key]['difference'];
|
||||
}
|
||||
|
||||
@@ -167,8 +167,8 @@ class TagController extends Controller
|
||||
'currency_code' => $journal['foreign_currency_code'],
|
||||
];
|
||||
$response[$foreignKey]['difference'] = bcadd(
|
||||
$response[$foreignKey]['difference'],
|
||||
app('steam')->positive($journal['foreign_amount'])
|
||||
(string) $response[$foreignKey]['difference'],
|
||||
(string) app('steam')->positive($journal['foreign_amount'])
|
||||
);
|
||||
$response[$foreignKey]['difference_float'] = (float) $response[$foreignKey]['difference'];
|
||||
}
|
||||
|
@@ -75,7 +75,7 @@ class PeriodController extends Controller
|
||||
'currency_id' => (string) $currencyId,
|
||||
'currency_code' => $currencyCode,
|
||||
];
|
||||
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], app('steam')->positive($journal[$field]));
|
||||
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], (string) app('steam')->positive($journal[$field]));
|
||||
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];
|
||||
|
||||
}
|
||||
|
@@ -99,7 +99,7 @@ class TagController extends Controller
|
||||
'currency_id' => (string) $currencyId,
|
||||
'currency_code' => $currencyCode,
|
||||
];
|
||||
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], app('steam')->positive($journal[$field]));
|
||||
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], (string) app('steam')->positive($journal[$field]));
|
||||
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];
|
||||
|
||||
}
|
||||
@@ -153,7 +153,7 @@ class TagController extends Controller
|
||||
'currency_id' => (string) $currencyId,
|
||||
'currency_code' => $journal['currency_code'],
|
||||
];
|
||||
$response[$key]['difference'] = bcadd($response[$key]['difference'], app('steam')->positive($journal['amount']));
|
||||
$response[$key]['difference'] = bcadd((string) $response[$key]['difference'], (string) app('steam')->positive($journal['amount']));
|
||||
$response[$key]['difference_float'] = (float) $response[$key]['difference'];
|
||||
}
|
||||
|
||||
@@ -166,8 +166,8 @@ class TagController extends Controller
|
||||
'currency_code' => $journal['foreign_currency_code'],
|
||||
];
|
||||
$response[$foreignKey]['difference'] = bcadd(
|
||||
$response[$foreignKey]['difference'],
|
||||
app('steam')->positive($journal['foreign_amount'])
|
||||
(string) $response[$foreignKey]['difference'],
|
||||
(string) app('steam')->positive($journal['foreign_amount'])
|
||||
);
|
||||
$response[$foreignKey]['difference_float'] = (float) $response[$foreignKey]['difference']; // intentional float
|
||||
}
|
||||
|
@@ -191,14 +191,14 @@ class BasicController extends Controller
|
||||
|
||||
// if it is the native currency already.
|
||||
if ($entry['currency_id'] === $default->id) {
|
||||
$sums[$default->id]['sum'] = bcadd($entry['sum'], $sums[$default->id]['sum']);
|
||||
$sums[$default->id]['sum'] = bcadd((string) $entry['sum'], $sums[$default->id]['sum']);
|
||||
|
||||
// don't forget to add it to newExpenses and newIncome
|
||||
if (0 === $index) {
|
||||
$newExpenses[$default->id]['sum'] = bcadd($newExpenses[$default->id]['sum'], $entry['sum']);
|
||||
$newExpenses[$default->id]['sum'] = bcadd($newExpenses[$default->id]['sum'], (string) $entry['sum']);
|
||||
}
|
||||
if (1 === $index) {
|
||||
$newIncomes[$default->id]['sum'] = bcadd($newIncomes[$default->id]['sum'], $entry['sum']);
|
||||
$newIncomes[$default->id]['sum'] = bcadd($newIncomes[$default->id]['sum'], (string) $entry['sum']);
|
||||
}
|
||||
|
||||
continue;
|
||||
@@ -229,7 +229,7 @@ class BasicController extends Controller
|
||||
'currency_decimal_places' => $entry['currency_decimal_places'],
|
||||
'sum' => '0',
|
||||
];
|
||||
$sums[$currencyId]['sum'] = bcadd($sums[$currencyId]['sum'], $entry['sum']);
|
||||
$sums[$currencyId]['sum'] = bcadd($sums[$currencyId]['sum'], (string) $entry['sum']);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -362,7 +362,7 @@ class BasicController extends Controller
|
||||
if (0 === $index) {
|
||||
// paid amount
|
||||
if ($currencyId === $this->nativeCurrency->id) {
|
||||
$newPaidAmount[0]['sum'] = bcadd($newPaidAmount[0]['sum'], $item['sum']);
|
||||
$newPaidAmount[0]['sum'] = bcadd($newPaidAmount[0]['sum'], (string) $item['sum']);
|
||||
|
||||
continue;
|
||||
}
|
||||
@@ -374,7 +374,7 @@ class BasicController extends Controller
|
||||
}
|
||||
// unpaid amount
|
||||
if ($currencyId === $this->nativeCurrency->id) {
|
||||
$newUnpaidAmount[0]['sum'] = bcadd($newUnpaidAmount[0]['sum'], $item['sum']);
|
||||
$newUnpaidAmount[0]['sum'] = bcadd($newUnpaidAmount[0]['sum'], (string) $item['sum']);
|
||||
|
||||
continue;
|
||||
}
|
||||
@@ -397,7 +397,7 @@ class BasicController extends Controller
|
||||
* @var array $info
|
||||
*/
|
||||
foreach ($paidAmount as $info) {
|
||||
$amount = bcmul($info['sum'], '-1');
|
||||
$amount = bcmul((string) $info['sum'], '-1');
|
||||
$return[] = [
|
||||
'key' => sprintf('bills-paid-in-%s', $info['code']),
|
||||
'title' => trans('firefly.box_bill_paid_in_currency', ['currency' => $info['symbol']]),
|
||||
@@ -416,7 +416,7 @@ class BasicController extends Controller
|
||||
* @var array $info
|
||||
*/
|
||||
foreach ($unpaidAmount as $info) {
|
||||
$amount = bcmul($info['sum'], '-1');
|
||||
$amount = bcmul((string) $info['sum'], '-1');
|
||||
$return[] = [
|
||||
'key' => sprintf('bills-unpaid-in-%s', $info['code']),
|
||||
'title' => trans('firefly.box_bill_unpaid_in_currency', ['currency' => $info['symbol']]),
|
||||
@@ -513,7 +513,7 @@ class BasicController extends Controller
|
||||
continue;
|
||||
}
|
||||
$spentInCurrency = $row['sum'];
|
||||
$leftToSpend = bcadd($amount, $spentInCurrency);
|
||||
$leftToSpend = bcadd($amount, (string) $spentInCurrency);
|
||||
$perDay = '0';
|
||||
if (0 !== $days && bccomp($leftToSpend, '0') > -1) {
|
||||
$perDay = bcdiv($leftToSpend, (string) $days);
|
||||
@@ -549,8 +549,8 @@ class BasicController extends Controller
|
||||
$currencyId = (int) $row['currency_id'];
|
||||
$spentInCurrency = $row['sum'];
|
||||
$perDay = '0';
|
||||
if (0 !== $days && -1 === bccomp($spentInCurrency, '0')) {
|
||||
$perDay = bcdiv($spentInCurrency, (string) $days);
|
||||
if (0 !== $days && -1 === bccomp((string) $spentInCurrency, '0')) {
|
||||
$perDay = bcdiv((string) $spentInCurrency, (string) $days);
|
||||
}
|
||||
|
||||
Log::debug(sprintf('Spent %s %s', $row['currency_code'], $row['sum']));
|
||||
@@ -631,7 +631,7 @@ class BasicController extends Controller
|
||||
continue;
|
||||
}
|
||||
$amount = $data['balance'];
|
||||
if (0 === bccomp($amount, '0')) {
|
||||
if (0 === bccomp((string) $amount, '0')) {
|
||||
continue;
|
||||
}
|
||||
// return stuff
|
||||
|
@@ -212,13 +212,13 @@ class BudgetController extends Controller
|
||||
foreach ($currentBudgetArray['transaction_journals'] as $journal) {
|
||||
// convert the amount to the native currency.
|
||||
$rate = $converter->getCurrencyRate($this->currencies[$currencyId], $this->currency, $journal['date']);
|
||||
$convertedAmount = bcmul($journal['amount'], $rate);
|
||||
$convertedAmount = bcmul((string) $journal['amount'], $rate);
|
||||
if ($journal['foreign_currency_id'] === $this->currency->id) {
|
||||
$convertedAmount = $journal['foreign_amount'];
|
||||
}
|
||||
|
||||
$return[$currencyId]['spent'] = bcadd($return[$currencyId]['spent'], $journal['amount']);
|
||||
$return[$currencyId]['native_spent'] = bcadd($return[$currencyId]['native_spent'], $convertedAmount);
|
||||
$return[$currencyId]['spent'] = bcadd($return[$currencyId]['spent'], (string) $journal['amount']);
|
||||
$return[$currencyId]['native_spent'] = bcadd($return[$currencyId]['native_spent'], (string) $convertedAmount);
|
||||
}
|
||||
}
|
||||
$converter->summarize();
|
||||
@@ -275,15 +275,15 @@ class BudgetController extends Controller
|
||||
}
|
||||
$result = $this->processExpenses($budget->id, $filtered, $limit->start_date, $end);
|
||||
if (1 === count($result)) {
|
||||
$compare = bccomp($limit->amount, app('steam')->positive($result[$limitCurrencyId]['spent']));
|
||||
$compare = bccomp($limit->amount, (string) app('steam')->positive($result[$limitCurrencyId]['spent']));
|
||||
if (1 === $compare) {
|
||||
// convert this amount into the native currency:
|
||||
$result[$limitCurrencyId]['left'] = bcadd($limit->amount, $result[$limitCurrencyId]['spent']);
|
||||
$result[$limitCurrencyId]['native_left'] = bcadd($convertedLimitAmount, $result[$limitCurrencyId]['native_spent']);
|
||||
$result[$limitCurrencyId]['left'] = bcadd($limit->amount, (string) $result[$limitCurrencyId]['spent']);
|
||||
$result[$limitCurrencyId]['native_left'] = bcadd($convertedLimitAmount, (string) $result[$limitCurrencyId]['native_spent']);
|
||||
}
|
||||
if ($compare <= 0) {
|
||||
$result[$limitCurrencyId]['overspent'] = app('steam')->positive(bcadd($limit->amount, $result[$limitCurrencyId]['spent']));
|
||||
$result[$limitCurrencyId]['native_overspent'] = app('steam')->positive(bcadd($convertedLimitAmount, $result[$limitCurrencyId]['native_spent']));
|
||||
$result[$limitCurrencyId]['overspent'] = app('steam')->positive(bcadd($limit->amount, (string) $result[$limitCurrencyId]['spent']));
|
||||
$result[$limitCurrencyId]['native_overspent'] = app('steam')->positive(bcadd($convertedLimitAmount, (string) $result[$limitCurrencyId]['native_spent']));
|
||||
}
|
||||
}
|
||||
$converter->summarize();
|
||||
|
@@ -100,7 +100,7 @@ class CategoryController extends Controller
|
||||
$currencyId = (int) $journal['currency_id'];
|
||||
$currency = $currencies[$currencyId] ?? $this->currencyRepos->find($currencyId);
|
||||
$currencies[$currencyId] = $currency;
|
||||
$categoryName = null === $journal['category_name'] ? (string) trans('firefly.no_category') : $journal['category_name'];
|
||||
$categoryName = $journal['category_name'] ?? (string) trans('firefly.no_category');
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$nativeAmount = $converter->convert($default, $currency, $journal['date'], $amount);
|
||||
$key = sprintf('%s-%s', $categoryName, $currency->code);
|
||||
@@ -128,8 +128,8 @@ class CategoryController extends Controller
|
||||
];
|
||||
|
||||
// add monies
|
||||
$return[$key]['amount'] = bcadd($return[$key]['amount'], $amount);
|
||||
$return[$key]['native_amount'] = bcadd($return[$key]['native_amount'], $nativeAmount);
|
||||
$return[$key]['amount'] = bcadd($return[$key]['amount'], (string) $amount);
|
||||
$return[$key]['native_amount'] = bcadd($return[$key]['native_amount'], (string) $nativeAmount);
|
||||
}
|
||||
$return = array_values($return);
|
||||
|
||||
|
@@ -174,8 +174,8 @@ class BasicController extends Controller
|
||||
* @var array $info
|
||||
*/
|
||||
foreach ($paidAmount as $info) {
|
||||
$amount = bcmul($info['sum'], '-1');
|
||||
$nativeAmount = bcmul($info['native_sum'], '-1');
|
||||
$amount = bcmul((string) $info['sum'], '-1');
|
||||
$nativeAmount = bcmul((string) $info['native_sum'], '-1');
|
||||
$return[] = [
|
||||
'key' => sprintf('bills-paid-in-%s', $info['currency_code']),
|
||||
'value' => $amount,
|
||||
@@ -198,8 +198,8 @@ class BasicController extends Controller
|
||||
* @var array $info
|
||||
*/
|
||||
foreach ($unpaidAmount as $info) {
|
||||
$amount = bcmul($info['sum'], '-1');
|
||||
$nativeAmount = bcmul($info['native_sum'], '-1');
|
||||
$amount = bcmul((string) $info['sum'], '-1');
|
||||
$nativeAmount = bcmul((string) $info['native_sum'], '-1');
|
||||
$return[] = [
|
||||
'key' => sprintf('bills-unpaid-in-%s', $info['currency_code']),
|
||||
'value' => $amount,
|
||||
@@ -279,8 +279,8 @@ class BasicController extends Controller
|
||||
if ((int) $journal['foreign_currency_id'] === $default->id) {
|
||||
$amountNative = $journal['foreign_amount'];
|
||||
}
|
||||
$spent = bcadd($spent, $amount);
|
||||
$spentNative = bcadd($spentNative, $amountNative);
|
||||
$spent = bcadd($spent, (string) $amount);
|
||||
$spentNative = bcadd($spentNative, (string) $amountNative);
|
||||
}
|
||||
app('log')->debug(sprintf('Total spent in budget "%s" is %s', $budget['name'], $spent));
|
||||
}
|
||||
|
@@ -48,8 +48,8 @@ class CorrectsLongDescriptions extends Command
|
||||
|
||||
/** @var TransactionJournal $journal */
|
||||
foreach ($journals as $journal) {
|
||||
if (strlen($journal->description) > self::MAX_LENGTH) {
|
||||
$journal->description = substr($journal->description, 0, self::MAX_LENGTH);
|
||||
if (strlen((string) $journal->description) > self::MAX_LENGTH) {
|
||||
$journal->description = substr((string) $journal->description, 0, self::MAX_LENGTH);
|
||||
$journal->save();
|
||||
$this->friendlyWarning(sprintf('Truncated description of transaction journal #%d', $journal->id));
|
||||
++$count;
|
||||
@@ -61,7 +61,7 @@ class CorrectsLongDescriptions extends Command
|
||||
/** @var TransactionGroup $group */
|
||||
foreach ($groups as $group) {
|
||||
if (strlen((string) $group->title) > self::MAX_LENGTH) {
|
||||
$group->title = substr($group->title, 0, self::MAX_LENGTH);
|
||||
$group->title = substr((string) $group->title, 0, self::MAX_LENGTH);
|
||||
$group->save();
|
||||
$this->friendlyWarning(sprintf('Truncated description of transaction group #%d', $group->id));
|
||||
++$count;
|
||||
|
@@ -100,7 +100,7 @@ class CorrectsRecurringTransactions extends Command
|
||||
$destination = $transaction->destinationAccount;
|
||||
$type = $recurrence->transactionType;
|
||||
$link = config(sprintf('firefly.account_to_transaction.%s.%s', $source->accountType->type, $destination->accountType->type));
|
||||
if (null !== $link && strtolower($type->type) !== strtolower($link)) {
|
||||
if (null !== $link && strtolower((string) $type->type) !== strtolower($link)) {
|
||||
$this->friendlyWarning(
|
||||
sprintf('Recurring transaction #%d should be a "%s" but is a "%s" and will be corrected.', $recurrence->id, $link, $type->type)
|
||||
);
|
||||
|
@@ -184,7 +184,7 @@ class CorrectsUnevenAmount extends Command
|
||||
return;
|
||||
}
|
||||
|
||||
$amount = bcmul('-1', $source->amount);
|
||||
$amount = bcmul('-1', (string) $source->amount);
|
||||
|
||||
// fix amount of destination:
|
||||
/** @var null|Transaction $destination */
|
||||
@@ -249,9 +249,9 @@ class CorrectsUnevenAmount extends Command
|
||||
// Log::debug(sprintf('[c] %s', var_export($source->transaction_currency_id === $destination->foreign_currency_id,true)));
|
||||
// Log::debug(sprintf('[d] %s', var_export((int) $destination->transaction_currency_id ===(int) $source->foreign_currency_id, true)));
|
||||
|
||||
if (0 === bccomp(app('steam')->positive($source->amount), app('steam')->positive($destination->foreign_amount))
|
||||
if (0 === bccomp((string) app('steam')->positive($source->amount), (string) app('steam')->positive($destination->foreign_amount))
|
||||
&& $source->transaction_currency_id === $destination->foreign_currency_id
|
||||
&& 0 === bccomp(app('steam')->positive($destination->amount), app('steam')->positive($source->foreign_amount))
|
||||
&& 0 === bccomp((string) app('steam')->positive($destination->amount), (string) app('steam')->positive($source->foreign_amount))
|
||||
&& (int) $destination->transaction_currency_id === (int) $source->foreign_currency_id
|
||||
) {
|
||||
return true;
|
||||
|
@@ -78,8 +78,8 @@ class UpgradesRuleActions extends Command
|
||||
|
||||
/** @var RuleAction $action */
|
||||
foreach ($actions as $action) {
|
||||
if (str_starts_with($action->action_value, '=')) {
|
||||
$action->action_value = sprintf('%s%s', '\=', substr($action->action_value, 1));
|
||||
if (str_starts_with((string) $action->action_value, '=')) {
|
||||
$action->action_value = sprintf('%s%s', '\=', substr((string) $action->action_value, 1));
|
||||
$action->save();
|
||||
++$count;
|
||||
}
|
||||
|
@@ -234,7 +234,7 @@ class UpgradesToGroups extends Command
|
||||
$categoryId = $this->getTransactionCategory($transaction, $opposingTr) ?? $categoryId;
|
||||
|
||||
return [
|
||||
'type' => strtolower($journal->transactionType->type),
|
||||
'type' => strtolower((string) $journal->transactionType->type),
|
||||
'date' => $journal->date,
|
||||
'user' => $journal->user,
|
||||
'user_group' => $journal->user->userGroup,
|
||||
|
@@ -218,7 +218,7 @@ class GracefulNotFoundHandler extends ExceptionHandler
|
||||
return redirect(route('accounts.index', ['asset']));
|
||||
}
|
||||
|
||||
return redirect(route('transactions.index', [strtolower($type)]));
|
||||
return redirect(route('transactions.index', [strtolower((string) $type)]));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -44,7 +44,7 @@ class AttachmentFactory
|
||||
public function create(array $data): ?Attachment
|
||||
{
|
||||
// append if necessary.
|
||||
$model = !str_contains($data['attachable_type'], 'FireflyIII') ? sprintf('FireflyIII\Models\%s', $data['attachable_type'])
|
||||
$model = !str_contains((string) $data['attachable_type'], 'FireflyIII') ? sprintf('FireflyIII\Models\%s', $data['attachable_type'])
|
||||
: $data['attachable_type'];
|
||||
|
||||
// get journal instead of transaction.
|
||||
|
@@ -59,7 +59,7 @@ class RecurrenceFactory
|
||||
public function create(array $data): Recurrence
|
||||
{
|
||||
try {
|
||||
$type = $this->findTransactionType(ucfirst($data['recurrence']['type']));
|
||||
$type = $this->findTransactionType(ucfirst((string) $data['recurrence']['type']));
|
||||
} catch (FireflyException $e) {
|
||||
$message = sprintf('Cannot make a recurring transaction of type "%s"', $data['recurrence']['type']);
|
||||
app('log')->error($message);
|
||||
|
@@ -77,7 +77,7 @@ class TagFactory
|
||||
$array = [
|
||||
'user_id' => $this->user->id,
|
||||
'user_group_id' => $this->userGroup->id,
|
||||
'tag' => trim($data['tag']),
|
||||
'tag' => trim((string) $data['tag']),
|
||||
'tagMode' => 'nothing',
|
||||
'date' => $data['date'],
|
||||
'description' => $data['description'],
|
||||
|
@@ -71,7 +71,7 @@ class TransactionGroupFactory
|
||||
$title = '' === $title ? null : $title;
|
||||
|
||||
if (null !== $title) {
|
||||
$title = substr($title, 0, 1000);
|
||||
$title = substr((string) $title, 0, 1000);
|
||||
}
|
||||
if (0 === $collection->count()) {
|
||||
throw new FireflyException('Created zero transaction journals.');
|
||||
|
@@ -159,7 +159,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
}
|
||||
}
|
||||
|
||||
$newBalance = bcadd($startBalance, $transactionAmount);
|
||||
$newBalance = bcadd((string) $startBalance, (string) $transactionAmount);
|
||||
$journals[$index]['balance_after'] = $newBalance;
|
||||
$startBalance = $newBalance;
|
||||
|
||||
|
@@ -194,12 +194,12 @@ class BudgetLimitHandler
|
||||
// if both equal each other, amount from this BL must be added to the AB
|
||||
if ($limitPeriod->equals($abPeriod)) {
|
||||
Log::debug('This budget limit is equal to the available budget period.');
|
||||
$newAmount = bcadd($newAmount, $budgetLimit->amount);
|
||||
$newAmount = bcadd($newAmount, (string) $budgetLimit->amount);
|
||||
}
|
||||
// if budget limit period is inside AB period, it can be added in full.
|
||||
if (!$limitPeriod->equals($abPeriod) && $abPeriod->contains($limitPeriod)) {
|
||||
Log::debug('This budget limit is smaller than the available budget period.');
|
||||
$newAmount = bcadd($newAmount, $budgetLimit->amount);
|
||||
$newAmount = bcadd($newAmount, (string) $budgetLimit->amount);
|
||||
}
|
||||
if (!$limitPeriod->equals($abPeriod) && !$abPeriod->contains($limitPeriod) && $abPeriod->overlapsWith($limitPeriod)) {
|
||||
Log::debug('This budget limit is something else entirely!');
|
||||
|
@@ -264,7 +264,7 @@ trait AccountCollection
|
||||
$date->subSecond();
|
||||
Log::debug(sprintf('accountBalanceIs: Call finalAccountBalance with date/time "%s"', $date->toIso8601String()));
|
||||
$balance = Steam::finalAccountBalance($account, $date);
|
||||
$result = bccomp($balance['balance'], $value);
|
||||
$result = bccomp((string) $balance['balance'], $value);
|
||||
Log::debug(sprintf('"%s" vs "%s" is %d', $balance['balance'], $value, $result));
|
||||
|
||||
switch ($operator) {
|
||||
|
@@ -51,8 +51,8 @@ trait AttachmentCollection
|
||||
foreach ($object['transactions'] as $transaction) {
|
||||
/** @var array $attachment */
|
||||
foreach ($transaction['attachments'] as $attachment) {
|
||||
$result = str_contains(strtolower($attachment['filename']), strtolower($name)) || str_contains(
|
||||
strtolower($attachment['title']),
|
||||
$result = str_contains(strtolower((string) $attachment['filename']), strtolower($name)) || str_contains(
|
||||
strtolower((string) $attachment['title']),
|
||||
strtolower($name)
|
||||
);
|
||||
if (true === $result) {
|
||||
@@ -131,8 +131,8 @@ trait AttachmentCollection
|
||||
foreach ($object['transactions'] as $transaction) {
|
||||
/** @var array $attachment */
|
||||
foreach ($transaction['attachments'] as $attachment) {
|
||||
$result = !str_contains(strtolower($attachment['filename']), strtolower($name)) && !str_contains(
|
||||
strtolower($attachment['title']),
|
||||
$result = !str_contains(strtolower((string) $attachment['filename']), strtolower($name)) && !str_contains(
|
||||
strtolower((string) $attachment['title']),
|
||||
strtolower($name)
|
||||
);
|
||||
if (true === $result) {
|
||||
@@ -166,8 +166,8 @@ trait AttachmentCollection
|
||||
foreach ($object['transactions'] as $transaction) {
|
||||
/** @var array $attachment */
|
||||
foreach ($transaction['attachments'] as $attachment) {
|
||||
$result = !str_ends_with(strtolower($attachment['filename']), strtolower($name)) && !str_ends_with(
|
||||
strtolower($attachment['title']),
|
||||
$result = !str_ends_with(strtolower((string) $attachment['filename']), strtolower($name)) && !str_ends_with(
|
||||
strtolower((string) $attachment['title']),
|
||||
strtolower($name)
|
||||
);
|
||||
if (true === $result) {
|
||||
@@ -201,8 +201,8 @@ trait AttachmentCollection
|
||||
foreach ($object['transactions'] as $transaction) {
|
||||
/** @var array $attachment */
|
||||
foreach ($transaction['attachments'] as $attachment) {
|
||||
$result = !str_starts_with(strtolower($attachment['filename']), strtolower($name)) && !str_starts_with(
|
||||
strtolower($attachment['title']),
|
||||
$result = !str_starts_with(strtolower((string) $attachment['filename']), strtolower($name)) && !str_starts_with(
|
||||
strtolower((string) $attachment['title']),
|
||||
strtolower($name)
|
||||
);
|
||||
if (true === $result) {
|
||||
@@ -227,8 +227,8 @@ trait AttachmentCollection
|
||||
foreach ($object['transactions'] as $transaction) {
|
||||
/** @var array $attachment */
|
||||
foreach ($transaction['attachments'] as $attachment) {
|
||||
$result = str_ends_with(strtolower($attachment['filename']), strtolower($name)) || str_ends_with(
|
||||
strtolower($attachment['title']),
|
||||
$result = str_ends_with(strtolower((string) $attachment['filename']), strtolower($name)) || str_ends_with(
|
||||
strtolower((string) $attachment['title']),
|
||||
strtolower($name)
|
||||
);
|
||||
if (true === $result) {
|
||||
@@ -299,8 +299,8 @@ trait AttachmentCollection
|
||||
foreach ($object['transactions'] as $transaction) {
|
||||
/** @var array $attachment */
|
||||
foreach ($transaction['attachments'] as $attachment) {
|
||||
$result = str_starts_with(strtolower($attachment['filename']), strtolower($name)) || str_starts_with(
|
||||
strtolower($attachment['title']),
|
||||
$result = str_starts_with(strtolower((string) $attachment['filename']), strtolower($name)) || str_starts_with(
|
||||
strtolower((string) $attachment['title']),
|
||||
strtolower($name)
|
||||
);
|
||||
if (true === $result) {
|
||||
|
@@ -492,7 +492,7 @@ trait MetaCollection
|
||||
'notes',
|
||||
static function (JoinClause $join): void {
|
||||
$join->on('notes.noteable_id', '=', 'transaction_journals.id');
|
||||
$join->where('notes.noteable_type', '=', 'FireflyIII\Models\TransactionJournal');
|
||||
$join->where('notes.noteable_type', '=', \FireflyIII\Models\TransactionJournal::class);
|
||||
$join->whereNull('notes.deleted_at');
|
||||
}
|
||||
);
|
||||
@@ -601,8 +601,8 @@ trait MetaCollection
|
||||
return false;
|
||||
}
|
||||
foreach ($transaction['tags'] as $tag) {
|
||||
Log::debug(sprintf('"%s" versus', strtolower($tag['name'])), $list);
|
||||
if (in_array(strtolower($tag['name']), $list, true)) {
|
||||
Log::debug(sprintf('"%s" versus', strtolower((string) $tag['name'])), $list);
|
||||
if (in_array(strtolower((string) $tag['name']), $list, true)) {
|
||||
app('log')->debug(sprintf('Transaction has tag "%s" so count++.', $tag['name']));
|
||||
++$foundTagCount;
|
||||
$journalId = $transaction['transaction_journal_id'];
|
||||
@@ -779,8 +779,8 @@ trait MetaCollection
|
||||
Log::debug(sprintf('Now in setTags(%s) filter', implode(', ', $list)));
|
||||
foreach ($object['transactions'] as $transaction) {
|
||||
foreach ($transaction['tags'] as $tag) {
|
||||
Log::debug(sprintf('"%s" versus', strtolower($tag['name'])), $list);
|
||||
if (in_array(strtolower($tag['name']), $list, true)) {
|
||||
Log::debug(sprintf('"%s" versus', strtolower((string) $tag['name'])), $list);
|
||||
if (in_array(strtolower((string) $tag['name']), $list, true)) {
|
||||
app('log')->debug(sprintf('Transaction has tag "%s" so return true.', $tag['name']));
|
||||
|
||||
return true;
|
||||
@@ -811,8 +811,8 @@ trait MetaCollection
|
||||
foreach ($object['transactions'] as $transaction) {
|
||||
app('log')->debug(sprintf('Transaction has %d tag(s)', count($transaction['tags'])));
|
||||
foreach ($transaction['tags'] as $tag) {
|
||||
Log::debug(sprintf('"%s" versus', strtolower($tag['name'])), $list);
|
||||
if (in_array(strtolower($tag['name']), $list, true)) {
|
||||
Log::debug(sprintf('"%s" versus', strtolower((string) $tag['name'])), $list);
|
||||
if (in_array(strtolower((string) $tag['name']), $list, true)) {
|
||||
app('log')->debug(sprintf('Transaction has tag "%s", but should not have it, return false.', $tag['name']));
|
||||
|
||||
return false;
|
||||
|
@@ -593,7 +593,7 @@ class GroupCollector implements GroupCollectorInterface
|
||||
if (array_key_exists('meta_name', $result) && in_array($result['meta_name'], $dates, true)) {
|
||||
$name = $result['meta_name'];
|
||||
if (array_key_exists('meta_data', $result) && '' !== (string) $result['meta_data']) {
|
||||
$result[$name] = Carbon::createFromFormat('!Y-m-d', substr(\Safe\json_decode($result['meta_data']), 0, 10));
|
||||
$result[$name] = Carbon::createFromFormat('!Y-m-d', substr((string) \Safe\json_decode($result['meta_data']), 0, 10));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -743,8 +743,8 @@ class GroupCollector implements GroupCollectorInterface
|
||||
$groups[$groudId]['sums'][$currencyId]['amount'] = '0';
|
||||
$groups[$groudId]['sums'][$currencyId]['native_amount'] = '0';
|
||||
}
|
||||
$groups[$groudId]['sums'][$currencyId]['amount'] = bcadd($groups[$groudId]['sums'][$currencyId]['amount'], $transaction['amount']);
|
||||
$groups[$groudId]['sums'][$currencyId]['native_amount'] = bcadd($groups[$groudId]['sums'][$currencyId]['native_amount'], $nativeAmount);
|
||||
$groups[$groudId]['sums'][$currencyId]['amount'] = bcadd((string) $groups[$groudId]['sums'][$currencyId]['amount'], $transaction['amount']);
|
||||
$groups[$groudId]['sums'][$currencyId]['native_amount'] = bcadd((string) $groups[$groudId]['sums'][$currencyId]['native_amount'], $nativeAmount);
|
||||
|
||||
if (null !== $transaction['foreign_amount'] && null !== $transaction['foreign_currency_id']) {
|
||||
$currencyId = (int) $transaction['foreign_currency_id'];
|
||||
@@ -758,7 +758,7 @@ class GroupCollector implements GroupCollectorInterface
|
||||
$groups[$groudId]['sums'][$currencyId]['amount'] = '0';
|
||||
$groups[$groudId]['sums'][$currencyId]['native_amount'] = '0';
|
||||
}
|
||||
$groups[$groudId]['sums'][$currencyId]['amount'] = bcadd($groups[$groudId]['sums'][$currencyId]['amount'], $foreignAmount);
|
||||
$groups[$groudId]['sums'][$currencyId]['amount'] = bcadd((string) $groups[$groudId]['sums'][$currencyId]['amount'], $foreignAmount);
|
||||
$groups[$groudId]['sums'][$currencyId]['native_amount'] = bcadd($groups[$groudId]['sums'][$currencyId]['amount'], $nativeForeignAmount);
|
||||
}
|
||||
}
|
||||
|
@@ -67,7 +67,7 @@ class HomeController extends Controller
|
||||
try {
|
||||
$stringStart = e((string) $request->get('start'));
|
||||
$start = Carbon::createFromFormat('Y-m-d', $stringStart);
|
||||
} catch (InvalidFormatException $e) {
|
||||
} catch (InvalidFormatException) {
|
||||
app('log')->error(sprintf('Start: could not parse date string "%s" so ignore it.', $stringStart));
|
||||
$start = Carbon::now()->startOfMonth();
|
||||
}
|
||||
|
@@ -57,24 +57,24 @@ use Illuminate\Support\Collection;
|
||||
class OperatorQuerySearch implements SearchInterface
|
||||
{
|
||||
protected Carbon $date;
|
||||
private AccountRepositoryInterface $accountRepository;
|
||||
private BillRepositoryInterface $billRepository;
|
||||
private BudgetRepositoryInterface $budgetRepository;
|
||||
private CategoryRepositoryInterface $categoryRepository;
|
||||
private readonly AccountRepositoryInterface $accountRepository;
|
||||
private readonly BillRepositoryInterface $billRepository;
|
||||
private readonly BudgetRepositoryInterface $budgetRepository;
|
||||
private readonly CategoryRepositoryInterface $categoryRepository;
|
||||
private GroupCollectorInterface $collector;
|
||||
private CurrencyRepositoryInterface $currencyRepository;
|
||||
private readonly CurrencyRepositoryInterface $currencyRepository;
|
||||
private array $excludeTags;
|
||||
private array $includeAnyTags;
|
||||
// added to fix #8632
|
||||
private array $includeTags;
|
||||
private array $invalidOperators;
|
||||
private int $limit;
|
||||
private Collection $operators;
|
||||
private readonly Collection $operators;
|
||||
private int $page;
|
||||
private array $prohibitedWords;
|
||||
private float $startTime;
|
||||
private TagRepositoryInterface $tagRepository;
|
||||
private array $validOperators;
|
||||
private readonly float $startTime;
|
||||
private readonly TagRepositoryInterface $tagRepository;
|
||||
private readonly array $validOperators;
|
||||
private array $words;
|
||||
|
||||
/**
|
||||
@@ -149,7 +149,7 @@ class OperatorQuerySearch implements SearchInterface
|
||||
|
||||
/** @var QueryParserInterface $parser */
|
||||
$parser = app(QueryParserInterface::class);
|
||||
app('log')->debug(sprintf('Using %s as implementation for QueryParserInterface', get_class($parser)));
|
||||
app('log')->debug(sprintf('Using %s as implementation for QueryParserInterface', $parser::class));
|
||||
|
||||
try {
|
||||
$parsedQuery = $parser->parse($query);
|
||||
@@ -177,7 +177,7 @@ class OperatorQuerySearch implements SearchInterface
|
||||
*/
|
||||
private function handleSearchNode(Node $node, bool $flipProhibitedFlag): void
|
||||
{
|
||||
app('log')->debug(sprintf('Now in handleSearchNode(%s)', get_class($node)));
|
||||
app('log')->debug(sprintf('Now in handleSearchNode(%s)', $node::class));
|
||||
|
||||
switch (true) {
|
||||
case $node instanceof StringNode:
|
||||
@@ -196,9 +196,9 @@ class OperatorQuerySearch implements SearchInterface
|
||||
break;
|
||||
|
||||
default:
|
||||
app('log')->error(sprintf('Cannot handle node %s', get_class($node)));
|
||||
app('log')->error(sprintf('Cannot handle node %s', $node::class));
|
||||
|
||||
throw new FireflyException(sprintf('Firefly III search can\'t handle "%s"-nodes', get_class($node)));
|
||||
throw new FireflyException(sprintf('Firefly III search can\'t handle "%s"-nodes', $node::class));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2009,9 +2009,7 @@ class OperatorQuerySearch implements SearchInterface
|
||||
}
|
||||
app('log')->debug(sprintf('Found %d accounts, will filter.', $accounts->count()));
|
||||
$filtered = $accounts->filter(
|
||||
static function (Account $account) use ($value, $stringMethod) {
|
||||
return $stringMethod(strtolower($account->name), strtolower($value));
|
||||
}
|
||||
static fn(Account $account) => $stringMethod(strtolower($account->name), strtolower($value))
|
||||
);
|
||||
|
||||
if (0 === $filtered->count()) {
|
||||
@@ -2095,7 +2093,7 @@ class OperatorQuerySearch implements SearchInterface
|
||||
|
||||
/** @var AccountMeta $meta */
|
||||
foreach ($account->accountMeta as $meta) {
|
||||
if ('account_number' === $meta->name && $stringMethod(strtolower($meta->data), strtolower($value))) {
|
||||
if ('account_number' === $meta->name && $stringMethod(strtolower((string) $meta->data), strtolower($value))) {
|
||||
$accountNrMatch = true;
|
||||
}
|
||||
}
|
||||
@@ -2146,7 +2144,7 @@ class OperatorQuerySearch implements SearchInterface
|
||||
|
||||
try {
|
||||
$parsedDate = $parser->parseDate($value);
|
||||
} catch (FireflyException $e) {
|
||||
} catch (FireflyException) {
|
||||
app('log')->debug(sprintf('Could not parse date "%s", will return empty array.', $value));
|
||||
$this->invalidOperators[] = [
|
||||
'type' => $type,
|
||||
|
@@ -109,8 +109,8 @@ class SearchRuleEngine implements RuleEngineInterface
|
||||
continue;
|
||||
}
|
||||
$contextSearch = $ruleTrigger->trigger_type;
|
||||
if (str_starts_with($ruleTrigger->trigger_type, '-')) {
|
||||
$contextSearch = substr($ruleTrigger->trigger_type, 1);
|
||||
if (str_starts_with((string) $ruleTrigger->trigger_type, '-')) {
|
||||
$contextSearch = substr((string) $ruleTrigger->trigger_type, 1);
|
||||
}
|
||||
|
||||
// if the trigger needs no context, value is different:
|
||||
|
@@ -201,7 +201,7 @@ class AccountTransformer extends AbstractTransformer
|
||||
}
|
||||
$monthlyPaymentDate = $object->toAtomString();
|
||||
}
|
||||
if (10 !== strlen($monthlyPaymentDate)) {
|
||||
if (10 !== strlen((string) $monthlyPaymentDate)) {
|
||||
$monthlyPaymentDate = Carbon::parse($monthlyPaymentDate, config('app.timezone'))->toAtomString();
|
||||
}
|
||||
}
|
||||
|
@@ -118,7 +118,7 @@ class TransactionGroupTransformer extends AbstractTransformer
|
||||
// amount:
|
||||
$amount = app('steam')->positive((string) ($transaction['amount'] ?? '0'));
|
||||
$foreignAmount = null;
|
||||
if (null !== $transaction['foreign_amount'] && '' !== $transaction['foreign_amount'] && 0 !== bccomp('0', $transaction['foreign_amount'])) {
|
||||
if (null !== $transaction['foreign_amount'] && '' !== $transaction['foreign_amount'] && 0 !== bccomp('0', (string) $transaction['foreign_amount'])) {
|
||||
$foreignAmount = app('steam')->positive($transaction['foreign_amount']);
|
||||
}
|
||||
$type = $this->stringFromArray($transaction, 'transaction_type_type', TransactionTypeEnum::WITHDRAWAL->value);
|
||||
@@ -132,7 +132,7 @@ class TransactionGroupTransformer extends AbstractTransformer
|
||||
return [
|
||||
'user' => (string) $transaction['user_id'],
|
||||
'transaction_journal_id' => (string) $transaction['transaction_journal_id'],
|
||||
'type' => strtolower($type),
|
||||
'type' => strtolower((string) $type),
|
||||
'date' => $transaction['date']->toAtomString(),
|
||||
'order' => $transaction['order'],
|
||||
|
||||
@@ -296,7 +296,7 @@ class TransactionGroupTransformer extends AbstractTransformer
|
||||
$type = $journal->transactionType->type;
|
||||
$currency = $source->transactionCurrency;
|
||||
$amount = app('steam')->bcround($this->getAmount($source->amount), $currency->decimal_places ?? 0);
|
||||
$foreignAmount = $this->getForeignAmount(null === $source->foreign_amount ? null : $source->foreign_amount);
|
||||
$foreignAmount = $this->getForeignAmount($source->foreign_amount ?? null);
|
||||
$metaFieldData = $this->groupRepos->getMetaFields($journal->id, $this->metaFields);
|
||||
$metaDates = $this->getDates($this->groupRepos->getMetaDateFields($journal->id, $this->metaDateFields));
|
||||
$foreignCurrency = $this->getForeignCurrency($source->foreignCurrency);
|
||||
@@ -321,7 +321,7 @@ class TransactionGroupTransformer extends AbstractTransformer
|
||||
return [
|
||||
'user' => $journal->user_id,
|
||||
'transaction_journal_id' => (string) $journal->id,
|
||||
'type' => strtolower($type),
|
||||
'type' => strtolower((string) $type),
|
||||
'date' => $journal->date->toAtomString(),
|
||||
'order' => $journal->order,
|
||||
|
||||
|
@@ -198,8 +198,8 @@ class AccountTransformer extends AbstractTransformer
|
||||
$id = $account->id;
|
||||
if (array_key_exists($id, $bStart) && array_key_exists($id, $bEnd)) {
|
||||
$this->balanceDifferences[$id] = [
|
||||
'balance' => bcsub($bEnd[$id]['balance'], $bStart[$id]['balance']),
|
||||
'native_balance' => bcsub($bEnd[$id]['native_balance'], $bStart[$id]['native_balance']),
|
||||
'balance' => bcsub((string) $bEnd[$id]['balance'], (string) $bStart[$id]['balance']),
|
||||
'native_balance' => bcsub((string) $bEnd[$id]['native_balance'], (string) $bStart[$id]['native_balance']),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -351,7 +351,7 @@ class AccountTransformer extends AbstractTransformer
|
||||
$nativeBalance = $this->convertedBalances[$id]['native_balance'] ?? null;
|
||||
|
||||
// no order for some accounts:
|
||||
if (!in_array(strtolower($accountType), ['liability', 'liabilities', 'asset'], true)) {
|
||||
if (!in_array(strtolower((string) $accountType), ['liability', 'liabilities', 'asset'], true)) {
|
||||
$order = null;
|
||||
}
|
||||
|
||||
@@ -381,7 +381,7 @@ class AccountTransformer extends AbstractTransformer
|
||||
'name' => $account->name,
|
||||
'iban' => '' === (string) $account->iban ? null : $account->iban,
|
||||
'account_number' => $this->accountMeta[$id]['account_number'] ?? null,
|
||||
'type' => strtolower($accountType),
|
||||
'type' => strtolower((string) $accountType),
|
||||
'account_role' => $accountRole,
|
||||
'currency_id' => (string) $currency->id,
|
||||
'currency_code' => $currency->code,
|
||||
|
@@ -196,9 +196,9 @@ class PiggyBankTransformer extends AbstractTransformer
|
||||
$group = $this->groups[$piggyBank->id] ?? null;
|
||||
|
||||
if (0 !== bccomp($targetAmount, '0')) { // target amount is not 0.00
|
||||
$leftToSave = bcsub($targetAmount, $currentAmount);
|
||||
$leftToSave = bcsub($targetAmount, (string) $currentAmount);
|
||||
$nativeLeftToSave = $this->converter->convert($this->default, $currency, today(), $leftToSave);
|
||||
$percentage = (int) bcmul(bcdiv($currentAmount, $targetAmount), '100');
|
||||
$percentage = (int) bcmul(bcdiv((string) $currentAmount, $targetAmount), '100');
|
||||
$savePerMonth = $this->getSuggestedMonthlyAmount($currentAmount, $targetAmount, $piggyBank->start_date, $piggyBank->target_date);
|
||||
$nativeSavePerMonth = $this->converter->convert($this->default, $currency, today(), $savePerMonth);
|
||||
}
|
||||
|
@@ -219,7 +219,7 @@ class TransactionGroupTransformer extends AbstractTransformer
|
||||
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($journal->transactions as $transaction) {
|
||||
if (-1 === bccomp($transaction->amount, '0')) {
|
||||
if (-1 === bccomp((string) $transaction->amount, '0')) {
|
||||
// only collect source account info
|
||||
$account = $transaction->account;
|
||||
$this->accountTypes[$account->account_type_id] ??= $account->accountType->type;
|
||||
@@ -349,7 +349,7 @@ class TransactionGroupTransformer extends AbstractTransformer
|
||||
'user' => (string) $transaction['user_id'],
|
||||
'user_group' => (string) $transaction['user_group_id'],
|
||||
'transaction_journal_id' => (string) $transaction['transaction_journal_id'],
|
||||
'type' => strtolower($type),
|
||||
'type' => strtolower((string) $type),
|
||||
'date' => $transaction['date']->toAtomString(),
|
||||
'order' => $transaction['order'],
|
||||
'amount' => $amount,
|
||||
|
@@ -418,7 +418,7 @@ class FireflyValidator extends Validator
|
||||
// check transaction type.
|
||||
// TODO create a helper to automatically return these.
|
||||
if ('transaction_type' === $triggerType) {
|
||||
$count = TransactionType::where('type', ucfirst($value))->count();
|
||||
$count = TransactionType::where('type', ucfirst((string) $value))->count();
|
||||
|
||||
return 1 === $count;
|
||||
}
|
||||
|
@@ -593,7 +593,7 @@ trait TransactionValidation
|
||||
/** @var null|TransactionJournal $journal */
|
||||
$journal = TransactionJournal::with(['transactionType'])->find($journalId);
|
||||
if (null !== $journal) {
|
||||
return strtolower($journal->transactionType->type);
|
||||
return strtolower((string) $journal->transactionType->type);
|
||||
}
|
||||
|
||||
return 'invalid';
|
||||
|
@@ -57,7 +57,7 @@ return [
|
||||
'app_id' => env('PUSHER_APP_ID'),
|
||||
'options' => [
|
||||
'cluster' => env('PUSHER_APP_CLUSTER'),
|
||||
'host' => null !== env('PUSHER_HOST') ? env('PUSHER_HOST') : 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com',
|
||||
'host' => env('PUSHER_HOST') ?? 'api-' . env('PUSHER_APP_CLUSTER', 'mt1') . '.pusher.com',
|
||||
'port' => env('PUSHER_PORT', 443),
|
||||
'scheme' => env('PUSHER_SCHEME', 'https'),
|
||||
'encrypted' => true,
|
||||
|
@@ -46,7 +46,7 @@ return [
|
||||
'timeout' => null,
|
||||
'scheme' => env('MAIL_SCHEME'),
|
||||
'url' => env('MAIL_URL'),
|
||||
'local_domain' => env('MAIL_EHLO_DOMAIN', parse_url(env('APP_URL', 'http://localhost'), PHP_URL_HOST)),
|
||||
'local_domain' => env('MAIL_EHLO_DOMAIN', parse_url((string) env('APP_URL', 'http://localhost'), PHP_URL_HOST)),
|
||||
'verify_peer' => env('MAIL_VERIFY_PEER', true),
|
||||
'allow_self_signed' => env('MAIL_ALLOW_SELF_SIGNED', false),
|
||||
'verify_peer_name' => env('MAIL_VERIFY_PEER_NAME', true),
|
||||
|
@@ -1202,7 +1202,7 @@ Breadcrumbs::for(
|
||||
static function (Generator $breadcrumbs, TransactionGroup $group): void {
|
||||
/** @var TransactionJournal $first */
|
||||
$first = $group->transactionJournals()->first();
|
||||
$type = strtolower($first->transactionType->type);
|
||||
$type = strtolower((string) $first->transactionType->type);
|
||||
$title = limitStringLength($first->description);
|
||||
if ($group->transactionJournals()->count() > 1) {
|
||||
$title = limitStringLength((string)$group->title);
|
||||
@@ -1241,7 +1241,7 @@ Breadcrumbs::for(
|
||||
'transactions.mass.edit',
|
||||
static function (Generator $breadcrumbs, array $journals): void {
|
||||
if (0 !== count($journals)) {
|
||||
$objectType = strtolower(reset($journals)['transaction_type_type']);
|
||||
$objectType = strtolower((string) reset($journals)['transaction_type_type']);
|
||||
$breadcrumbs->parent('transactions.index', $objectType);
|
||||
$breadcrumbs->push(trans('firefly.mass_edit_journals'), route('transactions.mass.edit', ['']));
|
||||
|
||||
@@ -1254,7 +1254,7 @@ Breadcrumbs::for(
|
||||
Breadcrumbs::for(
|
||||
'transactions.mass.delete',
|
||||
static function (Generator $breadcrumbs, array $journals): void {
|
||||
$objectType = strtolower(reset($journals)['transaction_type_type']);
|
||||
$objectType = strtolower((string) reset($journals)['transaction_type_type']);
|
||||
$breadcrumbs->parent('transactions.index', $objectType);
|
||||
$breadcrumbs->push(trans('firefly.mass_edit_journals'), route('transactions.mass.delete', ['']));
|
||||
}
|
||||
@@ -1267,7 +1267,7 @@ Breadcrumbs::for(
|
||||
if (0 !== count($journals)) {
|
||||
$ids = Arr::pluck($journals, 'transaction_journal_id');
|
||||
$first = reset($journals);
|
||||
$breadcrumbs->parent('transactions.index', strtolower($first['transaction_type_type']));
|
||||
$breadcrumbs->parent('transactions.index', strtolower((string) $first['transaction_type_type']));
|
||||
$breadcrumbs->push(trans('firefly.mass_bulk_journals'), route('transactions.bulk.edit', $ids));
|
||||
|
||||
return;
|
||||
|
@@ -40,6 +40,7 @@ final class AboutControllerTest extends TestCase
|
||||
use RefreshDatabase;
|
||||
private $user;
|
||||
|
||||
#[\Override]
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
@@ -44,6 +44,7 @@ final class BillControllerTest extends TestCase
|
||||
*/
|
||||
use RefreshDatabase;
|
||||
|
||||
#[\Override]
|
||||
protected function createAuthenticatedUser(): User
|
||||
{
|
||||
$userGroup = UserGroup::create(['title' => 'Test Group']);
|
||||
@@ -65,8 +66,8 @@ final class BillControllerTest extends TestCase
|
||||
'user_id' => $user->id,
|
||||
'name' => 'Bill '.$i,
|
||||
'user_group_id' => $user->user_group_id,
|
||||
'amount_min' => rand(1, 100), // random amount
|
||||
'amount_max' => rand(101, 200), // random amount
|
||||
'amount_min' => random_int(1, 100), // random amount
|
||||
'amount_max' => random_int(101, 200), // random amount
|
||||
'match' => 'MIGRATED_TO_RULES',
|
||||
'date' => '2024-01-01',
|
||||
'repeat_freq' => 'monthly',
|
||||
|
@@ -44,6 +44,7 @@ final class BudgetControllerTest extends TestCase
|
||||
*/
|
||||
use RefreshDatabase;
|
||||
|
||||
#[\Override]
|
||||
protected function createAuthenticatedUser(): User
|
||||
{
|
||||
$userGroup = UserGroup::create(['title' => 'Test Group']);
|
||||
|
@@ -44,6 +44,7 @@ final class CategoryControllerTest extends TestCase
|
||||
*/
|
||||
use RefreshDatabase;
|
||||
|
||||
#[\Override]
|
||||
protected function createAuthenticatedUser(): User
|
||||
{
|
||||
$userGroup = UserGroup::create(['title' => 'Test Group']);
|
||||
|
@@ -44,6 +44,7 @@ final class CurrencyControllerTest extends TestCase
|
||||
*/
|
||||
use RefreshDatabase;
|
||||
|
||||
#[\Override]
|
||||
protected function createAuthenticatedUser(): User
|
||||
{
|
||||
$userGroup = UserGroup::create(['title' => 'Test Group']);
|
||||
|
@@ -44,6 +44,7 @@ final class ObjectGroupControllerTest extends TestCase
|
||||
*/
|
||||
use RefreshDatabase;
|
||||
|
||||
#[\Override]
|
||||
protected function createAuthenticatedUser(): User
|
||||
{
|
||||
$userGroup = UserGroup::create(['title' => 'Test Group']);
|
||||
|
@@ -37,7 +37,7 @@ use Tests\integration\TestCase;
|
||||
*/
|
||||
final class BillDateCalculatorTest extends TestCase
|
||||
{
|
||||
private BillDateCalculator $calculator;
|
||||
private readonly BillDateCalculator $calculator;
|
||||
|
||||
public function __construct(string $name)
|
||||
{
|
||||
|
@@ -30,17 +30,11 @@ use Tests\unit\Support\Calendar\Periodicity\IntervalProvider;
|
||||
|
||||
readonly class CalculatorProvider
|
||||
{
|
||||
public IntervalProvider $intervalProvider;
|
||||
public string $label;
|
||||
public Periodicity $periodicity;
|
||||
public int $skip;
|
||||
|
||||
private function __construct(IntervalProvider $intervalProvider, Periodicity $periodicity, int $skip = 0)
|
||||
private function __construct(public IntervalProvider $intervalProvider, public Periodicity $periodicity, public int $skip = 0)
|
||||
{
|
||||
$this->skip = $skip;
|
||||
$this->intervalProvider = $intervalProvider;
|
||||
$this->periodicity = $periodicity;
|
||||
$this->label = "{$periodicity->name} {$intervalProvider->label}";
|
||||
$this->label = "{$this->periodicity->name} {$this->intervalProvider->label}";
|
||||
}
|
||||
|
||||
public static function providePeriodicityWithSkippedIntervals(): \Generator
|
||||
|
@@ -28,14 +28,10 @@ use Carbon\Carbon;
|
||||
|
||||
readonly class IntervalProvider
|
||||
{
|
||||
public Carbon $epoch;
|
||||
public Carbon $expected;
|
||||
public string $label;
|
||||
|
||||
public function __construct(Carbon $epoch, Carbon $expected)
|
||||
public function __construct(public Carbon $epoch, public Carbon $expected)
|
||||
{
|
||||
$this->epoch = $epoch;
|
||||
$this->expected = $expected;
|
||||
$this->label = "given {$epoch->toDateString()} expects {$expected->toDateString()}";
|
||||
$this->label = "given {$this->epoch->toDateString()} expects {$this->expected->toDateString()}";
|
||||
}
|
||||
}
|
||||
|
@@ -40,7 +40,7 @@ use Tests\integration\TestCase;
|
||||
*/
|
||||
final class NavigationAddPeriodTest extends TestCase
|
||||
{
|
||||
private Navigation $navigation;
|
||||
private readonly Navigation $navigation;
|
||||
|
||||
public function __construct(string $name)
|
||||
{
|
||||
|
@@ -39,7 +39,7 @@ use Tests\integration\TestCase;
|
||||
*/
|
||||
final class NavigationEndOfPeriodTest extends TestCase
|
||||
{
|
||||
private Navigation $navigation;
|
||||
private readonly Navigation $navigation;
|
||||
|
||||
public function __construct(string $name)
|
||||
{
|
||||
|
@@ -38,7 +38,7 @@ use Tests\integration\TestCase;
|
||||
*/
|
||||
final class NavigationPreferredCarbonFormatByPeriodTest extends TestCase
|
||||
{
|
||||
private Navigation $navigation;
|
||||
private readonly Navigation $navigation;
|
||||
|
||||
public function __construct(string $name)
|
||||
{
|
||||
|
@@ -39,7 +39,7 @@ use Tests\integration\TestCase;
|
||||
*/
|
||||
final class NavigationPreferredCarbonFormatTest extends TestCase
|
||||
{
|
||||
private Navigation $navigation;
|
||||
private readonly Navigation $navigation;
|
||||
|
||||
public function __construct(string $name)
|
||||
{
|
||||
|
@@ -39,7 +39,7 @@ use Tests\integration\TestCase;
|
||||
*/
|
||||
final class NavigationPreferredEndOfPeriodTest extends TestCase
|
||||
{
|
||||
private Navigation $navigation;
|
||||
private readonly Navigation $navigation;
|
||||
|
||||
public function __construct(string $name)
|
||||
{
|
||||
|
@@ -39,7 +39,7 @@ use Tests\integration\TestCase;
|
||||
*/
|
||||
final class NavigationPreferredRangeFormatTest extends TestCase
|
||||
{
|
||||
private Navigation $navigation;
|
||||
private readonly Navigation $navigation;
|
||||
|
||||
public function __construct(string $name)
|
||||
{
|
||||
|
@@ -39,7 +39,7 @@ use Tests\integration\TestCase;
|
||||
*/
|
||||
final class NavigationPreferredSqlFormatTest extends TestCase
|
||||
{
|
||||
private Navigation $navigation;
|
||||
private readonly Navigation $navigation;
|
||||
|
||||
public function __construct(string $name)
|
||||
{
|
||||
|
@@ -40,7 +40,7 @@ use Tests\integration\TestCase;
|
||||
*/
|
||||
final class NavigationStartOfPeriodTest extends TestCase
|
||||
{
|
||||
private Navigation $navigation;
|
||||
private readonly Navigation $navigation;
|
||||
|
||||
public function __construct(string $name)
|
||||
{
|
||||
|
Reference in New Issue
Block a user