Various code fixes

This commit is contained in:
James Cole
2022-12-31 13:32:42 +01:00
parent 5878b2c427
commit 7722ca2bf0
34 changed files with 106 additions and 174 deletions

View File

@@ -53,7 +53,7 @@ use Throwable;
class Handler extends ExceptionHandler class Handler extends ExceptionHandler
{ {
/** /**
* @var array * @var array<int, class-string<Throwable>>
*/ */
protected $dontReport protected $dontReport
= [ = [

View File

@@ -26,7 +26,6 @@ namespace FireflyIII\Generator\Report\Budget;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Generator\Report\ReportGeneratorInterface; use FireflyIII\Generator\Report\ReportGeneratorInterface;
use FireflyIII\Generator\Report\Support;
use FireflyIII\Helpers\Collector\GroupCollectorInterface; use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Models\TransactionType; use FireflyIII\Models\TransactionType;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;

View File

@@ -26,7 +26,6 @@ namespace FireflyIII\Generator\Report\Category;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Generator\Report\ReportGeneratorInterface; use FireflyIII\Generator\Report\ReportGeneratorInterface;
use FireflyIII\Generator\Report\Support;
use FireflyIII\Helpers\Collector\GroupCollectorInterface; use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Models\TransactionType; use FireflyIII\Models\TransactionType;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
@@ -41,26 +40,20 @@ use Throwable;
*/ */
class MonthReportGenerator implements ReportGeneratorInterface class MonthReportGenerator implements ReportGeneratorInterface
{ {
/** @var Collection The included accounts */ private Collection $accounts;
private $accounts; private Collection $categories;
/** @var Collection The included categories */ private Carbon $end;
private $categories; private array $expenses;
/** @var Carbon The end date */ private array $income;
private $end; private Carbon $start;
/** @var array The expenses */
private $expenses;
/** @var array The income in the report. */
private $income;
/** @var Carbon The start date. */
private $start;
/** /**
* MonthReportGenerator constructor. * MonthReportGenerator constructor.
*/ */
public function __construct() public function __construct()
{ {
$this->income = new Collection(); $this->income = [];
$this->expenses = new Collection(); $this->expenses = [];
} }
/** /**

View File

@@ -26,7 +26,6 @@ namespace FireflyIII\Generator\Report\Tag;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Generator\Report\ReportGeneratorInterface; use FireflyIII\Generator\Report\ReportGeneratorInterface;
use FireflyIII\Generator\Report\Support;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Log; use Log;
use Throwable; use Throwable;
@@ -38,27 +37,22 @@ use Throwable;
*/ */
class MonthReportGenerator implements ReportGeneratorInterface class MonthReportGenerator implements ReportGeneratorInterface
{ {
/** @var Collection The accounts involved */ private Collection $accounts;
private $accounts; private Carbon $end;
/** @var Carbon The end date */ private array $expenses;
private $end; private array $income;
/** @var array The expenses involved */ private Carbon $start;
private $expenses; private Collection $tags;
/** @var array The income involved */
private $income;
/** @var Carbon The start date */
private $start;
/** @var Collection The tags involved. */
private $tags;
/** /**
* MonthReportGenerator constructor. * MonthReportGenerator constructor.
*/ */
public function __construct() public function __construct()
{ {
$this->expenses = new Collection(); $this->expenses = [];
$this->income = new Collection(); $this->income = [];
$this->tags = new Collection(); $this->tags = new Collection();
$this->accounts = new Collection();
} }
/** /**

View File

@@ -1157,6 +1157,12 @@ interface GroupCollectorInterface
*/ */
public function setSearchWords(array $array): GroupCollectorInterface; public function setSearchWords(array $array): GroupCollectorInterface;
/**
* @param string $sepaCT
* @return GroupCollectorInterface
*/
public function setSepaCT(string $sepaCT): GroupCollectorInterface;
/** /**
* Set source accounts. * Set source accounts.
* *

View File

@@ -42,7 +42,7 @@ class FiscalHelper implements FiscalHelperInterface
*/ */
public function __construct() public function __construct()
{ {
$this->useCustomFiscalYear = app('preferences')->get('customFiscalYear', false)->data; $this->useCustomFiscalYear = (bool) app('preferences')->get('customFiscalYear', false)->data;
} }
/** /**

View File

@@ -165,7 +165,7 @@ class LoginController extends Controller
* *
* @param Request $request * @param Request $request
* *
* @return Response * @return RedirectResponse|Redirector|Response
*/ */
public function logout(Request $request) public function logout(Request $request)
{ {

View File

@@ -121,12 +121,13 @@ class BudgetLimitController extends Controller
} }
/** /**
* TODO why redirect AND json response?
* @param Request $request * @param Request $request
* *
* @return JsonResponse * @return RedirectResponse|JsonResponse
* @throws FireflyException * @throws FireflyException
*/ */
public function store(Request $request) public function store(Request $request): RedirectResponse|JsonResponse
{ {
Log::debug('Going to store new budget-limit.', $request->all()); Log::debug('Going to store new budget-limit.', $request->all());
// first search for existing one and update it if necessary. // first search for existing one and update it if necessary.

View File

@@ -236,84 +236,6 @@ class DebugController extends Controller
); );
} }
/**
* Return all possible routes.
*
* @return string
*/
public function routes(): string
{
$set = RouteFacade::getRoutes();
$ignore = [
'chart.',
'javascript.',
'json.',
'report-data.',
'popup.',
'debugbar.',
'attachments.download',
'attachments.preview',
'bills.rescan',
'budgets.income',
'currencies.def',
'error',
'flush',
'help.show',
'login',
'logout',
'password.reset',
'profile.confirm-email-change',
'profile.undo-email-change',
'register',
'report.options',
'routes',
'rule-groups.down',
'rule-groups.up',
'rules.up',
'rules.down',
'rules.select',
'search.search',
'test-flash',
'transactions.link.delete',
'transactions.link.switch',
'two-factor.lost',
'reports.options',
'debug',
'preferences.delete-code',
'rules.test-triggers',
'piggy-banks.remove-money',
'piggy-banks.add-money',
'accounts.reconcile.transactions',
'accounts.reconcile.overview',
'transactions.clone',
'two-factor.index',
'api.v1',
'installer.',
'attachments.view',
'recurring.events',
'recurring.suggest',
];
$return = '&nbsp;';
/** @var Route $route */
foreach ($set as $route) {
$name = (string)$route->getName();
if (in_array('GET', $route->methods(), true)) {
$found = false;
foreach ($ignore as $string) {
if (false !== stripos($name, $string)) {
$found = true;
break;
}
}
if (false === $found) {
$return .= 'touch '.$route->getName().'.md;';
}
}
}
return $return;
}
/** /**
* Flash all types of messages. * Flash all types of messages.
* *

View File

@@ -102,14 +102,14 @@ class ProfileController extends Controller
* *
* @param Request $request * @param Request $request
* *
* @return Factory|View * @return Factory|View|RedirectResponse
* @throws IncompatibleWithGoogleAuthenticatorException * @throws IncompatibleWithGoogleAuthenticatorException
* @throws InvalidCharactersException * @throws InvalidCharactersException
* @throws SecretKeyTooShortException * @throws SecretKeyTooShortException
* @throws ContainerExceptionInterface * @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface * @throws NotFoundExceptionInterface
*/ */
public function code(Request $request) public function code(Request $request): Factory|View|RedirectResponse
{ {
if (!$this->internalAuth || !$this->internalIdentity) { if (!$this->internalAuth || !$this->internalIdentity) {
$request->session()->flash('error', trans('firefly.external_user_mgt_disabled')); $request->session()->flash('error', trans('firefly.external_user_mgt_disabled'));
@@ -165,7 +165,7 @@ class ProfileController extends Controller
* *
* @throws FireflyException * @throws FireflyException
*/ */
public function confirmEmailChange(UserRepositoryInterface $repository, string $token) public function confirmEmailChange(UserRepositoryInterface $repository, string $token): RedirectResponse|Redirector
{ {
if (!$this->internalAuth || !$this->internalIdentity) { if (!$this->internalAuth || !$this->internalIdentity) {
throw new FireflyException(trans('firefly.external_user_mgt_disabled')); throw new FireflyException(trans('firefly.external_user_mgt_disabled'));
@@ -186,7 +186,7 @@ class ProfileController extends Controller
} }
$repository->unblockUser($user); $repository->unblockUser($user);
// return to login. // return to log in.
session()->flash('success', (string)trans('firefly.login_with_new_email')); session()->flash('success', (string)trans('firefly.login_with_new_email'));
return redirect(route('login')); return redirect(route('login'));
@@ -199,7 +199,7 @@ class ProfileController extends Controller
* *
* @return Application|RedirectResponse|Redirector * @return Application|RedirectResponse|Redirector
*/ */
public function deleteAccount(Request $request) public function deleteAccount(Request $request): Application|RedirectResponse|Redirector
{ {
if (!$this->internalAuth || !$this->internalIdentity) { if (!$this->internalAuth || !$this->internalIdentity) {
$request->session()->flash('error', trans('firefly.external_user_mgt_disabled')); $request->session()->flash('error', trans('firefly.external_user_mgt_disabled'));
@@ -218,7 +218,7 @@ class ProfileController extends Controller
* *
* @return RedirectResponse|Redirector * @return RedirectResponse|Redirector
*/ */
public function deleteCode(Request $request) public function deleteCode(Request $request): RedirectResponse|Redirector
{ {
if (!$this->internalAuth || !$this->internalIdentity) { if (!$this->internalAuth || !$this->internalIdentity) {
$request->session()->flash('error', trans('firefly.external_user_mgt_disabled')); $request->session()->flash('error', trans('firefly.external_user_mgt_disabled'));
@@ -247,7 +247,7 @@ class ProfileController extends Controller
* *
* @return RedirectResponse|Redirector * @return RedirectResponse|Redirector
*/ */
public function enable2FA(Request $request) public function enable2FA(Request $request): RedirectResponse|Redirector
{ {
if (!$this->internalAuth || !$this->internalIdentity) { if (!$this->internalAuth || !$this->internalIdentity) {
$request->session()->flash('error', trans('firefly.external_user_mgt_disabled')); $request->session()->flash('error', trans('firefly.external_user_mgt_disabled'));
@@ -279,7 +279,7 @@ class ProfileController extends Controller
* @throws ContainerExceptionInterface * @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface * @throws NotFoundExceptionInterface
*/ */
public function index() public function index(): Factory|View
{ {
/** @var User $user */ /** @var User $user */
$user = auth()->user(); $user = auth()->user();
@@ -311,9 +311,9 @@ class ProfileController extends Controller
} }
/** /**
* * @return Factory|View|RedirectResponse
*/ */
public function logoutOtherSessions() public function logoutOtherSessions(): Factory|View|RedirectResponse
{ {
if (!$this->internalAuth) { if (!$this->internalAuth) {
session()->flash('info', (string)trans('firefly.external_auth_disabled')); session()->flash('info', (string)trans('firefly.external_auth_disabled'));
@@ -327,10 +327,10 @@ class ProfileController extends Controller
/** /**
* @param Request $request * @param Request $request
* *
* @return Factory|View * @return Factory|View|RedirectResponse
* @throws FireflyException * @throws FireflyException
*/ */
public function newBackupCodes(Request $request) public function newBackupCodes(Request $request): Factory|View|RedirectResponse
{ {
if (!$this->internalAuth || !$this->internalIdentity) { if (!$this->internalAuth || !$this->internalIdentity) {
$request->session()->flash('error', trans('firefly.external_user_mgt_disabled')); $request->session()->flash('error', trans('firefly.external_user_mgt_disabled'));
@@ -359,9 +359,9 @@ class ProfileController extends Controller
* @param EmailFormRequest $request * @param EmailFormRequest $request
* @param UserRepositoryInterface $repository * @param UserRepositoryInterface $repository
* *
* @return $this|RedirectResponse|Redirector * @return Factory|RedirectResponse|Redirector
*/ */
public function postChangeEmail(EmailFormRequest $request, UserRepositoryInterface $repository) public function postChangeEmail(EmailFormRequest $request, UserRepositoryInterface $repository): Factory|RedirectResponse|Redirector
{ {
if (!$this->internalAuth || !$this->internalIdentity) { if (!$this->internalAuth || !$this->internalIdentity) {
$request->session()->flash('error', trans('firefly.external_user_mgt_disabled')); $request->session()->flash('error', trans('firefly.external_user_mgt_disabled'));
@@ -381,7 +381,7 @@ class ProfileController extends Controller
$existing = $repository->findByEmail($newEmail); $existing = $repository->findByEmail($newEmail);
if (null !== $existing) { if (null !== $existing) {
// force user logout. // force user logout.
Auth::guard()->logout(); Auth::guard()->logout(); // @phpstan-ignore-line (does not recognize function)
$request->session()->invalidate(); $request->session()->invalidate();
session()->flash('success', (string)trans('firefly.email_changed')); session()->flash('success', (string)trans('firefly.email_changed'));
@@ -395,7 +395,7 @@ class ProfileController extends Controller
event(new UserChangedEmail($user, $newEmail, $oldEmail)); event(new UserChangedEmail($user, $newEmail, $oldEmail));
// force user logout. // force user logout.
Auth::guard()->logout(); Auth::guard()->logout(); // @phpstan-ignore-line (does not recognize function)
$request->session()->invalidate(); $request->session()->invalidate();
session()->flash('success', (string)trans('firefly.email_changed')); session()->flash('success', (string)trans('firefly.email_changed'));
@@ -407,9 +407,9 @@ class ProfileController extends Controller
* *
* @param Request $request * @param Request $request
* *
* @return Factory|RedirectResponse|Redirector|View * @return Factory|RedirectResponse|View
*/ */
public function changeEmail(Request $request) public function changeEmail(Request $request): Factory|RedirectResponse|View
{ {
if (!$this->internalAuth || !$this->internalIdentity) { if (!$this->internalAuth || !$this->internalIdentity) {
$request->session()->flash('error', trans('firefly.external_user_mgt_disabled')); $request->session()->flash('error', trans('firefly.external_user_mgt_disabled'));

View File

@@ -93,14 +93,14 @@ class Authenticate
if ($this->auth->check()) { if ($this->auth->check()) {
// do an extra check on user object. // do an extra check on user object.
/** @var User $user */ /** @var User $user */
$user = $this->auth->authenticate(); $user = $this->auth->authenticate(); // @phpstan-ignore-line (thinks function returns void)
if (1 === (int)$user->blocked) { if (1 === (int)$user->blocked) {
$message = (string)trans('firefly.block_account_logout'); $message = (string)trans('firefly.block_account_logout');
if ('email_changed' === $user->blocked_code) { if ('email_changed' === $user->blocked_code) {
$message = (string)trans('firefly.email_changed_logout'); $message = (string)trans('firefly.email_changed_logout');
} }
app('session')->flash('logoutMessage', $message); app('session')->flash('logoutMessage', $message);
$this->auth->logout(); $this->auth->logout(); // @phpstan-ignore-line (thinks function is undefined)
throw new AuthenticationException('Blocked account.', $guards); throw new AuthenticationException('Blocked account.', $guards);
} }
@@ -116,7 +116,7 @@ class Authenticate
); );
} }
return $this->auth->authenticate(); return $this->auth->authenticate(); // @phpstan-ignore-line (thinks function returns void)
} }

View File

@@ -97,7 +97,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @property string $interest * @property string $interest
* @property string $interestPeriod * @property string $interestPeriod
* @property string $accountTypeString * @property string $accountTypeString
* @property string $location * @property Location $location
* @property string $liability_direction * @property string $liability_direction
* @property string $current_debt * @property string $current_debt
* @property int|null $user_group_id * @property int|null $user_group_id

View File

@@ -50,8 +50,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @property string $amount_min * @property string $amount_min
* @property string $amount_max * @property string $amount_max
* @property Carbon $date * @property Carbon $date
* @property string|null $end_date * @property Carbon|null $end_date
* @property string|null $extension_date * @property Carbon|null $extension_date
* @property string $repeat_freq * @property string $repeat_freq
* @property int $skip * @property int $skip
* @property bool $automatch * @property bool $automatch

View File

@@ -59,7 +59,8 @@ class AdminServiceProvider extends ServiceProvider
function (Application $app) { function (Application $app) {
/** @var LinkTypeRepository $repository */ /** @var LinkTypeRepository $repository */
$repository = app(LinkTypeRepository::class); $repository = app(LinkTypeRepository::class);
if ($app->auth->check()) { // reference to auth is not understood by phpstan.
if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user()); $repository->setUser(auth()->user());
} }

View File

@@ -51,7 +51,8 @@ class AttachmentServiceProvider extends ServiceProvider
function (Application $app) { function (Application $app) {
/** @var AttachmentRepositoryInterface $repository */ /** @var AttachmentRepositoryInterface $repository */
$repository = app(AttachmentRepository::class); $repository = app(AttachmentRepository::class);
if ($app->auth->check()) { // reference to auth is not understood by phpstan.
if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user()); $repository->setUser(auth()->user());
} }

View File

@@ -52,7 +52,8 @@ class BillServiceProvider extends ServiceProvider
/** @var BillRepositoryInterface $repository */ /** @var BillRepositoryInterface $repository */
$repository = app(BillRepository::class); $repository = app(BillRepository::class);
if ($app->auth->check()) { // reference to auth is not understood by phpstan.
if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user()); $repository->setUser(auth()->user());
} }

View File

@@ -54,12 +54,14 @@ class BudgetServiceProvider extends ServiceProvider
*/ */
public function register(): void public function register(): void
{ {
// reference to auth is not understood by phpstan.
$this->app->bind( $this->app->bind(
BudgetRepositoryInterface::class, BudgetRepositoryInterface::class,
static function (Application $app) { static function (Application $app) {
/** @var BudgetRepositoryInterface $repository */ /** @var BudgetRepositoryInterface $repository */
$repository = app(BudgetRepository::class); $repository = app(BudgetRepository::class);
if ($app->auth->check()) { if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user()); $repository->setUser(auth()->user());
} }
@@ -73,7 +75,7 @@ class BudgetServiceProvider extends ServiceProvider
static function (Application $app) { static function (Application $app) {
/** @var AvailableBudgetRepositoryInterface $repository */ /** @var AvailableBudgetRepositoryInterface $repository */
$repository = app(AvailableBudgetRepository::class); $repository = app(AvailableBudgetRepository::class);
if ($app->auth->check()) { if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user()); $repository->setUser(auth()->user());
} }
@@ -87,7 +89,7 @@ class BudgetServiceProvider extends ServiceProvider
static function (Application $app) { static function (Application $app) {
/** @var BudgetLimitRepositoryInterface $repository */ /** @var BudgetLimitRepositoryInterface $repository */
$repository = app(BudgetLimitRepository::class); $repository = app(BudgetLimitRepository::class);
if ($app->auth->check()) { if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user()); $repository->setUser(auth()->user());
} }
@@ -101,7 +103,7 @@ class BudgetServiceProvider extends ServiceProvider
static function (Application $app) { static function (Application $app) {
/** @var NoBudgetRepositoryInterface $repository */ /** @var NoBudgetRepositoryInterface $repository */
$repository = app(NoBudgetRepository::class); $repository = app(NoBudgetRepository::class);
if ($app->auth->check()) { if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user()); $repository->setUser(auth()->user());
} }
@@ -115,7 +117,7 @@ class BudgetServiceProvider extends ServiceProvider
static function (Application $app) { static function (Application $app) {
/** @var OperationsRepositoryInterface $repository */ /** @var OperationsRepositoryInterface $repository */
$repository = app(OperationsRepository::class); $repository = app(OperationsRepository::class);
if ($app->auth->check()) { if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user()); $repository->setUser(auth()->user());
} }

View File

@@ -50,12 +50,13 @@ class CategoryServiceProvider extends ServiceProvider
*/ */
public function register(): void public function register(): void
{ {
// phpstan does not understand reference to 'auth'.
$this->app->bind( $this->app->bind(
CategoryRepositoryInterface::class, CategoryRepositoryInterface::class,
static function (Application $app) { static function (Application $app) {
/** @var CategoryRepository $repository */ /** @var CategoryRepository $repository */
$repository = app(CategoryRepository::class); $repository = app(CategoryRepository::class);
if ($app->auth->check()) { if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user()); $repository->setUser(auth()->user());
} }
@@ -68,7 +69,7 @@ class CategoryServiceProvider extends ServiceProvider
static function (Application $app) { static function (Application $app) {
/** @var OperationsRepository $repository */ /** @var OperationsRepository $repository */
$repository = app(OperationsRepository::class); $repository = app(OperationsRepository::class);
if ($app->auth->check()) { if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user()); $repository->setUser(auth()->user());
} }
@@ -81,7 +82,7 @@ class CategoryServiceProvider extends ServiceProvider
static function (Application $app) { static function (Application $app) {
/** @var NoCategoryRepository $repository */ /** @var NoCategoryRepository $repository */
$repository = app(NoCategoryRepository::class); $repository = app(NoCategoryRepository::class);
if ($app->auth->check()) { if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user()); $repository->setUser(auth()->user());
} }

View File

@@ -51,7 +51,8 @@ class CurrencyServiceProvider extends ServiceProvider
function (Application $app) { function (Application $app) {
/** @var CurrencyRepository $repository */ /** @var CurrencyRepository $repository */
$repository = app(CurrencyRepository::class); $repository = app(CurrencyRepository::class);
if ($app->auth->check()) { // phpstan does not get the reference to auth
if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user()); $repository->setUser(auth()->user());
} }

View File

@@ -179,7 +179,7 @@ class FireflyServiceProvider extends ServiceProvider
static function (Application $app) { static function (Application $app) {
/** @var ObjectGroupRepository $repository */ /** @var ObjectGroupRepository $repository */
$repository = app(ObjectGroupRepository::class); $repository = app(ObjectGroupRepository::class);
if ($app->auth->check()) { if ($app->auth->check()) { // @phpstan-ignore-line (phpstan does not understand the reference to auth)
$repository->setUser(auth()->user()); $repository->setUser(auth()->user());
} }
@@ -192,7 +192,7 @@ class FireflyServiceProvider extends ServiceProvider
static function (Application $app) { static function (Application $app) {
/** @var WebhookRepository $repository */ /** @var WebhookRepository $repository */
$repository = app(WebhookRepository::class); $repository = app(WebhookRepository::class);
if ($app->auth->check()) { if ($app->auth->check()) { // @phpstan-ignore-line (phpstan does not understand the reference to auth)
$repository->setUser(auth()->user()); $repository->setUser(auth()->user());
} }
@@ -205,7 +205,7 @@ class FireflyServiceProvider extends ServiceProvider
static function (Application $app) { static function (Application $app) {
/** @var SearchRuleEngine $engine */ /** @var SearchRuleEngine $engine */
$engine = app(SearchRuleEngine::class); $engine = app(SearchRuleEngine::class);
if ($app->auth->check()) { if ($app->auth->check()) { // @phpstan-ignore-line (phpstan does not understand the reference to auth)
$engine->setUser(auth()->user()); $engine->setUser(auth()->user());
} }

View File

@@ -69,7 +69,7 @@ class JournalServiceProvider extends ServiceProvider
static function (Application $app) { static function (Application $app) {
/** @var JournalRepositoryInterface $repository */ /** @var JournalRepositoryInterface $repository */
$repository = app(JournalRepository::class); $repository = app(JournalRepository::class);
if ($app->auth->check()) { if ($app->auth->check()) { // @phpstan-ignore-line (phpstan does not understand the reference to auth)
$repository->setUser(auth()->user()); $repository->setUser(auth()->user());
} }
@@ -83,7 +83,7 @@ class JournalServiceProvider extends ServiceProvider
static function (Application $app) { static function (Application $app) {
/** @var JournalAPIRepositoryInterface $repository */ /** @var JournalAPIRepositoryInterface $repository */
$repository = app(JournalAPIRepository::class); $repository = app(JournalAPIRepository::class);
if ($app->auth->check()) { if ($app->auth->check()) { // @phpstan-ignore-line (phpstan does not understand the reference to auth)
$repository->setUser(auth()->user()); $repository->setUser(auth()->user());
} }
@@ -97,7 +97,7 @@ class JournalServiceProvider extends ServiceProvider
static function (Application $app) { static function (Application $app) {
/** @var JournalCLIRepositoryInterface $repository */ /** @var JournalCLIRepositoryInterface $repository */
$repository = app(JournalCLIRepository::class); $repository = app(JournalCLIRepository::class);
if ($app->auth->check()) { if ($app->auth->check()) { // @phpstan-ignore-line (phpstan does not understand the reference to auth)
$repository->setUser(auth()->user()); $repository->setUser(auth()->user());
} }
@@ -116,7 +116,7 @@ class JournalServiceProvider extends ServiceProvider
static function (Application $app) { static function (Application $app) {
/** @var TransactionGroupRepositoryInterface $repository */ /** @var TransactionGroupRepositoryInterface $repository */
$repository = app(TransactionGroupRepository::class); $repository = app(TransactionGroupRepository::class);
if ($app->auth->check()) { if ($app->auth->check()) { // @phpstan-ignore-line (phpstan does not understand the reference to auth)
$repository->setUser(auth()->user()); $repository->setUser(auth()->user());
} }
@@ -135,7 +135,7 @@ class JournalServiceProvider extends ServiceProvider
static function (Application $app) { static function (Application $app) {
/** @var GroupCollectorInterface $collector */ /** @var GroupCollectorInterface $collector */
$collector = app(GroupCollector::class); $collector = app(GroupCollector::class);
if ($app->auth->check()) { if ($app->auth->check()) { // @phpstan-ignore-line (phpstan does not understand the reference to auth)
$collector->setUser(auth()->user()); $collector->setUser(auth()->user());
} }

View File

@@ -51,7 +51,7 @@ class PiggyBankServiceProvider extends ServiceProvider
function (Application $app) { function (Application $app) {
/** @var PiggyBankRepository $repository */ /** @var PiggyBankRepository $repository */
$repository = app(PiggyBankRepository::class); $repository = app(PiggyBankRepository::class);
if ($app->auth->check()) { if ($app->auth->check()) { // @phpstan-ignore-line (phpstan does not understand the reference to auth)
$repository->setUser(auth()->user()); $repository->setUser(auth()->user());
} }

View File

@@ -52,7 +52,7 @@ class RecurringServiceProvider extends ServiceProvider
/** @var RecurringRepositoryInterface $repository */ /** @var RecurringRepositoryInterface $repository */
$repository = app(RecurringRepository::class); $repository = app(RecurringRepository::class);
if ($app->auth->check()) { if ($app->auth->check()) { // @phpstan-ignore-line (phpstan does not understand the reference to auth)
$repository->setUser(auth()->user()); $repository->setUser(auth()->user());
} }

View File

@@ -51,7 +51,7 @@ class RuleGroupServiceProvider extends ServiceProvider
function (Application $app) { function (Application $app) {
/** @var RuleGroupRepository $repository */ /** @var RuleGroupRepository $repository */
$repository = app(RuleGroupRepository::class); $repository = app(RuleGroupRepository::class);
if ($app->auth->check()) { if ($app->auth->check()) { // @phpstan-ignore-line (phpstan does not understand the reference to auth)
$repository->setUser(auth()->user()); $repository->setUser(auth()->user());
} }

View File

@@ -51,7 +51,7 @@ class RuleServiceProvider extends ServiceProvider
function (Application $app) { function (Application $app) {
/** @var RuleRepository $repository */ /** @var RuleRepository $repository */
$repository = app(RuleRepository::class); $repository = app(RuleRepository::class);
if ($app->auth->check()) { if ($app->auth->check()) { // @phpstan-ignore-line (phpstan does not understand the reference to auth)
$repository->setUser(auth()->user()); $repository->setUser(auth()->user());
} }

View File

@@ -51,7 +51,7 @@ class SearchServiceProvider extends ServiceProvider
function (Application $app) { function (Application $app) {
/** @var OperatorQuerySearch $search */ /** @var OperatorQuerySearch $search */
$search = app(OperatorQuerySearch::class); $search = app(OperatorQuerySearch::class);
if ($app->auth->check()) { if ($app->auth->check()) { // @phpstan-ignore-line (phpstan does not understand the reference to auth)
$search->setUser(auth()->user()); $search->setUser(auth()->user());
} }

View File

@@ -54,7 +54,7 @@ class TagServiceProvider extends ServiceProvider
/** @var TagRepository $repository */ /** @var TagRepository $repository */
$repository = app(TagRepository::class); $repository = app(TagRepository::class);
if ($app->auth->check()) { if ($app->auth->check()) { // @phpstan-ignore-line (phpstan does not understand the reference to auth)
$repository->setUser(auth()->user()); $repository->setUser(auth()->user());
} }
@@ -68,7 +68,7 @@ class TagServiceProvider extends ServiceProvider
/** @var OperationsRepository $repository */ /** @var OperationsRepository $repository */
$repository = app(OperationsRepository::class); $repository = app(OperationsRepository::class);
if ($app->auth->check()) { if ($app->auth->check()) { // @phpstan-ignore-line (phpstan does not understand the reference to auth)
$repository->setUser(auth()->user()); $repository->setUser(auth()->user());
} }

View File

@@ -38,7 +38,8 @@ class ALERepository implements ALERepositoryInterface
*/ */
public function getForObject(Model $model): Collection public function getForObject(Model $model): Collection
{ {
return AuditLogEntry::where('auditable_id', $model->id)->where('auditable_type', get_class($model))->get(); // all Models have an ID.
return AuditLogEntry::where('auditable_id', $model->id)->where('auditable_type', get_class($model))->get(); // @phpstan-ignore-line
} }
/** /**

View File

@@ -331,7 +331,12 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
*/ */
public function getPiggyBanks(): Collection public function getPiggyBanks(): Collection
{ {
return $this->user->piggyBanks()->with(['account', 'objectGroups'])->orderBy('order', 'ASC')->get(); return $this->user
->piggyBanks()
->with(
['account',
'objectGroups']) // @phpstan-ignore-line (phpstan does not recognize objectGroups)
->orderBy('order', 'ASC')->get();
} }
/** /**

View File

@@ -179,7 +179,8 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
$current = $attachment->toArray(); $current = $attachment->toArray();
$current['file_exists'] = true; $current['file_exists'] = true;
$current['notes'] = $repository->getNoteText($attachment); $current['notes'] = $repository->getNoteText($attachment);
$current['journal_title'] = $attachment->attachable->description; // already determined that this attachable is a TransactionJournal.
$current['journal_title'] = $attachment->attachable->description; // @phpstan-ignore-line
$result[$journalId][] = $current; $result[$journalId][] = $current;
} }
@@ -239,6 +240,8 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
$journalId = in_array($entry->source_id, $journals, true) ? $entry->source_id : $entry->destination_id; $journalId = in_array($entry->source_id, $journals, true) ? $entry->source_id : $entry->destination_id;
$return[$journalId] = $return[$journalId] ?? []; $return[$journalId] = $return[$journalId] ?? [];
// phpstan: the editable field is provided by the query.
if ($journalId === $entry->source_id) { if ($journalId === $entry->source_id) {
$amount = $this->getFormattedAmount($entry->destination); $amount = $this->getFormattedAmount($entry->destination);
$foreignAmount = $this->getFormattedForeignAmount($entry->destination); $foreignAmount = $this->getFormattedForeignAmount($entry->destination);
@@ -247,7 +250,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
'link' => $entry->outward, 'link' => $entry->outward,
'group' => $entry->destination->transaction_group_id, 'group' => $entry->destination->transaction_group_id,
'description' => $entry->destination->description, 'description' => $entry->destination->description,
'editable' => 1 === $entry->editable, 'editable' => 1 === (int)$entry->editable, // @phpstan-ignore-line
'amount' => $amount, 'amount' => $amount,
'foreign_amount' => $foreignAmount, 'foreign_amount' => $foreignAmount,
]; ];
@@ -260,7 +263,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
'link' => $entry->inward, 'link' => $entry->inward,
'group' => $entry->source->transaction_group_id, 'group' => $entry->source->transaction_group_id,
'description' => $entry->source->description, 'description' => $entry->source->description,
'editable' => 1 === $entry->editable, 'editable' => 1 === (int)$entry->editable, // @phpstan-ignore-line
'amount' => $amount, 'amount' => $amount,
'foreign_amount' => $foreignAmount, 'foreign_amount' => $foreignAmount,
]; ];

View File

@@ -222,7 +222,8 @@ class ExpandedForm
$fields = ['title', 'name', 'description']; $fields = ['title', 'name', 'description'];
/** @var Eloquent $entry */ /** @var Eloquent $entry */
foreach ($set as $entry) { foreach ($set as $entry) {
$entryId = (int)$entry->id; // All Eloquent models have an ID
$entryId = (int)$entry->id; // @phpstan-ignore-line
$current = $entry->toArray(); $current = $entry->toArray();
$title = null; $title = null;
foreach ($fields as $field) { foreach ($fields as $field) {

View File

@@ -577,7 +577,7 @@ class ExportDataGenerator
} }
/** @var RecurrenceTransaction $transaction */ /** @var RecurrenceTransaction $transaction */
foreach ($recurrence->recurrenceTransactions as $transaction) { foreach ($recurrence->recurrenceTransactions as $transaction) {
$categoryName = $recurringRepos->getCategory($transaction); $categoryName = $recurringRepos->getCategoryName($transaction);
$budgetId = $recurringRepos->getBudget($transaction); $budgetId = $recurringRepos->getBudget($transaction);
$piggyBankId = $recurringRepos->getPiggyBank($transaction); $piggyBankId = $recurringRepos->getPiggyBank($transaction);
$tags = $recurringRepos->getTags($transaction); $tags = $recurringRepos->getTags($transaction);

View File

@@ -189,7 +189,7 @@ class OperatorQuerySearch implements SearchInterface
throw new FireflyException(sprintf('Firefly III search cant handle "%s"-nodes', $class)); throw new FireflyException(sprintf('Firefly III search cant handle "%s"-nodes', $class));
case Subquery::class: case Subquery::class:
// loop all notes in subquery: // loop all notes in subquery:
foreach ($searchNode->getNodes() as $subNode) { foreach ($searchNode->getNodes() as $subNode) { // @phpstan-ignore-line PHPStan thinks getNodes() does not exist but it does.
$this->handleSearchNode($subNode); // let's hope it's not too recursive $this->handleSearchNode($subNode); // let's hope it's not too recursive
} }
break; break;

View File

@@ -83,8 +83,8 @@ class UpdatePiggybank implements ActionInterface
Log::debug(sprintf('Found piggy bank #%d ("%s")', $piggyBank->id, $piggyBank->name)); Log::debug(sprintf('Found piggy bank #%d ("%s")', $piggyBank->id, $piggyBank->name));
/** @var Transaction $source */ /** @var Transaction $source */
/** @var Transaction $destination */
$source = $journalObj->transactions()->where('amount', '<', 0)->first(); $source = $journalObj->transactions()->where('amount', '<', 0)->first();
/** @var Transaction $destination */
$destination = $journalObj->transactions()->where('amount', '>', 0)->first(); $destination = $journalObj->transactions()->where('amount', '>', 0)->first();
if ((int)$source->account_id === (int)$piggyBank->account_id) { if ((int)$source->account_id === (int)$piggyBank->account_id) {