mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-10-31 02:36:28 +00:00 
			
		
		
		
	Small code cleanup.
This commit is contained in:
		| @@ -39,9 +39,7 @@ use Log; | ||||
|  */ | ||||
| class LinkController extends Controller | ||||
| { | ||||
|  | ||||
|     /** @var LinkTypeRepositoryInterface */ | ||||
|     private $repository; | ||||
|     private LinkTypeRepositoryInterface $repository; | ||||
|  | ||||
|     /** | ||||
|      * LinkController constructor. | ||||
|   | ||||
| @@ -23,6 +23,7 @@ declare(strict_types=1); | ||||
|  | ||||
| namespace FireflyIII\Http\Controllers\Admin; | ||||
|  | ||||
| use FireflyIII\Exceptions\FireflyException; | ||||
| use FireflyIII\Helpers\Update\UpdateTrait; | ||||
| use FireflyIII\Http\Controllers\Controller; | ||||
| use FireflyIII\Http\Middleware\IsDemoUser; | ||||
| @@ -62,8 +63,7 @@ class UpdateController extends Controller | ||||
|      * Show page with update options. | ||||
|      * | ||||
|      * @return Factory|View | ||||
|      * @throws ContainerExceptionInterface | ||||
|      * @throws NotFoundExceptionInterface | ||||
|      * @throws FireflyException | ||||
|      */ | ||||
|     public function index() | ||||
|     { | ||||
|   | ||||
| @@ -159,7 +159,6 @@ class IndexController extends Controller | ||||
|                     continue; | ||||
|                 } | ||||
|  | ||||
|                 /** @var TransactionCurrency $currency */ | ||||
|                 $currencyId                     = $bill['currency_id']; | ||||
|                 $sums[$groupOrder][$currencyId] = $sums[$groupOrder][$currencyId] ?? [ | ||||
|                         'currency_id'             => $currencyId, | ||||
|   | ||||
| @@ -144,7 +144,7 @@ class ShowController extends Controller | ||||
|      */ | ||||
|     public function show(Request $request, Budget $budget) | ||||
|     { | ||||
|         /** @var Carbon $start */ | ||||
|         /** @var Carbon $allStart */ | ||||
|         $allStart    = session('first', Carbon::now()->startOfYear()); | ||||
|         $allEnd      = today(); | ||||
|         $page        = (int)$request->get('page'); | ||||
|   | ||||
| @@ -108,7 +108,7 @@ class BudgetController extends Controller | ||||
|         $currencies     = []; | ||||
|         $defaultEntries = []; | ||||
|         while ($end >= $loopStart) { | ||||
|             /** @var Carbon $currentEnd */ | ||||
|             /** @var Carbon $loopEnd */ | ||||
|             $loopEnd = app('navigation')->endOfPeriod($loopStart, $step); | ||||
|             $spent   = $this->opsRepository->sumExpenses($loopStart, $loopEnd, null, $collection); | ||||
|             $label   = trim(app('navigation')->periodShow($loopStart, $step)); | ||||
|   | ||||
| @@ -284,7 +284,7 @@ class CategoryController extends Controller | ||||
|      * TODO test method, for category refactor. | ||||
|      * | ||||
|      * @param Category $category | ||||
|      * @param                             $date | ||||
|      * @param Carbon   $date | ||||
|      * | ||||
|      * @return JsonResponse | ||||
|      */ | ||||
|   | ||||
| @@ -140,10 +140,8 @@ class CategoryReportController extends Controller | ||||
|      * @param Collection $categories | ||||
|      * @param Carbon     $start | ||||
|      * @param Carbon     $end | ||||
|      * @param string     $others | ||||
|      * | ||||
|      * @return JsonResponse | ||||
|      * | ||||
|      */ | ||||
|     public function categoryIncome(Collection $accounts, Collection $categories, Carbon $start, Carbon $end): JsonResponse | ||||
|     { | ||||
|   | ||||
| @@ -80,7 +80,7 @@ class PiggyBankController extends Controller | ||||
|         $locale = app('steam')->getLocale(); | ||||
|  | ||||
|         // get first event or start date of piggy bank or today | ||||
|         $startDate = $piggyBank->start_date ?? today(config('app.timezone')); | ||||
|         $startDate = $piggyBank->startdate ?? today(config('app.timezone')); | ||||
|  | ||||
|         /** @var PiggyBankEvent $first */ | ||||
|         $firstEvent = $set->first(); | ||||
|   | ||||
| @@ -52,12 +52,10 @@ class TransactionController extends Controller | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param string $objectType | ||||
|      * @param Carbon $start | ||||
|      * @param Carbon $end | ||||
|      * | ||||
|      * @return JsonResponse | ||||
|      * @throws FireflyException | ||||
|      */ | ||||
|     public function budgets(Carbon $start, Carbon $end) | ||||
|     { | ||||
|   | ||||
| @@ -32,7 +32,7 @@ class HelpController extends Controller | ||||
|     /** | ||||
|      * Show help for a route. | ||||
|      * | ||||
|      * @param   $route | ||||
|      * @param string $route | ||||
|      * | ||||
|      * @return JsonResponse | ||||
|      */ | ||||
|   | ||||
| @@ -30,54 +30,9 @@ use Illuminate\Http\Request; | ||||
|  | ||||
| /** | ||||
|  * Class AutoCompleteController. | ||||
|  * | ||||
|  * TODO autocomplete for transaction types. | ||||
|  * | ||||
|  */ | ||||
| class AutoCompleteController extends Controller | ||||
| { | ||||
|     /** | ||||
|      * Searches in the titles of all transaction journals. | ||||
|      * The result is limited to the top 15 unique results. | ||||
|      * | ||||
|      * If the query is numeric, it will append the journal with that particular ID. | ||||
|      * | ||||
|      * @param Request $request | ||||
|      * | ||||
|      * @return JsonResponse | ||||
|      */ | ||||
|     public function allJournalsWithID(Request $request): JsonResponse | ||||
|     { | ||||
|         $search = (string)$request->get('search'); | ||||
|         /** @var JournalRepositoryInterface $repository */ | ||||
|         $repository = app(JournalRepositoryInterface::class); | ||||
|  | ||||
|         /** @var TransactionGroupRepositoryInterface $groupRepos */ | ||||
|         $groupRepos = app(TransactionGroupRepositoryInterface::class); | ||||
|  | ||||
|         $result = $repository->searchJournalDescriptions($search); | ||||
|         $array  = []; | ||||
|         if (is_numeric($search)) { | ||||
|             // search for group, not journal. | ||||
|             $firstResult = $groupRepos->find((int)$search); | ||||
|             if (null !== $firstResult) { | ||||
|                 // group may contain multiple journals, each a result: | ||||
|                 foreach ($firstResult->transactionJournals as $journal) { | ||||
|                     $array[] = $journal->toArray(); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         // if not numeric, search ahead! | ||||
|  | ||||
|         // limit and unique | ||||
|         $limited = $result->slice(0, 15); | ||||
|         $array   = array_merge($array, $limited->toArray()); | ||||
|         foreach ($array as $index => $item) { | ||||
|             // give another key for consistency | ||||
|             $array[$index]['name'] = sprintf('#%d: %s', $item['transaction_group_id'], $item['description']); | ||||
|         } | ||||
|  | ||||
|         return response()->json($array); | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -191,7 +191,7 @@ class PreferencesController extends Controller | ||||
|  | ||||
|         // same for locale: | ||||
|         if (!auth()->user()->hasRole('demo')) { | ||||
|             /** @var Preference $currentLocale */ | ||||
|             /** @var Preference $locale */ | ||||
|             $locale = $request->get('locale'); | ||||
|             app('preferences')->set('locale', $locale); | ||||
|         } | ||||
|   | ||||
| @@ -148,13 +148,13 @@ class CreateController extends Controller | ||||
|             RecurrenceRepetition::WEEKEND_TO_MONDAY     => (string)trans('firefly.jump_to_monday'), | ||||
|         ]; | ||||
|  | ||||
|         /** @var Transaction $source */ | ||||
|         /** @var Transaction $dest */ | ||||
|  | ||||
|         // fill prefilled with journal info | ||||
|         $type = strtolower($journal->transactionType->type); | ||||
|  | ||||
|         /** @var Transaction $source */ | ||||
|         $source      = $journal->transactions()->where('amount', '<', 0)->first(); | ||||
|         /** @var Transaction $dest */ | ||||
|         $dest        = $journal->transactions()->where('amount', '>', 0)->first(); | ||||
|         $category    = $journal->categories()->first() ? $journal->categories()->first()->name : ''; | ||||
|         $budget      = $journal->budgets()->first() ? $journal->budgets()->first()->id : 0; | ||||
|   | ||||
| @@ -122,7 +122,7 @@ class TagController extends Controller | ||||
|         foreach ($earned as $currency) { | ||||
|             $currencyId = $currency['currency_id']; | ||||
|  | ||||
|             /** @var array $category */ | ||||
|             /** @var array $tag */ | ||||
|             foreach ($currency['tags'] as $tag) { | ||||
|                 foreach ($tag['transaction_journals'] as $journal) { | ||||
|                     $destinationId                                                                   = $journal['destination_account_id']; | ||||
|   | ||||
| @@ -34,7 +34,7 @@ use Illuminate\Http\Request; | ||||
| class TrustProxies extends Middleware | ||||
| { | ||||
|     /** @var int The headers to check. */ | ||||
|     protected $headers = Request::HEADER_X_FORWARDED_ALL; | ||||
|     //protected $headers = Request::HEADER_X_FORWARDED_ALL; | ||||
|  | ||||
|     /** | ||||
|      * TrustProxies constructor. | ||||
|   | ||||
| @@ -22,6 +22,7 @@ declare(strict_types=1); | ||||
|  | ||||
| namespace FireflyIII\Models; | ||||
|  | ||||
| use Carbon\Carbon; | ||||
| use Eloquent; | ||||
| use FireflyIII\User; | ||||
| use Illuminate\Database\Eloquent\Builder as EloquentBuilder; | ||||
| @@ -87,6 +88,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | ||||
|  * @method static Builder|Account withTrashed() | ||||
|  * @method static Builder|Account withoutTrashed() | ||||
|  * @mixin Eloquent | ||||
|  * @property Carbon $lastActivityDate | ||||
|  * | ||||
|  */ | ||||
| class Account extends Model | ||||
| { | ||||
|   | ||||
| @@ -44,6 +44,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | ||||
|  * @property \Illuminate\Support\Carbon|null $deleted_at | ||||
|  * @property int $user_id | ||||
|  * @property string $name | ||||
|  * @property Carbon $lastActivity | ||||
|  * @property bool $encrypted | ||||
|  * @property-read Collection|\FireflyIII\Models\Attachment[] $attachments | ||||
|  * @property-read int|null $attachments_count | ||||
|   | ||||
| @@ -40,6 +40,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | ||||
|  * @property string $name | ||||
|  * @property string $outward | ||||
|  * @property string $inward | ||||
|  * @property int $journalCount | ||||
|  * @property bool $editable | ||||
|  * @property-read Collection|\FireflyIII\Models\TransactionJournalLink[] $transactionJournalLinks | ||||
|  * @property-read int|null $transaction_journal_links_count | ||||
|   | ||||
| @@ -174,10 +174,10 @@ trait JournalServiceTrait | ||||
|         if (null === $account && null !== $data['number']) { | ||||
|             Log::debug(sprintf('Searching for account number "%s".', $data['number'])); | ||||
|             // find by preferred type. | ||||
|             $source = $this->accountRepository->findByAccountNumber($data['number'], [$types[0]]); | ||||
|             $source = $this->accountRepository->findByAccountNumber((string) $data['number'], [$types[0]]); | ||||
|  | ||||
|             // or any expected type. | ||||
|             $source = $source ?? $this->accountRepository->findByAccountNumber($data['iban'], $types); | ||||
|             $source = $source ?? $this->accountRepository->findByAccountNumber((string) $data['number'], $types); | ||||
|  | ||||
|             if (null !== $source) { | ||||
|                 Log::debug(sprintf('Found account: #%d, %s', $source->id, $source->name)); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user