PHPstan fixes.

This commit is contained in:
James Cole
2023-11-05 08:15:17 +01:00
parent ff599795d3
commit c1cc71f85c
48 changed files with 101 additions and 166 deletions

View File

@@ -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.

View File

@@ -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)

View File

@@ -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]));

View File

@@ -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));

View File

@@ -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()));

View File

@@ -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([]);
}

View File

@@ -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');
}

View File

@@ -56,6 +56,7 @@ class InstallController extends Controller
*/
public function __construct()
{
parent::__construct();
// empty on purpose.
$this->upgradeCommands = [
// there are 5 initial commands

View File

@@ -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'));
}

View File

@@ -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'));

View File

@@ -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)) {

View File

@@ -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'));