Various PSR12 code cleanup

This commit is contained in:
James Cole
2022-12-29 19:42:26 +01:00
parent dbf3e76ecc
commit 6cfdc58cb1
415 changed files with 7462 additions and 6874 deletions

View File

@@ -55,7 +55,7 @@ class CreateAutoBudgetLimits implements ShouldQueue
*
* @codeCoverageIgnore
*
* @param Carbon|null $date
* @param Carbon|null $date
*/
public function __construct(?Carbon $date)
{
@@ -83,7 +83,7 @@ class CreateAutoBudgetLimits implements ShouldQueue
}
/**
* @param AutoBudget $autoBudget
* @param AutoBudget $autoBudget
*
* @throws FireflyException
*/
@@ -133,7 +133,7 @@ class CreateAutoBudgetLimits implements ShouldQueue
// find budget limit:
$budgetLimit = $this->findBudgetLimit($autoBudget->budget, $start, $end);
if (null === $budgetLimit && AutoBudget::AUTO_BUDGET_RESET === (int) $autoBudget->auto_budget_type) {
if (null === $budgetLimit && AutoBudget::AUTO_BUDGET_RESET === (int)$autoBudget->auto_budget_type) {
// that's easy: create one.
// do nothing else.
$this->createBudgetLimit($autoBudget, $start, $end);
@@ -142,7 +142,7 @@ class CreateAutoBudgetLimits implements ShouldQueue
return;
}
if (null === $budgetLimit && AutoBudget::AUTO_BUDGET_ROLLOVER === (int) $autoBudget->auto_budget_type) {
if (null === $budgetLimit && AutoBudget::AUTO_BUDGET_ROLLOVER === (int)$autoBudget->auto_budget_type) {
// budget limit exists already,
$this->createRollover($autoBudget);
Log::debug(sprintf('Done with auto budget #%d', $autoBudget->id));
@@ -153,7 +153,7 @@ class CreateAutoBudgetLimits implements ShouldQueue
}
/**
* @param AutoBudget $autoBudget
* @param AutoBudget $autoBudget
*
* @return bool
* @throws FireflyException
@@ -190,9 +190,9 @@ class CreateAutoBudgetLimits implements ShouldQueue
}
/**
* @param Budget $budget
* @param Carbon $start
* @param Carbon $end
* @param Budget $budget
* @param Carbon $start
* @param Carbon $end
*
* @return BudgetLimit|null
*/
@@ -214,10 +214,10 @@ class CreateAutoBudgetLimits implements ShouldQueue
}
/**
* @param AutoBudget $autoBudget
* @param Carbon $start
* @param Carbon $end
* @param string|null $amount
* @param AutoBudget $autoBudget
* @param Carbon $start
* @param Carbon $end
* @param string|null $amount
*/
private function createBudgetLimit(AutoBudget $autoBudget, Carbon $start, Carbon $end, ?string $amount = null)
{
@@ -239,7 +239,7 @@ class CreateAutoBudgetLimits implements ShouldQueue
}
/**
* @param AutoBudget $autoBudget
* @param AutoBudget $autoBudget
*
* @throws FireflyException
*/
@@ -280,7 +280,7 @@ class CreateAutoBudgetLimits implements ShouldQueue
$repository = app(OperationsRepositoryInterface::class);
$repository->setUser($autoBudget->budget->user);
$spent = $repository->sumExpenses($previousStart, $previousEnd, null, new Collection([$autoBudget->budget]), $autoBudget->transactionCurrency);
$currencyId = (int) $autoBudget->transaction_currency_id;
$currencyId = (int)$autoBudget->transaction_currency_id;
$spentAmount = $spent[$currencyId]['sum'] ?? '0';
Log::debug(sprintf('Spent in previous budget period (%s-%s) is %s', $previousStart->format('Y-m-d'), $previousEnd->format('Y-m-d'), $spentAmount));
@@ -304,7 +304,7 @@ class CreateAutoBudgetLimits implements ShouldQueue
}
/**
* @param Carbon $date
* @param Carbon $date
*/
public function setDate(Carbon $date): void
{

View File

@@ -61,10 +61,10 @@ class CreateRecurringTransactions implements ShouldQueue
private Carbon $date;
private bool $force;
private TransactionGroupRepositoryInterface $groupRepository;
private JournalRepositoryInterface $journalRepository;
private RecurringRepositoryInterface $repository;
private Collection $recurrences;
private Collection $groups;
private JournalRepositoryInterface $journalRepository;
private Collection $recurrences;
private RecurringRepositoryInterface $repository;
/**
* Create a new job instance.
@@ -97,6 +97,14 @@ class CreateRecurringTransactions implements ShouldQueue
Log::debug(sprintf('Created new CreateRecurringTransactions("%s")', $this->date->format('Y-m-d')));
}
/**
* @return Collection
*/
public function getGroups(): Collection
{
return $this->groups;
}
/**
* Execute the job.
*/
@@ -520,12 +528,4 @@ class CreateRecurringTransactions implements ShouldQueue
{
$this->recurrences = $recurrences;
}
/**
* @return Collection
*/
public function getGroups(): Collection
{
return $this->groups;
}
}

View File

@@ -47,9 +47,9 @@ class DownloadExchangeRates implements ShouldQueue
use Queueable;
use SerializesModels;
private array $active;
private Carbon $date;
private CurrencyRepositoryInterface $repository;
private array $active;
private Collection $users;
/**
@@ -57,7 +57,7 @@ class DownloadExchangeRates implements ShouldQueue
*
* @codeCoverageIgnore
*
* @param Carbon|null $date
* @param Carbon|null $date
*/
public function __construct(?Carbon $date)
{
@@ -92,23 +92,13 @@ class DownloadExchangeRates implements ShouldQueue
}
/**
* @param Carbon $date
*/
public function setDate(Carbon $date): void
{
$newDate = clone $date;
$newDate->startOfDay();
$this->date = $newDate;
}
/**
* @param TransactionCurrency $currency
* @param TransactionCurrency $currency
* @return void
*/
private function downloadRates(TransactionCurrency $currency): void
{
Log::debug(sprintf('Now downloading new exchange rates for currency %s.', $currency->code));
$base = sprintf('%s/%s/%s', (string) config('cer.url'), $this->date->year, $this->date->isoWeek);
$base = sprintf('%s/%s/%s', (string)config('cer.url'), $this->date->year, $this->date->isoWeek);
$client = new Client();
$url = sprintf('%s/%s.json', $base, $currency->code);
$res = $client->get($url);
@@ -117,7 +107,7 @@ class DownloadExchangeRates implements ShouldQueue
app('log')->warning(sprintf('Trying to grab "%s" resulted in status code %d.', $url, $statusCode));
return;
}
$body = (string) $res->getBody();
$body = (string)$res->getBody();
$json = json_decode($body, true);
if (false === $json || null === $json) {
app('log')->warning(sprintf('Trying to grab "%s" resulted in bad JSON.', $url));
@@ -128,8 +118,8 @@ class DownloadExchangeRates implements ShouldQueue
}
/**
* @param TransactionCurrency $currency
* @param array $rates
* @param TransactionCurrency $currency
* @param array $rates
* @return void
*/
private function saveRates(TransactionCurrency $currency, Carbon $date, array $rates): void
@@ -146,7 +136,7 @@ class DownloadExchangeRates implements ShouldQueue
}
/**
* @param string $code
* @param string $code
* @return TransactionCurrency|null
*/
private function getCurrency(string $code): ?TransactionCurrency
@@ -185,4 +175,14 @@ class DownloadExchangeRates implements ShouldQueue
}
}
}
/**
* @param Carbon $date
*/
public function setDate(Carbon $date): void
{
$newDate = clone $date;
$newDate->startOfDay();
$this->date = $newDate;
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* Job.php
* Copyright (c) 2019 james@firefly-iii.org

View File

@@ -1,4 +1,5 @@
<?php
/**
* MailError.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -48,10 +49,10 @@ class MailError extends Job implements ShouldQueue
/**
* MailError constructor.
*
* @param array $userData
* @param string $destination
* @param string $ipAddress
* @param array $exceptionData
* @param array $userData
* @param string $destination
* @param string $ipAddress
* @param array $exceptionData
*/
public function __construct(array $userData, string $destination, string $ipAddress, array $exceptionData)
{
@@ -70,7 +71,7 @@ class MailError extends Job implements ShouldQueue
*/
public function handle()
{
$email = (string) config('firefly.site_owner');
$email = (string)config('firefly.site_owner');
$args = $this->exception;
$args['loggedIn'] = $this->userData['id'] > 0;
$args['user'] = $this->userData;
@@ -83,12 +84,12 @@ class MailError extends Job implements ShouldQueue
$args,
function (Message $message) use ($email) {
if ('mail@example.com' !== $email) {
$message->to($email, $email)->subject((string) trans('email.error_subject'));
$message->to($email, $email)->subject((string)trans('email.error_subject'));
}
}
);
} catch (Exception $e) {
Log::error('Exception when mailing: ' . $e->getMessage());
Log::error('Exception when mailing: '.$e->getMessage());
}
}
}

View File

@@ -48,7 +48,7 @@ class SendWebhookMessage implements ShouldQueue
/**
* Create a new job instance.
*
* @param WebhookMessage $message
* @param WebhookMessage $message
*/
public function __construct(WebhookMessage $message)
{

View File

@@ -52,7 +52,7 @@ class WarnAboutBills implements ShouldQueue
*
* @codeCoverageIgnore
*
* @param Carbon|null $date
* @param Carbon|null $date
*/
public function __construct(?Carbon $date)
{
@@ -97,7 +97,7 @@ class WarnAboutBills implements ShouldQueue
}
/**
* @param Bill $bill
* @param Bill $bill
* @return bool
*/
private function hasDateFields(Bill $bill): bool
@@ -114,8 +114,8 @@ class WarnAboutBills implements ShouldQueue
}
/**
* @param Bill $bill
* @param string $field
* @param Bill $bill
* @param string $field
* @return bool
*/
private function needsWarning(Bill $bill, string $field): bool
@@ -133,8 +133,8 @@ class WarnAboutBills implements ShouldQueue
}
/**
* @param Bill $bill
* @param string $field
* @param Bill $bill
* @param string $field
* @return int
*/
private function getDiff(Bill $bill, string $field): int
@@ -145,8 +145,8 @@ class WarnAboutBills implements ShouldQueue
}
/**
* @param Bill $bill
* @param string $field
* @param Bill $bill
* @param string $field
* @return void
*/
private function sendWarning(Bill $bill, string $field): void
@@ -157,7 +157,7 @@ class WarnAboutBills implements ShouldQueue
}
/**
* @param Carbon $date
* @param Carbon $date
*/
public function setDate(Carbon $date): void
{
@@ -167,7 +167,7 @@ class WarnAboutBills implements ShouldQueue
}
/**
* @param bool $force
* @param bool $force
*/
public function setForce(bool $force): void
{