mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
PHPstan fixes.
This commit is contained in:
parent
ff599795d3
commit
c1cc71f85c
@ -33,7 +33,7 @@ if [[ $GITHUB_ACTIONS = "" ]]
|
||||
then
|
||||
./vendor/bin/phpstan analyse -c .ci/phpstan.neon --error-format=table > phpstan-report.txt
|
||||
EXIT_CODE=$?
|
||||
echo 'The PHPstan report can be found in phpstan-report.txt'
|
||||
echo "The PHPstan report can be found in phpstan-report.txt. Exit code is $EXIT_CODE."
|
||||
fi
|
||||
|
||||
if [[ $GITHUB_ACTIONS = "true" ]]
|
||||
@ -42,7 +42,7 @@ then
|
||||
EXIT_CODE=$?
|
||||
|
||||
# temporary exit code 0
|
||||
EXIT_CODE=0
|
||||
# EXIT_CODE=0
|
||||
fi
|
||||
|
||||
exit $EXIT_CODE
|
||||
|
@ -1,63 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
#
|
||||
# phpunit.sh
|
||||
# Copyright (c) 2021 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/>.
|
||||
#
|
||||
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||
# enable test .env file.
|
||||
cp $SCRIPT_DIR/../.env $SCRIPT_DIR/../.env.backup
|
||||
cp $SCRIPT_DIR/.env.ci $SCRIPT_DIR/../.env
|
||||
|
||||
COVERAGE=false
|
||||
RESET=false
|
||||
FILE=storage/database/database.sqlite
|
||||
|
||||
while getopts "cr" o; do
|
||||
case "${o}" in
|
||||
c) COVERAGE=true;;
|
||||
r) RESET=true;;
|
||||
esac
|
||||
done
|
||||
|
||||
# reset if necessary.
|
||||
if [ $RESET = "true" ] ; then
|
||||
rm -f $FILE
|
||||
fi
|
||||
|
||||
# download test database
|
||||
if [ -f "$FILE" ]; then
|
||||
echo 'DB exists, will use it'
|
||||
else
|
||||
echo 'Download new DB'
|
||||
wget --quiet https://github.com/firefly-iii/test-fixtures/raw/main/test-database.sqlite -O $FILE
|
||||
fi
|
||||
|
||||
# run phpunit
|
||||
if [ $COVERAGE = "true" ] ; then
|
||||
echo 'Run with coverage'
|
||||
XDEBUG_MODE=coverage ./vendor/bin/phpunit --configuration phpunit.xml --coverage-html $SCRIPT_DIR/coverage
|
||||
else
|
||||
echo 'Run without coverage'
|
||||
./vendor/bin/phpunit --configuration phpunit.xml
|
||||
fi
|
||||
|
||||
# restore .env file
|
||||
mv $SCRIPT_DIR/../.env.backup $SCRIPT_DIR/../.env
|
||||
|
||||
cd $SCRIPT_DIR/..
|
@ -74,7 +74,7 @@ class Cron extends Command
|
||||
} catch (InvalidArgumentException $e) {
|
||||
$this->friendlyError(sprintf('"%s" is not a valid date', $this->option('date')));
|
||||
}
|
||||
$force = (bool) $this->option('force');
|
||||
$force = (bool) $this->option('force'); // @phpstan-ignore-line
|
||||
|
||||
/*
|
||||
* Fire exchange rates cron job.
|
||||
|
@ -213,7 +213,7 @@ class DecryptDatabase extends Command
|
||||
}
|
||||
|
||||
/** @var Preference $object */
|
||||
$object = Preference::find((int)$id);
|
||||
$object = Preference::find($id);
|
||||
if (null !== $object) {
|
||||
$object->data = $newValue;
|
||||
$object->save();
|
||||
|
@ -26,6 +26,7 @@ namespace FireflyIII\Exceptions;
|
||||
|
||||
use ErrorException;
|
||||
use FireflyIII\Jobs\MailError;
|
||||
use FireflyIII\Models\ObjectGroup;
|
||||
use Illuminate\Auth\AuthenticationException;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Database\QueryException;
|
||||
@ -124,7 +125,7 @@ class Handler extends ExceptionHandler
|
||||
$errorCode = 500;
|
||||
$errorCode = $e instanceof MethodNotAllowedHttpException ? 405 : $errorCode;
|
||||
|
||||
$isDebug = config('app.debug', false);
|
||||
$isDebug = (bool) config('app.debug', false);
|
||||
if ($isDebug) {
|
||||
app('log')->debug(sprintf('Return JSON %s with debug.', get_class($e)));
|
||||
return response()->json(
|
||||
@ -183,7 +184,7 @@ class Handler extends ExceptionHandler
|
||||
*/
|
||||
public function report(Throwable $e)
|
||||
{
|
||||
$doMailError = config('firefly.send_error_message');
|
||||
$doMailError = (bool) config('firefly.send_error_message');
|
||||
if ($this->shouldntReportLocal($e) || !$doMailError) {
|
||||
parent::report($e);
|
||||
|
||||
|
@ -82,7 +82,7 @@ class TransactionCurrencyFactory
|
||||
*/
|
||||
public function find(?int $currencyId, ?string $currencyCode): ?TransactionCurrency
|
||||
{
|
||||
$currencyCode = (string)e($currencyCode);
|
||||
$currencyCode = e($currencyCode);
|
||||
$currencyId = (int)$currencyId;
|
||||
|
||||
if ('' === $currencyCode && 0 === $currencyId) {
|
||||
|
@ -368,10 +368,10 @@ class TransactionJournalFactory
|
||||
|
||||
// validate source account.
|
||||
$array = [
|
||||
'id' => $data['source_id'] ? (int)$data['source_id'] : null,
|
||||
'name' => $data['source_name'] ? (string)$data['source_name'] : null,
|
||||
'iban' => $data['source_iban'] ? (string)$data['source_iban'] : null,
|
||||
'number' => $data['source_number'] ? (string)$data['source_number'] : null,
|
||||
'id' => null !== $data['source_id'] ? (int)$data['source_id'] : null,
|
||||
'name' => null !== $data['source_name'] ? (string)$data['source_name'] : null,
|
||||
'iban' => null !== $data['source_iban'] ? (string)$data['source_iban'] : null,
|
||||
'number' => null !== $data['source_number'] ? (string)$data['source_number'] : null,
|
||||
];
|
||||
$validSource = $this->accountValidator->validateSource($array);
|
||||
|
||||
@ -383,10 +383,10 @@ class TransactionJournalFactory
|
||||
|
||||
// validate destination account
|
||||
$array = [
|
||||
'id' => $data['destination_id'] ? (int)$data['destination_id'] : null,
|
||||
'name' => $data['destination_name'] ? (string)$data['destination_name'] : null,
|
||||
'iban' => $data['destination_iban'] ? (string)$data['destination_iban'] : null,
|
||||
'number' => $data['destination_number'] ? (string)$data['destination_number'] : null,
|
||||
'id' => null !== $data['destination_id'] ? (int)$data['destination_id'] : null,
|
||||
'name' => null !== $data['destination_name'] ? (string)$data['destination_name'] : null,
|
||||
'iban' => null !== $data['destination_iban'] ? (string)$data['destination_iban'] : null,
|
||||
'number' => null !== $data['destination_number'] ? (string)$data['destination_number'] : null,
|
||||
];
|
||||
|
||||
$validDestination = $this->accountValidator->validateDestination($array);
|
||||
|
@ -228,7 +228,7 @@ class UserEventHandler
|
||||
*/
|
||||
public function sendAdminRegistrationNotification(RegisteredUser $event): void
|
||||
{
|
||||
$sendMail = app('fireflyconfig')->get('notification_admin_new_reg', true)->data;
|
||||
$sendMail = (bool) app('fireflyconfig')->get('notification_admin_new_reg', true)->data;
|
||||
if ($sendMail) {
|
||||
/** @var UserRepositoryInterface $repository */
|
||||
$repository = app(UserRepositoryInterface::class);
|
||||
@ -358,7 +358,7 @@ class UserEventHandler
|
||||
*/
|
||||
public function sendRegistrationMail(RegisteredUser $event): void
|
||||
{
|
||||
$sendMail = app('fireflyconfig')->get('notification_user_new_reg', true)->data;
|
||||
$sendMail = (bool) app('fireflyconfig')->get('notification_user_new_reg', true)->data;
|
||||
if ($sendMail) {
|
||||
try {
|
||||
Notification::send($event->user, new UserRegistrationNotification());
|
||||
|
@ -170,7 +170,7 @@ class UserController extends Controller
|
||||
$subTitle = (string)trans('firefly.user_administration');
|
||||
$subTitleIcon = 'fa-users';
|
||||
$users = $this->repository->all();
|
||||
$singleUserMode = app('fireflyconfig')->get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
|
||||
$singleUserMode = (bool) app('fireflyconfig')->get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
|
||||
$allowInvites = false;
|
||||
if (!$this->externalIdentity && $singleUserMode) {
|
||||
// also registration enabled.
|
||||
|
@ -191,9 +191,7 @@ class LoginController extends Controller
|
||||
|
||||
$request->session()->regenerateToken();
|
||||
|
||||
if ($response = $this->loggedOut($request)) {
|
||||
return $response;
|
||||
}
|
||||
$this->loggedOut($request);
|
||||
|
||||
return $request->wantsJson()
|
||||
? new Response('', 204)
|
||||
|
@ -112,7 +112,7 @@ class ShowController extends Controller
|
||||
// file the rule(s)
|
||||
$ruleEngine->fire();
|
||||
|
||||
$request->session()->flash('success', (string)trans_choice('firefly.rescanned_bill', $total));
|
||||
$request->session()->flash('success', trans_choice('firefly.rescanned_bill', $total));
|
||||
app('preferences')->mark();
|
||||
|
||||
return redirect(route('bills.show', [$bill->id]));
|
||||
|
@ -147,7 +147,7 @@ class ExpenseReportController extends Controller
|
||||
|
||||
while ($currentStart < $end) {
|
||||
$currentEnd = clone $currentStart;
|
||||
$currentEnd = $currentEnd->$function();
|
||||
$currentEnd = $currentEnd->$function(); // @phpstan-ignore-line
|
||||
|
||||
// get expenses grouped by opposing name:
|
||||
$expenses = $this->groupByName($this->getExpensesForOpposing($accounts, $all, $currentStart, $currentEnd));
|
||||
|
@ -674,7 +674,7 @@ class CategoryController extends Controller
|
||||
|
||||
|
||||
try {
|
||||
$result = (string)view('reports.partials.categories', compact('report'))->render();
|
||||
$result = view('reports.partials.categories', compact('report'))->render();
|
||||
$cache->store($result);
|
||||
} catch (Throwable $e) {
|
||||
app('log')->error(sprintf('Could not render category::expenses: %s', $e->getMessage()));
|
||||
|
@ -89,7 +89,7 @@ class IndexController extends Controller
|
||||
public function moveRule(Request $request, Rule $rule, RuleGroup $ruleGroup): JsonResponse
|
||||
{
|
||||
$order = (int)$request->get('order');
|
||||
$this->ruleRepos->moveRule($rule, $ruleGroup, (int)$order);
|
||||
$this->ruleRepos->moveRule($rule, $ruleGroup, $order);
|
||||
|
||||
return response()->json([]);
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ class SelectController extends Controller
|
||||
$newRuleEngine->fire();
|
||||
$resultCount = $newRuleEngine->getResults();
|
||||
|
||||
session()->flash('success', (string)trans_choice('firefly.applied_rule_selection', $resultCount, ['title' => $rule->title]));
|
||||
session()->flash('success', trans_choice('firefly.applied_rule_selection', $resultCount, ['title' => $rule->title]));
|
||||
|
||||
return redirect()->route('rules.index');
|
||||
}
|
||||
|
@ -56,6 +56,7 @@ class InstallController extends Controller
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// empty on purpose.
|
||||
$this->upgradeCommands = [
|
||||
// there are 5 initial commands
|
||||
|
@ -201,7 +201,7 @@ class TagController extends Controller
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
session()->flash('success', (string)trans_choice('firefly.deleted_x_tags', $count));
|
||||
session()->flash('success', trans_choice('firefly.deleted_x_tags', $count));
|
||||
|
||||
return redirect(route('tags.index'));
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ class BulkController extends Controller
|
||||
}
|
||||
|
||||
app('preferences')->mark();
|
||||
$request->session()->flash('success', (string)trans_choice('firefly.mass_edited_transactions_success', $count));
|
||||
$request->session()->flash('success', trans_choice('firefly.mass_edited_transactions_success', $count));
|
||||
|
||||
// redirect to previous URL:
|
||||
return redirect($this->getPreviousUrl('transactions.bulk-edit.url'));
|
||||
|
@ -117,10 +117,10 @@ class DeleteController extends Controller
|
||||
|
||||
// grab asset account(s) from group:
|
||||
$accounts = [];
|
||||
/** @var TransactionJournal $journal */
|
||||
foreach ($group->transactionJournals as $journal) {
|
||||
/** @var TransactionJournal $currentJournal */
|
||||
foreach ($group->transactionJournals as $currentJournal) {
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($journal->transactions as $transaction) {
|
||||
foreach ($currentJournal->transactions as $transaction) {
|
||||
$type = $transaction->account->accountType->type;
|
||||
// if is valid liability, trigger event!
|
||||
if (in_array($type, config('firefly.valid_liabilities'), true)) {
|
||||
|
@ -118,7 +118,7 @@ class MassController extends Controller
|
||||
}
|
||||
}
|
||||
app('preferences')->mark();
|
||||
session()->flash('success', (string)trans_choice('firefly.mass_deleted_transactions_success', $count));
|
||||
session()->flash('success', trans_choice('firefly.mass_deleted_transactions_success', $count));
|
||||
|
||||
// redirect to previous URL:
|
||||
return redirect($this->getPreviousUrl('transactions.mass-delete.url'));
|
||||
@ -190,7 +190,7 @@ class MassController extends Controller
|
||||
}
|
||||
|
||||
app('preferences')->mark();
|
||||
session()->flash('success', (string)trans_choice('firefly.mass_edited_transactions_success', $count));
|
||||
session()->flash('success', trans_choice('firefly.mass_edited_transactions_success', $count));
|
||||
|
||||
// redirect to previous URL:
|
||||
return redirect($this->getPreviousUrl('transactions.mass-edit.url'));
|
||||
|
@ -67,7 +67,7 @@ class ReportNewJournalsMail extends Mailable
|
||||
|
||||
return $this
|
||||
->markdown('emails.report-new-journals')
|
||||
->subject((string)trans_choice('email.new_journals_subject', $this->groups->count()));
|
||||
->subject(trans_choice('email.new_journals_subject', $this->groups->count()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -49,7 +49,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @property int|string $user_id
|
||||
* @property int|string $account_type_id
|
||||
* @property string $name
|
||||
* @property string|null $virtual_balance
|
||||
* @property string|float|null $virtual_balance
|
||||
* @property string|null $iban
|
||||
* @property bool $active
|
||||
* @property bool $encrypted
|
||||
|
@ -36,9 +36,9 @@ use Carbon\Carbon;
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property int|string $rule_id
|
||||
* @property string $action_type
|
||||
* @property string $action_value
|
||||
* @property int $order
|
||||
* @property string|null $action_type
|
||||
* @property string|null $action_value
|
||||
* @property int|string $order
|
||||
* @property bool $active
|
||||
* @property bool $stop_processing
|
||||
* @property-read Rule $rule
|
||||
|
@ -44,7 +44,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @property int|string $user_id
|
||||
* @property string|null $title
|
||||
* @property string|null $description
|
||||
* @property int $order
|
||||
* @property int|string $order
|
||||
* @property bool $active
|
||||
* @property bool $stop_processing
|
||||
* @property Collection|Rule[] $rules
|
||||
|
@ -38,7 +38,7 @@ use Carbon\Carbon;
|
||||
* @property int|string $rule_id
|
||||
* @property string|null $trigger_type
|
||||
* @property string|null $trigger_value
|
||||
* @property int $order
|
||||
* @property int|string $order
|
||||
* @property bool $active
|
||||
* @property bool $stop_processing
|
||||
* @property-read Rule $rule
|
||||
|
@ -46,8 +46,8 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
* @property int|string $transaction_journal_id
|
||||
* @property string|null $description
|
||||
* @property int|null $transaction_currency_id
|
||||
* @property string $modified
|
||||
* @property string $modified_foreign
|
||||
* @property string|null $modified
|
||||
* @property string|null $modified_foreign
|
||||
* @property string $date
|
||||
* @property string $max_date
|
||||
* @property string|float $amount
|
||||
|
@ -41,16 +41,16 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
/**
|
||||
* FireflyIII\Models\TransactionJournal
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property int|string $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int|string $user_id
|
||||
* @property int |string $transaction_type_id
|
||||
* @property int|null $transaction_group_id
|
||||
* @property int|null $bill_id
|
||||
* @property int|null $transaction_currency_id
|
||||
* @property string $description
|
||||
* @property int|string $user_id
|
||||
* @property int |string $transaction_type_id
|
||||
* @property int|string|null $transaction_group_id
|
||||
* @property int|string|null $bill_id
|
||||
* @property int|string|null $transaction_currency_id
|
||||
* @property string|null $description
|
||||
* @property Carbon $date
|
||||
* @property Carbon|null $interest_date
|
||||
* @property Carbon|null $book_date
|
||||
@ -114,7 +114,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method static \Illuminate\Database\Query\Builder|TransactionJournal withoutTrashed()
|
||||
* @property-read Collection|Location[] $locations
|
||||
* @property-read int|null $locations_count
|
||||
* @property int $the_count
|
||||
* @property int|string $the_count
|
||||
* @property int|null $user_group_id
|
||||
* @method static EloquentBuilder|TransactionJournal whereUserGroupId($value)
|
||||
* @property-read Collection<int, AuditLogEntry> $auditLogEntries
|
||||
|
@ -72,7 +72,7 @@ class TransactionCreation extends Notification
|
||||
{
|
||||
return (new MailMessage())
|
||||
->markdown('emails.report-new-journals', ['transformed' => $this->collection])
|
||||
->subject((string)trans_choice('email.new_journals_subject', count($this->collection)));
|
||||
->subject(trans_choice('email.new_journals_subject', count($this->collection)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -111,7 +111,7 @@ class OperationsRepository implements OperationsRepositoryInterface
|
||||
];
|
||||
|
||||
$array[$currencyId]['transaction_journals'][$journalId] = [
|
||||
'amount' => app('steam')->$direction((string)$journal['amount']),
|
||||
'amount' => app('steam')->$direction((string)$journal['amount']), // @phpstan-ignore-line
|
||||
'date' => $journal['date'],
|
||||
'transaction_journal_id' => $journalId,
|
||||
'budget_name' => $journal['budget_name'],
|
||||
@ -268,7 +268,7 @@ class OperationsRepository implements OperationsRepositoryInterface
|
||||
'currency_code' => $journal['currency_code'],
|
||||
'currency_decimal_places' => $journal['currency_decimal_places'],
|
||||
];
|
||||
$array[$currencyId]['sum'] = bcadd($array[$currencyId]['sum'], app('steam')->$direction($journal['amount']));
|
||||
$array[$currencyId]['sum'] = bcadd($array[$currencyId]['sum'], app('steam')->$direction($journal['amount']));// @phpstan-ignore-line
|
||||
|
||||
// also do foreign amount:
|
||||
$foreignId = (int)$journal['foreign_currency_id'];
|
||||
@ -281,7 +281,7 @@ class OperationsRepository implements OperationsRepositoryInterface
|
||||
'currency_code' => $journal['foreign_currency_code'],
|
||||
'currency_decimal_places' => $journal['foreign_currency_decimal_places'],
|
||||
];
|
||||
$array[$foreignId]['sum'] = bcadd($array[$foreignId]['sum'], app('steam')->$direction($journal['foreign_amount']));
|
||||
$array[$foreignId]['sum'] = bcadd($array[$foreignId]['sum'], app('steam')->$direction($journal['foreign_amount']));// @phpstan-ignore-line
|
||||
}
|
||||
}
|
||||
|
||||
@ -328,7 +328,7 @@ class OperationsRepository implements OperationsRepositoryInterface
|
||||
'currency_code' => $journal['currency_code'],
|
||||
'currency_decimal_places' => $journal['currency_decimal_places'],
|
||||
];
|
||||
$array[$key]['sum'] = bcadd($array[$key]['sum'], app('steam')->$method((string)$journal['amount']));
|
||||
$array[$key]['sum'] = bcadd($array[$key]['sum'], app('steam')->$method((string)$journal['amount']));// @phpstan-ignore-line
|
||||
|
||||
// also do foreign amount:
|
||||
if (0 !== (int)$journal['foreign_currency_id']) {
|
||||
@ -343,7 +343,7 @@ class OperationsRepository implements OperationsRepositoryInterface
|
||||
'currency_code' => $journal['foreign_currency_code'],
|
||||
'currency_decimal_places' => $journal['foreign_currency_decimal_places'],
|
||||
];
|
||||
$array[$key]['sum'] = bcadd($array[$key]['sum'], app('steam')->$method((string)$journal['foreign_amount']));
|
||||
$array[$key]['sum'] = bcadd($array[$key]['sum'], app('steam')->$method((string)$journal['foreign_amount']));// @phpstan-ignore-line
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ class BillRepository implements BillRepositoryInterface
|
||||
public function findBill(?int $billId, ?string $billName): ?Bill
|
||||
{
|
||||
if (null !== $billId) {
|
||||
$searchResult = $this->find((int)$billId);
|
||||
$searchResult = $this->find($billId);
|
||||
if (null !== $searchResult) {
|
||||
app('log')->debug(sprintf('Found bill based on #%d, will return it.', $billId));
|
||||
|
||||
@ -145,7 +145,7 @@ class BillRepository implements BillRepositoryInterface
|
||||
}
|
||||
}
|
||||
if (null !== $billName) {
|
||||
$searchResult = $this->findByName((string)$billName);
|
||||
$searchResult = $this->findByName($billName);
|
||||
if (null !== $searchResult) {
|
||||
app('log')->debug(sprintf('Found bill based on "%s", will return it.', $billName));
|
||||
|
||||
|
@ -530,7 +530,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
$result = $this->find((int)$budgetId);
|
||||
if (null === $result && null !== $budgetName && '' !== $budgetName) {
|
||||
app('log')->debug(sprintf('Searching for budget with name %s...', $budgetName));
|
||||
$result = $this->findByName((string)$budgetName);
|
||||
$result = $this->findByName($budgetName);
|
||||
}
|
||||
if (null !== $result) {
|
||||
app('log')->debug(sprintf('Found budget #%d: %s', $result->id, $result->name));
|
||||
|
@ -382,8 +382,8 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
|
||||
*/
|
||||
public function updateLink(TransactionJournalLink $journalLink, array $data): TransactionJournalLink
|
||||
{
|
||||
$journalLink->source_id = $data['inward_id'] ?: $journalLink->source_id;
|
||||
$journalLink->destination_id = $data['outward_id'] ?: $journalLink->destination_id;
|
||||
$journalLink->source_id = null === $data['inward_id'] ? $journalLink->source_id : $data['inward_id'];
|
||||
$journalLink->destination_id = null === $data['outward_id'] ? $journalLink->destination_id : $data['outward_id'];
|
||||
$journalLink->save();
|
||||
if (array_key_exists('link_type_name', $data)) {
|
||||
$linkType = LinkType::whereName($data['link_type_name'])->first();
|
||||
@ -394,7 +394,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
|
||||
$journalLink->refresh();
|
||||
}
|
||||
|
||||
$journalLink->link_type_id = $data['link_type_id'] ?: $journalLink->link_type_id;
|
||||
$journalLink->link_type_id = null === $data['link_type_id'] ? $journalLink->link_type_id : $data['link_type_id'];
|
||||
$journalLink->save();
|
||||
if (array_key_exists('notes', $data) && null !== $data['notes']) {
|
||||
$this->setNoteText($journalLink, $data['notes']);
|
||||
|
@ -68,7 +68,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
app('log')->debug('Searching for piggy information.');
|
||||
|
||||
if (null !== $piggyBankId) {
|
||||
$searchResult = $this->find((int)$piggyBankId);
|
||||
$searchResult = $this->find($piggyBankId);
|
||||
if (null !== $searchResult) {
|
||||
app('log')->debug(sprintf('Found piggy based on #%d, will return it.', $piggyBankId));
|
||||
|
||||
@ -76,7 +76,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
}
|
||||
}
|
||||
if (null !== $piggyBankName) {
|
||||
$searchResult = $this->findByName((string)$piggyBankName);
|
||||
$searchResult = $this->findByName($piggyBankName);
|
||||
if (null !== $searchResult) {
|
||||
app('log')->debug(sprintf('Found piggy based on "%s", will return it.', $piggyBankName));
|
||||
|
||||
@ -227,11 +227,11 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
$amount = null;
|
||||
if ((int)$source->transaction_currency_id === (int)$currency->id) {
|
||||
app('log')->debug('Use normal amount');
|
||||
$amount = app('steam')->$operator($source->amount);
|
||||
$amount = app('steam')->$operator($source->amount); // @phpstan-ignore-line
|
||||
}
|
||||
if ((int)$source->foreign_currency_id === (int)$currency->id) {
|
||||
app('log')->debug('Use foreign amount');
|
||||
$amount = app('steam')->$operator($source->foreign_amount);
|
||||
$amount = app('steam')->$operator($source->foreign_amount); // @phpstan-ignore-line
|
||||
}
|
||||
if (null === $amount) {
|
||||
app('log')->debug('No match on currency, so amount remains null, return "0".');
|
||||
|
@ -85,7 +85,7 @@ class UserGroupRepository implements UserGroupRepositoryInterface
|
||||
'recurrences', 'rules', 'ruleGroups', 'tags', 'transactionGroups', 'transactionJournals', 'piggyBanks', 'accounts', 'webhooks',
|
||||
];
|
||||
foreach ($objects as $object) {
|
||||
foreach ($userGroup->$object()->get() as $item) {
|
||||
foreach ($userGroup->$object()->get() as $item) { // @phpstan-ignore-line
|
||||
$item->delete();
|
||||
}
|
||||
}
|
||||
@ -135,7 +135,7 @@ class UserGroupRepository implements UserGroupRepositoryInterface
|
||||
}
|
||||
if (null !== $existingGroup) {
|
||||
// group already exists
|
||||
$groupName = sprintf('%s-%s', $user->email, substr(sha1((string)(rand(1000, 9999) . microtime())), 0, 4));
|
||||
$groupName = sprintf('%s-%s', $user->email, substr(sha1((rand(1000, 9999) . microtime())), 0, 4));
|
||||
}
|
||||
$loop++;
|
||||
}
|
||||
|
@ -49,7 +49,6 @@ class BelongsUser implements ValidationRule
|
||||
$fail('validation.belongs_user')->translate();
|
||||
return;
|
||||
}
|
||||
$attribute = (string)$attribute;
|
||||
app('log')->debug(sprintf('Going to validate %s', $attribute));
|
||||
|
||||
$result = match ($attribute) {
|
||||
@ -135,7 +134,7 @@ class BelongsUser implements ValidationRule
|
||||
}
|
||||
$count = 0;
|
||||
foreach ($objects as $object) {
|
||||
$objectValue = trim((string)$object->$field);
|
||||
$objectValue = trim((string)$object->$field); // @phpstan-ignore-line
|
||||
app('log')->debug(sprintf('Comparing object "%s" with value "%s"', $objectValue, $value));
|
||||
if ($objectValue === $value) {
|
||||
$count++;
|
||||
|
@ -64,7 +64,6 @@ class BelongsUserGroup implements ValidationRule
|
||||
$fail('validation.belongs_user_or_user_group')->translate();
|
||||
return;
|
||||
}
|
||||
$attribute = (string)$attribute;
|
||||
app('log')->debug(sprintf('Group: Going to validate "%s"', $attribute));
|
||||
|
||||
$result = match ($attribute) {
|
||||
@ -150,7 +149,7 @@ class BelongsUserGroup implements ValidationRule
|
||||
}
|
||||
$count = 0;
|
||||
foreach ($objects as $object) {
|
||||
$objectValue = trim((string)$object->$field);
|
||||
$objectValue = trim((string)$object->$field); // @phpstan-ignore-line
|
||||
app('log')->debug(sprintf('Comparing object "%s" with value "%s"', $objectValue, $value));
|
||||
if ($objectValue === $value) {
|
||||
$count++;
|
||||
|
@ -107,7 +107,7 @@ class IsValidAttachmentModel implements ValidationRule
|
||||
}
|
||||
$method = $methods[$this->model];
|
||||
|
||||
$result = $this->$method((int)$value);
|
||||
$result = $this->$method((int)$value); // @phpstan-ignore-line
|
||||
if(false === $result) {
|
||||
$fail('validation.model_id_invalid')->translate();
|
||||
}
|
||||
@ -221,6 +221,6 @@ class IsValidAttachmentModel implements ValidationRule
|
||||
$repository = app(JournalAPIRepositoryInterface::class);
|
||||
$repository->setUser(auth()->user());
|
||||
|
||||
return null !== $repository->findTransaction((int)$value);
|
||||
return null !== $repository->findTransaction($value);
|
||||
}
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ trait RecurringTransactionTrait
|
||||
$repository->setUser($this->user);
|
||||
|
||||
// if user has submitted an account ID, search for it.
|
||||
$result = $repository->find((int)$accountId);
|
||||
$result = $repository->find($accountId);
|
||||
if (null !== $result) {
|
||||
return $result;
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ class CurrencyUpdateService
|
||||
$currency->enabled = false;
|
||||
|
||||
if (array_key_exists('decimal_places', $data) && is_int($data['decimal_places'])) {
|
||||
$currency->decimal_places = (int)$data['decimal_places'];
|
||||
$currency->decimal_places = $data['decimal_places'];
|
||||
}
|
||||
$currency->userEnabled = null;
|
||||
$currency->userDefault = null;
|
||||
|
@ -536,12 +536,12 @@ class JournalUpdateService
|
||||
$this->transactionJournal->user,
|
||||
$this->transactionJournal,
|
||||
sprintf('update_%s', $fieldName),
|
||||
$this->transactionJournal->$fieldName,
|
||||
$this->transactionJournal->$fieldName, // @phpstan-ignore-line
|
||||
$value
|
||||
)
|
||||
);
|
||||
|
||||
$this->transactionJournal->$fieldName = $value;
|
||||
$this->transactionJournal->$fieldName = $value;// @phpstan-ignore-line
|
||||
app('log')->debug(sprintf('Updated %s', $fieldName));
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ class CLIToken implements BinderInterface
|
||||
$users = $repository->all();
|
||||
|
||||
// check for static token
|
||||
if ($value === config('firefly.static_cron_token') && 32 === strlen((string)config('firefly.static_cron_token'))) {
|
||||
if ($value === config('firefly.static_cron_token') && 32 === strlen(config('firefly.static_cron_token'))) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
@ -249,7 +249,7 @@ trait ModelInformation
|
||||
$values[$index] = $notes->text;
|
||||
}
|
||||
|
||||
foreach ($journalTriggers as $index => $trigger) {
|
||||
foreach ($journalTriggers as $ii => $trigger) {
|
||||
try {
|
||||
$string = view(
|
||||
'rules.partials.trigger',
|
||||
@ -257,14 +257,13 @@ trait ModelInformation
|
||||
'oldTrigger' => $trigger,
|
||||
'oldValue' => $values[$index],
|
||||
'oldChecked' => false,
|
||||
'count' => $index + 1,
|
||||
'count' => $ii + 1,
|
||||
'triggers' => $triggers,
|
||||
]
|
||||
)->render();
|
||||
} catch (Throwable $e) {
|
||||
app('log')->debug(sprintf('Throwable was thrown in getTriggersForJournal(): %s', $e->getMessage()));
|
||||
app('log')->debug($e->getTraceAsString());
|
||||
$string = '';
|
||||
throw new FireflyException('Could not render trigger', 0, $e);
|
||||
}
|
||||
if ('' !== $string) {
|
||||
|
@ -46,7 +46,7 @@ class Navigation
|
||||
*/
|
||||
public function __construct(Calculator $calculator = null)
|
||||
{
|
||||
$this->calculator = ($calculator instanceof Calculator) ?: new Calculator();
|
||||
$this->calculator = $calculator instanceof Calculator ? $calculator : new Calculator();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -213,7 +213,7 @@ class Navigation
|
||||
];
|
||||
if (array_key_exists($repeatFreq, $functionMap)) {
|
||||
$function = $functionMap[$repeatFreq];
|
||||
$date->$function();
|
||||
$date->$function(); // @phpstan-ignore-line
|
||||
|
||||
return $date;
|
||||
}
|
||||
@ -325,7 +325,7 @@ class Navigation
|
||||
$function = $functionMap[$repeatFreq];
|
||||
|
||||
if (array_key_exists($repeatFreq, $modifierMap)) {
|
||||
$currentEnd->$function($modifierMap[$repeatFreq]);
|
||||
$currentEnd->$function($modifierMap[$repeatFreq]); // @phpstan-ignore-line
|
||||
if (in_array($repeatFreq, $subDay, true)) {
|
||||
$currentEnd->subDay();
|
||||
}
|
||||
@ -333,7 +333,7 @@ class Navigation
|
||||
|
||||
return $currentEnd;
|
||||
}
|
||||
$currentEnd->$function();
|
||||
$currentEnd->$function(); // @phpstan-ignore-line
|
||||
$currentEnd->endOfDay();
|
||||
if (in_array($repeatFreq, $subDay, true)) {
|
||||
$currentEnd->subDay();
|
||||
@ -372,7 +372,7 @@ class Navigation
|
||||
}
|
||||
$func = $map[$period];
|
||||
// first do the diff
|
||||
$floatDiff = $beginning->$func($end);
|
||||
$floatDiff = $beginning->$func($end); // @phpstan-ignore-line
|
||||
|
||||
|
||||
// then correct for quarterly or half-year
|
||||
@ -434,7 +434,7 @@ class Navigation
|
||||
|
||||
if (array_key_exists($repeatFreq, $functionMap)) {
|
||||
$function = $functionMap[$repeatFreq];
|
||||
$currentEnd->$function();
|
||||
$currentEnd->$function(); // @phpstan-ignore-line
|
||||
}
|
||||
|
||||
if (null !== $maxDate && $currentEnd > $maxDate) {
|
||||
@ -508,7 +508,7 @@ class Navigation
|
||||
$formatted = $begin->format($format);
|
||||
$displayed = $begin->isoFormat($displayFormat);
|
||||
$entries[$formatted] = $displayed;
|
||||
$begin->$increment();
|
||||
$begin->$increment(); // @phpstan-ignore-line
|
||||
}
|
||||
|
||||
return $entries;
|
||||
@ -563,7 +563,7 @@ class Navigation
|
||||
];
|
||||
|
||||
if (array_key_exists($repeatFrequency, $formatMap)) {
|
||||
return $date->isoFormat((string)$formatMap[$repeatFrequency]);
|
||||
return $date->isoFormat($formatMap[$repeatFrequency]);
|
||||
}
|
||||
if ('3M' === $repeatFrequency || 'quarter' === $repeatFrequency) {
|
||||
$quarter = ceil($theDate->month / 3);
|
||||
@ -726,7 +726,7 @@ class Navigation
|
||||
];
|
||||
if (array_key_exists($repeatFreq, $functionMap)) {
|
||||
$function = $functionMap[$repeatFreq];
|
||||
$date->$function($subtract);
|
||||
$date->$function($subtract); // @phpstan-ignore-line
|
||||
|
||||
return $date;
|
||||
}
|
||||
@ -801,7 +801,7 @@ class Navigation
|
||||
|
||||
if (array_key_exists($range, $functionMap)) {
|
||||
$function = $functionMap[$range];
|
||||
$end->$function();
|
||||
$end->$function(); // @phpstan-ignore-line
|
||||
|
||||
return $end;
|
||||
}
|
||||
@ -862,7 +862,7 @@ class Navigation
|
||||
];
|
||||
if (array_key_exists($range, $functionMap)) {
|
||||
$function = $functionMap[$range];
|
||||
$start->$function();
|
||||
$start->$function(); // @phpstan-ignore-line
|
||||
|
||||
return $start;
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ class ParseDateString
|
||||
}
|
||||
$func = $functions[$direction][$period];
|
||||
app('log')->debug(sprintf('Will now do %s(%d) on %s', $func, $number, $today->format('Y-m-d')));
|
||||
$today->$func($number);
|
||||
$today->$func($number); // @phpstan-ignore-line
|
||||
app('log')->debug(sprintf('Resulting date is %s', $today->format('Y-m-d')));
|
||||
}
|
||||
|
||||
|
@ -117,9 +117,9 @@ trait AppendsLocationData
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function isValidPOST(?string $prefix): bool
|
||||
private function isValidPost(?string $prefix): bool
|
||||
{
|
||||
app('log')->debug('Now in isValidPOST()');
|
||||
app('log')->debug('Now in isValidPost()');
|
||||
$longitudeKey = $this->getLocationKey($prefix, 'longitude');
|
||||
$latitudeKey = $this->getLocationKey($prefix, 'latitude');
|
||||
$zoomLevelKey = $this->getLocationKey($prefix, 'zoom_level');
|
||||
|
@ -353,7 +353,7 @@ trait ConvertsDataTypes
|
||||
{
|
||||
$return = [];
|
||||
foreach ($fields as $field => $info) {
|
||||
if ($this->has($info[0])) {
|
||||
if (true === $this->has($info[0])) {
|
||||
$method = $info[1];
|
||||
$return[$field] = $this->$method($info[0]); // @phpstan-ignore-line
|
||||
}
|
||||
@ -422,7 +422,7 @@ trait ConvertsDataTypes
|
||||
*/
|
||||
protected function nullableInteger(string $field): ?int
|
||||
{
|
||||
if (!$this->has($field)) {
|
||||
if (false === $this->has($field)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,8 @@ use TypeError;
|
||||
/**
|
||||
* Class OperatorQuerySearch
|
||||
*/
|
||||
class OperatorQuerySearch implements SearchInterface
|
||||
class
|
||||
OperatorQuerySearch implements SearchInterface
|
||||
{
|
||||
protected Carbon $date;
|
||||
private AccountRepositoryInterface $accountRepository;
|
||||
@ -1422,7 +1423,7 @@ class OperatorQuerySearch implements SearchInterface
|
||||
return;
|
||||
}
|
||||
app('log')->debug(sprintf('Left with %d, set as %s().', $filtered->count(), $collectorMethod));
|
||||
$this->collector->$collectorMethod($filtered);
|
||||
$this->collector->$collectorMethod($filtered); // @phpstan-ignore-line
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1512,7 +1513,7 @@ class OperatorQuerySearch implements SearchInterface
|
||||
return;
|
||||
}
|
||||
app('log')->debug(sprintf('Left with %d, set as %s().', $filtered->count(), $collectorMethod));
|
||||
$this->collector->$collectorMethod($filtered);
|
||||
$this->collector->$collectorMethod($filtered);// @phpstan-ignore-line
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -164,8 +164,8 @@ class Steam
|
||||
/** @var Transaction $entry */
|
||||
foreach ($set as $entry) {
|
||||
// normal amount and foreign amount
|
||||
$modified = null === $entry->modified ? '0' : (string)$entry->modified;
|
||||
$foreignModified = null === $entry->modified_foreign ? '0' : (string)$entry->modified_foreign;
|
||||
$modified = null === $entry->modified ? '0' : $entry->modified;
|
||||
$foreignModified = null === $entry->modified_foreign ? '0' :$entry->modified_foreign;
|
||||
$amount = '0';
|
||||
if ($currencyId === (int)$entry->transaction_currency_id || 0 === $currencyId) {
|
||||
// use normal amount:
|
||||
|
Loading…
Reference in New Issue
Block a user