Fix phpstan issues.

This commit is contained in:
James Cole
2023-11-05 16:55:16 +01:00
parent 4edd9fe3da
commit a0564751d6
72 changed files with 110 additions and 138 deletions

View File

@@ -158,7 +158,7 @@ class CreateController extends Controller
}
// store attachment(s):
/** @var array $files */
/** @var array|null $files */
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
if (null !== $files && !auth()->user()->hasRole('demo')) {
$this->attachments->saveAttachmentsForModel($account, $files);

View File

@@ -79,7 +79,7 @@ class ForgotPasswordController extends Controller
$this->validateEmail($request);
// verify if the user is not a demo user. If so, we give him back an error.
/** @var User $user */
/** @var User|null $user */
$user = User::where('email', $request->get('email'))->first();
if (null !== $user && $repository->hasRole($user, 'demo')) {

View File

@@ -97,7 +97,7 @@ class LoginController extends Controller
// If the class is using the ThrottlesLogins trait, we can automatically throttle
// the login attempts for this application. We'll key this by the username and
// the IP address of the client making these requests into this application.
if (method_exists($this, 'hasTooManyLoginAttempts') && $this->hasTooManyLoginAttempts($request)) {
if ($this->hasTooManyLoginAttempts($request)) {
Log::channel('audit')->info(sprintf('Login for user "%s" was locked out.', $request->get($this->username())));
app('log')->error(sprintf('Login for user "%s" was locked out.', $request->get($this->username())));
$this->fireLockoutEvent($request);

View File

@@ -114,7 +114,7 @@ class CreateController extends Controller
$request->session()->flash('success', (string)trans('firefly.stored_new_bill', ['name' => $bill->name]));
app('preferences')->mark();
/** @var array $files */
/** @var array|null $files */
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
if (null !== $files && !auth()->user()->hasRole('demo')) {
$this->attachments->saveAttachmentsForModel($bill, $files);

View File

@@ -128,7 +128,7 @@ class EditController extends Controller
$request->session()->flash('success', (string)trans('firefly.updated_bill', ['name' => $bill->name]));
app('preferences')->mark();
/** @var array $files */
/** @var array|null $files */
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
if (null !== $files && !auth()->user()->hasRole('demo')) {
$this->attachments->saveAttachmentsForModel($bill, $files);

View File

@@ -90,11 +90,7 @@ class ShowController extends Controller
return redirect(route('bills.show', [$bill->id]));
}
$set = new Collection();
if (true === $bill->active) {
$set = $this->repository->getRulesForBill($bill);
$total = 0;
}
$set = $this->repository->getRulesForBill($bill);
if (0 === $set->count()) {
$request->session()->flash('error', (string)trans('firefly.no_rules_for_bill'));

View File

@@ -103,7 +103,7 @@ class CreateController extends Controller
app('preferences')->mark();
// store attachment(s):
/** @var array $files */
/** @var array|null $files */
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
if (null !== $files && !auth()->user()->hasRole('demo')) {
$this->attachments->saveAttachmentsForModel($piggyBank, $files);

View File

@@ -127,7 +127,7 @@ class EditController extends Controller
app('preferences')->mark();
// store new attachment(s):
/** @var array $files */
/** @var array|null $files */
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
if (null !== $files && !auth()->user()->hasRole('demo')) {
$this->attachments->saveAttachmentsForModel($piggyBank, $files);

View File

@@ -241,7 +241,7 @@ class CreateController extends Controller
app('preferences')->mark();
// store attachment(s):
/** @var array $files */
/** @var array|null $files */
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
if (null !== $files && !auth()->user()->hasRole('demo')) {
$this->attachments->saveAttachmentsForModel($recurrence, $files);

View File

@@ -327,7 +327,7 @@ class TagController extends Controller
app('preferences')->mark();
// store attachment(s):
/** @var array $files */
/** @var array|null $files */
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
if (null !== $files && !auth()->user()->hasRole('demo')) {
$this->attachmentsHelper->saveAttachmentsForModel($result, $files);
@@ -366,7 +366,7 @@ class TagController extends Controller
app('preferences')->mark();
// store new attachment(s):
/** @var array $files */
/** @var array|null $files */
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
if (null !== $files && !auth()->user()->hasRole('demo')) {
$this->attachmentsHelper->saveAttachmentsForModel($tag, $files);

View File

@@ -106,7 +106,7 @@ class MassController extends Controller
/** @var string $journalId */
foreach ($ids as $journalId) {
app('log')->debug(sprintf('Searching for ID #%d', $journalId));
/** @var TransactionJournal $journal */
/** @var TransactionJournal|null $journal */
$journal = $this->repository->find((int)$journalId);
if (null !== $journal && (int)$journalId === (int)$journal->id) {
$this->repository->destroyJournal($journal);