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

@@ -43,7 +43,7 @@ abstract class AbstractTransformer extends TransformerAbstract
}
/**
* @param ParameterBag $parameters
* @param ParameterBag $parameters
*/
final public function setParameters(ParameterBag $parameters): void
{

View File

@@ -52,7 +52,7 @@ class AccountTransformer extends AbstractTransformer
/**
* Transform the account.
*
* @param Account $account
* @param Account $account
*
* @return array
* @throws JsonException
@@ -63,8 +63,8 @@ class AccountTransformer extends AbstractTransformer
// get account type:
$fullType = $account->accountType->type;
$accountType = (string) config(sprintf('firefly.shortNamesByFullName.%s', $fullType));
$liabilityType = (string) config(sprintf('firefly.shortLiabilityNameByFullName.%s', $fullType));
$accountType = (string)config(sprintf('firefly.shortNamesByFullName.%s', $fullType));
$liabilityType = (string)config(sprintf('firefly.shortLiabilityNameByFullName.%s', $fullType));
$liabilityType = '' === $liabilityType ? null : strtolower($liabilityType);
$liabilityDirection = $this->repository->getMetaValue($account, 'liability_direction');
@@ -87,17 +87,17 @@ class AccountTransformer extends AbstractTransformer
if (null !== $location) {
$longitude = $location->longitude;
$latitude = $location->latitude;
$zoomLevel = (int) $location->zoom_level;
$zoomLevel = (int)$location->zoom_level;
}
// no order for some accounts:
$order = (int) $account->order;
$order = (int)$account->order;
if (!in_array(strtolower($accountType), ['liability', 'liabilities', 'asset'], true)) {
$order = null;
}
return [
'id' => (string) $account->id,
'id' => (string)$account->id,
'created_at' => $account->created_at->toAtomString(),
'updated_at' => $account->updated_at->toAtomString(),
'active' => $account->active,
@@ -132,23 +132,23 @@ class AccountTransformer extends AbstractTransformer
'links' => [
[
'rel' => 'self',
'uri' => '/accounts/' . $account->id,
'uri' => '/accounts/'.$account->id,
],
],
];
}
/**
* @param Account $account
* @param Account $account
*
* @param string $accountType
* @param string $accountType
*
* @return string|null
*/
private function getAccountRole(Account $account, string $accountType): ?string
{
$accountRole = $this->repository->getMetaValue($account, 'account_role');
if ('asset' !== $accountType || '' === (string) $accountRole) {
if ('asset' !== $accountType || '' === (string)$accountRole) {
$accountRole = null;
}
@@ -170,7 +170,7 @@ class AccountTransformer extends AbstractTransformer
}
/**
* @param Account $account
* @param Account $account
*
* @return array
* @throws FireflyException
@@ -184,7 +184,7 @@ class AccountTransformer extends AbstractTransformer
if (null === $currency) {
$currency = app('amount')->getDefaultCurrencyByUser($account->user);
}
$currencyId = (string) $currency->id;
$currencyId = (string)$currency->id;
$currencyCode = $currency->code;
$decimalPlaces = $currency->decimal_places;
$currencySymbol = $currency->symbol;
@@ -193,9 +193,9 @@ class AccountTransformer extends AbstractTransformer
}
/**
* @param Account $account
* @param string|null $accountRole
* @param string $accountType
* @param Account $account
* @param string|null $accountRole
* @param string $accountType
*
* @return array
*/
@@ -215,8 +215,8 @@ class AccountTransformer extends AbstractTransformer
}
/**
* @param Account $account
* @param string $accountType
* @param Account $account
* @param string $accountType
*
* @return array
*
@@ -239,8 +239,8 @@ class AccountTransformer extends AbstractTransformer
}
/**
* @param Account $account
* @param string $accountType
* @param Account $account
* @param string $accountType
*
* @return array
*/

View File

@@ -46,7 +46,7 @@ class AttachmentTransformer extends AbstractTransformer
/**
* Transform attachment.
*
* @param Attachment $attachment
* @param Attachment $attachment
*
* @return array
*/
@@ -55,10 +55,10 @@ class AttachmentTransformer extends AbstractTransformer
$this->repository->setUser($attachment->user);
return [
'id' => (string) $attachment->id,
'id' => (string)$attachment->id,
'created_at' => $attachment->created_at->toAtomString(),
'updated_at' => $attachment->updated_at->toAtomString(),
'attachable_id' => (string) $attachment->attachable_id,
'attachable_id' => (string)$attachment->attachable_id,
'attachable_type' => str_replace('FireflyIII\\Models\\', '', $attachment->attachable_type),
'md5' => $attachment->md5,
'filename' => $attachment->filename,
@@ -67,11 +67,11 @@ class AttachmentTransformer extends AbstractTransformer
'title' => $attachment->title,
'notes' => $this->repository->getNoteText($attachment),
'mime' => $attachment->mime,
'size' => (int) $attachment->size,
'size' => (int)$attachment->size,
'links' => [
[
'rel' => 'self',
'uri' => '/attachment/' . $attachment->id,
'uri' => '/attachment/'.$attachment->id,
],
],
];

View File

@@ -52,7 +52,7 @@ class AvailableBudgetTransformer extends AbstractTransformer
/**
* Transform the note.
*
* @param AvailableBudget $availableBudget
* @param AvailableBudget $availableBudget
*
* @return array
*/
@@ -62,13 +62,13 @@ class AvailableBudgetTransformer extends AbstractTransformer
$currency = $availableBudget->transactionCurrency;
$data = [
'id' => (string) $availableBudget->id,
'id' => (string)$availableBudget->id,
'created_at' => $availableBudget->created_at->toAtomString(),
'updated_at' => $availableBudget->updated_at->toAtomString(),
'currency_id' => (string) $currency->id,
'currency_id' => (string)$currency->id,
'currency_code' => $currency->code,
'currency_symbol' => $currency->symbol,
'currency_decimal_places' => (int) $currency->decimal_places,
'currency_decimal_places' => (int)$currency->decimal_places,
'amount' => app('steam')->bcround($availableBudget->amount, $currency->decimal_places),
'start' => $availableBudget->start_date->toAtomString(),
'end' => $availableBudget->end_date->endOfDay()->toAtomString(),
@@ -77,7 +77,7 @@ class AvailableBudgetTransformer extends AbstractTransformer
'links' => [
[
'rel' => 'self',
'uri' => '/available_budgets/' . $availableBudget->id,
'uri' => '/available_budgets/'.$availableBudget->id,
],
],
];

View File

@@ -52,7 +52,7 @@ class BillTransformer extends AbstractTransformer
/**
* Transform the bill.
*
* @param Bill $bill
* @param Bill $bill
*
* @return array
*/
@@ -72,8 +72,8 @@ class BillTransformer extends AbstractTransformer
/** @var ObjectGroup $objectGroup */
$objectGroup = $bill->objectGroups->first();
if (null !== $objectGroup) {
$objectGroupId = (int) $objectGroup->id;
$objectGroupOrder = (int) $objectGroup->order;
$objectGroupId = (int)$objectGroup->id;
$objectGroupOrder = (int)$objectGroup->order;
$objectGroupTitle = $objectGroup->title;
}
@@ -107,13 +107,13 @@ class BillTransformer extends AbstractTransformer
unset($temp, $temp2);
return [
'id' => (int) $bill->id,
'id' => (int)$bill->id,
'created_at' => $bill->created_at->toAtomString(),
'updated_at' => $bill->updated_at->toAtomString(),
'currency_id' => (string) $bill->transaction_currency_id,
'currency_id' => (string)$bill->transaction_currency_id,
'currency_code' => $currency->code,
'currency_symbol' => $currency->symbol,
'currency_decimal_places' => (int) $currency->decimal_places,
'currency_decimal_places' => (int)$currency->decimal_places,
'name' => $bill->name,
'amount_min' => app('steam')->bcround($bill->amount_min, $currency->decimal_places),
'amount_max' => app('steam')->bcround($bill->amount_max, $currency->decimal_places),
@@ -121,11 +121,11 @@ class BillTransformer extends AbstractTransformer
'end_date' => $bill->end_date?->toAtomString(),
'extension_date' => $bill->extension_date?->toAtomString(),
'repeat_freq' => $bill->repeat_freq,
'skip' => (int) $bill->skip,
'skip' => (int)$bill->skip,
'active' => $bill->active,
'order' => (int) $bill->order,
'order' => (int)$bill->order,
'notes' => $notes,
'object_group_id' => $objectGroupId ? (string) $objectGroupId : null,
'object_group_id' => $objectGroupId ? (string)$objectGroupId : null,
'object_group_order' => $objectGroupOrder,
'object_group_title' => $objectGroupTitle,
@@ -137,7 +137,7 @@ class BillTransformer extends AbstractTransformer
'links' => [
[
'rel' => 'self',
'uri' => '/bills/' . $bill->id,
'uri' => '/bills/'.$bill->id,
],
],
];
@@ -146,7 +146,7 @@ class BillTransformer extends AbstractTransformer
/**
* Get the data the bill was paid and predict the next expected match.
*
* @param Bill $bill
* @param Bill $bill
*
* @return array
*/
@@ -203,8 +203,8 @@ class BillTransformer extends AbstractTransformer
$result = [];
foreach ($set as $entry) {
$result[] = [
'transaction_group_id' => (int) $entry->transaction_group_id,
'transaction_journal_id' => (int) $entry->id,
'transaction_group_id' => (int)$entry->transaction_group_id,
'transaction_journal_id' => (int)$entry->id,
'date' => $entry->date->format('Y-m-d'),
];
}
@@ -220,8 +220,8 @@ class BillTransformer extends AbstractTransformer
/**
* Returns the latest date in the set, or start when set is empty.
*
* @param Collection $dates
* @param Carbon $default
* @param Collection $dates
* @param Carbon $default
*
* @return Carbon
*/
@@ -242,7 +242,7 @@ class BillTransformer extends AbstractTransformer
}
/**
* @param Bill $bill
* @param Bill $bill
*
* @return array
*/
@@ -285,8 +285,8 @@ class BillTransformer extends AbstractTransformer
* Given a bill and a date, this method will tell you at which moment this bill expects its next
* transaction. Whether or not it is there already, is not relevant.
*
* @param Bill $bill
* @param Carbon $date
* @param Bill $bill
* @param Carbon $date
*
* @return Carbon
*/