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('
  • %3$s
  • ', $class, $route, trans($breadcrumb['title'])); } - $html .= ''; - return $html; + return $html . ''; } } \ No newline at end of file diff --git a/app/TransactionRules/Engine/SearchRuleEngine.php b/app/TransactionRules/Engine/SearchRuleEngine.php index 99307a22f4..11ee09ced9 100644 --- a/app/TransactionRules/Engine/SearchRuleEngine.php +++ b/app/TransactionRules/Engine/SearchRuleEngine.php @@ -116,9 +116,7 @@ class SearchRuleEngine implements RuleEngineInterface } $collection = $collection->merge($found); } - $collection = $collection->unique(); - - return $collection; + return $collection->unique(); } /** diff --git a/app/Transformers/BillTransformer.php b/app/Transformers/BillTransformer.php index 5d14bfb6a3..e09d4e93b8 100644 --- a/app/Transformers/BillTransformer.php +++ b/app/Transformers/BillTransformer.php @@ -47,9 +47,6 @@ class BillTransformer extends AbstractTransformer public function __construct() { $this->repository = app(BillRepositoryInterface::class); - if ('testing' === config('app.env')) { - Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this))); - } } /** @@ -80,7 +77,7 @@ class BillTransformer extends AbstractTransformer $objectGroupTitle = $objectGroup->title; } - $data = [ + return [ 'id' => (int)$bill->id, 'created_at' => $bill->created_at->toAtomString(), 'updated_at' => $bill->updated_at->toAtomString(), @@ -110,9 +107,6 @@ class BillTransformer extends AbstractTransformer ], ], ]; - - return $data; - } /** diff --git a/app/Transformers/BudgetLimitTransformer.php b/app/Transformers/BudgetLimitTransformer.php index 2486777992..5fb75dc8ac 100644 --- a/app/Transformers/BudgetLimitTransformer.php +++ b/app/Transformers/BudgetLimitTransformer.php @@ -31,18 +31,6 @@ use Log; */ class BudgetLimitTransformer extends AbstractTransformer { - /** - * CurrencyTransformer 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))); - } - } - /** * Transform the note. * @@ -68,7 +56,7 @@ class BudgetLimitTransformer extends AbstractTransformer $currencyDecimalPlaces = $currency->decimal_places; } $amount = number_format((float) $amount, $currencyDecimalPlaces, '.', ''); - $data = [ + return [ 'id' => (int) $budgetLimit->id, 'created_at' => $budgetLimit->created_at->toAtomString(), 'updated_at' => $budgetLimit->updated_at->toAtomString(), @@ -88,7 +76,5 @@ class BudgetLimitTransformer extends AbstractTransformer ], ], ]; - - return $data; } } diff --git a/app/Transformers/BudgetTransformer.php b/app/Transformers/BudgetTransformer.php index 00af00361c..9120ab2f3a 100644 --- a/app/Transformers/BudgetTransformer.php +++ b/app/Transformers/BudgetTransformer.php @@ -50,9 +50,6 @@ class BudgetTransformer extends AbstractTransformer { $this->opsRepository = app(OperationsRepositoryInterface::class); $this->repository = app(BudgetRepositoryInterface::class); - if ('testing' === config('app.env')) { - Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this))); - } } /** @@ -92,7 +89,7 @@ class BudgetTransformer extends AbstractTransformer $abPeriod = $autoBudget->period; } - $data = [ + return [ 'id' => (int)$budget->id, 'created_at' => $budget->created_at->toAtomString(), 'updated_at' => $budget->updated_at->toAtomString(), @@ -111,8 +108,6 @@ class BudgetTransformer extends AbstractTransformer ], ], ]; - - return $data; } /** diff --git a/app/Transformers/CategoryTransformer.php b/app/Transformers/CategoryTransformer.php index 15c6bd93c4..ed32ba088e 100644 --- a/app/Transformers/CategoryTransformer.php +++ b/app/Transformers/CategoryTransformer.php @@ -45,9 +45,6 @@ class CategoryTransformer extends AbstractTransformer public function __construct() { $this->opsRepository = app(OperationsRepositoryInterface::class); - if ('testing' === config('app.env')) { - Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this))); - } } /** @@ -69,7 +66,7 @@ class CategoryTransformer extends AbstractTransformer $earned = $this->beautify($this->opsRepository->sumIncome($start, $end, null, new Collection([$category]))); $spent = $this->beautify($this->opsRepository->sumExpenses($start, $end, null, new Collection([$category]))); } - $data = [ + return [ 'id' => (int)$category->id, 'created_at' => $category->created_at->toAtomString(), 'updated_at' => $category->updated_at->toAtomString(), @@ -83,8 +80,6 @@ class CategoryTransformer extends AbstractTransformer ], ], ]; - - return $data; } /** diff --git a/app/Transformers/CurrencyExchangeRateTransformer.php b/app/Transformers/CurrencyExchangeRateTransformer.php index ccff93976c..3490533bd6 100644 --- a/app/Transformers/CurrencyExchangeRateTransformer.php +++ b/app/Transformers/CurrencyExchangeRateTransformer.php @@ -32,19 +32,6 @@ use Log; */ class CurrencyExchangeRateTransformer extends AbstractTransformer { - - /** - * PiggyBankEventTransformer 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 CurrencyExchangeRate $rate * @@ -54,7 +41,7 @@ class CurrencyExchangeRateTransformer extends AbstractTransformer { $result = number_format((float) $rate->rate * (float) $this->parameters->get('amount'), $rate->toCurrency->decimal_places, '.', ''); $result = 0.0 === $result ? null : $result; - $data = [ + return [ 'id' => (int)$rate->id, 'created_at' => $rate->created_at->toAtomString(), 'updated_at' => $rate->updated_at->toAtomString(), @@ -78,7 +65,5 @@ class CurrencyExchangeRateTransformer extends AbstractTransformer ], ], ]; - - return $data; } } diff --git a/app/Transformers/CurrencyTransformer.php b/app/Transformers/CurrencyTransformer.php index 50d34a31cf..f10a17da39 100644 --- a/app/Transformers/CurrencyTransformer.php +++ b/app/Transformers/CurrencyTransformer.php @@ -31,17 +31,6 @@ use Log; */ class CurrencyTransformer extends AbstractTransformer { - /** - * CurrencyTransformer 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))); - } - } /** * Transform the currency. @@ -57,7 +46,7 @@ class CurrencyTransformer extends AbstractTransformer if (null !== $defaultCurrency) { $isDefault = (int) $defaultCurrency->id === (int) $currency->id; } - $data = [ + return [ 'id' => (int) $currency->id, 'created_at' => $currency->created_at->toAtomString(), 'updated_at' => $currency->updated_at->toAtomString(), @@ -74,7 +63,5 @@ class CurrencyTransformer extends AbstractTransformer ], ], ]; - - return $data; } } diff --git a/app/Transformers/LinkTypeTransformer.php b/app/Transformers/LinkTypeTransformer.php index c3e9d97d14..385c4daea0 100644 --- a/app/Transformers/LinkTypeTransformer.php +++ b/app/Transformers/LinkTypeTransformer.php @@ -33,18 +33,6 @@ use Log; */ class LinkTypeTransformer extends AbstractTransformer { - /** - * CurrencyTransformer 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))); - } - } - /** * Transform the currency. * @@ -54,7 +42,7 @@ class LinkTypeTransformer extends AbstractTransformer */ public function transform(LinkType $linkType): array { - $data = [ + return [ 'id' => (int)$linkType->id, 'created_at' => $linkType->created_at->toAtomString(), 'updated_at' => $linkType->updated_at->toAtomString(), @@ -69,7 +57,5 @@ class LinkTypeTransformer extends AbstractTransformer ], ], ]; - - return $data; } } diff --git a/app/Transformers/PiggyBankEventTransformer.php b/app/Transformers/PiggyBankEventTransformer.php index ee952434e3..8b2f81029a 100644 --- a/app/Transformers/PiggyBankEventTransformer.php +++ b/app/Transformers/PiggyBankEventTransformer.php @@ -52,9 +52,6 @@ class PiggyBankEventTransformer extends AbstractTransformer $this->repository = app(AccountRepositoryInterface::class); $this->currencyRepos = app(CurrencyRepositoryInterface::class); $this->piggyRepos = app(PiggyBankRepositoryInterface::class); - if ('testing' === config('app.env')) { - Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this))); - } } /** @@ -84,7 +81,7 @@ class PiggyBankEventTransformer extends AbstractTransformer $groupId = (int) $event->transactionJournal->transaction_group_id; $journalId = (int) $journalId; } - $data = [ + return [ 'id' => (int) $event->id, 'created_at' => $event->created_at->toAtomString(), 'updated_at' => $event->updated_at->toAtomString(), @@ -102,8 +99,6 @@ class PiggyBankEventTransformer extends AbstractTransformer ], ], ]; - - return $data; } } diff --git a/app/Transformers/PiggyBankTransformer.php b/app/Transformers/PiggyBankTransformer.php index ccff382712..dd55953532 100644 --- a/app/Transformers/PiggyBankTransformer.php +++ b/app/Transformers/PiggyBankTransformer.php @@ -54,9 +54,6 @@ class PiggyBankTransformer extends AbstractTransformer $this->accountRepos = app(AccountRepositoryInterface::class); $this->currencyRepos = app(CurrencyRepositoryInterface::class); $this->piggyRepos = app(PiggyBankRepositoryInterface::class); - if ('testing' === config('app.env')) { - Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this))); - } } @@ -108,7 +105,7 @@ class PiggyBankTransformer extends AbstractTransformer $targetAmount = $piggyBank->targetamount; $targetAmount = 1 === bccomp('0.01', (string) $targetAmount) ? '0.01' : $targetAmount; $percentage = (int) (0 !== bccomp('0', $currentAmountStr) ? $currentAmountStr / $targetAmount * 100 : 0); - $data = [ + return [ 'id' => (int) $piggyBank->id, 'created_at' => $piggyBank->created_at->toAtomString(), 'updated_at' => $piggyBank->updated_at->toAtomString(), @@ -139,7 +136,5 @@ class PiggyBankTransformer extends AbstractTransformer ], ], ]; - - return $data; } } diff --git a/app/Transformers/RecurrenceTransformer.php b/app/Transformers/RecurrenceTransformer.php index f7509ea390..7ac33c0847 100644 --- a/app/Transformers/RecurrenceTransformer.php +++ b/app/Transformers/RecurrenceTransformer.php @@ -63,9 +63,6 @@ class RecurrenceTransformer extends AbstractTransformer $this->factory = app(CategoryFactory::class); $this->budgetRepos = app(BudgetRepositoryInterface::class); - if ('testing' === config('app.env')) { - Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this))); - } } /** @@ -90,7 +87,7 @@ class RecurrenceTransformer extends AbstractTransformer $reps = 0 === (int)$recurrence->repetitions ? null : (int)$recurrence->repetitions; Log::debug('Get basic data.'); // basic data. - $return = [ + return [ 'id' => (int)$recurrence->id, 'created_at' => $recurrence->created_at->toAtomString(), 'updated_at' => $recurrence->updated_at->toAtomString(), @@ -113,9 +110,6 @@ class RecurrenceTransformer extends AbstractTransformer ], ], ]; - - - return $return; } /** diff --git a/app/Transformers/RuleGroupTransformer.php b/app/Transformers/RuleGroupTransformer.php index 6194f9f51d..908a4a6202 100644 --- a/app/Transformers/RuleGroupTransformer.php +++ b/app/Transformers/RuleGroupTransformer.php @@ -31,17 +31,6 @@ use Log; */ class RuleGroupTransformer extends AbstractTransformer { - /** - * RuleGroupTransformer 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))); - } - } /** * Transform the rule group @@ -52,7 +41,7 @@ class RuleGroupTransformer extends AbstractTransformer */ public function transform(RuleGroup $ruleGroup): array { - $data = [ + return [ 'id' => (int)$ruleGroup->id, 'created_at' => $ruleGroup->created_at->toAtomString(), 'updated_at' => $ruleGroup->updated_at->toAtomString(), @@ -67,8 +56,6 @@ class RuleGroupTransformer extends AbstractTransformer ], ], ]; - - return $data; } diff --git a/app/Transformers/RuleTransformer.php b/app/Transformers/RuleTransformer.php index 0cb9e521d2..0bfb5bd4d4 100644 --- a/app/Transformers/RuleTransformer.php +++ b/app/Transformers/RuleTransformer.php @@ -47,9 +47,6 @@ class RuleTransformer extends AbstractTransformer public function __construct() { $this->ruleRepository = app(RuleRepositoryInterface::class); - if ('testing' === config('app.env')) { - Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this))); - } } /** @@ -64,7 +61,7 @@ class RuleTransformer extends AbstractTransformer { $this->ruleRepository->setUser($rule->user); - $data = [ + return [ 'id' => (int)$rule->id, 'created_at' => $rule->created_at->toAtomString(), 'updated_at' => $rule->updated_at->toAtomString(), @@ -85,8 +82,6 @@ class RuleTransformer extends AbstractTransformer ], ], ]; - - return $data; } /** diff --git a/app/Transformers/TagTransformer.php b/app/Transformers/TagTransformer.php index 63e41f2b8f..aebc522ad4 100644 --- a/app/Transformers/TagTransformer.php +++ b/app/Transformers/TagTransformer.php @@ -33,17 +33,6 @@ use Log; */ class TagTransformer extends AbstractTransformer { - /** - * TagTransformer 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))); - } - } /** * Transform a tag. @@ -67,7 +56,7 @@ class TagTransformer extends AbstractTransformer $longitude = $location->longitude; $zoomLevel = $location->zoom_level; } - $data = [ + return [ 'id' => (int)$tag->id, 'created_at' => $tag->created_at->toAtomString(), 'updated_at' => $tag->updated_at->toAtomString(), @@ -84,8 +73,6 @@ class TagTransformer extends AbstractTransformer ], ], ]; - - return $data; } } diff --git a/app/Transformers/TransactionGroupTransformer.php b/app/Transformers/TransactionGroupTransformer.php index 50af1df190..5db09e28cb 100644 --- a/app/Transformers/TransactionGroupTransformer.php +++ b/app/Transformers/TransactionGroupTransformer.php @@ -76,7 +76,7 @@ class TransactionGroupTransformer extends AbstractTransformer { $data = new NullArrayObject($group); $first = new NullArrayObject(reset($group['transactions'])); - $result = [ + return [ 'id' => (int) $first['transaction_group_id'], 'created_at' => $first['created_at']->toAtomString(), 'updated_at' => $first['updated_at']->toAtomString(), @@ -90,10 +90,6 @@ class TransactionGroupTransformer extends AbstractTransformer ], ], ]; - - // do something else. - - return $result; } /** diff --git a/app/Transformers/TransactionLinkTransformer.php b/app/Transformers/TransactionLinkTransformer.php index 8c6d7fafac..fca0dcec79 100644 --- a/app/Transformers/TransactionLinkTransformer.php +++ b/app/Transformers/TransactionLinkTransformer.php @@ -45,10 +45,6 @@ class TransactionLinkTransformer extends AbstractTransformer public function __construct() { $this->repository = app(JournalRepositoryInterface::class); - - if ('testing' === config('app.env')) { - Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this))); - } } /** @@ -59,7 +55,7 @@ class TransactionLinkTransformer extends AbstractTransformer public function transform(TransactionJournalLink $link): array { $notes = $this->repository->getLinkNoteText($link); - $data = [ + return [ 'id' => (int)$link->id, 'created_at' => $link->created_at->toAtomString(), 'updated_at' => $link->updated_at->toAtomString(), @@ -74,7 +70,5 @@ class TransactionLinkTransformer extends AbstractTransformer ], ], ]; - - return $data; } } diff --git a/app/Validation/Account/DepositValidation.php b/app/Validation/Account/DepositValidation.php index 1894775386..65e02abceb 100644 --- a/app/Validation/Account/DepositValidation.php +++ b/app/Validation/Account/DepositValidation.php @@ -134,9 +134,6 @@ trait DepositValidation $account->accountType = $accountType; $this->source = $account; } - $result = $result ?? false; - - // don't expect to end up here: - return $result; + return $result ?? false; } } diff --git a/app/Validation/Account/OBValidation.php b/app/Validation/Account/OBValidation.php index 2f366ddac4..86c358a80c 100644 --- a/app/Validation/Account/OBValidation.php +++ b/app/Validation/Account/OBValidation.php @@ -143,8 +143,6 @@ trait OBValidation $account->accountType = $accountType; $this->source = $account; } - $result = $result ?? false; - - return $result; + return $result ?? false; } }