Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Replace magic facades
James Coleb830bd273201
diff --git a/app/Factory/TransactionFactory.php b/app/Factory/TransactionFactory.phpindex 83294e2045..1065b7bda3 100644--- a/app/Factory/TransactionFactory.php+++ b/app/Factory/TransactionFactory.php@@ -32,6 +32,7 @@ use FireflyIII\Models\TransactionJournal;use FireflyIII\Rules\UniqueIban;use FireflyIII\Services\Internal\Update\AccountUpdateService;use Illuminate\Database\QueryException;+use Illuminate\Support\Facades\Validator;/*** Class TransactionFactory@@ -152,7 +153,7 @@ class TransactionFactoryreturn;}// validate info:- $validator = \Validator::make(['iban' => $this->accountInformation['iban']], [+ $validator = Validator::make(['iban' => $this->accountInformation['iban']], ['iban' => ['required', new UniqueIban($this->account, $this->account->accountType->type)],]);if ($validator->fails()) {diff --git a/app/Handlers/Events/UserEventHandler.php b/app/Handlers/Events/UserEventHandler.phpindex 62643d884e..261a4bda33 100644--- a/app/Handlers/Events/UserEventHandler.php+++ b/app/Handlers/Events/UserEventHandler.php@@ -54,6 +54,7 @@ use FireflyIII\Repositories\User\UserRepositoryInterface;use FireflyIII\User;use Illuminate\Auth\Events\Login;use Illuminate\Support\Facades\Log;+use Illuminate\Support\Facades\Mail;use Illuminate\Support\Facades\Notification;use Mail;@@ -266,7 +267,7 @@ class UserEventHandler$url = route('profile.confirm-email-change', [$token->data]);try {- \Mail::to($newEmail)->send(new ConfirmEmailChangeMail($newEmail, $oldEmail, $url));+ Mail::to($newEmail)->send(new ConfirmEmailChangeMail($newEmail, $oldEmail, $url));} catch (\Exception $e) {app('log')->error($e->getMessage());app('log')->error($e->getTraceAsString());@@ -291,7 +292,7 @@ class UserEventHandler$url = route('profile.undo-email-change', [$token->data, $hashed]);try {- \Mail::to($oldEmail)->send(new UndoEmailChangeMail($newEmail, $oldEmail, $url));+ Mail::to($oldEmail)->send(new UndoEmailChangeMail($newEmail, $oldEmail, $url));} catch (\Exception $e) {app('log')->error($e->getMessage());app('log')->error($e->getTraceAsString());@@ -355,7 +356,7 @@ class UserEventHandler$url = route('invite', [$event->invitee->invite_code]);try {- \Mail::to($invitee)->send(new InvitationMail($invitee, $admin, $url));+ Mail::to($invitee)->send(new InvitationMail($invitee, $admin, $url));} catch (\Exception $e) {app('log')->error($e->getMessage());app('log')->error($e->getTraceAsString());diff --git a/app/Jobs/MailError.php b/app/Jobs/MailError.phpindex 7b906b93a6..229a55b28d 100644--- a/app/Jobs/MailError.php+++ b/app/Jobs/MailError.php@@ -28,6 +28,7 @@ use Illuminate\Mail\Message;use Illuminate\Queue\InteractsWithQueue;use Illuminate\Queue\SerializesModels;use Illuminate\Support\Facades\Log;+use Illuminate\Support\Facades\Mail;use Symfony\Component\Mailer\Exception\TransportException;/**@@ -70,7 +71,7 @@ class MailError extends Job implements ShouldQueueif ($this->attempts() < 3 && '' !== $email) {try {- \Mail::send(+ Mail::send(['emails.error-html', 'emails.error-text'],$args,static function (Message $message) use ($email): void {diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.phpindex ec474c598b..7de4243aaf 100644--- a/app/Providers/AppServiceProvider.php+++ b/app/Providers/AppServiceProvider.php@@ -59,7 +59,7 @@ class AppServiceProvider extends ServiceProvider// blade extensionBlade::directive('activeXRoutePartial', function (string $route) {- $name = \Route::getCurrentRoute()->getName() ?? '';+ $name = Route::getCurrentRoute()->getName() ?? '';if (str_contains($name, $route)) {return 'menu-open';}diff --git a/app/Services/Internal/Support/AccountServiceTrait.php b/app/Services/Internal/Support/AccountServiceTrait.phpindex 787a08c239..15fe51dfdd 100644--- a/app/Services/Internal/Support/AccountServiceTrait.php+++ b/app/Services/Internal/Support/AccountServiceTrait.php@@ -39,6 +39,7 @@ use FireflyIII\Models\TransactionGroup;use FireflyIII\Models\TransactionJournal;use FireflyIII\Repositories\Account\AccountRepositoryInterface;use FireflyIII\Services\Internal\Destroy\TransactionGroupDestroyService;+use Illuminate\Support\Facades\Validator;/*** Trait AccountServiceTrait@@ -54,7 +55,7 @@ trait AccountServiceTrait}$data = ['iban' => $iban];$rules = ['iban' => 'required|iban'];- $validator = \Validator::make($data, $rules);+ $validator = Validator::make($data, $rules);if ($validator->fails()) {app('log')->info(sprintf('Detected invalid IBAN ("%s"). Return NULL instead.', $iban));diff --git a/app/Support/FireflyConfig.php b/app/Support/FireflyConfig.phpindex a9e182b519..009fc71390 100644--- a/app/Support/FireflyConfig.php+++ b/app/Support/FireflyConfig.php@@ -28,6 +28,7 @@ use FireflyIII\Models\Configuration;use Illuminate\Contracts\Encryption\DecryptException;use Illuminate\Contracts\Encryption\EncryptException;use Illuminate\Database\QueryException;+use Illuminate\Support\Facades\Cache;use Illuminate\Support\Facades\Log;/**@@ -38,8 +39,8 @@ class FireflyConfigpublic function delete(string $name): void{$fullName = 'ff-config-'.$name;- if (\Cache::has($fullName)) {- \Cache::forget($fullName);+ if (Cache::has($fullName)) {+ Cache::forget($fullName);}Configuration::where('name', $name)->forceDelete();}@@ -80,8 +81,8 @@ class FireflyConfigpublic function get(string $name, mixed $default = null): ?Configuration{$fullName = 'ff-config-'.$name;- if (\Cache::has($fullName)) {- return \Cache::get($fullName);+ if (Cache::has($fullName)) {+ return Cache::get($fullName);}try {@@ -92,7 +93,7 @@ class FireflyConfig}if (null !== $config) {- \Cache::forever($fullName, $config);+ Cache::forever($fullName, $config);return $config;}@@ -122,13 +123,13 @@ class FireflyConfig$item->name = $name;$item->data = $value;$item->save();- \Cache::forget('ff-config-'.$name);+ Cache::forget('ff3-config-'.$name);return $item;}$config->data = $value;$config->save();- \Cache::forget('ff-config-'.$name);+ Cache::forget('ff3-config-'.$name);return $config;}diff --git a/app/Support/System/OAuthKeys.php b/app/Support/System/OAuthKeys.phpindex e0c0fa0b7a..0ba89c644d 100644--- a/app/Support/System/OAuthKeys.php+++ b/app/Support/System/OAuthKeys.php@@ -26,6 +26,7 @@ namespace FireflyIII\Support\System;use FireflyIII\Exceptions\FireflyException;use Illuminate\Contracts\Encryption\DecryptException;+use Illuminate\Support\Facades\Artisan;use Illuminate\Support\Facades\Crypt;use Laravel\Passport\Console\KeysCommand;use Psr\Container\ContainerExceptionInterface;@@ -88,8 +89,8 @@ class OAuthKeyspublic static function generateKeys(): void{- \Artisan::registerCommand(new KeysCommand());- \Artisan::call('firefly-iii:laravel-passport-keys');+ Artisan::registerCommand(new KeysCommand());+ Artisan::call('firefly-iii:laravel-passport-keys');}public static function storeKeysInDB(): voiddiff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.phpindex 4ae8da0019..6e369e4086 100644--- a/app/Support/Twig/General.php+++ b/app/Support/Twig/General.php@@ -247,7 +247,7 @@ class General extends AbstractExtensionstatic function (): string {$args = func_get_args();$route = $args[0]; // name of the route.- $name = \Route::getCurrentRoute()->getName() ?? '';+ $name = Route::getCurrentRoute()->getName() ?? '';if (str_contains($name, $route)) {return 'active';}@@ -271,7 +271,7 @@ class General extends AbstractExtensionif ($objectType === $activeObjectType&& false !== stripos(- (string) \Route::getCurrentRoute()->getName(),+ (string) Route::getCurrentRoute()->getName(),(string) $route)) {return 'active';@@ -294,7 +294,7 @@ class General extends AbstractExtensionstatic function (): string {$args = func_get_args();$route = $args[0]; // name of the route.- $name = \Route::getCurrentRoute()->getName() ?? '';+ $name = Route::getCurrentRoute()->getName() ?? '';if (str_contains($name, $route)) {return 'menu-open';}diff --git a/app/User.php b/app/User.phpindex 51d27e3b6f..f6bc724e5f 100644--- a/app/User.php+++ b/app/User.php@@ -61,6 +61,7 @@ use Illuminate\Foundation\Auth\User as Authenticatable;use Illuminate\Notifications\Notifiable;use Illuminate\Notifications\Notification;use Illuminate\Support\Collection;+use Illuminate\Support\Facades\Request;use Illuminate\Support\Str;use Laravel\Passport\HasApiTokens;use NotificationChannels\Pushover\PushoverReceiver;@@ -464,7 +465,7 @@ class User extends Authenticatable*/public function sendPasswordResetNotification($token): void{- $ipAddress = \Request::ip();+ $ipAddress = Request::ip();event(new RequestedNewPassword($this, $token, $ipAddress));}diff --git a/app/Validation/FireflyValidator.php b/app/Validation/FireflyValidator.phpindex 86409ed951..0ea1c687fd 100644--- a/app/Validation/FireflyValidator.php+++ b/app/Validation/FireflyValidator.php@@ -44,6 +44,7 @@ use Illuminate\Validation\Validator;use PragmaRX\Google2FA\Exceptions\IncompatibleWithGoogleAuthenticatorException;use PragmaRX\Google2FA\Exceptions\InvalidCharactersException;use PragmaRX\Google2FA\Exceptions\SecretKeyTooShortException;+use PragmaRX\Google2FALaravel\Facade;/*** Class FireflyValidator.@@ -79,7 +80,7 @@ class FireflyValidator extends Validator}$secret = (string) $secret;- return (bool) \Google2FA::verifyKey($secret, $value);+ return (bool) Facade::verifyKey($secret, $value);}/**@@ -131,7 +132,7 @@ class FireflyValidator extends Validator}$secret = (string) $user->mfa_secret;- return (bool) \Google2FA::verifyKey($secret, $value);+ return (bool) Facade::verifyKey($secret, $value);}/**diff --git a/routes/api-noauth.php b/routes/api-noauth.phpindex 7e4e1da126..743ec20051 100644--- a/routes/api-noauth.php+++ b/routes/api-noauth.php@@ -22,6 +22,8 @@declare(strict_types=1);+use Illuminate\Support\Facades\Route;+// Cron job API routes:use FireflyIII\Http\Middleware\AcceptHeaders;diff --git a/routes/api.php b/routes/api.phpindex 02bd5643ca..9be3f75bfa 100644--- a/routes/api.php+++ b/routes/api.php@@ -22,6 +22,8 @@declare(strict_types=1);+use Illuminate\Support\Facades\Route;+/*** ____ ____ ___ .______ ______ __ __ .___________. _______ _______.diff --git a/routes/channels.php b/routes/channels.phpindex 702805feed..25c8051eec 100644--- a/routes/channels.php+++ b/routes/channels.php@@ -22,6 +22,7 @@declare(strict_types=1);+use Illuminate\Support\Facades\Broadcast;/*|--------------------------------------------------------------------------| Broadcast Channelsdiff --git a/routes/web.php b/routes/web.phpindex ee6039a7ae..2fa1d255b6 100644--- a/routes/web.php+++ b/routes/web.php@@ -19,9 +19,11 @@* You should have received a copy of the GNU Affero General Public License* along with this program. If not, see <https://www.gnu.org/licenses/>.*/-declare(strict_types=1);+use Illuminate\Support\Facades\Route;++if (!defined('DATEFORMAT')) {define('DATEFORMAT', '(19|20)[0-9]{2}-?[0-9]{2}-?[0-9]{2}');}