From ad541635185a8a7e1e7222f859f12183168ca30d Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 24 May 2021 08:57:02 +0200 Subject: [PATCH] Various code cleanup. --- app/Support/Binder/AccountList.php | 2 +- app/Support/Binder/BudgetList.php | 2 +- app/Support/Binder/CLIToken.php | 4 +- app/Support/Binder/CategoryList.php | 4 +- app/Support/Binder/CurrencyCode.php | 2 +- app/Support/Binder/DynamicConfigKey.php | 2 +- app/Support/Binder/EitherConfigKey.php | 2 +- app/Support/Binder/JournalList.php | 2 +- app/Support/CacheProperties.php | 4 +- .../Chart/Budget/FrontpageChartGenerator.php | 2 +- .../Category/WholePeriodChartGenerator.php | 2 - app/Support/ExpandedForm.php | 88 ++++++++--------- app/Support/Export/ExportDataGenerator.php | 21 ++-- app/Support/FireflyConfig.php | 3 +- .../Http/Controllers/PeriodOverview.php | 10 +- .../Http/Controllers/UserNavigation.php | 2 +- app/Support/Navigation.php | 95 +++++++++---------- app/Support/Preferences.php | 29 +++--- .../Report/Budget/BudgetReportGenerator.php | 4 +- app/Support/Steam.php | 33 ++++--- app/Support/Telemetry.php | 8 +- 21 files changed, 157 insertions(+), 164 deletions(-) diff --git a/app/Support/Binder/AccountList.php b/app/Support/Binder/AccountList.php index 4a6c9b8ada..d355a46ca3 100644 --- a/app/Support/Binder/AccountList.php +++ b/app/Support/Binder/AccountList.php @@ -39,7 +39,7 @@ class AccountList implements BinderInterface * @param Route $route * * @return Collection - * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException + * @throws NotFoundHttpException * */ public static function routeBinder(string $value, Route $route): Collection diff --git a/app/Support/Binder/BudgetList.php b/app/Support/Binder/BudgetList.php index 134f17233d..efbd567577 100644 --- a/app/Support/Binder/BudgetList.php +++ b/app/Support/Binder/BudgetList.php @@ -38,7 +38,7 @@ class BudgetList implements BinderInterface * @param Route $route * * @return Collection - * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException + * @throws NotFoundHttpException * */ public static function routeBinder(string $value, Route $route): Collection diff --git a/app/Support/Binder/CLIToken.php b/app/Support/Binder/CLIToken.php index 3ada7a4585..1ec5574fd6 100644 --- a/app/Support/Binder/CLIToken.php +++ b/app/Support/Binder/CLIToken.php @@ -39,7 +39,7 @@ class CLIToken implements BinderInterface * @param Route $route * * @return mixed - * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException + * @throws \FireflyIII\Exceptions\FireflyException */ public static function routeBinder(string $value, Route $route) { @@ -53,7 +53,7 @@ class CLIToken implements BinderInterface } foreach ($users as $user) { - $accessToken = app('preferences')->getForUser($user, 'access_token', null); + $accessToken = app('preferences')->getForUser($user, 'access_token'); if (null !== $accessToken && $accessToken->data === $value) { Log::info(sprintf('Recognized user #%d (%s) from his acccess token.', $user->id, $user->email)); diff --git a/app/Support/Binder/CategoryList.php b/app/Support/Binder/CategoryList.php index 60a36b97d4..001396e6b9 100644 --- a/app/Support/Binder/CategoryList.php +++ b/app/Support/Binder/CategoryList.php @@ -37,7 +37,7 @@ class CategoryList implements BinderInterface * @param Route $route * * @return Collection - * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException + * @throws NotFoundHttpException * */ public static function routeBinder(string $value, Route $route): Collection @@ -54,7 +54,7 @@ class CategoryList implements BinderInterface throw new NotFoundHttpException; } - /** @var \Illuminate\Support\Collection $collection */ + /** @var Collection $collection */ $collection = auth()->user()->categories() ->whereIn('id', $list) ->get(); diff --git a/app/Support/Binder/CurrencyCode.php b/app/Support/Binder/CurrencyCode.php index af99b3eb81..50ecd16b34 100644 --- a/app/Support/Binder/CurrencyCode.php +++ b/app/Support/Binder/CurrencyCode.php @@ -36,7 +36,7 @@ class CurrencyCode implements BinderInterface * @param Route $route * * @return TransactionCurrency - * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException + * @throws NotFoundHttpException */ public static function routeBinder(string $value, Route $route): TransactionCurrency { diff --git a/app/Support/Binder/DynamicConfigKey.php b/app/Support/Binder/DynamicConfigKey.php index 745a026a38..c8d83f5a4b 100644 --- a/app/Support/Binder/DynamicConfigKey.php +++ b/app/Support/Binder/DynamicConfigKey.php @@ -43,7 +43,7 @@ class DynamicConfigKey * @param Route $route * * @return string - * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException + * @throws NotFoundHttpException */ public static function routeBinder(string $value, Route $route): string { diff --git a/app/Support/Binder/EitherConfigKey.php b/app/Support/Binder/EitherConfigKey.php index 3956afb77d..93b0fa4fd2 100644 --- a/app/Support/Binder/EitherConfigKey.php +++ b/app/Support/Binder/EitherConfigKey.php @@ -47,7 +47,7 @@ class EitherConfigKey * @param Route $route * * @return string - * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException + * @throws NotFoundHttpException */ public static function routeBinder(string $value, Route $route): string { diff --git a/app/Support/Binder/JournalList.php b/app/Support/Binder/JournalList.php index c562ebebc6..4c1f8d50f9 100644 --- a/app/Support/Binder/JournalList.php +++ b/app/Support/Binder/JournalList.php @@ -38,7 +38,7 @@ class JournalList implements BinderInterface * * @return array * - * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException + * @throws NotFoundHttpException */ public static function routeBinder(string $value, Route $route): array { diff --git a/app/Support/CacheProperties.php b/app/Support/CacheProperties.php index 8301e839f9..7eb90f8927 100644 --- a/app/Support/CacheProperties.php +++ b/app/Support/CacheProperties.php @@ -74,6 +74,7 @@ class CacheProperties /** * @return bool + * @throws JsonException */ public function has(): bool { @@ -86,14 +87,13 @@ class CacheProperties } /** - * @throws JsonException */ private function hash(): void { $content = ''; foreach ($this->properties as $property) { try { - $content .= json_encode($property, JSON_THROW_ON_ERROR, 512); + $content .= json_encode($property, JSON_THROW_ON_ERROR); } catch (JsonException $e) { // @ignoreException $content .= hash('sha256', (string)time()); diff --git a/app/Support/Chart/Budget/FrontpageChartGenerator.php b/app/Support/Chart/Budget/FrontpageChartGenerator.php index 941fdfabe0..e2d5dc435f 100644 --- a/app/Support/Chart/Budget/FrontpageChartGenerator.php +++ b/app/Support/Chart/Budget/FrontpageChartGenerator.php @@ -112,7 +112,7 @@ class FrontpageChartGenerator */ private function noBudgetLimits(array $data, Budget $budget): array { - $spent = $this->opsRepository->sumExpenses($this->start, $this->end, null, new Collection([$budget]), null); + $spent = $this->opsRepository->sumExpenses($this->start, $this->end, null, new Collection([$budget])); /** @var array $entry */ foreach ($spent as $entry) { $title = sprintf('%s (%s)', $budget->name, $entry['currency_name']); diff --git a/app/Support/Chart/Category/WholePeriodChartGenerator.php b/app/Support/Chart/Category/WholePeriodChartGenerator.php index 97efb1a165..c8c526b442 100644 --- a/app/Support/Chart/Category/WholePeriodChartGenerator.php +++ b/app/Support/Chart/Category/WholePeriodChartGenerator.php @@ -59,7 +59,6 @@ class WholePeriodChartGenerator $spent = []; $earned = []; - /** @var Carbon $current */ $current = clone $start; while ($current <= $end) { @@ -92,7 +91,6 @@ class WholePeriodChartGenerator ]; } - /** @var Carbon $current */ $current = clone $start; while ($current <= $end) { diff --git a/app/Support/ExpandedForm.php b/app/Support/ExpandedForm.php index d82ff2314c..d700106ca4 100644 --- a/app/Support/ExpandedForm.php +++ b/app/Support/ExpandedForm.php @@ -41,12 +41,11 @@ class ExpandedForm use FormSupport; /** - * @param string $name - * @param mixed $value - * @param array $options + * @param string $name + * @param mixed $value + * @param array|null $options * * @return string - * */ public function amountNoCurrency(string $name, $value = null, array $options = null): string { @@ -73,13 +72,12 @@ class ExpandedForm } /** - * @param string $name - * @param int $value - * @param mixed $checked - * @param array $options + * @param string $name + * @param int|null $value + * @param mixed $checked + * @param array|null $options * * @return string - * */ public function checkbox(string $name, int $value = null, $checked = null, array $options = null): string { @@ -109,12 +107,11 @@ class ExpandedForm } /** - * @param string $name - * @param mixed $value - * @param array $options + * @param string $name + * @param mixed $value + * @param array|null $options * * @return string - * */ public function date(string $name, $value = null, array $options = null): string { @@ -134,11 +131,10 @@ class ExpandedForm } /** - * @param string $name - * @param array $options + * @param string $name + * @param array|null $options * * @return string - * */ public function file(string $name, array $options = null): string { @@ -157,12 +153,11 @@ class ExpandedForm } /** - * @param string $name - * @param mixed $value - * @param array $options + * @param string $name + * @param mixed $value + * @param array|null $options * * @return string - * */ public function integer(string $name, $value = null, array $options = null): string { @@ -183,12 +178,11 @@ class ExpandedForm } /** - * @param string $name - * @param mixed $value - * @param array $options + * @param string $name + * @param mixed $value + * @param array|null $options * * @return string - * */ public function location(string $name, $value = null, array $options = null): string { @@ -234,9 +228,9 @@ class ExpandedForm } /** - * @param string $name - * @param mixed $value - * @param array $options + * @param string $name + * @param mixed $value + * @param array|null $options * * @return string */ @@ -265,12 +259,11 @@ class ExpandedForm } /** - * @param string $name - * @param mixed $value - * @param array $options + * @param string $name + * @param mixed $value + * @param array|null $options * * @return string - * */ public function number(string $name, $value = null, array $options = null): string { @@ -339,11 +332,10 @@ class ExpandedForm } /** - * @param string $name - * @param array $options + * @param string $name + * @param array|null $options * * @return string - * */ public function password(string $name, array $options = null): string { @@ -364,12 +356,11 @@ class ExpandedForm /** * Function to render a percentage. * - * @param string $name - * @param mixed $value - * @param array $options + * @param string $name + * @param mixed $value + * @param array|null $options * * @return string - * */ public function percentage(string $name, $value = null, array $options = null): string { @@ -390,12 +381,11 @@ class ExpandedForm } /** - * @param string $name - * @param mixed $value - * @param array $options + * @param string $name + * @param mixed $value + * @param array|null $options * * @return string - * */ public function staticText(string $name, $value, array $options = null): string { @@ -413,12 +403,11 @@ class ExpandedForm } /** - * @param string $name - * @param mixed $value - * @param array $options + * @param string $name + * @param mixed $value + * @param array|null $options * * @return string - * */ public function text(string $name, $value = null, array $options = null): string { @@ -437,12 +426,11 @@ class ExpandedForm } /** - * @param string $name - * @param mixed $value - * @param array $options + * @param string $name + * @param mixed $value + * @param array|null $options * * @return string - * */ public function textarea(string $name, $value = null, array $options = null): string { diff --git a/app/Support/Export/ExportDataGenerator.php b/app/Support/Export/ExportDataGenerator.php index 2d11087c7b..d9e2def51d 100644 --- a/app/Support/Export/ExportDataGenerator.php +++ b/app/Support/Export/ExportDataGenerator.php @@ -97,8 +97,6 @@ class ExportDataGenerator /** * @return array - * @throws CannotInsertRecord - * @throws Exception * @throws FireflyException */ public function export(): array @@ -137,6 +135,7 @@ class ExportDataGenerator /** * @return string + * @throws FireflyException */ private function exportAccounts(): string { @@ -172,7 +171,7 @@ class ExportDataGenerator } //load the CSV document from a string - $csv = Writer::createFromString(''); + $csv = Writer::createFromString(); //insert the header try { @@ -226,7 +225,7 @@ class ExportDataGenerator } //load the CSV document from a string - $csv = Writer::createFromString(''); + $csv = Writer::createFromString(); //insert the header try { @@ -290,7 +289,7 @@ class ExportDataGenerator } //load the CSV document from a string - $csv = Writer::createFromString(''); + $csv = Writer::createFromString(); //insert the header try { @@ -339,7 +338,7 @@ class ExportDataGenerator } //load the CSV document from a string - $csv = Writer::createFromString(''); + $csv = Writer::createFromString(); //insert the header try { @@ -403,7 +402,7 @@ class ExportDataGenerator } //load the CSV document from a string - $csv = Writer::createFromString(''); + $csv = Writer::createFromString(); //insert the header try { @@ -501,7 +500,7 @@ class ExportDataGenerator } } //load the CSV document from a string - $csv = Writer::createFromString(''); + $csv = Writer::createFromString(); //insert the header try { @@ -568,7 +567,7 @@ class ExportDataGenerator } //load the CSV document from a string - $csv = Writer::createFromString(''); + $csv = Writer::createFromString(); //insert the header try { @@ -618,7 +617,7 @@ class ExportDataGenerator } //load the CSV document from a string - $csv = Writer::createFromString(''); + $csv = Writer::createFromString(); //insert the header try { @@ -738,7 +737,7 @@ class ExportDataGenerator } //load the CSV document from a string - $csv = Writer::createFromString(''); + $csv = Writer::createFromString(); //insert the header try { diff --git a/app/Support/FireflyConfig.php b/app/Support/FireflyConfig.php index 5f923758b9..b5b72516a3 100644 --- a/app/Support/FireflyConfig.php +++ b/app/Support/FireflyConfig.php @@ -100,7 +100,7 @@ class FireflyConfig * @param string $name * @param mixed $default * - * @return \FireflyIII\Models\Configuration|null + * @return Configuration|null */ public function getFresh(string $name, $default = null): ?Configuration { @@ -147,7 +147,6 @@ class FireflyConfig return $item; } if (null === $config) { - /** @var Configuration $item */ $item = new Configuration; $item->name = $name; $item->data = $value; diff --git a/app/Support/Http/Controllers/PeriodOverview.php b/app/Support/Http/Controllers/PeriodOverview.php index 374702dbf7..095f2ba10e 100644 --- a/app/Support/Http/Controllers/PeriodOverview.php +++ b/app/Support/Http/Controllers/PeriodOverview.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Support\Http\Controllers; use Carbon\Carbon; +use FireflyIII\Exceptions\FireflyException; use FireflyIII\Helpers\Collector\GroupCollectorInterface; use FireflyIII\Models\Account; use FireflyIII\Models\Category; @@ -76,6 +77,7 @@ trait PeriodOverview * @param Carbon $end * * @return array + * @throws FireflyException */ protected function getAccountPeriodOverview(Account $account, Carbon $start, Carbon $end): array { @@ -266,6 +268,7 @@ trait PeriodOverview * @param Carbon $end * * @return array + * @throws FireflyException */ protected function getCategoryPeriodOverview(Category $category, Carbon $start, Carbon $end): array { @@ -343,6 +346,7 @@ trait PeriodOverview * @param Carbon $end * * @return array + * @throws FireflyException */ protected function getNoBudgetPeriodOverview(Carbon $start, Carbon $end): array { @@ -395,7 +399,7 @@ trait PeriodOverview * @param Carbon $theDate * * @return array - * + * @throws FireflyException */ protected function getNoCategoryPeriodOverview(Carbon $theDate): array { @@ -475,7 +479,7 @@ trait PeriodOverview * @param Carbon $end * * @return array - * @throws \FireflyIII\Exceptions\FireflyException + * @throws FireflyException */ protected function getTagPeriodOverview(Tag $tag, Carbon $start, Carbon $end): array // period overview for tags. { @@ -549,7 +553,7 @@ trait PeriodOverview * @param Carbon $end * * @return array - * @throws \FireflyIII\Exceptions\FireflyException + * @throws FireflyException */ protected function getTransactionPeriodOverview(string $transactionType, Carbon $start, Carbon $end): array { diff --git a/app/Support/Http/Controllers/UserNavigation.php b/app/Support/Http/Controllers/UserNavigation.php index c0696bdace..d25e11b200 100644 --- a/app/Support/Http/Controllers/UserNavigation.php +++ b/app/Support/Http/Controllers/UserNavigation.php @@ -59,7 +59,7 @@ trait UserNavigation $uri = (string)session($identifier); Log::debug(sprintf('The URI is %s', $uri)); - if (false !== strpos($uri, 'jscript')) { + if (str_contains($uri, 'jscript')) { $uri = $this->redirectUri; Log::debug(sprintf('URI is now %s (uri contains jscript)', $uri)); } diff --git a/app/Support/Navigation.php b/app/Support/Navigation.php index 0322a5ed49..145ac905ed 100644 --- a/app/Support/Navigation.php +++ b/app/Support/Navigation.php @@ -33,11 +33,11 @@ use Log; class Navigation { /** - * @param \Carbon\Carbon $theDate - * @param string $repeatFreq - * @param int $skip + * @param Carbon $theDate + * @param string $repeatFreq + * @param int $skip * - * @return \Carbon\Carbon + * @return Carbon */ public function addPeriod(Carbon $theDate, string $repeatFreq, int $skip): Carbon { @@ -99,15 +99,14 @@ class Navigation } /** - * @param \Carbon\Carbon $start - * @param \Carbon\Carbon $end - * @param string $range + * @param Carbon $start + * @param Carbon $end + * @param string $range * * @return array - * @throws \FireflyIII\Exceptions\FireflyException * */ - public function blockPeriods(\Carbon\Carbon $start, \Carbon\Carbon $end, string $range): array + public function blockPeriods(Carbon $start, Carbon $end, string $range): array { if ($end < $start) { [$start, $end] = [$end, $start]; @@ -161,12 +160,12 @@ class Navigation } /** - * @param \Carbon\Carbon $end - * @param string $repeatFreq + * @param Carbon $end + * @param string $repeatFreq * - * @return \Carbon\Carbon + * @return Carbon */ - public function endOfPeriod(\Carbon\Carbon $end, string $repeatFreq): Carbon + public function endOfPeriod(Carbon $end, string $repeatFreq): Carbon { $currentEnd = clone $end; @@ -239,11 +238,11 @@ class Navigation } /** - * @param \Carbon\Carbon $theCurrentEnd - * @param string $repeatFreq - * @param \Carbon\Carbon|null $maxDate + * @param Carbon $theCurrentEnd + * @param string $repeatFreq + * @param Carbon|null $maxDate * - * @return \Carbon\Carbon + * @return Carbon */ public function endOfX(Carbon $theCurrentEnd, string $repeatFreq, ?Carbon $maxDate): Carbon { @@ -279,8 +278,8 @@ class Navigation } /** - * @param \Carbon\Carbon $start - * @param \Carbon\Carbon $end + * @param Carbon $start + * @param Carbon $end * * @return array */ @@ -315,12 +314,12 @@ class Navigation } /** - * @param \Carbon\Carbon $theDate - * @param string $repeatFrequency + * @param Carbon $theDate + * @param string $repeatFrequency * * @return string */ - public function periodShow(\Carbon\Carbon $theDate, string $repeatFrequency): string + public function periodShow(Carbon $theDate, string $repeatFrequency): string { $date = clone $theDate; $formatMap = [ @@ -359,8 +358,8 @@ class Navigation * If the date difference between start and end is less than a month, method returns "Y-m-d". If the difference is less than a year, * method returns "Y-m". If the date difference is larger, method returns "Y". * - * @param \Carbon\Carbon $start - * @param \Carbon\Carbon $end + * @param Carbon $start + * @param Carbon $end * * @return string */ @@ -382,8 +381,8 @@ class Navigation * If the date difference between start and end is less than a month, method returns trans(config.month_and_day). If the difference is less than a year, * method returns "config.month". If the date difference is larger, method returns "config.year". * - * @param \Carbon\Carbon $start - * @param \Carbon\Carbon $end + * @param Carbon $start + * @param Carbon $end * * @return string */ @@ -406,8 +405,8 @@ class Navigation * If the date difference between start and end is less than a month, method returns "endOfDay". If the difference is less than a year, * method returns "endOfMonth". If the date difference is larger, method returns "endOfYear". * - * @param \Carbon\Carbon $start - * @param \Carbon\Carbon $end + * @param Carbon $start + * @param Carbon $end * * @return string */ @@ -429,8 +428,8 @@ class Navigation * If the date difference between start and end is less than a month, method returns "1D". If the difference is less than a year, * method returns "1M". If the date difference is larger, method returns "1Y". * - * @param \Carbon\Carbon $start - * @param \Carbon\Carbon $end + * @param Carbon $start + * @param Carbon $end * * @return string */ @@ -452,8 +451,8 @@ class Navigation * If the date difference between start and end is less than a month, method returns "%Y-%m-%d". If the difference is less than a year, * method returns "%Y-%m". If the date difference is larger, method returns "%Y". * - * @param \Carbon\Carbon $start - * @param \Carbon\Carbon $end + * @param Carbon $start + * @param Carbon $end * * @return string */ @@ -472,10 +471,10 @@ class Navigation } /** - * @param \Carbon\Carbon $theDate - * @param string $repeatFreq + * @param Carbon $theDate + * @param string $repeatFreq * - * @return \Carbon\Carbon + * @return Carbon */ public function startOfPeriod(Carbon $theDate, string $repeatFreq): Carbon { @@ -523,13 +522,13 @@ class Navigation } /** - * @param \Carbon\Carbon $theDate - * @param string $repeatFreq - * @param int $subtract + * @param Carbon $theDate + * @param string $repeatFreq + * @param int|null $subtract * - * @return \Carbon\Carbon + * @return Carbon * - * @throws \FireflyIII\Exceptions\FireflyException + * @throws FireflyException */ public function subtractPeriod(Carbon $theDate, string $repeatFreq, int $subtract = null): Carbon { @@ -586,12 +585,12 @@ class Navigation } /** - * @param string $range - * @param \Carbon\Carbon $start + * @param string $range + * @param Carbon $start * - * @return \Carbon\Carbon + * @return Carbon * - * @throws \FireflyIII\Exceptions\FireflyException + * @throws FireflyException */ public function updateEndDate(string $range, Carbon $start): Carbon { @@ -632,12 +631,12 @@ class Navigation } /** - * @param string $range - * @param \Carbon\Carbon $start + * @param string $range + * @param Carbon $start * - * @return \Carbon\Carbon + * @return Carbon * - * @throws \FireflyIII\Exceptions\FireflyException + * @throws FireflyException */ public function updateStartDate(string $range, Carbon $start): Carbon { diff --git a/app/Support/Preferences.php b/app/Support/Preferences.php index 23b37550b2..a75b5ec580 100644 --- a/app/Support/Preferences.php +++ b/app/Support/Preferences.php @@ -84,7 +84,8 @@ class Preferences * @param string $name * @param mixed $default * - * @return \FireflyIII\Models\Preference|null + * @return Preference|null + * @throws FireflyException */ public function get(string $name, $default = null): ?Preference { @@ -104,7 +105,7 @@ class Preferences * @param string $name * @param mixed $default * - * @return \FireflyIII\Models\Preference|null + * @return Preference|null */ public function getFresh(string $name, $default = null): ?Preference { @@ -121,8 +122,8 @@ class Preferences } /** - * @param \FireflyIII\User $user - * @param array $list + * @param User $user + * @param array $list * * @return array */ @@ -148,7 +149,7 @@ class Preferences * @param string $name * @param null|string|int $default * - * @return \FireflyIII\Models\Preference|null + * @return Preference|null * @throws FireflyException */ public function getForUser(User $user, string $name, $default = null): ?Preference @@ -177,12 +178,13 @@ class Preferences } /** - * @param User $user - * @param string $name - * @param null|string $default + * @param User $user + * @param string $name + * @param null $default * - * @return \FireflyIII\Models\Preference|null + * @return Preference|null * TODO remove me + * @throws FireflyException */ public function getFreshForUser(User $user, string $name, $default = null): ?Preference { @@ -220,7 +222,8 @@ class Preferences * @param string $name * @param mixed $value * - * @return \FireflyIII\Models\Preference + * @return Preference + * @throws FireflyException */ public function set(string $name, $value): Preference { @@ -249,9 +252,9 @@ class Preferences } /** - * @param \FireflyIII\User $user - * @param string $name - * @param mixed $value + * @param User $user + * @param string $name + * @param mixed $value * * @return Preference * @throws FireflyException diff --git a/app/Support/Report/Budget/BudgetReportGenerator.php b/app/Support/Report/Budget/BudgetReportGenerator.php index c3cd5ce743..860804bfd1 100644 --- a/app/Support/Report/Budget/BudgetReportGenerator.php +++ b/app/Support/Report/Budget/BudgetReportGenerator.php @@ -51,7 +51,6 @@ class BudgetReportGenerator private array $report; private BudgetRepositoryInterface $repository; private Carbon $start; - private User $user; /** * BudgetReportGenerator constructor. @@ -367,11 +366,10 @@ class BudgetReportGenerator */ public function setUser(User $user): void { - $this->user = $user; $this->repository->setUser($user); $this->blRepository->setUser($user); $this->opsRepository->setUser($user); $this->nbRepository->setUser($user); - $this->currency = app('amount')->getDefaultCurrencyByUser($this->user); + $this->currency = app('amount')->getDefaultCurrencyByUser($user); } } diff --git a/app/Support/Steam.php b/app/Support/Steam.php index 063ea03783..9ed9edecc9 100644 --- a/app/Support/Steam.php +++ b/app/Support/Steam.php @@ -42,10 +42,13 @@ class Steam /** * Gets balance at the end of current month by default * - * @param \FireflyIII\Models\Account $account - * @param \Carbon\Carbon $date + * @param Account $account + * @param Carbon $date + * @param TransactionCurrency|null $currency * * @return string + * @throws \FireflyIII\Exceptions\FireflyException + * @throws \JsonException */ public function balance(Account $account, Carbon $date, ?TransactionCurrency $currency = null): string { @@ -88,8 +91,8 @@ class Steam } /** - * @param \FireflyIII\Models\Account $account - * @param \Carbon\Carbon $date + * @param Account $account + * @param Carbon $date * * @return string */ @@ -153,10 +156,10 @@ class Steam * * [yyyy-mm-dd] => 123,2 * - * @param \FireflyIII\Models\Account $account - * @param \Carbon\Carbon $start - * @param \Carbon\Carbon $end - * @param TransactionCurrency|null $currency + * @param Account $account + * @param Carbon $start + * @param Carbon $end + * @param TransactionCurrency|null $currency * * @return array */ @@ -237,8 +240,8 @@ class Steam } /** - * @param \FireflyIII\Models\Account $account - * @param \Carbon\Carbon $date + * @param Account $account + * @param Carbon $date * * @return array */ @@ -270,8 +273,8 @@ class Steam /** * This method always ignores the virtual balance. * - * @param \Illuminate\Support\Collection $accounts - * @param \Carbon\Carbon $date + * @param Collection $accounts + * @param Carbon $date * * @return array */ @@ -302,8 +305,8 @@ class Steam /** * Same as above, but also groups per currency. * - * @param \Illuminate\Support\Collection $accounts - * @param \Carbon\Carbon $date + * @param Collection $accounts + * @param Carbon $date * * @return array */ @@ -372,7 +375,7 @@ class Steam } /** - * @param string $amount + * @param string|null $amount * * @return string|null */ diff --git a/app/Support/Telemetry.php b/app/Support/Telemetry.php index ab0600e5d7..978fde2592 100644 --- a/app/Support/Telemetry.php +++ b/app/Support/Telemetry.php @@ -123,7 +123,7 @@ class Telemetry private function hasEntry(string $type, string $key, string $value): bool { try { - $jsonEncoded = json_encode($value, JSON_THROW_ON_ERROR, 512); + $jsonEncoded = json_encode($value, JSON_THROW_ON_ERROR); } catch (JsonException $e) { Log::error(sprintf('JSON Exception encoding the following value: %s: %s', $value, $e->getMessage())); $jsonEncoded = []; @@ -153,7 +153,7 @@ class Telemetry private function hasRecentEntry(string $type, string $key, string $value, Carbon $date): bool { try { - $jsonEncoded = json_encode($value, JSON_THROW_ON_ERROR, 512); + $jsonEncoded = json_encode($value, JSON_THROW_ON_ERROR); } catch (JsonException $e) { Log::error(sprintf('JSON Exception encoding the following value: %s: %s', $value, $e->getMessage())); $jsonEncoded = []; @@ -173,11 +173,13 @@ class Telemetry * @param string $type * @param string $name * @param string $value + * + * @throws \FireflyIII\Exceptions\FireflyException */ private function storeEntry(string $type, string $name, string $value): void { $this->generateInstallationId(); - $config = app('fireflyconfig')->get('installation_id', null); + $config = app('fireflyconfig')->get('installation_id'); $installationId = null !== $config ? $config->data : 'empty'; try { TelemetryModel::create(