diff --git a/app/Api/V1/Controllers/Chart/BudgetController.php b/app/Api/V1/Controllers/Chart/BudgetController.php index 8621619982..dde99549dc 100644 --- a/app/Api/V1/Controllers/Chart/BudgetController.php +++ b/app/Api/V1/Controllers/Chart/BudgetController.php @@ -133,9 +133,9 @@ class BudgetController extends Controller $row['pc_left'] = '0'; $row['pc_overspent'] = '0'; - if (null !== $limit) { + if ($limit instanceof BudgetLimit) { $row['budgeted'] = $limit->amount; - $row['left'] = bcsub($row['budgeted'], bcmul($row['spent'], '-1')); + $row['left'] = bcsub((string) $row['budgeted'], bcmul((string) $row['spent'], '-1')); $row['overspent'] = bcmul($row['left'], '-1'); $row['left'] = 1 === bccomp($row['left'], '0') ? $row['left'] : '0'; $row['overspent'] = 1 === bccomp($row['overspent'], '0') ? $row['overspent'] : '0'; diff --git a/app/Api/V1/Controllers/Models/CurrencyExchangeRate/StoreController.php b/app/Api/V1/Controllers/Models/CurrencyExchangeRate/StoreController.php index a2228832d7..45da4ff67e 100644 --- a/app/Api/V1/Controllers/Models/CurrencyExchangeRate/StoreController.php +++ b/app/Api/V1/Controllers/Models/CurrencyExchangeRate/StoreController.php @@ -70,7 +70,7 @@ class StoreController extends Controller foreach ($data as $date => $rate) { $date = Carbon::createFromFormat('Y-m-d', $date); $existing = $this->repository->getSpecificRateOnDate($from, $to, $date); - if (null !== $existing) { + if ($existing instanceof CurrencyExchangeRate) { // update existing rate. $existing = $this->repository->updateExchangeRate($existing, $rate); $collection->push($existing); @@ -101,7 +101,7 @@ class StoreController extends Controller foreach ($data['rates'] as $key => $rate) { $to = Amount::getTransactionCurrencyByCode($key); $existing = $this->repository->getSpecificRateOnDate($from, $to, $date); - if (null !== $existing) { + if ($existing instanceof CurrencyExchangeRate) { // update existing rate. $existing = $this->repository->updateExchangeRate($existing, $rate); $collection->push($existing); diff --git a/app/Api/V1/Requests/Models/Account/ShowRequest.php b/app/Api/V1/Requests/Models/Account/ShowRequest.php index bfb4a18e2c..6d6dcb71c5 100644 --- a/app/Api/V1/Requests/Models/Account/ShowRequest.php +++ b/app/Api/V1/Requests/Models/Account/ShowRequest.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Requests\Models\Account; +use Illuminate\Validation\Validator; use Carbon\Carbon; use FireflyIII\Models\Account; use FireflyIII\Rules\IsValidSortInstruction; @@ -30,7 +31,6 @@ use FireflyIII\Support\Facades\Preferences; use FireflyIII\Support\Http\Api\AccountFilter; use FireflyIII\Support\Request\ConvertsDataTypes; use FireflyIII\User; -use Illuminate\Validation\Validator; use Illuminate\Foundation\Http\FormRequest; class ShowRequest extends FormRequest diff --git a/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreByDateRequest.php b/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreByDateRequest.php index e3d1696db4..971237b737 100644 --- a/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreByDateRequest.php +++ b/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreByDateRequest.php @@ -24,13 +24,13 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Requests\Models\CurrencyExchangeRate; +use Illuminate\Validation\Validator; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Models\TransactionCurrency; use FireflyIII\Support\Facades\Amount; use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; use Illuminate\Foundation\Http\FormRequest; -use Illuminate\Validation\Validator; class StoreByDateRequest extends FormRequest { diff --git a/app/Api/V1/Requests/Models/PiggyBank/StoreRequest.php b/app/Api/V1/Requests/Models/PiggyBank/StoreRequest.php index 3ea6c1727b..0810b4ce4b 100644 --- a/app/Api/V1/Requests/Models/PiggyBank/StoreRequest.php +++ b/app/Api/V1/Requests/Models/PiggyBank/StoreRequest.php @@ -24,8 +24,8 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Requests\Models\PiggyBank; -use FireflyIII\Support\Facades\Amount; use Illuminate\Validation\Validator; +use FireflyIII\Support\Facades\Amount; use FireflyIII\Models\TransactionCurrency; use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Rules\IsValidZeroOrMoreAmount; @@ -97,7 +97,7 @@ class StoreRequest extends FormRequest // validate start before end only if both are there. $data = $validator->getData(); $currency = $this->getCurrencyFromData($validator, $data); - if (null === $currency) { + if (!$currency instanceof TransactionCurrency) { return; } $targetAmount = (string) ($data['target_amount'] ?? '0'); diff --git a/app/Handlers/Events/AdminEventHandler.php b/app/Handlers/Events/AdminEventHandler.php index 3c87c66d27..6619763806 100644 --- a/app/Handlers/Events/AdminEventHandler.php +++ b/app/Handlers/Events/AdminEventHandler.php @@ -32,7 +32,6 @@ use FireflyIII\Notifications\Admin\UserInvitation; use FireflyIII\Notifications\Admin\VersionCheckResult; use FireflyIII\Notifications\Notifiables\OwnerNotifiable; use FireflyIII\Notifications\Test\OwnerTestNotificationEmail; -use FireflyIII\Notifications\Test\OwnerTestNotificationNtfy; use FireflyIII\Notifications\Test\OwnerTestNotificationPushover; use FireflyIII\Notifications\Test\OwnerTestNotificationSlack; use Illuminate\Support\Facades\Log; diff --git a/app/Handlers/Events/UserEventHandler.php b/app/Handlers/Events/UserEventHandler.php index 9b7c7fea0d..991f7751d9 100644 --- a/app/Handlers/Events/UserEventHandler.php +++ b/app/Handlers/Events/UserEventHandler.php @@ -44,7 +44,6 @@ use FireflyIII\Models\UserRole; use FireflyIII\Notifications\Admin\UserRegistration as AdminRegistrationNotification; use FireflyIII\Notifications\Security\UserFailedLoginAttempt; use FireflyIII\Notifications\Test\UserTestNotificationEmail; -use FireflyIII\Notifications\Test\UserTestNotificationNtfy; use FireflyIII\Notifications\Test\UserTestNotificationPushover; use FireflyIII\Notifications\Test\UserTestNotificationSlack; use FireflyIII\Notifications\User\UserLogin; diff --git a/app/Http/Requests/PiggyBankStoreRequest.php b/app/Http/Requests/PiggyBankStoreRequest.php index 87a13140da..868b1cc4bd 100644 --- a/app/Http/Requests/PiggyBankStoreRequest.php +++ b/app/Http/Requests/PiggyBankStoreRequest.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Requests; +use Illuminate\Validation\Validator; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Models\TransactionCurrency; use FireflyIII\Repositories\Account\AccountRepositoryInterface; @@ -32,7 +33,6 @@ use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class PiggyBankStoreRequest. diff --git a/app/Http/Requests/PiggyBankUpdateRequest.php b/app/Http/Requests/PiggyBankUpdateRequest.php index 1e2489a932..e0ecaf9614 100644 --- a/app/Http/Requests/PiggyBankUpdateRequest.php +++ b/app/Http/Requests/PiggyBankUpdateRequest.php @@ -23,8 +23,8 @@ declare(strict_types=1); namespace FireflyIII\Http\Requests; -use FireflyIII\Exceptions\FireflyException; use Illuminate\Validation\Validator; +use FireflyIII\Exceptions\FireflyException; use FireflyIII\Models\PiggyBank; use FireflyIII\Models\TransactionCurrency; use FireflyIII\Repositories\Account\AccountRepositoryInterface; diff --git a/app/Notifications/Admin/UnknownUserLoginAttempt.php b/app/Notifications/Admin/UnknownUserLoginAttempt.php index 0edb61ab2e..86015ac892 100644 --- a/app/Notifications/Admin/UnknownUserLoginAttempt.php +++ b/app/Notifications/Admin/UnknownUserLoginAttempt.php @@ -26,7 +26,6 @@ namespace FireflyIII\Notifications\Admin; use FireflyIII\Notifications\Notifiables\OwnerNotifiable; use FireflyIII\Notifications\ReturnsAvailableChannels; -use FireflyIII\Notifications\ReturnsSettings; use FireflyIII\Support\Facades\FireflyConfig; use FireflyIII\Support\Facades\Steam; use Illuminate\Bus\Queueable; @@ -35,7 +34,6 @@ use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Notification; use Illuminate\Support\Facades\Request; use NotificationChannels\Pushover\PushoverMessage; -use Ntfy\Message; class UnknownUserLoginAttempt extends Notification { diff --git a/app/Notifications/Admin/UserInvitation.php b/app/Notifications/Admin/UserInvitation.php index 40c002ef27..0ea2f8023f 100644 --- a/app/Notifications/Admin/UserInvitation.php +++ b/app/Notifications/Admin/UserInvitation.php @@ -27,7 +27,6 @@ namespace FireflyIII\Notifications\Admin; use FireflyIII\Models\InvitedUser; use FireflyIII\Notifications\Notifiables\OwnerNotifiable; use FireflyIII\Notifications\ReturnsAvailableChannels; -use FireflyIII\Notifications\ReturnsSettings; use FireflyIII\Support\Facades\Steam; use Illuminate\Bus\Queueable; use Illuminate\Notifications\Messages\MailMessage; @@ -36,7 +35,6 @@ use Illuminate\Notifications\Notification; use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Request; use NotificationChannels\Pushover\PushoverMessage; -use Ntfy\Message; /** * Class UserInvitation diff --git a/app/Notifications/Admin/UserRegistration.php b/app/Notifications/Admin/UserRegistration.php index 5c43c06697..9847201d61 100644 --- a/app/Notifications/Admin/UserRegistration.php +++ b/app/Notifications/Admin/UserRegistration.php @@ -26,7 +26,6 @@ namespace FireflyIII\Notifications\Admin; use FireflyIII\Notifications\Notifiables\OwnerNotifiable; use FireflyIII\Notifications\ReturnsAvailableChannels; -use FireflyIII\Notifications\ReturnsSettings; use FireflyIII\Support\Facades\Steam; use FireflyIII\User; use Illuminate\Bus\Queueable; @@ -36,7 +35,6 @@ use Illuminate\Notifications\Notification; use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Request; use NotificationChannels\Pushover\PushoverMessage; -use Ntfy\Message; /** * Class UserRegistration diff --git a/app/Notifications/Admin/VersionCheckResult.php b/app/Notifications/Admin/VersionCheckResult.php index 72acaf4fb2..39f449f9bd 100644 --- a/app/Notifications/Admin/VersionCheckResult.php +++ b/app/Notifications/Admin/VersionCheckResult.php @@ -26,14 +26,12 @@ namespace FireflyIII\Notifications\Admin; use FireflyIII\Notifications\Notifiables\OwnerNotifiable; use FireflyIII\Notifications\ReturnsAvailableChannels; -use FireflyIII\Notifications\ReturnsSettings; use Illuminate\Bus\Queueable; use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Notification; use Illuminate\Support\Facades\Log; use NotificationChannels\Pushover\PushoverMessage; -use Ntfy\Message; /** * Class VersionCheckResult diff --git a/app/Notifications/Security/DisabledMFANotification.php b/app/Notifications/Security/DisabledMFANotification.php index f93fce58ab..2d7fb02922 100644 --- a/app/Notifications/Security/DisabledMFANotification.php +++ b/app/Notifications/Security/DisabledMFANotification.php @@ -25,7 +25,6 @@ declare(strict_types=1); namespace FireflyIII\Notifications\Security; use FireflyIII\Notifications\ReturnsAvailableChannels; -use FireflyIII\Notifications\ReturnsSettings; use FireflyIII\Support\Facades\Steam; use FireflyIII\User; use Illuminate\Bus\Queueable; @@ -34,7 +33,6 @@ use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Notification; use Illuminate\Support\Facades\Request; use NotificationChannels\Pushover\PushoverMessage; -use Ntfy\Message; class DisabledMFANotification extends Notification { diff --git a/app/Notifications/Security/EnabledMFANotification.php b/app/Notifications/Security/EnabledMFANotification.php index 452ccafda6..d661aec9bb 100644 --- a/app/Notifications/Security/EnabledMFANotification.php +++ b/app/Notifications/Security/EnabledMFANotification.php @@ -25,7 +25,6 @@ declare(strict_types=1); namespace FireflyIII\Notifications\Security; use FireflyIII\Notifications\ReturnsAvailableChannels; -use FireflyIII\Notifications\ReturnsSettings; use FireflyIII\Support\Facades\Steam; use FireflyIII\User; use Illuminate\Bus\Queueable; @@ -34,7 +33,6 @@ use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Notification; use Illuminate\Support\Facades\Request; use NotificationChannels\Pushover\PushoverMessage; -use Ntfy\Message; class EnabledMFANotification extends Notification { diff --git a/app/Notifications/Security/MFABackupFewLeftNotification.php b/app/Notifications/Security/MFABackupFewLeftNotification.php index c70b2a0b8e..8f691e3dd0 100644 --- a/app/Notifications/Security/MFABackupFewLeftNotification.php +++ b/app/Notifications/Security/MFABackupFewLeftNotification.php @@ -25,7 +25,6 @@ declare(strict_types=1); namespace FireflyIII\Notifications\Security; use FireflyIII\Notifications\ReturnsAvailableChannels; -use FireflyIII\Notifications\ReturnsSettings; use FireflyIII\Support\Facades\Steam; use FireflyIII\User; use Illuminate\Bus\Queueable; @@ -34,7 +33,6 @@ use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Notification; use Illuminate\Support\Facades\Request; use NotificationChannels\Pushover\PushoverMessage; -use Ntfy\Message; class MFABackupFewLeftNotification extends Notification { diff --git a/app/Notifications/Security/MFABackupNoLeftNotification.php b/app/Notifications/Security/MFABackupNoLeftNotification.php index 1a2db608a5..0c1fe520a6 100644 --- a/app/Notifications/Security/MFABackupNoLeftNotification.php +++ b/app/Notifications/Security/MFABackupNoLeftNotification.php @@ -25,7 +25,6 @@ declare(strict_types=1); namespace FireflyIII\Notifications\Security; use FireflyIII\Notifications\ReturnsAvailableChannels; -use FireflyIII\Notifications\ReturnsSettings; use FireflyIII\Support\Facades\Steam; use FireflyIII\User; use Illuminate\Bus\Queueable; @@ -34,7 +33,6 @@ use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Notification; use Illuminate\Support\Facades\Request; use NotificationChannels\Pushover\PushoverMessage; -use Ntfy\Message; class MFABackupNoLeftNotification extends Notification { diff --git a/app/Notifications/Security/MFAManyFailedAttemptsNotification.php b/app/Notifications/Security/MFAManyFailedAttemptsNotification.php index 6680bad6c4..a235fcbd28 100644 --- a/app/Notifications/Security/MFAManyFailedAttemptsNotification.php +++ b/app/Notifications/Security/MFAManyFailedAttemptsNotification.php @@ -25,7 +25,6 @@ declare(strict_types=1); namespace FireflyIII\Notifications\Security; use FireflyIII\Notifications\ReturnsAvailableChannels; -use FireflyIII\Notifications\ReturnsSettings; use FireflyIII\Support\Facades\Steam; use FireflyIII\User; use Illuminate\Bus\Queueable; @@ -34,7 +33,6 @@ use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Notification; use Illuminate\Support\Facades\Request; use NotificationChannels\Pushover\PushoverMessage; -use Ntfy\Message; class MFAManyFailedAttemptsNotification extends Notification { diff --git a/app/Notifications/Security/MFAUsedBackupCodeNotification.php b/app/Notifications/Security/MFAUsedBackupCodeNotification.php index 21dc6e4b28..3c0d61739f 100644 --- a/app/Notifications/Security/MFAUsedBackupCodeNotification.php +++ b/app/Notifications/Security/MFAUsedBackupCodeNotification.php @@ -25,7 +25,6 @@ declare(strict_types=1); namespace FireflyIII\Notifications\Security; use FireflyIII\Notifications\ReturnsAvailableChannels; -use FireflyIII\Notifications\ReturnsSettings; use FireflyIII\Support\Facades\Steam; use FireflyIII\User; use Illuminate\Bus\Queueable; @@ -34,7 +33,6 @@ use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Notification; use Illuminate\Support\Facades\Request; use NotificationChannels\Pushover\PushoverMessage; -use Ntfy\Message; class MFAUsedBackupCodeNotification extends Notification { diff --git a/app/Notifications/Security/NewBackupCodesNotification.php b/app/Notifications/Security/NewBackupCodesNotification.php index 7b08593f2e..a07d4282d3 100644 --- a/app/Notifications/Security/NewBackupCodesNotification.php +++ b/app/Notifications/Security/NewBackupCodesNotification.php @@ -25,7 +25,6 @@ declare(strict_types=1); namespace FireflyIII\Notifications\Security; use FireflyIII\Notifications\ReturnsAvailableChannels; -use FireflyIII\Notifications\ReturnsSettings; use FireflyIII\Support\Facades\Steam; use FireflyIII\User; use Illuminate\Bus\Queueable; @@ -34,7 +33,6 @@ use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Notification; use Illuminate\Support\Facades\Request; use NotificationChannels\Pushover\PushoverMessage; -use Ntfy\Message; class NewBackupCodesNotification extends Notification { diff --git a/app/Notifications/Security/UserFailedLoginAttempt.php b/app/Notifications/Security/UserFailedLoginAttempt.php index d947cae266..8f9362d76f 100644 --- a/app/Notifications/Security/UserFailedLoginAttempt.php +++ b/app/Notifications/Security/UserFailedLoginAttempt.php @@ -25,7 +25,6 @@ declare(strict_types=1); namespace FireflyIII\Notifications\Security; use FireflyIII\Notifications\ReturnsAvailableChannels; -use FireflyIII\Notifications\ReturnsSettings; use FireflyIII\Support\Facades\FireflyConfig; use FireflyIII\Support\Facades\Steam; use FireflyIII\User; @@ -35,7 +34,6 @@ use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Notification; use Illuminate\Support\Facades\Request; use NotificationChannels\Pushover\PushoverMessage; -use Ntfy\Message; class UserFailedLoginAttempt extends Notification { diff --git a/app/Notifications/Test/OwnerTestNotificationNtfy.php b/app/Notifications/Test/OwnerTestNotificationNtfy.php index 760ed44690..6edae32817 100644 --- a/app/Notifications/Test/OwnerTestNotificationNtfy.php +++ b/app/Notifications/Test/OwnerTestNotificationNtfy.php @@ -25,11 +25,8 @@ declare(strict_types=1); namespace FireflyIII\Notifications\Test; use FireflyIII\Notifications\Notifiables\OwnerNotifiable; -use FireflyIII\Notifications\ReturnsSettings; use Illuminate\Bus\Queueable; use Illuminate\Notifications\Notification; -use Ntfy\Message; -use Wijourdil\NtfyNotificationChannel\Channels\NtfyChannel; // use Illuminate\Notifications\Slack\SlackMessage; diff --git a/app/Notifications/Test/UserTestNotificationNtfy.php b/app/Notifications/Test/UserTestNotificationNtfy.php index fcdc89aa4b..7517e962c7 100644 --- a/app/Notifications/Test/UserTestNotificationNtfy.php +++ b/app/Notifications/Test/UserTestNotificationNtfy.php @@ -24,12 +24,9 @@ declare(strict_types=1); namespace FireflyIII\Notifications\Test; -use FireflyIII\Notifications\ReturnsSettings; use FireflyIII\User; use Illuminate\Bus\Queueable; use Illuminate\Notifications\Notification; -use Ntfy\Message; -use Wijourdil\NtfyNotificationChannel\Channels\NtfyChannel; // use Illuminate\Notifications\Slack\SlackMessage; diff --git a/app/Notifications/User/BillReminder.php b/app/Notifications/User/BillReminder.php index 6017342e99..6765545d92 100644 --- a/app/Notifications/User/BillReminder.php +++ b/app/Notifications/User/BillReminder.php @@ -26,14 +26,12 @@ namespace FireflyIII\Notifications\User; use FireflyIII\Models\Bill; use FireflyIII\Notifications\ReturnsAvailableChannels; -use FireflyIII\Notifications\ReturnsSettings; use FireflyIII\User; use Illuminate\Bus\Queueable; use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Notification; use NotificationChannels\Pushover\PushoverMessage; -use Ntfy\Message; /** * Class BillReminder diff --git a/app/Notifications/User/NewAccessToken.php b/app/Notifications/User/NewAccessToken.php index 5c8be33650..d6f4728e25 100644 --- a/app/Notifications/User/NewAccessToken.php +++ b/app/Notifications/User/NewAccessToken.php @@ -25,7 +25,6 @@ declare(strict_types=1); namespace FireflyIII\Notifications\User; use FireflyIII\Notifications\ReturnsAvailableChannels; -use FireflyIII\Notifications\ReturnsSettings; use FireflyIII\Support\Facades\FireflyConfig; use FireflyIII\Support\Facades\Steam; use FireflyIII\User; @@ -35,7 +34,6 @@ use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Notification; use Illuminate\Support\Facades\Request; use NotificationChannels\Pushover\PushoverMessage; -use Ntfy\Message; /** * Class NewAccessToken diff --git a/app/Notifications/User/RuleActionFailed.php b/app/Notifications/User/RuleActionFailed.php index 4503e9bb0d..4a2cd4fd75 100644 --- a/app/Notifications/User/RuleActionFailed.php +++ b/app/Notifications/User/RuleActionFailed.php @@ -25,13 +25,11 @@ declare(strict_types=1); namespace FireflyIII\Notifications\User; use FireflyIII\Notifications\ReturnsAvailableChannels; -use FireflyIII\Notifications\ReturnsSettings; use FireflyIII\User; use Illuminate\Bus\Queueable; use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Notification; use NotificationChannels\Pushover\PushoverMessage; -use Ntfy\Message; /** * Class RuleActionFailed diff --git a/app/Notifications/User/SubscriptionsOverdueReminder.php b/app/Notifications/User/SubscriptionsOverdueReminder.php index 1031afe852..14bc238535 100644 --- a/app/Notifications/User/SubscriptionsOverdueReminder.php +++ b/app/Notifications/User/SubscriptionsOverdueReminder.php @@ -27,7 +27,6 @@ namespace FireflyIII\Notifications\User; use Carbon\Carbon; use FireflyIII\Notifications\ReturnsAvailableChannels; -use FireflyIII\Notifications\ReturnsSettings; use FireflyIII\User; use Illuminate\Bus\Queueable; use Illuminate\Notifications\Messages\MailMessage; @@ -63,9 +62,7 @@ class SubscriptionsOverdueReminder extends Notification 'bill' => $item['bill'], ]; $current['pay_dates'] = array_map( - static function (string $date): string { - return new Carbon($date)->isoFormat((string)trans('config.month_and_day_moment_js')); - }, + static fn(string $date): string => new Carbon($date)->isoFormat((string)trans('config.month_and_day_moment_js')), $item['dates']['pay_dates'] ); $info[] = $current; diff --git a/app/Notifications/User/UserLogin.php b/app/Notifications/User/UserLogin.php index 8e2ca5ecf6..fc49a102f3 100644 --- a/app/Notifications/User/UserLogin.php +++ b/app/Notifications/User/UserLogin.php @@ -25,7 +25,6 @@ declare(strict_types=1); namespace FireflyIII\Notifications\User; use FireflyIII\Notifications\ReturnsAvailableChannels; -use FireflyIII\Notifications\ReturnsSettings; use FireflyIII\Support\Facades\Steam; use FireflyIII\User; use Illuminate\Bus\Queueable; @@ -34,7 +33,6 @@ use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Notification; use Illuminate\Support\Facades\Request; use NotificationChannels\Pushover\PushoverMessage; -use Ntfy\Message; /** * Class UserLogin diff --git a/app/Notifications/User/UserNewPassword.php b/app/Notifications/User/UserNewPassword.php index ae6a8a0760..b9d708b698 100644 --- a/app/Notifications/User/UserNewPassword.php +++ b/app/Notifications/User/UserNewPassword.php @@ -25,7 +25,6 @@ declare(strict_types=1); namespace FireflyIII\Notifications\User; use FireflyIII\Notifications\ReturnsAvailableChannels; -use FireflyIII\Notifications\ReturnsSettings; use FireflyIII\Support\Facades\Steam; use FireflyIII\User; use Illuminate\Bus\Queueable; @@ -34,7 +33,6 @@ use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Notification; use Illuminate\Support\Facades\Request; use NotificationChannels\Pushover\PushoverMessage; -use Ntfy\Message; /** * Class UserNewPassword diff --git a/app/Repositories/Budget/OperationsRepository.php b/app/Repositories/Budget/OperationsRepository.php index 33a2afc27a..aba6fbff18 100644 --- a/app/Repositories/Budget/OperationsRepository.php +++ b/app/Repositories/Budget/OperationsRepository.php @@ -294,9 +294,7 @@ class OperationsRepository implements OperationsRepositoryInterface, UserGroupIn $summarizer->setConvertToPrimary($convertToPrimary); // filter $journals by range AND currency if it is present. - $expenses = array_filter($expenses, static function (array $expense) use ($start, $end, $transactionCurrency): bool { - return $expense['date']->between($start, $end) && $expense['currency_id'] === $transactionCurrency->id; - }); + $expenses = array_filter($expenses, static fn(array $expense): bool => $expense['date']->between($start, $end) && $expense['currency_id'] === $transactionCurrency->id); return $summarizer->groupByCurrencyId($expenses, 'negative', false); } @@ -308,9 +306,7 @@ class OperationsRepository implements OperationsRepositoryInterface, UserGroupIn $summarizer->setConvertToPrimary($convertToPrimary); // filter $journals by range AND currency if it is present. - $expenses = array_filter($expenses, static function (array $expense) use ($budget): bool { - return $expense['budget_id'] === $budget->id; - }); + $expenses = array_filter($expenses, static fn(array $expense): bool => $expense['budget_id'] === $budget->id); return $summarizer->groupByCurrencyId($expenses, 'negative', false); } diff --git a/app/Rules/IsValidSortInstruction.php b/app/Rules/IsValidSortInstruction.php index 015602e0fe..4185583d98 100644 --- a/app/Rules/IsValidSortInstruction.php +++ b/app/Rules/IsValidSortInstruction.php @@ -28,11 +28,8 @@ use Illuminate\Contracts\Validation\ValidationRule; class IsValidSortInstruction implements ValidationRule { - private string $class; - - public function __construct(string $class) + public function __construct(private readonly string $class) { - $this->class = $class; } public function validate(string $attribute, mixed $value, Closure $fail): void diff --git a/app/Services/Internal/Update/JournalUpdateService.php b/app/Services/Internal/Update/JournalUpdateService.php index cc9a698a98..14233e25c3 100644 --- a/app/Services/Internal/Update/JournalUpdateService.php +++ b/app/Services/Internal/Update/JournalUpdateService.php @@ -221,13 +221,7 @@ class JournalUpdateService private function hasFields(array $fields): bool { - foreach ($fields as $field) { - if (array_key_exists($field, $this->data)) { - return true; - } - } - - return false; + return array_any($fields, fn($field) => array_key_exists($field, $this->data)); } private function getOriginalSourceAccount(): Account diff --git a/app/Support/JsonApi/Enrichments/AccountEnrichment.php b/app/Support/JsonApi/Enrichments/AccountEnrichment.php index 587756ab0a..bf78751e65 100644 --- a/app/Support/JsonApi/Enrichments/AccountEnrichment.php +++ b/app/Support/JsonApi/Enrichments/AccountEnrichment.php @@ -60,7 +60,7 @@ class AccountEnrichment implements EnrichmentInterface private array $currencies = []; private array $locations = []; private array $meta = []; - private TransactionCurrency $primaryCurrency; + private readonly TransactionCurrency $primaryCurrency; private array $notes = []; private array $openingBalances = []; private User $user; @@ -69,7 +69,7 @@ class AccountEnrichment implements EnrichmentInterface private ?Carbon $date = null; private ?Carbon $start = null; private ?Carbon $end = null; - private bool $convertToPrimary; + private readonly bool $convertToPrimary; private array $balances = []; private array $startBalances = []; private array $endBalances = []; @@ -365,7 +365,7 @@ class AccountEnrichment implements EnrichmentInterface private function collectBalances(): void { $this->balances = Steam::accountsBalancesOptimized($this->collection, $this->getDate(), $this->primaryCurrency, $this->convertToPrimary); - if (null !== $this->start && null !== $this->end) { + if ($this->start instanceof Carbon && $this->end instanceof Carbon) { $this->startBalances = Steam::accountsBalancesOptimized($this->collection, $this->start, $this->primaryCurrency, $this->convertToPrimary); $this->endBalances = Steam::accountsBalancesOptimized($this->collection, $this->end, $this->primaryCurrency, $this->convertToPrimary); } @@ -395,7 +395,7 @@ class AccountEnrichment implements EnrichmentInterface public function setDate(?Carbon $date): void { - if (null !== $date) { + if ($date instanceof Carbon) { $date->endOfDay(); Log::debug(sprintf('Date is now %s', $date->toW3cString())); } @@ -404,7 +404,7 @@ class AccountEnrichment implements EnrichmentInterface public function getDate(): Carbon { - if (null === $this->date) { + if (!$this->date instanceof Carbon) { return now(); } @@ -423,7 +423,7 @@ class AccountEnrichment implements EnrichmentInterface private function getBalanceDifference(int $id, TransactionCurrency $currency): ?string { - if (null === $this->start || null === $this->end) { + if (!$this->start instanceof Carbon || !$this->end instanceof Carbon) { return null; } $startBalance = $this->startBalances[$id] ?? []; @@ -458,9 +458,7 @@ class AccountEnrichment implements EnrichmentInterface case 'current_balance': case 'pc_current_balance': - $this->collection = $this->collection->sortBy(static function (Account $account) use ($parameter) { - return $account->meta['balances'][$parameter[0]] ?? '0'; - }, SORT_NUMERIC, 'desc' === $parameter[1]); + $this->collection = $this->collection->sortBy(static fn(Account $account) => $account->meta['balances'][$parameter[0]] ?? '0', SORT_NUMERIC, 'desc' === $parameter[1]); break; } diff --git a/app/Support/JsonApi/Enrichments/AvailableBudgetEnrichment.php b/app/Support/JsonApi/Enrichments/AvailableBudgetEnrichment.php index 1d2702cf54..6154c941aa 100644 --- a/app/Support/JsonApi/Enrichments/AvailableBudgetEnrichment.php +++ b/app/Support/JsonApi/Enrichments/AvailableBudgetEnrichment.php @@ -42,7 +42,7 @@ class AvailableBudgetEnrichment implements EnrichmentInterface { private User $user; // @phpstan-ignore-line private UserGroup $userGroup; // @phpstan-ignore-line - private bool $convertToPrimary; + private readonly bool $convertToPrimary; private array $ids = []; private array $currencyIds = []; private array $currencies = []; diff --git a/app/Support/JsonApi/Enrichments/BudgetEnrichment.php b/app/Support/JsonApi/Enrichments/BudgetEnrichment.php index b84c1c82d4..821cd051c8 100644 --- a/app/Support/JsonApi/Enrichments/BudgetEnrichment.php +++ b/app/Support/JsonApi/Enrichments/BudgetEnrichment.php @@ -161,7 +161,7 @@ class BudgetEnrichment implements EnrichmentInterface private function collectExpenses(): void { - if (null !== $this->start && null !== $this->end) { + if ($this->start instanceof Carbon && $this->end instanceof Carbon) { /** @var OperationsRepositoryInterface $opsRepository */ $opsRepository = app(OperationsRepositoryInterface::class); $opsRepository->setUser($this->user); diff --git a/app/Support/JsonApi/Enrichments/BudgetLimitEnrichment.php b/app/Support/JsonApi/Enrichments/BudgetLimitEnrichment.php index bd32855412..a870917920 100644 --- a/app/Support/JsonApi/Enrichments/BudgetLimitEnrichment.php +++ b/app/Support/JsonApi/Enrichments/BudgetLimitEnrichment.php @@ -53,7 +53,7 @@ class BudgetLimitEnrichment implements EnrichmentInterface private array $currencyIds = []; private array $currencies = []; private bool $convertToPrimary = true; - private TransactionCurrency $primaryCurrency; + private readonly TransactionCurrency $primaryCurrency; public function __construct() { @@ -181,27 +181,21 @@ class BudgetLimitEnrichment implements EnrichmentInterface private function stringifyIds(): void { - $this->expenses = array_map(function ($first) { - return array_map(function ($second) { - $second['currency_id'] = (string)($second['currency_id'] ?? 0); + $this->expenses = array_map(fn($first) => array_map(function ($second) { + $second['currency_id'] = (string)($second['currency_id'] ?? 0); - return $second; - }, $first); - }, $this->expenses); + return $second; + }, $first), $this->expenses); - $this->pcExpenses = array_map(function ($first) { - return array_map(function ($second) { - $second['currency_id'] = (string)($second['currency_id'] ?? 0); + $this->pcExpenses = array_map(fn($first) => array_map(function ($second) { + $second['currency_id'] = (string)($second['currency_id'] ?? 0); - return $second; - }, $first); - }, $this->expenses); + return $second; + }, $first), $this->expenses); } private function filterToBudget(array $expenses, int $budget): array { - return array_filter($expenses, function (array $item) use ($budget) { - return (int)$item['budget_id'] === $budget; - }); + return array_filter($expenses, fn(array $item) => (int)$item['budget_id'] === $budget); } } diff --git a/app/Support/JsonApi/Enrichments/PiggyBankEnrichment.php b/app/Support/JsonApi/Enrichments/PiggyBankEnrichment.php index e4e01b214c..7266cec54d 100644 --- a/app/Support/JsonApi/Enrichments/PiggyBankEnrichment.php +++ b/app/Support/JsonApi/Enrichments/PiggyBankEnrichment.php @@ -53,7 +53,7 @@ class PiggyBankEnrichment implements EnrichmentInterface // private array $accountCurrencies = []; private array $notes = []; private array $mappedObjects = []; - private TransactionCurrency $primaryCurrency; + private readonly TransactionCurrency $primaryCurrency; private array $amounts = []; private array $accounts = []; private array $objectGroups = []; @@ -271,7 +271,7 @@ class PiggyBankEnrichment implements EnrichmentInterface */ private function getSuggestedMonthlyAmount(?Carbon $startDate, ?Carbon $targetDate, ?string $targetAmount, string $currentAmount): string { - if (null === $targetAmount || null === $targetDate || null === $startDate) { + if (null === $targetAmount || !$targetDate instanceof Carbon || !$startDate instanceof Carbon) { return '0'; } $savePerMonth = '0'; diff --git a/app/Support/JsonApi/Enrichments/PiggyBankEventEnrichment.php b/app/Support/JsonApi/Enrichments/PiggyBankEventEnrichment.php index 8aff973ccf..9247bbbf18 100644 --- a/app/Support/JsonApi/Enrichments/PiggyBankEventEnrichment.php +++ b/app/Support/JsonApi/Enrichments/PiggyBankEventEnrichment.php @@ -27,7 +27,6 @@ namespace FireflyIII\Support\JsonApi\Enrichments; use FireflyIII\Models\AccountMeta; use FireflyIII\Models\PiggyBankEvent; -use FireflyIII\Models\TransactionCurrency; use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\UserGroup; use FireflyIII\Support\Facades\Amount; diff --git a/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php b/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php index 727f51bced..edcf16d7c1 100644 --- a/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php +++ b/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php @@ -49,7 +49,7 @@ class SubscriptionEnrichment implements EnrichmentInterface private User $user; private UserGroup $userGroup; // @phpstan-ignore-line private Collection $collection; - private bool $convertToPrimary; + private readonly bool $convertToPrimary; private ?Carbon $start = null; private ?Carbon $end = null; private array $subscriptionIds = []; @@ -58,7 +58,7 @@ class SubscriptionEnrichment implements EnrichmentInterface private array $paidDates = []; private array $notes = []; private array $payDates = []; - private TransactionCurrency $primaryCurrency; + private readonly TransactionCurrency $primaryCurrency; private BillDateCalculator $calculator; public function __construct() @@ -210,7 +210,7 @@ class SubscriptionEnrichment implements EnrichmentInterface { $this->paidDates = []; Log::debug('Now in collectPaidDates for bills'); - if (null === $this->start || null === $this->end) { + if (!$this->start instanceof Carbon || !$this->end instanceof Carbon) { Log::debug('Parameters are NULL, set empty array'); return; @@ -274,9 +274,7 @@ class SubscriptionEnrichment implements EnrichmentInterface // At this point the "next match" is exactly after the last time the bill was paid. $result = []; - $filtered = $set->filter(function (TransactionJournal $journal) use ($subscription) { - return (int)$journal->bill_id === (int)$subscription->id; - }); + $filtered = $set->filter(fn(TransactionJournal $journal) => (int)$journal->bill_id === (int)$subscription->id); foreach ($filtered as $entry) { $array = [ 'transaction_group_id' => (string)$entry->transaction_group_id, @@ -346,9 +344,7 @@ class SubscriptionEnrichment implements EnrichmentInterface */ protected function lastPaidDate(Bill $subscription, Collection $dates, Carbon $default): Carbon { - $filtered = $dates->filter(function (TransactionJournal $journal) use ($subscription) { - return (int)$journal->bill_id === (int)$subscription->id; - }); + $filtered = $dates->filter(fn(TransactionJournal $journal) => (int)$journal->bill_id === (int)$subscription->id); Log::debug(sprintf('Filtered down from %d to %d entries for bill #%d.', $dates->count(), $filtered->count(), $subscription->id)); if (0 === $filtered->count()) { return $default; @@ -392,7 +388,7 @@ class SubscriptionEnrichment implements EnrichmentInterface private function collectPayDates(): void { - if (null === $this->start || null === $this->end) { + if (!$this->start instanceof Carbon || !$this->end instanceof Carbon) { Log::debug('Parameters are NULL, set empty array'); return; @@ -440,8 +436,8 @@ class SubscriptionEnrichment implements EnrichmentInterface // nullify again when it's outside the current view range. if ( - (null !== $this->start && $nemDate->lt($this->start)) - || (null !== $this->end && $nemDate->gt($this->end)) + ($this->start instanceof Carbon && $nemDate->lt($this->start)) + || ($this->end instanceof Carbon && $nemDate->gt($this->end)) ) { $nem = null; $nemDate = null; @@ -454,7 +450,7 @@ class SubscriptionEnrichment implements EnrichmentInterface private function getNextExpectedMatchDiff(?Carbon $nem, array $payDates): string { - if (null === $nem) { + if (!$nem instanceof Carbon) { return trans('firefly.not_expected_period'); } $nemDiff = trans('firefly.not_expected_period'); diff --git a/app/Support/Repositories/UserGroup/UserGroupTrait.php b/app/Support/Repositories/UserGroup/UserGroupTrait.php index ef39abc530..98781e5596 100644 --- a/app/Support/Repositories/UserGroup/UserGroupTrait.php +++ b/app/Support/Repositories/UserGroup/UserGroupTrait.php @@ -72,7 +72,7 @@ trait UserGroupTrait return; } - $class = null === $user ? 'NULL' : $user::class; + $class = $user instanceof Authenticatable ? $user::class : 'NULL'; throw new FireflyException(sprintf('Object is %s, not User.', $class)); } diff --git a/app/Support/Request/ValidatesWebhooks.php b/app/Support/Request/ValidatesWebhooks.php index 15d41f41ef..5647184ef4 100644 --- a/app/Support/Request/ValidatesWebhooks.php +++ b/app/Support/Request/ValidatesWebhooks.php @@ -25,10 +25,10 @@ declare(strict_types=1); namespace FireflyIII\Support\Request; +use Illuminate\Validation\Validator; use FireflyIII\Enums\WebhookTrigger; use FireflyIII\Models\Webhook; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; trait ValidatesWebhooks { diff --git a/app/Support/Steam.php b/app/Support/Steam.php index 991491d353..69432ff0f5 100644 --- a/app/Support/Steam.php +++ b/app/Support/Steam.php @@ -348,9 +348,7 @@ class Steam $currency = $currencies[$account->id]; // second array - $accountSum = array_filter($arrayOfSums, function ($entry) use ($account) { - return $entry['account_id'] === $account->id; - }); + $accountSum = array_filter($arrayOfSums, fn($entry) => $entry['account_id'] === $account->id); if (0 === count($accountSum)) { $result[$account->id] = $return; diff --git a/app/Transformers/PiggyBankTransformer.php b/app/Transformers/PiggyBankTransformer.php index 14096c5306..10c3379441 100644 --- a/app/Transformers/PiggyBankTransformer.php +++ b/app/Transformers/PiggyBankTransformer.php @@ -34,7 +34,7 @@ use FireflyIII\Support\Facades\Amount; */ class PiggyBankTransformer extends AbstractTransformer { - private TransactionCurrency $primaryCurrency; + private readonly TransactionCurrency $primaryCurrency; /** * PiggyBankTransformer constructor. @@ -53,8 +53,8 @@ class PiggyBankTransformer extends AbstractTransformer { // Amounts, depending on 0.0 state of target amount $percentage = null; - if (null !== $piggyBank->meta['target_amount'] && 0 !== bccomp($piggyBank->meta['current_amount'], '0')) { // target amount is not 0.00 - $percentage = (int)bcmul(bcdiv($piggyBank->meta['current_amount'], $piggyBank->meta['target_amount']), '100'); + if (null !== $piggyBank->meta['target_amount'] && 0 !== bccomp((string) $piggyBank->meta['current_amount'], '0')) { // target amount is not 0.00 + $percentage = (int)bcmul(bcdiv((string) $piggyBank->meta['current_amount'], $piggyBank->meta['target_amount']), '100'); } $startDate = $piggyBank->start_date?->toAtomString(); $targetDate = $piggyBank->target_date?->toAtomString(); diff --git a/tests/integration/Api/Chart/AccountControllerTest.php b/tests/integration/Api/Chart/AccountControllerTest.php index 9fe3436cef..565c93f19b 100644 --- a/tests/integration/Api/Chart/AccountControllerTest.php +++ b/tests/integration/Api/Chart/AccountControllerTest.php @@ -25,6 +25,7 @@ declare(strict_types=1); namespace Tests\integration\Api\Chart; +use Override; use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\integration\TestCase; @@ -39,7 +40,7 @@ final class AccountControllerTest extends TestCase private $user; #[Override] - #[\Override] + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/integration/Api/Chart/BalanceControllerTest.php b/tests/integration/Api/Chart/BalanceControllerTest.php index 2a984e5f9d..42de53fe32 100644 --- a/tests/integration/Api/Chart/BalanceControllerTest.php +++ b/tests/integration/Api/Chart/BalanceControllerTest.php @@ -25,6 +25,7 @@ declare(strict_types=1); namespace Tests\integration\Api\Chart; +use Override; use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\integration\TestCase; @@ -39,7 +40,7 @@ final class BalanceControllerTest extends TestCase private $user; #[Override] - #[\Override] + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/integration/Api/Chart/BudgetControllerTest.php b/tests/integration/Api/Chart/BudgetControllerTest.php index 56ca6f5099..4ce539c591 100644 --- a/tests/integration/Api/Chart/BudgetControllerTest.php +++ b/tests/integration/Api/Chart/BudgetControllerTest.php @@ -25,6 +25,7 @@ declare(strict_types=1); namespace Tests\integration\Api\Chart; +use Override; use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\integration\TestCase; @@ -39,7 +40,7 @@ final class BudgetControllerTest extends TestCase private $user; #[Override] - #[\Override] + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/integration/Api/Chart/CategoryControllerTest.php b/tests/integration/Api/Chart/CategoryControllerTest.php index 5c8540b3fb..0cf1a49809 100644 --- a/tests/integration/Api/Chart/CategoryControllerTest.php +++ b/tests/integration/Api/Chart/CategoryControllerTest.php @@ -25,6 +25,7 @@ declare(strict_types=1); namespace Tests\integration\Api\Chart; +use Override; use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\integration\TestCase; @@ -39,7 +40,7 @@ final class CategoryControllerTest extends TestCase private $user; #[Override] - #[\Override] + #[Override] protected function setUp(): void { parent::setUp();