Skip to content

Firefly III: a personal finances manager

Various code fixes

James Cole7722ca2bf0a0
diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php
index 1c503ce83c..54e7ae0d7f 100644
--- a/app/Exceptions/Handler.php
+++ b/app/Exceptions/Handler.php
@@ -53,7 +53,7 @@ use Throwable;
class Handler extends ExceptionHandler
{
/**
- * @var array
+ * @var array<int, class-string<Throwable>>
*/
protected $dontReport
= [
diff --git a/app/Generator/Report/Budget/MonthReportGenerator.php b/app/Generator/Report/Budget/MonthReportGenerator.php
index ccf0f86320..dc83bfe32b 100644
--- a/app/Generator/Report/Budget/MonthReportGenerator.php
+++ b/app/Generator/Report/Budget/MonthReportGenerator.php
@@ -26,7 +26,6 @@ namespace FireflyIII\Generator\Report\Budget;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Generator\Report\ReportGeneratorInterface;
-use FireflyIII\Generator\Report\Support;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Models\TransactionType;
use Illuminate\Support\Collection;
diff --git a/app/Generator/Report/Category/MonthReportGenerator.php b/app/Generator/Report/Category/MonthReportGenerator.php
index 0422ad565d..087d33f68c 100644
--- a/app/Generator/Report/Category/MonthReportGenerator.php
+++ b/app/Generator/Report/Category/MonthReportGenerator.php
@@ -26,7 +26,6 @@ namespace FireflyIII\Generator\Report\Category;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Generator\Report\ReportGeneratorInterface;
-use FireflyIII\Generator\Report\Support;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Models\TransactionType;
use Illuminate\Support\Collection;
@@ -41,26 +40,20 @@ use Throwable;
*/
class MonthReportGenerator implements ReportGeneratorInterface
{
- /** @var Collection The included accounts */
- private $accounts;
- /** @var Collection The included categories */
- private $categories;
- /** @var Carbon The end date */
- private $end;
- /** @var array The expenses */
- private $expenses;
- /** @var array The income in the report. */
- private $income;
- /** @var Carbon The start date. */
- private $start;
+ private Collection $accounts;
+ private Collection $categories;
+ private Carbon $end;
+ private array $expenses;
+ private array $income;
+ private Carbon $start;
/**
* MonthReportGenerator constructor.
*/
public function __construct()
{
- $this->income = new Collection();
- $this->expenses = new Collection();
+ $this->income = [];
+ $this->expenses = [];
}
/**
diff --git a/app/Generator/Report/Tag/MonthReportGenerator.php b/app/Generator/Report/Tag/MonthReportGenerator.php
index 3e12d520ba..c95f550c52 100644
--- a/app/Generator/Report/Tag/MonthReportGenerator.php
+++ b/app/Generator/Report/Tag/MonthReportGenerator.php
@@ -26,7 +26,6 @@ namespace FireflyIII\Generator\Report\Tag;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Generator\Report\ReportGeneratorInterface;
-use FireflyIII\Generator\Report\Support;
use Illuminate\Support\Collection;
use Log;
use Throwable;
@@ -38,27 +37,22 @@ use Throwable;
*/
class MonthReportGenerator implements ReportGeneratorInterface
{
- /** @var Collection The accounts involved */
- private $accounts;
- /** @var Carbon The end date */
- private $end;
- /** @var array The expenses involved */
- private $expenses;
- /** @var array The income involved */
- private $income;
- /** @var Carbon The start date */
- private $start;
- /** @var Collection The tags involved. */
- private $tags;
+ private Collection $accounts;
+ private Carbon $end;
+ private array $expenses;
+ private array $income;
+ private Carbon $start;
+ private Collection $tags;
/**
* MonthReportGenerator constructor.
*/
public function __construct()
{
- $this->expenses = new Collection();
- $this->income = new Collection();
+ $this->expenses = [];
+ $this->income = [];
$this->tags = new Collection();
+ $this->accounts = new Collection();
}
/**
diff --git a/app/Helpers/Collector/GroupCollectorInterface.php b/app/Helpers/Collector/GroupCollectorInterface.php
index ff2351a66a..e8409de225 100644
--- a/app/Helpers/Collector/GroupCollectorInterface.php
+++ b/app/Helpers/Collector/GroupCollectorInterface.php
@@ -1157,6 +1157,12 @@ interface GroupCollectorInterface
*/
public function setSearchWords(array $array): GroupCollectorInterface;
+ /**
+ * @param string $sepaCT
+ * @return GroupCollectorInterface
+ */
+ public function setSepaCT(string $sepaCT): GroupCollectorInterface;
+
/**
* Set source accounts.
*
diff --git a/app/Helpers/Fiscal/FiscalHelper.php b/app/Helpers/Fiscal/FiscalHelper.php
index 86f5605567..47fbd76ce6 100644
--- a/app/Helpers/Fiscal/FiscalHelper.php
+++ b/app/Helpers/Fiscal/FiscalHelper.php
@@ -42,7 +42,7 @@ class FiscalHelper implements FiscalHelperInterface
*/
public function __construct()
{
- $this->useCustomFiscalYear = app('preferences')->get('customFiscalYear', false)->data;
+ $this->useCustomFiscalYear = (bool) app('preferences')->get('customFiscalYear', false)->data;
}
/**
diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php
index 33632e8b49..1c6f2ae1d5 100644
--- a/app/Http/Controllers/Auth/LoginController.php
+++ b/app/Http/Controllers/Auth/LoginController.php
@@ -165,7 +165,7 @@ class LoginController extends Controller
*
* @param Request $request
*
- * @return Response
+ * @return RedirectResponse|Redirector|Response
*/
public function logout(Request $request)
{
diff --git a/app/Http/Controllers/Budget/BudgetLimitController.php b/app/Http/Controllers/Budget/BudgetLimitController.php
index 6e2e4cbd89..67df3abb32 100644
--- a/app/Http/Controllers/Budget/BudgetLimitController.php
+++ b/app/Http/Controllers/Budget/BudgetLimitController.php
@@ -121,12 +121,13 @@ class BudgetLimitController extends Controller
}
/**
+ * TODO why redirect AND json response?
* @param Request $request
*
- * @return JsonResponse
+ * @return RedirectResponse|JsonResponse
* @throws FireflyException
*/
- public function store(Request $request)
+ public function store(Request $request): RedirectResponse|JsonResponse
{
Log::debug('Going to store new budget-limit.', $request->all());
// first search for existing one and update it if necessary.
diff --git a/app/Http/Controllers/DebugController.php b/app/Http/Controllers/DebugController.php
index 50badfc0f5..0dcac8326f 100644
--- a/app/Http/Controllers/DebugController.php
+++ b/app/Http/Controllers/DebugController.php
@@ -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.
*
diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php
index 7b536464b1..237d6b9de5 100644
--- a/app/Http/Controllers/ProfileController.php
+++ b/app/Http/Controllers/ProfileController.php
@@ -102,14 +102,14 @@ class ProfileController extends Controller
*
* @param Request $request
*
- * @return Factory|View
+ * @return Factory|View|RedirectResponse
* @throws IncompatibleWithGoogleAuthenticatorException
* @throws InvalidCharactersException
* @throws SecretKeyTooShortException
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
- public function code(Request $request)
+ public function code(Request $request): Factory|View|RedirectResponse
{
if (!$this->internalAuth || !$this->internalIdentity) {
$request->session()->flash('error', trans('firefly.external_user_mgt_disabled'));
@@ -165,7 +165,7 @@ class ProfileController extends Controller
*
* @throws FireflyException
*/
- public function confirmEmailChange(UserRepositoryInterface $repository, string $token)
+ public function confirmEmailChange(UserRepositoryInterface $repository, string $token): RedirectResponse|Redirector
{
if (!$this->internalAuth || !$this->internalIdentity) {
throw new FireflyException(trans('firefly.external_user_mgt_disabled'));
@@ -186,7 +186,7 @@ class ProfileController extends Controller
}
$repository->unblockUser($user);
- // return to login.
+ // return to log in.
session()->flash('success', (string)trans('firefly.login_with_new_email'));
return redirect(route('login'));
@@ -199,7 +199,7 @@ class ProfileController extends Controller
*
* @return Application|RedirectResponse|Redirector
*/
- public function deleteAccount(Request $request)
+ public function deleteAccount(Request $request): Application|RedirectResponse|Redirector
{
if (!$this->internalAuth || !$this->internalIdentity) {
$request->session()->flash('error', trans('firefly.external_user_mgt_disabled'));
@@ -218,7 +218,7 @@ class ProfileController extends Controller
*
* @return RedirectResponse|Redirector
*/
- public function deleteCode(Request $request)
+ public function deleteCode(Request $request): RedirectResponse|Redirector
{
if (!$this->internalAuth || !$this->internalIdentity) {
$request->session()->flash('error', trans('firefly.external_user_mgt_disabled'));
@@ -247,7 +247,7 @@ class ProfileController extends Controller
*
* @return RedirectResponse|Redirector
*/
- public function enable2FA(Request $request)
+ public function enable2FA(Request $request): RedirectResponse|Redirector
{
if (!$this->internalAuth || !$this->internalIdentity) {
$request->session()->flash('error', trans('firefly.external_user_mgt_disabled'));
@@ -279,7 +279,7 @@ class ProfileController extends Controller
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
- public function index()
+ public function index(): Factory|View
{
/** @var User $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) {
session()->flash('info', (string)trans('firefly.external_auth_disabled'));
@@ -327,10 +327,10 @@ class ProfileController extends Controller
/**
* @param Request $request
*
- * @return Factory|View
+ * @return Factory|View|RedirectResponse
* @throws FireflyException
*/
- public function newBackupCodes(Request $request)
+ public function newBackupCodes(Request $request): Factory|View|RedirectResponse
{
if (!$this->internalAuth || !$this->internalIdentity) {
$request->session()->flash('error', trans('firefly.external_user_mgt_disabled'));
@@ -359,9 +359,9 @@ class ProfileController extends Controller
* @param EmailFormRequest $request
* @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) {
$request->session()->flash('error', trans('firefly.external_user_mgt_disabled'));
@@ -381,7 +381,7 @@ class ProfileController extends Controller
$existing = $repository->findByEmail($newEmail);
if (null !== $existing) {
// force user logout.
- Auth::guard()->logout();
+ Auth::guard()->logout(); // @phpstan-ignore-line (does not recognize function)
$request->session()->invalidate();
session()->flash('success', (string)trans('firefly.email_changed'));
@@ -395,7 +395,7 @@ class ProfileController extends Controller
event(new UserChangedEmail($user, $newEmail, $oldEmail));
// force user logout.
- Auth::guard()->logout();
+ Auth::guard()->logout(); // @phpstan-ignore-line (does not recognize function)
$request->session()->invalidate();
session()->flash('success', (string)trans('firefly.email_changed'));
@@ -407,9 +407,9 @@ class ProfileController extends Controller
*
* @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) {
$request->session()->flash('error', trans('firefly.external_user_mgt_disabled'));
diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php
index 9bbb715417..0a346826ea 100644
--- a/app/Http/Middleware/Authenticate.php
+++ b/app/Http/Middleware/Authenticate.php
@@ -93,14 +93,14 @@ class Authenticate
if ($this->auth->check()) {
// do an extra check on user object.
/** @var User $user */
- $user = $this->auth->authenticate();
+ $user = $this->auth->authenticate(); // @phpstan-ignore-line (thinks function returns void)
if (1 === (int)$user->blocked) {
$message = (string)trans('firefly.block_account_logout');
if ('email_changed' === $user->blocked_code) {
$message = (string)trans('firefly.email_changed_logout');
}
app('session')->flash('logoutMessage', $message);
- $this->auth->logout();
+ $this->auth->logout(); // @phpstan-ignore-line (thinks function is undefined)
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)
}
diff --git a/app/Models/Account.php b/app/Models/Account.php
index 8375ef8737..4ae11fdcc6 100644
--- a/app/Models/Account.php
+++ b/app/Models/Account.php
@@ -97,7 +97,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @property string $interest
* @property string $interestPeriod
* @property string $accountTypeString
- * @property string $location
+ * @property Location $location
* @property string $liability_direction
* @property string $current_debt
* @property int|null $user_group_id
diff --git a/app/Models/Bill.php b/app/Models/Bill.php
index 2e7673fcae..4d5ad3c687 100644
--- a/app/Models/Bill.php
+++ b/app/Models/Bill.php
@@ -50,8 +50,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @property string $amount_min
* @property string $amount_max
* @property Carbon $date
- * @property string|null $end_date
- * @property string|null $extension_date
+ * @property Carbon|null $end_date
+ * @property Carbon|null $extension_date
* @property string $repeat_freq
* @property int $skip
* @property bool $automatch
diff --git a/app/Providers/AdminServiceProvider.php b/app/Providers/AdminServiceProvider.php
index 5e72a7b9e5..b68b55657b 100644
--- a/app/Providers/AdminServiceProvider.php
+++ b/app/Providers/AdminServiceProvider.php
@@ -59,7 +59,8 @@ class AdminServiceProvider extends ServiceProvider
function (Application $app) {
/** @var LinkTypeRepository $repository */
$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());
}
diff --git a/app/Providers/AttachmentServiceProvider.php b/app/Providers/AttachmentServiceProvider.php
index 712f631a73..4d65930e4f 100644
--- a/app/Providers/AttachmentServiceProvider.php
+++ b/app/Providers/AttachmentServiceProvider.php
@@ -51,7 +51,8 @@ class AttachmentServiceProvider extends ServiceProvider
function (Application $app) {
/** @var AttachmentRepositoryInterface $repository */
$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());
}
diff --git a/app/Providers/BillServiceProvider.php b/app/Providers/BillServiceProvider.php
index ea3def27f9..0b55493126 100644
--- a/app/Providers/BillServiceProvider.php
+++ b/app/Providers/BillServiceProvider.php
@@ -52,7 +52,8 @@ class BillServiceProvider extends ServiceProvider
/** @var BillRepositoryInterface $repository */
$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());
}
diff --git a/app/Providers/BudgetServiceProvider.php b/app/Providers/BudgetServiceProvider.php
index 6b9ebe6369..b20a33c548 100644
--- a/app/Providers/BudgetServiceProvider.php
+++ b/app/Providers/BudgetServiceProvider.php
@@ -54,12 +54,14 @@ class BudgetServiceProvider extends ServiceProvider
*/
public function register(): void
{
+ // reference to auth is not understood by phpstan.
+
$this->app->bind(
BudgetRepositoryInterface::class,
static function (Application $app) {
/** @var BudgetRepositoryInterface $repository */
$repository = app(BudgetRepository::class);
- if ($app->auth->check()) {
+ if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user());
}
@@ -73,7 +75,7 @@ class BudgetServiceProvider extends ServiceProvider
static function (Application $app) {
/** @var AvailableBudgetRepositoryInterface $repository */
$repository = app(AvailableBudgetRepository::class);
- if ($app->auth->check()) {
+ if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user());
}
@@ -87,7 +89,7 @@ class BudgetServiceProvider extends ServiceProvider
static function (Application $app) {
/** @var BudgetLimitRepositoryInterface $repository */
$repository = app(BudgetLimitRepository::class);
- if ($app->auth->check()) {
+ if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user());
}
@@ -101,7 +103,7 @@ class BudgetServiceProvider extends ServiceProvider
static function (Application $app) {
/** @var NoBudgetRepositoryInterface $repository */
$repository = app(NoBudgetRepository::class);
- if ($app->auth->check()) {
+ if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user());
}
@@ -115,7 +117,7 @@ class BudgetServiceProvider extends ServiceProvider
static function (Application $app) {
/** @var OperationsRepositoryInterface $repository */
$repository = app(OperationsRepository::class);
- if ($app->auth->check()) {
+ if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user());
}
diff --git a/app/Providers/CategoryServiceProvider.php b/app/Providers/CategoryServiceProvider.php
index 131e9c8a1d..f84a151241 100644
--- a/app/Providers/CategoryServiceProvider.php
+++ b/app/Providers/CategoryServiceProvider.php
@@ -50,12 +50,13 @@ class CategoryServiceProvider extends ServiceProvider
*/
public function register(): void
{
+ // phpstan does not understand reference to 'auth'.
$this->app->bind(
CategoryRepositoryInterface::class,
static function (Application $app) {
/** @var CategoryRepository $repository */
$repository = app(CategoryRepository::class);
- if ($app->auth->check()) {
+ if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user());
}
@@ -68,7 +69,7 @@ class CategoryServiceProvider extends ServiceProvider
static function (Application $app) {
/** @var OperationsRepository $repository */
$repository = app(OperationsRepository::class);
- if ($app->auth->check()) {
+ if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user());
}
@@ -81,7 +82,7 @@ class CategoryServiceProvider extends ServiceProvider
static function (Application $app) {
/** @var NoCategoryRepository $repository */
$repository = app(NoCategoryRepository::class);
- if ($app->auth->check()) {
+ if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user());
}
diff --git a/app/Providers/CurrencyServiceProvider.php b/app/Providers/CurrencyServiceProvider.php
index 442877d21f..99397399d7 100644
--- a/app/Providers/CurrencyServiceProvider.php
+++ b/app/Providers/CurrencyServiceProvider.php
@@ -51,7 +51,8 @@ class CurrencyServiceProvider extends ServiceProvider
function (Application $app) {
/** @var CurrencyRepository $repository */
$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());
}
diff --git a/app/Providers/FireflyServiceProvider.php b/app/Providers/FireflyServiceProvider.php
index 9782412436..d8f32f46e9 100644
--- a/app/Providers/FireflyServiceProvider.php
+++ b/app/Providers/FireflyServiceProvider.php
@@ -179,7 +179,7 @@ class FireflyServiceProvider extends ServiceProvider
static function (Application $app) {
/** @var ObjectGroupRepository $repository */
$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());
}
@@ -192,7 +192,7 @@ class FireflyServiceProvider extends ServiceProvider
static function (Application $app) {
/** @var WebhookRepository $repository */
$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());
}
@@ -205,7 +205,7 @@ class FireflyServiceProvider extends ServiceProvider
static function (Application $app) {
/** @var SearchRuleEngine $engine */
$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());
}
diff --git a/app/Providers/JournalServiceProvider.php b/app/Providers/JournalServiceProvider.php
index d0ae1c155c..df99d30c77 100644
--- a/app/Providers/JournalServiceProvider.php
+++ b/app/Providers/JournalServiceProvider.php
@@ -69,7 +69,7 @@ class JournalServiceProvider extends ServiceProvider
static function (Application $app) {
/** @var JournalRepositoryInterface $repository */
$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());
}
@@ -83,7 +83,7 @@ class JournalServiceProvider extends ServiceProvider
static function (Application $app) {
/** @var JournalAPIRepositoryInterface $repository */
$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());
}
@@ -97,7 +97,7 @@ class JournalServiceProvider extends ServiceProvider
static function (Application $app) {
/** @var JournalCLIRepositoryInterface $repository */
$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());
}
@@ -116,7 +116,7 @@ class JournalServiceProvider extends ServiceProvider
static function (Application $app) {
/** @var TransactionGroupRepositoryInterface $repository */
$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());
}
@@ -135,7 +135,7 @@ class JournalServiceProvider extends ServiceProvider
static function (Application $app) {
/** @var GroupCollectorInterface $collector */
$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());
}
diff --git a/app/Providers/PiggyBankServiceProvider.php b/app/Providers/PiggyBankServiceProvider.php
index 54c1132ec1..bbf34d26c7 100644
--- a/app/Providers/PiggyBankServiceProvider.php
+++ b/app/Providers/PiggyBankServiceProvider.php
@@ -51,7 +51,7 @@ class PiggyBankServiceProvider extends ServiceProvider
function (Application $app) {
/** @var PiggyBankRepository $repository */
$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());
}
diff --git a/app/Providers/RecurringServiceProvider.php b/app/Providers/RecurringServiceProvider.php
index b6d096a81c..137d58e408 100644
--- a/app/Providers/RecurringServiceProvider.php
+++ b/app/Providers/RecurringServiceProvider.php
@@ -52,7 +52,7 @@ class RecurringServiceProvider extends ServiceProvider
/** @var RecurringRepositoryInterface $repository */
$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());
}
diff --git a/app/Providers/RuleGroupServiceProvider.php b/app/Providers/RuleGroupServiceProvider.php
index 2fbde7d142..9145a1faa4 100644
--- a/app/Providers/RuleGroupServiceProvider.php
+++ b/app/Providers/RuleGroupServiceProvider.php
@@ -51,7 +51,7 @@ class RuleGroupServiceProvider extends ServiceProvider
function (Application $app) {
/** @var RuleGroupRepository $repository */
$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());
}
diff --git a/app/Providers/RuleServiceProvider.php b/app/Providers/RuleServiceProvider.php
index c384faf0b3..ab766531bb 100644
--- a/app/Providers/RuleServiceProvider.php
+++ b/app/Providers/RuleServiceProvider.php
@@ -51,7 +51,7 @@ class RuleServiceProvider extends ServiceProvider
function (Application $app) {
/** @var RuleRepository $repository */
$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());
}
diff --git a/app/Providers/SearchServiceProvider.php b/app/Providers/SearchServiceProvider.php
index c47e7688eb..fed6e8718b 100644
--- a/app/Providers/SearchServiceProvider.php
+++ b/app/Providers/SearchServiceProvider.php
@@ -51,7 +51,7 @@ class SearchServiceProvider extends ServiceProvider
function (Application $app) {
/** @var OperatorQuerySearch $search */
$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());
}
diff --git a/app/Providers/TagServiceProvider.php b/app/Providers/TagServiceProvider.php
index e8b7a063fd..1e53acdb20 100644
--- a/app/Providers/TagServiceProvider.php
+++ b/app/Providers/TagServiceProvider.php
@@ -54,7 +54,7 @@ class TagServiceProvider extends ServiceProvider
/** @var TagRepository $repository */
$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());
}
@@ -68,7 +68,7 @@ class TagServiceProvider extends ServiceProvider
/** @var OperationsRepository $repository */
$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());
}
diff --git a/app/Repositories/AuditLogEntry/ALERepository.php b/app/Repositories/AuditLogEntry/ALERepository.php
index 9832b8c001..8e3af7ca94 100644
--- a/app/Repositories/AuditLogEntry/ALERepository.php
+++ b/app/Repositories/AuditLogEntry/ALERepository.php
@@ -38,7 +38,8 @@ class ALERepository implements ALERepositoryInterface
*/
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
}
/**
diff --git a/app/Repositories/PiggyBank/PiggyBankRepository.php b/app/Repositories/PiggyBank/PiggyBankRepository.php
index 221d15ae87..0ae61a1de1 100644
--- a/app/Repositories/PiggyBank/PiggyBankRepository.php
+++ b/app/Repositories/PiggyBank/PiggyBankRepository.php
@@ -331,7 +331,12 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
*/
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();
}
/**
diff --git a/app/Repositories/TransactionGroup/TransactionGroupRepository.php b/app/Repositories/TransactionGroup/TransactionGroupRepository.php
index a6389f142b..163bdc3416 100644
--- a/app/Repositories/TransactionGroup/TransactionGroupRepository.php
+++ b/app/Repositories/TransactionGroup/TransactionGroupRepository.php
@@ -179,7 +179,8 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
$current = $attachment->toArray();
$current['file_exists'] = true;
$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;
}
@@ -239,6 +240,8 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
$journalId = in_array($entry->source_id, $journals, true) ? $entry->source_id : $entry->destination_id;
$return[$journalId] = $return[$journalId] ?? [];
+ // phpstan: the editable field is provided by the query.
+
if ($journalId === $entry->source_id) {
$amount = $this->getFormattedAmount($entry->destination);
$foreignAmount = $this->getFormattedForeignAmount($entry->destination);
@@ -247,7 +250,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
'link' => $entry->outward,
'group' => $entry->destination->transaction_group_id,
'description' => $entry->destination->description,
- 'editable' => 1 === $entry->editable,
+ 'editable' => 1 === (int)$entry->editable, // @phpstan-ignore-line
'amount' => $amount,
'foreign_amount' => $foreignAmount,
];
@@ -260,7 +263,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
'link' => $entry->inward,
'group' => $entry->source->transaction_group_id,
'description' => $entry->source->description,
- 'editable' => 1 === $entry->editable,
+ 'editable' => 1 === (int)$entry->editable, // @phpstan-ignore-line
'amount' => $amount,
'foreign_amount' => $foreignAmount,
];
diff --git a/app/Support/ExpandedForm.php b/app/Support/ExpandedForm.php
index 7f4a1b0ab9..e0141c4589 100644
--- a/app/Support/ExpandedForm.php
+++ b/app/Support/ExpandedForm.php
@@ -222,7 +222,8 @@ class ExpandedForm
$fields = ['title', 'name', 'description'];
/** @var Eloquent $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();
$title = null;
foreach ($fields as $field) {
diff --git a/app/Support/Export/ExportDataGenerator.php b/app/Support/Export/ExportDataGenerator.php
index 0729961773..a8b11f1552 100644
--- a/app/Support/Export/ExportDataGenerator.php
+++ b/app/Support/Export/ExportDataGenerator.php
@@ -577,7 +577,7 @@ class ExportDataGenerator
}
/** @var RecurrenceTransaction $transaction */
foreach ($recurrence->recurrenceTransactions as $transaction) {
- $categoryName = $recurringRepos->getCategory($transaction);
+ $categoryName = $recurringRepos->getCategoryName($transaction);
$budgetId = $recurringRepos->getBudget($transaction);
$piggyBankId = $recurringRepos->getPiggyBank($transaction);
$tags = $recurringRepos->getTags($transaction);
diff --git a/app/Support/Search/OperatorQuerySearch.php b/app/Support/Search/OperatorQuerySearch.php
index 77ae90d4f8..e2ca15d071 100644
--- a/app/Support/Search/OperatorQuerySearch.php
+++ b/app/Support/Search/OperatorQuerySearch.php
@@ -189,7 +189,7 @@ class OperatorQuerySearch implements SearchInterface
throw new FireflyException(sprintf('Firefly III search cant handle "%s"-nodes', $class));
case Subquery::class:
// 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
}
break;
diff --git a/app/TransactionRules/Actions/UpdatePiggybank.php b/app/TransactionRules/Actions/UpdatePiggybank.php
index 10ad6a967c..a2dc6ef1d4 100644
--- a/app/TransactionRules/Actions/UpdatePiggybank.php
+++ b/app/TransactionRules/Actions/UpdatePiggybank.php
@@ -83,8 +83,8 @@ class UpdatePiggybank implements ActionInterface
Log::debug(sprintf('Found piggy bank #%d ("%s")', $piggyBank->id, $piggyBank->name));
/** @var Transaction $source */
- /** @var Transaction $destination */
$source = $journalObj->transactions()->where('amount', '<', 0)->first();
+ /** @var Transaction $destination */
$destination = $journalObj->transactions()->where('amount', '>', 0)->first();
if ((int)$source->account_id === (int)$piggyBank->account_id) {