mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-10-31 02:36:28 +00:00 
			
		
		
		
	Various code cleanup.
This commit is contained in:
		| @@ -82,7 +82,7 @@ class RemoteUserGuard implements Guard | ||||
|  | ||||
|         if (null !== $header) { | ||||
|             $emailAddress = (string)(request()->server($header) ?? null); | ||||
|             $preference   = app('preferences')->getForUser($retrievedUser, 'remote_guard_alt_email', null); | ||||
|             $preference   = app('preferences')->getForUser($retrievedUser, 'remote_guard_alt_email'); | ||||
|  | ||||
|             if (null !== $emailAddress && null === $preference && $emailAddress !== $userID) { | ||||
|                 app('preferences')->setForUser($retrievedUser, 'remote_guard_alt_email', $emailAddress); | ||||
|   | ||||
| @@ -23,6 +23,7 @@ declare(strict_types=1); | ||||
|  | ||||
| namespace FireflyIII\Support\Binder; | ||||
|  | ||||
| use FireflyIII\Exceptions\FireflyException; | ||||
| use FireflyIII\Repositories\User\UserRepositoryInterface; | ||||
| use Illuminate\Routing\Route; | ||||
| use Log; | ||||
| @@ -39,7 +40,7 @@ class CLIToken implements BinderInterface | ||||
|      * @param Route  $route | ||||
|      * | ||||
|      * @return mixed | ||||
|      * @throws \FireflyIII\Exceptions\FireflyException | ||||
|      * @throws FireflyException | ||||
|      */ | ||||
|     public static function routeBinder(string $value, Route $route) | ||||
|     { | ||||
|   | ||||
| @@ -160,7 +160,7 @@ class ExportDataGenerator | ||||
|                 $account->iban, | ||||
|                 $account->account_number, | ||||
|                 $account->active, | ||||
|                 $currency ? $currency->code : null, | ||||
|                 $currency?->code, | ||||
|                 $repository->getMetaValue($account, 'account_role'), | ||||
|                 $repository->getMetaValue($account, 'cc_type'), | ||||
|                 $repository->getMetaValue($account, 'cc_monthly_payment_date'), | ||||
| @@ -391,11 +391,11 @@ class ExportDataGenerator | ||||
|                 $piggy->account->name, | ||||
|                 $piggy->account->accountType->type, | ||||
|                 $piggy->name, | ||||
|                 $currency ? $currency->code : null, | ||||
|                 $currency?->code, | ||||
|                 $piggy->targetamount, | ||||
|                 $repetition ? $repetition->currentamount : null, | ||||
|                 $piggy->startdate ? $piggy->startdate->format('Y-m-d') : null, | ||||
|                 $piggy->targetdate ? $piggy->targetdate->format('Y-m-d') : null, | ||||
|                 $repetition?->currentamount, | ||||
|                 $piggy->startdate?->format('Y-m-d'), | ||||
|                 $piggy->targetdate?->format('Y-m-d'), | ||||
|                 $piggy->order, | ||||
|                 $piggy->active, | ||||
|             ]; | ||||
| @@ -457,9 +457,9 @@ class ExportDataGenerator | ||||
|                 $recurrence->transactionType->type, | ||||
|                 $recurrence->title, | ||||
|                 $recurrence->description, | ||||
|                 null !== $recurrence->first_date ? $recurrence->first_date->format('Y-m-d') : null, | ||||
|                 $recurrence->repeat_until ? $recurrence->repeat_until->format('Y-m-d') : null, | ||||
|                 $recurrence->latest_date ? $recurrence->latest_date->format('Y-m-d') : null, | ||||
|                 $recurrence->first_date?->format('Y-m-d'), | ||||
|                 $recurrence->repeat_until?->format('Y-m-d'), | ||||
|                 $recurrence->latest_date?->format('Y-m-d'), | ||||
|                 $recurrence->repetitions, | ||||
|                 $recurrence->apply_rules, | ||||
|                 $recurrence->active, | ||||
| @@ -492,7 +492,7 @@ class ExportDataGenerator | ||||
|                     null, null, null, null, | ||||
|  | ||||
|                     // transaction: | ||||
|                     $transaction->transactionCurrency->code, $transaction->foreignCurrency ? $transaction->foreignCurrency->code : null, | ||||
|                     $transaction->transactionCurrency->code, $transaction->foreignCurrency?->code, | ||||
|                     $transaction->sourceAccount->name, $transaction->sourceAccount->accountType->type, $transaction->destinationAccount->name, | ||||
|                     $transaction->destinationAccount->accountType->type, $transaction->amount, $transaction->foreign_amount, | ||||
|                     $categoryName, $budgetId, $piggyBankId, implode(',', $tags), | ||||
| @@ -608,7 +608,7 @@ class ExportDataGenerator | ||||
|                 $tag->created_at->toAtomString(), | ||||
|                 $tag->updated_at->toAtomString(), | ||||
|                 $tag->tag, | ||||
|                 $tag->date ? $tag->date->format('Y-m-d') : null, | ||||
|                 $tag->date?->format('Y-m-d'), | ||||
|                 $tag->description, | ||||
|                 $tag->latitude, | ||||
|                 $tag->longitude, | ||||
|   | ||||
| @@ -67,7 +67,7 @@ class ParseDateString | ||||
|         } | ||||
|  | ||||
|         // if + or -: | ||||
|         if (0 === strpos($date, '+') || 0 === strpos($date, '-')) { | ||||
|         if (str_starts_with($date, '+') || str_starts_with($date, '-')) { | ||||
|  | ||||
|             return $this->parseRelativeDate($date); | ||||
|         } | ||||
| @@ -81,7 +81,7 @@ class ParseDateString | ||||
|         } | ||||
|  | ||||
|         // maybe a date range | ||||
|         if (10 === strlen($date) && (false !== strpos($date, 'xx') || false !== strpos($date, 'xxxx'))) { | ||||
|         if (10 === strlen($date) && (str_contains($date, 'xx') || str_contains($date, 'xxxx'))) { | ||||
|             Log::debug(sprintf('[c]Detected a date range ("%s"), return a fake date.', $date)); | ||||
|             // very lazy way to parse the date without parsing it, because this specific function | ||||
|             // cant handle date ranges. | ||||
| @@ -112,7 +112,7 @@ class ParseDateString | ||||
|             return false; | ||||
|         } | ||||
|         // no x'es | ||||
|         if (false === strpos($date, 'xx') && false === strpos($date, 'xxxx')) { | ||||
|         if (!str_contains($date, 'xx') && !str_contains($date, 'xxxx')) { | ||||
|             return false; | ||||
|         } | ||||
|  | ||||
| @@ -383,7 +383,7 @@ class ParseDateString | ||||
|                 Log::error(sprintf('Part "%s" does not match regular expression. Will be skipped.', $part)); | ||||
|                 continue; | ||||
|             } | ||||
|             $direction = 0 === strpos($part, '+') ? 1 : 0; | ||||
|             $direction = str_starts_with($part, '+') ? 1 : 0; | ||||
|             $period    = $part[strlen($part) - 1]; | ||||
|             $number    = (int) substr($part, 1, -1); | ||||
|             if (!array_key_exists($period, $functions[$direction])) { | ||||
|   | ||||
| @@ -26,6 +26,7 @@ namespace FireflyIII\Support\Search; | ||||
| use FireflyIII\User; | ||||
| use Illuminate\Database\Eloquent\Builder; | ||||
| use Illuminate\Support\Collection; | ||||
| use JsonException; | ||||
|  | ||||
| /** | ||||
|  * Class AccountSearch | ||||
| @@ -55,7 +56,7 @@ class AccountSearch implements GenericSearchInterface | ||||
|  | ||||
|     /** | ||||
|      * @return Collection | ||||
|      * @throws \JsonException | ||||
|      * @throws JsonException | ||||
|      */ | ||||
|     public function search(): Collection | ||||
|     { | ||||
|   | ||||
| @@ -71,10 +71,8 @@ class OperatorQuerySearch implements SearchInterface | ||||
|     private int                         $limit; | ||||
|     private Collection                  $operators; | ||||
|     private int                         $page; | ||||
|     private ParsedQuery                 $query; | ||||
|     private float                       $startTime; | ||||
|     private TagRepositoryInterface      $tagRepository; | ||||
|     private User                        $user; | ||||
|     private array                       $validOperators; | ||||
|     private array                       $words; | ||||
|     private array                       $invalidOperators; | ||||
| @@ -146,11 +144,11 @@ class OperatorQuerySearch implements SearchInterface | ||||
|     public function parseQuery(string $query) | ||||
|     { | ||||
|         Log::debug(sprintf('Now in parseQuery(%s)', $query)); | ||||
|         $parser      = new QueryParser(); | ||||
|         $this->query = $parser->parse($query); | ||||
|         $parser = new QueryParser(); | ||||
|         $query1 = $parser->parse($query); | ||||
|  | ||||
|         Log::debug(sprintf('Found %d node(s)', count($this->query->getNodes()))); | ||||
|         foreach ($this->query->getNodes() as $searchNode) { | ||||
|         Log::debug(sprintf('Found %d node(s)', count($query1->getNodes()))); | ||||
|         foreach ($query1->getNodes() as $searchNode) { | ||||
|             $this->handleSearchNode($searchNode); | ||||
|         } | ||||
|  | ||||
| @@ -220,14 +218,13 @@ class OperatorQuerySearch implements SearchInterface | ||||
|      */ | ||||
|     public function setUser(User $user): void | ||||
|     { | ||||
|         $this->user = $user; | ||||
|         $this->accountRepository->setUser($user); | ||||
|         $this->billRepository->setUser($user); | ||||
|         $this->categoryRepository->setUser($user); | ||||
|         $this->budgetRepository->setUser($user); | ||||
|         $this->tagRepository->setUser($user); | ||||
|         $this->collector = app(GroupCollectorInterface::class); | ||||
|         $this->collector->setUser($this->user); | ||||
|         $this->collector->setUser($user); | ||||
|         $this->collector->withAccountInformation()->withCategoryInformation()->withBudgetInformation(); | ||||
|  | ||||
|         $this->setLimit((int)app('preferences')->getForUser($user, 'listPageSize', 50)->data); | ||||
|   | ||||
| @@ -24,11 +24,13 @@ namespace FireflyIII\Support; | ||||
|  | ||||
| use Carbon\Carbon; | ||||
| use DB; | ||||
| use FireflyIII\Exceptions\FireflyException; | ||||
| use FireflyIII\Models\Account; | ||||
| use FireflyIII\Models\Transaction; | ||||
| use FireflyIII\Models\TransactionCurrency; | ||||
| use FireflyIII\Repositories\Account\AccountRepositoryInterface; | ||||
| use Illuminate\Support\Collection; | ||||
| use JsonException; | ||||
| use stdClass; | ||||
|  | ||||
| /** | ||||
| @@ -47,8 +49,8 @@ class Steam | ||||
|      * @param TransactionCurrency|null $currency | ||||
|      * | ||||
|      * @return string | ||||
|      * @throws \FireflyIII\Exceptions\FireflyException | ||||
|      * @throws \JsonException | ||||
|      * @throws FireflyException | ||||
|      * @throws JsonException | ||||
|      */ | ||||
|     public function balance(Account $account, Carbon $date, ?TransactionCurrency $currency = null): string | ||||
|     { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user