diff --git a/app/Api/V1/Controllers/Controller.php b/app/Api/V1/Controllers/Controller.php index ebfe70a9b3..5bc4cc2871 100644 --- a/app/Api/V1/Controllers/Controller.php +++ b/app/Api/V1/Controllers/Controller.php @@ -60,8 +60,10 @@ abstract class Controller extends BaseController $language = app('steam')->getLanguage(); app()->setLocale($language); } + return $next($request); - }); + } + ); } @@ -73,7 +75,7 @@ abstract class Controller extends BaseController private function getParameters(): ParameterBag { $bag = new ParameterBag; - $page = (int) request()->get('page'); + $page = (int)request()->get('page'); if (0 === $page) { $page = 1; } @@ -100,7 +102,7 @@ abstract class Controller extends BaseController foreach ($integers as $integer) { $value = request()->query->get($integer); if (null !== $value) { - $bag->set($integer, (int) $value); + $bag->set($integer, (int)$value); } } @@ -127,9 +129,8 @@ abstract class Controller extends BaseController } $params[$key] = $value; } - $return .= http_build_query($params); - return $return; + return $return . http_build_query($params); } /** diff --git a/app/Api/V1/Requests/AccountStoreRequest.php b/app/Api/V1/Requests/AccountStoreRequest.php index 1b476f4ee3..54f99ce71b 100644 --- a/app/Api/V1/Requests/AccountStoreRequest.php +++ b/app/Api/V1/Requests/AccountStoreRequest.php @@ -132,8 +132,6 @@ class AccountStoreRequest extends FormRequest 'interest_period' => 'required_if:type,liability|in:daily,monthly,yearly', 'notes' => 'min:0|max:65536', ]; - $rules = Location::requestRules($rules); - - return $rules; + return Location::requestRules($rules); } } diff --git a/app/Api/V1/Requests/AccountUpdateRequest.php b/app/Api/V1/Requests/AccountUpdateRequest.php index af8b807c76..94af467d7a 100644 --- a/app/Api/V1/Requests/AccountUpdateRequest.php +++ b/app/Api/V1/Requests/AccountUpdateRequest.php @@ -134,8 +134,6 @@ class AccountUpdateRequest extends FormRequest 'interest_period' => 'required_if:type,liability|in:daily,monthly,yearly', 'notes' => 'min:0|max:65536', ]; - $rules = Location::requestRules($rules); - - return $rules; + return Location::requestRules($rules); } } diff --git a/app/Api/V1/Requests/RuleGroupTestRequest.php b/app/Api/V1/Requests/RuleGroupTestRequest.php index 25853aa49f..044832787b 100644 --- a/app/Api/V1/Requests/RuleGroupTestRequest.php +++ b/app/Api/V1/Requests/RuleGroupTestRequest.php @@ -67,10 +67,7 @@ class RuleGroupTestRequest extends FormRequest */ private function getDate(string $field): ?Carbon { - /** @var Carbon $result */ - $result = null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', $this->query($field)); - - return $result; + return null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', $this->query($field)); } /** diff --git a/app/Api/V1/Requests/RuleGroupTriggerRequest.php b/app/Api/V1/Requests/RuleGroupTriggerRequest.php index c14e353ee6..313e88c5b6 100644 --- a/app/Api/V1/Requests/RuleGroupTriggerRequest.php +++ b/app/Api/V1/Requests/RuleGroupTriggerRequest.php @@ -66,7 +66,6 @@ class RuleGroupTriggerRequest extends FormRequest */ private function getDate(string $field): ?Carbon { - /** @var Carbon $result */ return null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', $this->query($field)); } diff --git a/app/Api/V1/Requests/RuleTestRequest.php b/app/Api/V1/Requests/RuleTestRequest.php index e2b6c9de2c..90139fbb79 100644 --- a/app/Api/V1/Requests/RuleTestRequest.php +++ b/app/Api/V1/Requests/RuleTestRequest.php @@ -77,10 +77,7 @@ class RuleTestRequest extends FormRequest */ private function getDate(string $field): ?Carbon { - /** @var Carbon $result */ - $result = null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', $this->query($field)); - - return $result; + return null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', $this->query($field)); } /** diff --git a/app/Factory/BillFactory.php b/app/Factory/BillFactory.php index b4dfc6b4b7..d68c68b68d 100644 --- a/app/Factory/BillFactory.php +++ b/app/Factory/BillFactory.php @@ -40,21 +40,7 @@ class BillFactory { use BillServiceTrait, CreatesObjectGroups; - /** @var User */ - private $user; - - - /** - * Constructor. - * - * @codeCoverageIgnore - */ - public function __construct() - { - if ('testing' === config('app.env')) { - Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this))); - } - } + private User $user; /** * @param array $data @@ -153,11 +139,7 @@ class BillFactory */ public function findByName(string $name): ?Bill { - $query = sprintf('%%%s%%', $name); - /** @var Bill $first */ - $first = $this->user->bills()->where('name', 'LIKE', $query)->first(); - - return $first; + return $this->user->bills()->where('name', 'LIKE', sprintf('%%%s%%', $name))->first(); } /** diff --git a/app/Factory/BudgetFactory.php b/app/Factory/BudgetFactory.php index d28e677f6c..48a8751907 100644 --- a/app/Factory/BudgetFactory.php +++ b/app/Factory/BudgetFactory.php @@ -32,21 +32,7 @@ use Log; */ class BudgetFactory { - /** @var User */ - private $user; - - - /** - * Constructor. - * - * @codeCoverageIgnore - */ - public function __construct() - { - if ('testing' === config('app.env')) { - Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this))); - } - } + private User $user; /** * @param int|null $budgetId diff --git a/app/Factory/CategoryFactory.php b/app/Factory/CategoryFactory.php index dac41a622c..ff95292f10 100644 --- a/app/Factory/CategoryFactory.php +++ b/app/Factory/CategoryFactory.php @@ -35,21 +35,7 @@ use Log; */ class CategoryFactory { - /** @var User */ - private $user; - - - /** - * Constructor. - * - * @codeCoverageIgnore - */ - public function __construct() - { - if ('testing' === config('app.env')) { - Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this))); - } - } + private User $user; /** * @param string $name diff --git a/app/Factory/PiggyBankEventFactory.php b/app/Factory/PiggyBankEventFactory.php index 6f52157185..727be78405 100644 --- a/app/Factory/PiggyBankEventFactory.php +++ b/app/Factory/PiggyBankEventFactory.php @@ -37,18 +37,6 @@ use Log; */ class PiggyBankEventFactory { - /** - * Constructor. - * - * @codeCoverageIgnore - */ - public function __construct() - { - if ('testing' === config('app.env')) { - Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this))); - } - } - /** * @param TransactionJournal $journal * @param PiggyBank|null $piggyBank diff --git a/app/Factory/PiggyBankFactory.php b/app/Factory/PiggyBankFactory.php index 3275582667..03a83a706d 100644 --- a/app/Factory/PiggyBankFactory.php +++ b/app/Factory/PiggyBankFactory.php @@ -33,21 +33,7 @@ use Log; */ class PiggyBankFactory { - /** @var User */ - private $user; - - - /** - * Constructor. - * - * @codeCoverageIgnore - */ - public function __construct() - { - if ('testing' === config('app.env')) { - Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this))); - } - } + private User $user; /** * @param int|null $piggyBankId diff --git a/app/Generator/Chart/Basic/ChartJsGenerator.php b/app/Generator/Chart/Basic/ChartJsGenerator.php index b3a39b31ad..a9a4134e2c 100644 --- a/app/Generator/Chart/Basic/ChartJsGenerator.php +++ b/app/Generator/Chart/Basic/ChartJsGenerator.php @@ -209,7 +209,7 @@ class ChartJsGenerator implements GeneratorInterface */ public function singleSet(string $setLabel, array $data): array { - $chartData = [ + return [ 'count' => 1, 'labels' => array_keys($data), // take ALL labels from the first set. 'datasets' => [ @@ -219,7 +219,5 @@ class ChartJsGenerator implements GeneratorInterface ], ], ]; - - return $chartData; } } diff --git a/app/Generator/Report/Audit/MonthReportGenerator.php b/app/Generator/Report/Audit/MonthReportGenerator.php index 6ccd228b27..b7b5b03aff 100644 --- a/app/Generator/Report/Audit/MonthReportGenerator.php +++ b/app/Generator/Report/Audit/MonthReportGenerator.php @@ -41,12 +41,9 @@ use Throwable; */ class MonthReportGenerator implements ReportGeneratorInterface { - /** @var Collection The accounts used. */ - private $accounts; - /** @var Carbon End date of the report. */ - private $end; - /** @var Carbon Start date of the report. */ - private $start; + private Collection $accounts; + private Carbon $end; + private Carbon $start; /** * Generates the report. @@ -155,7 +152,7 @@ class MonthReportGenerator implements ReportGeneratorInterface } $locale = app('steam')->getLocale(); - $return = [ + return [ 'journals' => $journals, 'currency' => $currency, 'exists' => count($journals) > 0, @@ -164,8 +161,6 @@ class MonthReportGenerator implements ReportGeneratorInterface 'dayBefore' => $date->formatLocalized((string) trans('config.month_and_day', [], $locale)), 'dayBeforeBalance' => $dayBeforeBalance, ]; - - return $return; } /** diff --git a/app/Http/Requests/ConfigurationRequest.php b/app/Http/Requests/ConfigurationRequest.php index b54b3c73e6..220844a2e6 100644 --- a/app/Http/Requests/ConfigurationRequest.php +++ b/app/Http/Requests/ConfigurationRequest.php @@ -50,11 +50,9 @@ class ConfigurationRequest extends LoggedInRequest public function rules(): array { // fixed - $rules = [ + return [ 'single_user_mode' => 'between:0,1|numeric', 'is_demo_site' => 'between:0,1|numeric', ]; - - return $rules; } } diff --git a/app/Http/Requests/LinkTypeFormRequest.php b/app/Http/Requests/LinkTypeFormRequest.php index cffa17845b..22704c3b0a 100644 --- a/app/Http/Requests/LinkTypeFormRequest.php +++ b/app/Http/Requests/LinkTypeFormRequest.php @@ -46,13 +46,11 @@ class LinkTypeFormRequest extends LoggedInRequest $nameRule = 'required|min:1'; } - $rules = [ + return [ 'id' => $idRule, 'name' => $nameRule, 'inward' => 'required|min:1|different:outward', 'outward' => 'required|min:1|different:inward', ]; - - return $rules; } } diff --git a/app/Http/Requests/RuleFormRequest.php b/app/Http/Requests/RuleFormRequest.php index f88f020c34..4172346e7d 100644 --- a/app/Http/Requests/RuleFormRequest.php +++ b/app/Http/Requests/RuleFormRequest.php @@ -41,7 +41,7 @@ class RuleFormRequest extends LoggedInRequest */ public function getRuleData(): array { - $data = [ + return [ 'title' => $this->string('title'), 'rule_group_id' => $this->integer('rule_group_id'), 'active' => $this->boolean('active'), @@ -52,8 +52,6 @@ class RuleFormRequest extends LoggedInRequest 'triggers' => $this->getRuleTriggerData(), 'actions' => $this->getRuleActionData(), ]; - - return $data; } /** diff --git a/app/Http/Requests/TestRuleFormRequest.php b/app/Http/Requests/TestRuleFormRequest.php index 2eaa9d40f7..19e420c79b 100644 --- a/app/Http/Requests/TestRuleFormRequest.php +++ b/app/Http/Requests/TestRuleFormRequest.php @@ -43,11 +43,9 @@ class TestRuleFormRequest extends LoggedInRequest { // fixed $validTriggers = $this->getTriggers(); - $rules = [ + return [ 'rule-trigger.*' => 'required|min:1|in:' . implode(',', $validTriggers), 'rule-trigger-value.*' => 'required|min:1|ruleTriggerValue', ]; - - return $rules; } } diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php index 9fdc6203aa..9ed7621f5d 100644 --- a/app/Repositories/Account/AccountRepository.php +++ b/app/Repositories/Account/AccountRepository.php @@ -614,9 +614,7 @@ class AccountRepository implements AccountRepositoryInterface { /** @var AccountUpdateService $service */ $service = app(AccountUpdateService::class); - $account = $service->update($account, $data); - - return $account; + return $service->update($account, $data); } /** @@ -661,7 +659,7 @@ class AccountRepository implements AccountRepositoryInterface /** @var Storage $disk */ $disk = Storage::disk('upload'); - $set = $set->each( + return $set->each( static function (Attachment $attachment) use ($disk) { $notes = $attachment->notes()->first(); $attachment->file_exists = $disk->exists($attachment->fileName()); @@ -670,8 +668,6 @@ class AccountRepository implements AccountRepositoryInterface return $attachment; } ); - - return $set; } /** diff --git a/app/Repositories/Bill/BillRepository.php b/app/Repositories/Bill/BillRepository.php index b49debc7ca..8ac12398a2 100644 --- a/app/Repositories/Bill/BillRepository.php +++ b/app/Repositories/Bill/BillRepository.php @@ -140,13 +140,10 @@ class BillRepository implements BillRepositoryInterface */ public function getActiveBills(): Collection { - /** @var Collection $set */ - $set = $this->user->bills() + return $this->user->bills() ->where('active', 1) ->orderBy('bills.name', 'ASC') ->get(['bills.*', DB::raw('((bills.amount_min + bills.amount_max) / 2) AS expectedAmount'),]); - - return $set; } /** @@ -163,7 +160,7 @@ class BillRepository implements BillRepositoryInterface /** @var Storage $disk */ $disk = Storage::disk('upload'); - $set = $set->each( + return $set->each( static function (Attachment $attachment) use ($disk) { $notes = $attachment->notes()->first(); $attachment->file_exists = $disk->exists($attachment->fileName()); @@ -172,8 +169,6 @@ class BillRepository implements BillRepositoryInterface return $attachment; } ); - - return $set; } /** @@ -198,7 +193,7 @@ class BillRepository implements BillRepositoryInterface $fields = ['bills.id', 'bills.created_at', 'bills.updated_at', 'bills.deleted_at', 'bills.user_id', 'bills.name', 'bills.amount_min', 'bills.amount_max', 'bills.date', 'bills.transaction_currency_id', 'bills.repeat_freq', 'bills.skip', 'bills.automatch', 'bills.active',]; $ids = $accounts->pluck('id')->toArray(); - $set = $this->user->bills() + return $this->user->bills() ->leftJoin( 'transaction_journals', static function (JoinClause $join) { @@ -217,7 +212,6 @@ class BillRepository implements BillRepositoryInterface ->orderBy('bills.name', 'ASC') ->groupBy($fields) ->get($fields); - return $set; } /** diff --git a/app/Repositories/Budget/BudgetLimitRepository.php b/app/Repositories/Budget/BudgetLimitRepository.php index ad98e0b2e6..1007bfe02e 100644 --- a/app/Repositories/Budget/BudgetLimitRepository.php +++ b/app/Repositories/Budget/BudgetLimitRepository.php @@ -148,13 +148,11 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface { // both are NULL: if (null === $start && null === $end) { - $set = BudgetLimit::leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id') + return BudgetLimit::leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id') ->with(['budget']) ->where('budgets.user_id', $this->user->id) ->whereNull('budgets.deleted_at') ->get(['budget_limits.*']); - - return $set; } // one of the two is NULL. if (null === $start xor null === $end) { @@ -170,12 +168,10 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface // start date must be after $start. $query->where('start_date', '>=', $start->format('Y-m-d 00:00:00')); } - $set = $query->get(['budget_limits.*']); - - return $set; + return $query->get(['budget_limits.*']); } // neither are NULL: - $set = BudgetLimit::leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id') + return BudgetLimit::leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id') ->with(['budget']) ->where('budgets.user_id', $this->user->id) ->whereNull('budgets.deleted_at') @@ -206,8 +202,6 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface ); } )->get(['budget_limits.*']); - - return $set; } /** @@ -250,13 +244,11 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface // start date must be after $start. $query->where('start_date', '>=', $start->format('Y-m-d 00:00:00')); } - $set = $query->get(['budget_limits.*']); - - return $set; + return $query->get(['budget_limits.*']); } // when both dates are set: - $set = $budget->budgetlimits() + return $budget->budgetlimits() ->where( static function (Builder $q5) use ($start, $end) { $q5->where( @@ -286,8 +278,6 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface ); } )->orderBy('budget_limits.start_date', 'DESC')->get(['budget_limits.*']); - - return $set; } /** diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.php index d6fb4b5ab1..200cc527e4 100644 --- a/app/Repositories/Budget/BudgetRepository.php +++ b/app/Repositories/Budget/BudgetRepository.php @@ -170,12 +170,10 @@ class BudgetRepository implements BudgetRepositoryInterface */ public function getActiveBudgets(): Collection { - /** @var Collection $set */ - $set = $this->user->budgets()->where('active', 1) + return $this->user->budgets()->where('active', 1) ->orderBy('order', 'ASC') ->orderBy('name', 'ASC') ->get(); - return $set; } /** @@ -183,11 +181,8 @@ class BudgetRepository implements BudgetRepositoryInterface */ public function getBudgets(): Collection { - /** @var Collection $set */ - $set = $this->user->budgets()->orderBy('order', 'ASC') + return $this->user->budgets()->orderBy('order', 'ASC') ->orderBy('name', 'ASC')->get(); - - return $set; } /** @@ -207,12 +202,9 @@ class BudgetRepository implements BudgetRepositoryInterface */ public function getInactiveBudgets(): Collection { - /** @var Collection $set */ - $set = $this->user->budgets() + return $this->user->budgets() ->orderBy('order', 'ASC') ->orderBy('name', 'ASC')->where('active', 0)->get(); - - return $set; } /** @@ -475,7 +467,7 @@ class BudgetRepository implements BudgetRepositoryInterface /** @var Storage $disk */ $disk = Storage::disk('upload'); - $set = $set->each( + return $set->each( static function (Attachment $attachment) use ($disk) { $notes = $attachment->notes()->first(); $attachment->file_exists = $disk->exists($attachment->fileName()); @@ -484,8 +476,6 @@ class BudgetRepository implements BudgetRepositoryInterface return $attachment; } ); - - return $set; } public function getMaxOrder(): int diff --git a/app/Repositories/Category/CategoryRepository.php b/app/Repositories/Category/CategoryRepository.php index 324834988b..3378e6cf10 100644 --- a/app/Repositories/Category/CategoryRepository.php +++ b/app/Repositories/Category/CategoryRepository.php @@ -168,10 +168,7 @@ class CategoryRepository implements CategoryRepositoryInterface */ public function getCategories(): Collection { - /** @var Collection $set */ - $set = $this->user->categories()->with(['attachments'])->orderBy('name', 'ASC')->get(); - - return $set; + return $this->user->categories()->with(['attachments'])->orderBy('name', 'ASC')->get(); } /** @@ -376,7 +373,7 @@ class CategoryRepository implements CategoryRepositoryInterface /** @var Storage $disk */ $disk = Storage::disk('upload'); - $set = $set->each( + return $set->each( static function (Attachment $attachment) use ($disk) { $notes = $attachment->notes()->first(); $attachment->file_exists = $disk->exists($attachment->fileName()); @@ -385,7 +382,5 @@ class CategoryRepository implements CategoryRepositoryInterface return $attachment; } ); - - return $set; } } diff --git a/app/Repositories/Category/OperationsRepository.php b/app/Repositories/Category/OperationsRepository.php index 4bef77b518..0b45f367e7 100644 --- a/app/Repositories/Category/OperationsRepository.php +++ b/app/Repositories/Category/OperationsRepository.php @@ -312,9 +312,6 @@ class OperationsRepository implements OperationsRepositoryInterface */ private function getCategories(): Collection { - /** @var Collection $set */ - $set = $this->user->categories()->get(); - - return $set; + return $this->user->categories()->get(); } } diff --git a/app/Repositories/Currency/CurrencyRepository.php b/app/Repositories/Currency/CurrencyRepository.php index f87d02dedb..038cd8d106 100644 --- a/app/Repositories/Currency/CurrencyRepository.php +++ b/app/Repositories/Currency/CurrencyRepository.php @@ -58,10 +58,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface { $count = $currency->transactions()->whereNull('deleted_at')->count() + $currency->transactionJournals()->whereNull('deleted_at')->count(); // also count foreign: - $count += Transaction::where('foreign_currency_id', $currency->id)->count(); - - return $count; - + return $count + Transaction::where('foreign_currency_id', $currency->id)->count(); } /** diff --git a/app/Repositories/Journal/JournalAPIRepository.php b/app/Repositories/Journal/JournalAPIRepository.php index 5dd293af98..a685fe213f 100644 --- a/app/Repositories/Journal/JournalAPIRepository.php +++ b/app/Repositories/Journal/JournalAPIRepository.php @@ -37,18 +37,7 @@ use Storage; */ class JournalAPIRepository implements JournalAPIRepositoryInterface { - /** @var User */ - private $user; - - /** - * Constructor. - */ - public function __construct() - { - if ('testing' === config('app.env')) { - Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this))); - } - } + private User $user; /** * Returns transaction by ID. Used to validate attachments. @@ -59,12 +48,10 @@ class JournalAPIRepository implements JournalAPIRepositoryInterface */ public function findTransaction(int $transactionId): ?Transaction { - $transaction = Transaction::leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id') + return Transaction::leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id') ->where('transaction_journals.user_id', $this->user->id) ->where('transactions.id', $transactionId) ->first(['transactions.*']); - - return $transaction; } /** @@ -81,7 +68,7 @@ class JournalAPIRepository implements JournalAPIRepositoryInterface /** @var Storage $disk */ $disk = Storage::disk('upload'); - $set = $set->each( + return $set->each( static function (Attachment $attachment) use ($disk) { $notes = $attachment->notes()->first(); $attachment->file_exists = $disk->exists($attachment->fileName()); @@ -90,8 +77,6 @@ class JournalAPIRepository implements JournalAPIRepositoryInterface return $attachment; } ); - - return $set; } /** diff --git a/app/Repositories/LinkType/LinkTypeRepository.php b/app/Repositories/LinkType/LinkTypeRepository.php index 75a209ba4e..bbf8cd5338 100644 --- a/app/Repositories/LinkType/LinkTypeRepository.php +++ b/app/Repositories/LinkType/LinkTypeRepository.php @@ -210,13 +210,11 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface $inward = TransactionJournalLink::whereDestinationId($journal->id)->get(); $merged = $outward->merge($inward); - $filtered = $merged->filter( + return $merged->filter( function (TransactionJournalLink $link) { return (null !== $link->source && null !== $link->destination); } ); - - return $filtered; } /** diff --git a/app/Repositories/PiggyBank/ModifiesPiggyBanks.php b/app/Repositories/PiggyBank/ModifiesPiggyBanks.php index 3dc7c627ad..72d0bafccc 100644 --- a/app/Repositories/PiggyBank/ModifiesPiggyBanks.php +++ b/app/Repositories/PiggyBank/ModifiesPiggyBanks.php @@ -161,10 +161,7 @@ trait ModifiesPiggyBanks if (0 === bccomp('0', $amount)) { return new PiggyBankEvent; } - /** @var PiggyBankEvent $event */ - $event = PiggyBankEvent::create(['date' => Carbon::now(), 'amount' => $amount, 'piggy_bank_id' => $piggyBank->id]); - - return $event; + return PiggyBankEvent::create(['date' => Carbon::now(), 'amount' => $amount, 'piggy_bank_id' => $piggyBank->id]); } /** @@ -176,16 +173,13 @@ trait ModifiesPiggyBanks */ public function createEventWithJournal(PiggyBank $piggyBank, string $amount, TransactionJournal $journal): PiggyBankEvent { - /** @var PiggyBankEvent $event */ - $event = PiggyBankEvent::create( + return PiggyBankEvent::create( [ 'piggy_bank_id' => $piggyBank->id, 'transaction_journal_id' => $journal->id, 'date' => $journal->date->format('Y-m-d'), 'amount' => $amount] ); - - return $event; } /** diff --git a/app/Repositories/PiggyBank/PiggyBankRepository.php b/app/Repositories/PiggyBank/PiggyBankRepository.php index ad042c1f53..3d9506e81d 100644 --- a/app/Repositories/PiggyBank/PiggyBankRepository.php +++ b/app/Repositories/PiggyBank/PiggyBankRepository.php @@ -44,19 +44,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface { use ModifiesPiggyBanks; - /** @var User */ - private $user; - - /** - * Constructor. - */ - public function __construct() - { - if ('testing' === config('app.env')) { - Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this))); - } - } - + private User $user; /** * Find by name or return NULL. @@ -384,7 +372,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface /** @var Storage $disk */ $disk = Storage::disk('upload'); - $set = $set->each( + return $set->each( static function (Attachment $attachment) use ($disk) { $notes = $attachment->notes()->first(); $attachment->file_exists = $disk->exists($attachment->fileName()); @@ -393,8 +381,6 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface return $attachment; } ); - - return $set; } diff --git a/app/Repositories/Recurring/RecurringRepository.php b/app/Repositories/Recurring/RecurringRepository.php index f5f53a3d02..54d26835f3 100644 --- a/app/Repositories/Recurring/RecurringRepository.php +++ b/app/Repositories/Recurring/RecurringRepository.php @@ -53,18 +53,8 @@ use Log; class RecurringRepository implements RecurringRepositoryInterface { use CalculateRangeOccurrences, CalculateXOccurrences, CalculateXOccurrencesSince, FiltersWeekends; - /** @var User */ - private $user; + private User $user; - /** - * Constructor. - */ - public function __construct() - { - if ('testing' === config('app.env')) { - Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this))); - } - } /** * Destroy a recurring transaction. @@ -246,9 +236,7 @@ class RecurringRepository implements RecurringRepositoryInterface // filter out all the weekend days: - $occurrences = $this->filterWeekends($repetition, $occurrences); - - return $occurrences; + return $this->filterWeekends($repetition, $occurrences); } /** @@ -386,9 +374,7 @@ class RecurringRepository implements RecurringRepositoryInterface } // filter out all the weekend days: - $occurrences = $this->filterWeekends($repetition, $occurrences); - - return $occurrences; + return $this->filterWeekends($repetition, $occurrences); } /** @@ -536,9 +522,7 @@ class RecurringRepository implements RecurringRepositoryInterface // filter out everything if "repeat_until" is set. $repeatUntil = $repetition->recurrence->repeat_until; - $occurrences = $this->filterMaxDate($repeatUntil, $occurrences); - - return $occurrences; + return $this->filterMaxDate($repeatUntil, $occurrences); } /** diff --git a/app/Repositories/Tag/TagRepository.php b/app/Repositories/Tag/TagRepository.php index fcfb6505d1..343f833267 100644 --- a/app/Repositories/Tag/TagRepository.php +++ b/app/Repositories/Tag/TagRepository.php @@ -156,10 +156,7 @@ class TagRepository implements TagRepositoryInterface */ public function get(): Collection { - /** @var Collection $tags */ - $tags = $this->user->tags()->orderBy('tag', 'ASC')->get(); - - return $tags; + return $this->user->tags()->orderBy('tag', 'ASC')->get(); } /** @@ -575,7 +572,7 @@ class TagRepository implements TagRepositoryInterface /** @var Storage $disk */ $disk = Storage::disk('upload'); - $set = $set->each( + return $set->each( static function (Attachment $attachment) use ($disk) { $notes = $attachment->notes()->first(); $attachment->file_exists = $disk->exists($attachment->fileName()); @@ -584,8 +581,6 @@ class TagRepository implements TagRepositoryInterface return $attachment; } ); - - return $set; } /** diff --git a/app/Rules/IsValidAttachmentModel.php b/app/Rules/IsValidAttachmentModel.php index 4dc3dbcf92..90560a3779 100644 --- a/app/Rules/IsValidAttachmentModel.php +++ b/app/Rules/IsValidAttachmentModel.php @@ -229,8 +229,6 @@ class IsValidAttachmentModel implements Rule $replace = ''; $model = str_replace($search, $replace, $model); - $model = sprintf('FireflyIII\Models\%s', $model); - - return $model; + return sprintf('FireflyIII\Models\%s', $model); } } diff --git a/app/Services/Internal/Support/JournalServiceTrait.php b/app/Services/Internal/Support/JournalServiceTrait.php index 62951ecccf..8fd9c1ca61 100644 --- a/app/Services/Internal/Support/JournalServiceTrait.php +++ b/app/Services/Internal/Support/JournalServiceTrait.php @@ -109,9 +109,7 @@ trait JournalServiceTrait $result = $this->findAccountByName($result, $data, $expectedTypes[$transactionType]); $result = $this->findAccountByIban($result, $data, $expectedTypes[$transactionType]); $result = $this->createAccount($result, $data, $expectedTypes[$transactionType][0]); - $result = $this->getCashAccount($result, $data, $expectedTypes[$transactionType]); - - return $result; + return $this->getCashAccount($result, $data, $expectedTypes[$transactionType]); } /** diff --git a/app/Support/Http/Controllers/BasicDataSupport.php b/app/Support/Http/Controllers/BasicDataSupport.php index 2b39a0e6a9..f631a41511 100644 --- a/app/Support/Http/Controllers/BasicDataSupport.php +++ b/app/Support/Http/Controllers/BasicDataSupport.php @@ -41,9 +41,7 @@ trait BasicDataSupport */ protected function isInArray(array $array, int $entryId) // helper for data (math, calculations) { - $result = $array[$entryId] ?? '0'; - - return $result; + return $array[$entryId] ?? '0'; } diff --git a/app/Support/Http/Controllers/DateCalculation.php b/app/Support/Http/Controllers/DateCalculation.php index 697d483ee1..f82a2954e0 100644 --- a/app/Support/Http/Controllers/DateCalculation.php +++ b/app/Support/Http/Controllers/DateCalculation.php @@ -50,9 +50,7 @@ trait DateCalculation if ($start->lte($today) && $end->gte($today)) { $difference = $today->diffInDays($end); } - $difference = 0 === $difference ? 1 : $difference; - - return $difference; + return 0 === $difference ? 1 : $difference; } /** diff --git a/app/Support/Http/Controllers/GetConfigurationData.php b/app/Support/Http/Controllers/GetConfigurationData.php index 33577c798f..59ba461f4e 100644 --- a/app/Support/Http/Controllers/GetConfigurationData.php +++ b/app/Support/Http/Controllers/GetConfigurationData.php @@ -51,9 +51,7 @@ trait GetConfigurationData E_ALL & ~E_NOTICE & ~E_STRICT => 'E_ALL & ~E_NOTICE & ~E_STRICT', E_COMPILE_ERROR | E_RECOVERABLE_ERROR | E_ERROR | E_CORE_ERROR => 'E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR', ]; - $result = $array[$value] ?? (string)$value; - - return $result; + return $array[$value] ?? (string)$value; } /** @@ -150,7 +148,7 @@ trait GetConfigurationData $index = (string)trans('firefly.everything'); $ranges[$index] = [$first, new Carbon]; - $return = [ + return [ 'title' => $title, 'configuration' => [ 'apply' => (string)trans('firefly.apply'), @@ -163,8 +161,6 @@ trait GetConfigurationData 'ranges' => $ranges, ], ]; - - return $return; } /** diff --git a/app/Support/Http/Controllers/RequestInformation.php b/app/Support/Http/Controllers/RequestInformation.php index 67c8d68f2f..46f8689665 100644 --- a/app/Support/Http/Controllers/RequestInformation.php +++ b/app/Support/Http/Controllers/RequestInformation.php @@ -98,9 +98,7 @@ trait RequestInformation // also check cache first: if ($help->inCache($route, $language)) { Log::debug(sprintf('Help text %s was in cache.', $language)); - $content = $help->getFromCache($route, $language); - - return $content; + return $help->getFromCache($route, $language); } $baseHref = route('index'); $helpString = sprintf( diff --git a/app/Support/Preferences.php b/app/Support/Preferences.php index 74c42dcd5d..9e7deb6168 100644 --- a/app/Support/Preferences.php +++ b/app/Support/Preferences.php @@ -45,12 +45,7 @@ class Preferences */ public function beginsWith(User $user, string $search): Collection { - if ('testing' === config('app.env')) { - Log::warning(sprintf('%s should NOT be called in the TEST environment!', __METHOD__)); - } - $set = Preference::where('user_id', $user->id)->where('name', 'LIKE', $search . '%')->get(); - - return $set; + return Preference::where('user_id', $user->id)->where('name', 'LIKE', $search . '%')->get(); } /** @@ -60,9 +55,6 @@ class Preferences */ public function delete(string $name): bool { - if ('testing' === config('app.env')) { - Log::warning(sprintf('%s should NOT be called in the TEST environment!', __METHOD__)); - } $fullName = sprintf('preference%s%s', auth()->user()->id, $name); if (Cache::has($fullName)) { Cache::forget($fullName); diff --git a/app/Support/Steam.php b/app/Support/Steam.php index 783f98f1e3..075994615c 100644 --- a/app/Support/Steam.php +++ b/app/Support/Steam.php @@ -540,9 +540,7 @@ class Steam if (null === $amount) { return null; } - $amount = bcmul($amount, '-1'); - - return $amount; + return bcmul($amount, '-1'); } /** diff --git a/app/Support/Twig/Breadcrumbs.php b/app/Support/Twig/Breadcrumbs.php index 656d2bd0e1..84996d1cf2 100644 --- a/app/Support/Twig/Breadcrumbs.php +++ b/app/Support/Twig/Breadcrumbs.php @@ -121,8 +121,7 @@ class Breadcrumbs extends AbstractExtension } $html .= sprintf('