Code cleanup

This commit is contained in:
James Cole
2024-12-22 08:43:12 +01:00
parent 5751f7e5a3
commit 565bd87959
574 changed files with 4600 additions and 4604 deletions

View File

@@ -54,8 +54,8 @@ class AttachmentHelper implements AttachmentHelperInterface
*/
public function __construct()
{
$this->maxUploadSize = (int)config('firefly.maxUploadSize');
$this->allowedMimes = (array)config('firefly.allowedMimes');
$this->maxUploadSize = (int) config('firefly.maxUploadSize');
$this->allowedMimes = (array) config('firefly.allowedMimes');
$this->errors = new MessageBag();
$this->messages = new MessageBag();
$this->attachments = new Collection();
@@ -67,7 +67,7 @@ class AttachmentHelper implements AttachmentHelperInterface
*/
public function getAttachmentContent(Attachment $attachment): string
{
$encryptedData = (string)$this->uploadDisk->get(sprintf('at-%d.data', $attachment->id));
$encryptedData = (string) $this->uploadDisk->get(sprintf('at-%d.data', $attachment->id));
try {
$unencryptedData = \Crypt::decrypt($encryptedData); // verified
@@ -146,7 +146,7 @@ class AttachmentHelper implements AttachmentHelperInterface
return false;
}
$mime = (string)finfo_file($finfo, $path);
$mime = (string) finfo_file($finfo, $path);
$allowedMime = config('firefly.allowedMimes');
if (!in_array($mime, $allowedMime, true)) {
Log::error(sprintf('Mime type %s is not allowed for API file upload.', $mime));
@@ -162,7 +162,7 @@ class AttachmentHelper implements AttachmentHelperInterface
$this->uploadDisk->put($file, $content);
// update attachment.
$attachment->md5 = (string)md5_file($path);
$attachment->md5 = (string) md5_file($path);
$attachment->mime = $mime;
$attachment->size = strlen($content);
$attachment->uploaded = true;
@@ -224,7 +224,7 @@ class AttachmentHelper implements AttachmentHelperInterface
$attachment = new Attachment(); // create Attachment object.
$attachment->user()->associate($user);
$attachment->attachable()->associate($model);
$attachment->md5 = (string)md5_file($file->getRealPath());
$attachment->md5 = (string) md5_file($file->getRealPath());
$attachment->filename = $file->getClientOriginalName();
$attachment->mime = $file->getMimeType();
$attachment->size = $file->getSize();
@@ -241,7 +241,7 @@ class AttachmentHelper implements AttachmentHelperInterface
return null;
}
$content = (string)$fileObject->fread($file->getSize());
$content = (string) $fileObject->fread($file->getSize());
Log::debug(sprintf('Full file length is %d and upload size is %d.', strlen($content), $file->getSize()));
// store it without encryption.
@@ -251,7 +251,7 @@ class AttachmentHelper implements AttachmentHelperInterface
$this->attachments->push($attachment);
$name = e($file->getClientOriginalName()); // add message:
$msg = (string)trans('validation.file_attached', ['name' => $name]);
$msg = (string) trans('validation.file_attached', ['name' => $name]);
$this->messages->add('attachments', $msg);
}
@@ -298,7 +298,7 @@ class AttachmentHelper implements AttachmentHelperInterface
$result = true;
if (!in_array($mime, $this->allowedMimes, true)) {
$msg = (string)trans('validation.file_invalid_mime', ['name' => $name, 'mime' => $mime]);
$msg = (string) trans('validation.file_invalid_mime', ['name' => $name, 'mime' => $mime]);
$this->errors->add('attachments', $msg);
Log::error($msg);
@@ -317,7 +317,7 @@ class AttachmentHelper implements AttachmentHelperInterface
$name = e($file->getClientOriginalName());
$result = true;
if ($size > $this->maxUploadSize) {
$msg = (string)trans('validation.file_too_large', ['name' => $name]);
$msg = (string) trans('validation.file_too_large', ['name' => $name]);
$this->errors->add('attachments', $msg);
Log::error($msg);
@@ -345,7 +345,7 @@ class AttachmentHelper implements AttachmentHelperInterface
}
$result = false;
if ($count > 0) {
$msg = (string)trans('validation.file_already_attached', ['name' => $name]);
$msg = (string) trans('validation.file_already_attached', ['name' => $name]);
$this->errors->add('attachments', $msg);
Log::error($msg);
$result = true;

View File

@@ -327,7 +327,7 @@ trait AttachmentCollection
foreach ($transaction['attachments'] as $attachment) {
/** @var null|Attachment $object */
$object = auth()->user()->attachments()->find($attachment['id']);
$notes = (string)$object?->notes()->first()?->text;
$notes = (string) $object?->notes()->first()?->text;
return '' !== $notes && $notes === $value;
}
@@ -351,7 +351,7 @@ trait AttachmentCollection
foreach ($transaction['attachments'] as $attachment) {
/** @var null|Attachment $object */
$object = auth()->user()->attachments()->find($attachment['id']);
$notes = (string)$object?->notes()->first()?->text;
$notes = (string) $object?->notes()->first()?->text;
return '' !== $notes && $notes !== $value;
}
@@ -375,7 +375,7 @@ trait AttachmentCollection
foreach ($transaction['attachments'] as $attachment) {
/** @var null|Attachment $object */
$object = auth()->user()->attachments()->find($attachment['id']);
$notes = (string)$object?->notes()->first()?->text;
$notes = (string) $object?->notes()->first()?->text;
return '' !== $notes && str_contains(strtolower($notes), strtolower($value));
}
@@ -399,7 +399,7 @@ trait AttachmentCollection
foreach ($transaction['attachments'] as $attachment) {
/** @var null|Attachment $object */
$object = auth()->user()->attachments()->find($attachment['id']);
$notes = (string)$object?->notes()->first()?->text;
$notes = (string) $object?->notes()->first()?->text;
return '' !== $notes && !str_contains(strtolower($notes), strtolower($value));
}
@@ -423,7 +423,7 @@ trait AttachmentCollection
foreach ($transaction['attachments'] as $attachment) {
/** @var null|Attachment $object */
$object = auth()->user()->attachments()->find($attachment['id']);
$notes = (string)$object?->notes()->first()?->text;
$notes = (string) $object?->notes()->first()?->text;
return '' !== $notes && !str_ends_with(strtolower($notes), strtolower($value));
}
@@ -447,7 +447,7 @@ trait AttachmentCollection
foreach ($transaction['attachments'] as $attachment) {
/** @var null|Attachment $object */
$object = auth()->user()->attachments()->find($attachment['id']);
$notes = (string)$object?->notes()->first()?->text;
$notes = (string) $object?->notes()->first()?->text;
return '' !== $notes && !str_starts_with(strtolower($notes), strtolower($value));
}
@@ -471,7 +471,7 @@ trait AttachmentCollection
foreach ($transaction['attachments'] as $attachment) {
/** @var null|Attachment $object */
$object = auth()->user()->attachments()->find($attachment['id']);
$notes = (string)$object?->notes()->first()?->text;
$notes = (string) $object?->notes()->first()?->text;
return '' !== $notes && str_ends_with(strtolower($notes), strtolower($value));
}
@@ -495,7 +495,7 @@ trait AttachmentCollection
foreach ($transaction['attachments'] as $attachment) {
/** @var null|Attachment $object */
$object = auth()->user()->attachments()->find($attachment['id']);
$notes = (string)$object?->notes()->first()?->text;
$notes = (string) $object?->notes()->first()?->text;
return '' !== $notes && str_starts_with(strtolower($notes), strtolower($value));
}

View File

@@ -195,7 +195,7 @@ trait MetaCollection
public function excludeInternalReference(string $internalReference): GroupCollectorInterface
{
$internalReference = (string)json_encode($internalReference);
$internalReference = (string) json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
$this->joinMetaDataTables();
@@ -216,7 +216,7 @@ trait MetaCollection
public function externalIdContains(string $externalId): GroupCollectorInterface
{
$externalId = (string)json_encode($externalId);
$externalId = (string) json_encode($externalId);
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
$this->joinMetaDataTables();
@@ -228,7 +228,7 @@ trait MetaCollection
public function externalIdDoesNotContain(string $externalId): GroupCollectorInterface
{
$externalId = (string)json_encode($externalId);
$externalId = (string) json_encode($externalId);
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
$this->joinMetaDataTables();
@@ -240,7 +240,7 @@ trait MetaCollection
public function externalIdDoesNotEnd(string $externalId): GroupCollectorInterface
{
$externalId = (string)json_encode($externalId);
$externalId = (string) json_encode($externalId);
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
$this->joinMetaDataTables();
@@ -252,7 +252,7 @@ trait MetaCollection
public function externalIdDoesNotStart(string $externalId): GroupCollectorInterface
{
$externalId = (string)json_encode($externalId);
$externalId = (string) json_encode($externalId);
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
$this->joinMetaDataTables();
@@ -264,7 +264,7 @@ trait MetaCollection
public function externalIdEnds(string $externalId): GroupCollectorInterface
{
$externalId = (string)json_encode($externalId);
$externalId = (string) json_encode($externalId);
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
$this->joinMetaDataTables();
@@ -276,7 +276,7 @@ trait MetaCollection
public function externalIdStarts(string $externalId): GroupCollectorInterface
{
$externalId = (string)json_encode($externalId);
$externalId = (string) json_encode($externalId);
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
$this->joinMetaDataTables();
@@ -289,7 +289,7 @@ trait MetaCollection
public function externalUrlContains(string $url): GroupCollectorInterface
{
$this->joinMetaDataTables();
$url = (string)json_encode($url);
$url = (string) json_encode($url);
$url = str_replace('\\', '\\\\', trim($url, '"'));
$this->query->where('journal_meta.name', '=', 'external_url');
$this->query->whereLike('journal_meta.data', sprintf('%%%s%%', $url));
@@ -300,7 +300,7 @@ trait MetaCollection
public function externalUrlDoesNotContain(string $url): GroupCollectorInterface
{
$this->joinMetaDataTables();
$url = (string)json_encode($url);
$url = (string) json_encode($url);
$url = str_replace('\\', '\\\\', trim($url, '"'));
$this->query->where('journal_meta.name', '=', 'external_url');
$this->query->whereNotLike('journal_meta.data', sprintf('%%%s%%', $url));
@@ -311,7 +311,7 @@ trait MetaCollection
public function externalUrlDoesNotEnd(string $url): GroupCollectorInterface
{
$this->joinMetaDataTables();
$url = (string)json_encode($url);
$url = (string) json_encode($url);
$url = str_replace('\\', '\\\\', ltrim($url, '"'));
$this->query->where('journal_meta.name', '=', 'external_url');
$this->query->whereNotLike('journal_meta.data', sprintf('%%%s', $url));
@@ -322,7 +322,7 @@ trait MetaCollection
public function externalUrlDoesNotStart(string $url): GroupCollectorInterface
{
$this->joinMetaDataTables();
$url = (string)json_encode($url);
$url = (string) json_encode($url);
$url = str_replace('\\', '\\\\', rtrim($url, '"'));
// var_dump($url);
@@ -335,7 +335,7 @@ trait MetaCollection
public function externalUrlEnds(string $url): GroupCollectorInterface
{
$this->joinMetaDataTables();
$url = (string)json_encode($url);
$url = (string) json_encode($url);
$url = str_replace('\\', '\\\\', ltrim($url, '"'));
$this->query->where('journal_meta.name', '=', 'external_url');
$this->query->whereLike('journal_meta.data', sprintf('%%%s', $url));
@@ -346,7 +346,7 @@ trait MetaCollection
public function externalUrlStarts(string $url): GroupCollectorInterface
{
$this->joinMetaDataTables();
$url = (string)json_encode($url);
$url = (string) json_encode($url);
$url = str_replace('\\', '\\\\', rtrim($url, '"'));
// var_dump($url);
@@ -397,7 +397,7 @@ trait MetaCollection
public function internalReferenceContains(string $internalReference): GroupCollectorInterface
{
$internalReference = (string)json_encode($internalReference);
$internalReference = (string) json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
// var_dump($internalReference);
// exit;
@@ -411,7 +411,7 @@ trait MetaCollection
public function internalReferenceDoesNotContain(string $internalReference): GroupCollectorInterface
{
$internalReference = (string)json_encode($internalReference);
$internalReference = (string) json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
$this->joinMetaDataTables();
@@ -423,7 +423,7 @@ trait MetaCollection
public function internalReferenceDoesNotEnd(string $internalReference): GroupCollectorInterface
{
$internalReference = (string)json_encode($internalReference);
$internalReference = (string) json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
$this->joinMetaDataTables();
@@ -435,7 +435,7 @@ trait MetaCollection
public function internalReferenceDoesNotStart(string $internalReference): GroupCollectorInterface
{
$internalReference = (string)json_encode($internalReference);
$internalReference = (string) json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
$this->joinMetaDataTables();
@@ -447,7 +447,7 @@ trait MetaCollection
public function internalReferenceEnds(string $internalReference): GroupCollectorInterface
{
$internalReference = (string)json_encode($internalReference);
$internalReference = (string) json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
$this->joinMetaDataTables();
@@ -459,7 +459,7 @@ trait MetaCollection
public function internalReferenceStarts(string $internalReference): GroupCollectorInterface
{
$internalReference = (string)json_encode($internalReference);
$internalReference = (string) json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
$this->joinMetaDataTables();
@@ -712,7 +712,7 @@ trait MetaCollection
public function setInternalReference(string $internalReference): GroupCollectorInterface
{
$internalReference = (string)json_encode($internalReference);
$internalReference = (string) json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
$this->joinMetaDataTables();

View File

@@ -125,7 +125,7 @@ trait TimeCollection
foreach ($object['transactions'] as $transaction) {
if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon
) {
return $transaction[$field]->day >= (int)$day;
return $transaction[$field]->day >= (int) $day;
}
}
@@ -143,7 +143,7 @@ trait TimeCollection
foreach ($object['transactions'] as $transaction) {
if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon
) {
return $transaction[$field]->day <= (int)$day;
return $transaction[$field]->day <= (int) $day;
}
}
@@ -161,7 +161,7 @@ trait TimeCollection
foreach ($object['transactions'] as $transaction) {
if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon
) {
return (int)$day === $transaction[$field]->day;
return (int) $day === $transaction[$field]->day;
}
}
@@ -179,7 +179,7 @@ trait TimeCollection
foreach ($object['transactions'] as $transaction) {
if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon
) {
return (int)$day !== $transaction[$field]->day;
return (int) $day !== $transaction[$field]->day;
}
}
@@ -197,7 +197,7 @@ trait TimeCollection
foreach ($object['transactions'] as $transaction) {
if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon
) {
return $transaction[$field]->month >= (int)$month;
return $transaction[$field]->month >= (int) $month;
}
}
@@ -215,7 +215,7 @@ trait TimeCollection
foreach ($object['transactions'] as $transaction) {
if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon
) {
return $transaction[$field]->month <= (int)$month;
return $transaction[$field]->month <= (int) $month;
}
}
@@ -233,7 +233,7 @@ trait TimeCollection
foreach ($object['transactions'] as $transaction) {
if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon
) {
return (int)$month === $transaction[$field]->month;
return (int) $month === $transaction[$field]->month;
}
}
@@ -251,7 +251,7 @@ trait TimeCollection
foreach ($object['transactions'] as $transaction) {
if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon
) {
return (int)$month !== $transaction[$field]->month;
return (int) $month !== $transaction[$field]->month;
}
}
@@ -269,7 +269,7 @@ trait TimeCollection
foreach ($object['transactions'] as $transaction) {
if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon
) {
return $transaction[$field]->year >= (int)$year;
return $transaction[$field]->year >= (int) $year;
}
}
@@ -287,7 +287,7 @@ trait TimeCollection
foreach ($object['transactions'] as $transaction) {
if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon
) {
return $transaction[$field]->year <= (int)$year;
return $transaction[$field]->year <= (int) $year;
}
}
@@ -305,7 +305,7 @@ trait TimeCollection
foreach ($object['transactions'] as $transaction) {
if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon
) {
return $year === (string)$transaction[$field]->year;
return $year === (string) $transaction[$field]->year;
}
}
@@ -323,7 +323,7 @@ trait TimeCollection
foreach ($object['transactions'] as $transaction) {
if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon
) {
return $year !== (string)$transaction[$field]->year;
return $year !== (string) $transaction[$field]->year;
}
}

View File

@@ -292,7 +292,7 @@ class GroupCollector implements GroupCollectorInterface
foreach ($params as $param) {
$replace = sprintf('"%s"', $param);
if (is_int($param)) {
$replace = (string)$param;
$replace = (string) $param;
}
$pos = strpos($query, '?');
if (false !== $pos) {
@@ -503,13 +503,13 @@ class GroupCollector implements GroupCollectorInterface
/** @var TransactionJournal $augumentedJournal */
foreach ($collection as $augumentedJournal) {
$groupId = (int)$augumentedJournal->transaction_group_id;
$groupId = (int) $augumentedJournal->transaction_group_id;
if (!array_key_exists($groupId, $groups)) {
// make new array
$parsedGroup = $this->parseAugmentedJournal($augumentedJournal);
$groupArray = [
'id' => (int)$augumentedJournal->transaction_group_id,
'id' => (int) $augumentedJournal->transaction_group_id,
'user_id' => $augumentedJournal->user_id,
'user_group_id' => $augumentedJournal->user_group_id,
// Field transaction_group_title was added by the query.
@@ -522,7 +522,7 @@ class GroupCollector implements GroupCollectorInterface
'transactions' => [],
];
// Field transaction_journal_id was added by the query.
$journalId = (int)$augumentedJournal->transaction_journal_id; // @phpstan-ignore-line
$journalId = (int) $augumentedJournal->transaction_journal_id; // @phpstan-ignore-line
$groupArray['transactions'][$journalId] = $parsedGroup;
$groups[$groupId] = $groupArray;
@@ -530,7 +530,7 @@ class GroupCollector implements GroupCollectorInterface
}
// or parse the rest.
// Field transaction_journal_id was added by the query.
$journalId = (int)$augumentedJournal->transaction_journal_id; // @phpstan-ignore-line
$journalId = (int) $augumentedJournal->transaction_journal_id; // @phpstan-ignore-line
if (array_key_exists($journalId, $groups[$groupId]['transactions'])) {
// append data to existing group + journal (for multiple tags or multiple attachments)
$groups[$groupId]['transactions'][$journalId] = $this->mergeTags($groups[$groupId]['transactions'][$journalId], $augumentedJournal);
@@ -583,7 +583,7 @@ class GroupCollector implements GroupCollectorInterface
$dates = ['interest_date', 'payment_date', 'invoice_date', 'book_date', 'due_date', 'process_date'];
if (array_key_exists('meta_name', $result) && in_array($result['meta_name'], $dates, true)) {
$name = $result['meta_name'];
if (array_key_exists('meta_data', $result) && '' !== (string)$result['meta_data']) {
if (array_key_exists('meta_data', $result) && '' !== (string) $result['meta_data']) {
$result[$name] = Carbon::createFromFormat('!Y-m-d', substr(json_decode($result['meta_data']), 0, 10));
}
}
@@ -594,9 +594,9 @@ class GroupCollector implements GroupCollectorInterface
// convert back to strings because SQLite is dumb like that.
$result = $this->convertToStrings($result);
$result['reconciled'] = 1 === (int)$result['reconciled'];
$result['reconciled'] = 1 === (int) $result['reconciled'];
if (array_key_exists('tag_id', $result) && null !== $result['tag_id']) { // assume the other fields are present as well.
$tagId = (int)$augumentedJournal['tag_id'];
$tagId = (int) $augumentedJournal['tag_id'];
$tagDate = null;
try {
@@ -606,7 +606,7 @@ class GroupCollector implements GroupCollectorInterface
}
$result['tags'][$tagId] = [
'id' => (int)$result['tag_id'],
'id' => (int) $result['tag_id'],
'name' => $result['tag_name'],
'date' => $tagDate,
'description' => $result['tag_description'],
@@ -615,8 +615,8 @@ class GroupCollector implements GroupCollectorInterface
// also merge attachments:
if (array_key_exists('attachment_id', $result)) {
$uploaded = 1 === (int)$result['attachment_uploaded'];
$attachmentId = (int)$augumentedJournal['attachment_id'];
$uploaded = 1 === (int) $result['attachment_uploaded'];
$attachmentId = (int) $augumentedJournal['attachment_id'];
if (0 !== $attachmentId && $uploaded) {
$result['attachments'][$attachmentId] = [
'id' => $attachmentId,
@@ -642,7 +642,7 @@ class GroupCollector implements GroupCollectorInterface
private function convertToInteger(array $array): array
{
foreach ($this->integerFields as $field) {
$array[$field] = array_key_exists($field, $array) ? (int)$array[$field] : null;
$array[$field] = array_key_exists($field, $array) ? (int) $array[$field] : null;
}
return $array;
@@ -651,7 +651,7 @@ class GroupCollector implements GroupCollectorInterface
private function convertToStrings(array $array): array
{
foreach ($this->stringFields as $field) {
$array[$field] = array_key_exists($field, $array) && null !== $array[$field] ? (string)$array[$field] : null;
$array[$field] = array_key_exists($field, $array) && null !== $array[$field] ? (string) $array[$field] : null;
}
return $array;
@@ -661,7 +661,7 @@ class GroupCollector implements GroupCollectorInterface
{
$newArray = $newJournal->toArray();
if (array_key_exists('tag_id', $newArray)) { // assume the other fields are present as well.
$tagId = (int)$newJournal['tag_id'];
$tagId = (int) $newJournal['tag_id'];
$tagDate = null;
@@ -672,7 +672,7 @@ class GroupCollector implements GroupCollectorInterface
}
$existingJournal['tags'][$tagId] = [
'id' => (int)$newArray['tag_id'],
'id' => (int) $newArray['tag_id'],
'name' => $newArray['tag_name'],
'date' => $tagDate,
'description' => $newArray['tag_description'],
@@ -686,7 +686,7 @@ class GroupCollector implements GroupCollectorInterface
{
$newArray = $newJournal->toArray();
if (array_key_exists('attachment_id', $newArray)) {
$attachmentId = (int)$newJournal['attachment_id'];
$attachmentId = (int) $newJournal['attachment_id'];
$existingJournal['attachments'][$attachmentId] = [
'id' => $attachmentId,
@@ -705,7 +705,7 @@ class GroupCollector implements GroupCollectorInterface
foreach ($groups as $groudId => $group) {
/** @var array $transaction */
foreach ($group['transactions'] as $transaction) {
$currencyId = (int)$transaction['currency_id'];
$currencyId = (int) $transaction['currency_id'];
if (null === $transaction['amount']) {
throw new FireflyException(sprintf('Amount is NULL for a transaction in group #%d, please investigate.', $groudId));
}
@@ -721,7 +721,7 @@ class GroupCollector implements GroupCollectorInterface
$groups[$groudId]['sums'][$currencyId]['amount'] = bcadd($groups[$groudId]['sums'][$currencyId]['amount'], $transaction['amount']);
if (null !== $transaction['foreign_amount'] && null !== $transaction['foreign_currency_id']) {
$currencyId = (int)$transaction['foreign_currency_id'];
$currencyId = (int) $transaction['foreign_currency_id'];
// set default:
if (!array_key_exists($currencyId, $groups[$groudId]['sums'])) {

View File

@@ -38,7 +38,7 @@ class FiscalHelper implements FiscalHelperInterface
*/
public function __construct()
{
$this->useCustomFiscalYear = (bool)app('preferences')->get('customFiscalYear', false)->data;
$this->useCustomFiscalYear = (bool) app('preferences')->get('customFiscalYear', false)->data;
}
/**
@@ -73,9 +73,9 @@ class FiscalHelper implements FiscalHelperInterface
if (is_array($prefStartStr)) {
$prefStartStr = '01-01';
}
$prefStartStr = (string)$prefStartStr;
$prefStartStr = (string) $prefStartStr;
[$mth, $day] = explode('-', $prefStartStr);
$startDate->day((int)$day)->month((int)$mth);
$startDate->day((int) $day)->month((int) $mth);
// if start date is after passed date, sub 1 year.
if ($startDate > $date) {

View File

@@ -122,12 +122,12 @@ class NetWorth implements NetWorthInterface
$netWorth[$currencyCode] ??= [
'balance' => '0',
'native_balance' => '0',
'currency_id' => (string)$currency->id,
'currency_id' => (string) $currency->id,
'currency_code' => $currency->code,
'currency_name' => $currency->name,
'currency_symbol' => $currency->symbol,
'currency_decimal_places' => $currency->decimal_places,
'native_currency_id' => (string)$default->id,
'native_currency_id' => (string) $default->id,
'native_currency_code' => $default->code,
'native_currency_name' => $default->name,
'native_currency_symbol' => $default->symbol,
@@ -199,7 +199,7 @@ class NetWorth implements NetWorthInterface
}
$return[$currency->id] ??= [
'id' => (string)$currency->id,
'id' => (string) $currency->id,
'name' => $currency->name,
'symbol' => $currency->symbol,
'code' => $currency->code,
@@ -221,7 +221,7 @@ class NetWorth implements NetWorthInterface
/** @var Account $account */
foreach ($accounts as $account) {
if (1 === (int)$this->getRepository()->getMetaValue($account, 'include_net_worth')) {
if (1 === (int) $this->getRepository()->getMetaValue($account, 'include_net_worth')) {
$filtered->push($account);
}
}

View File

@@ -66,7 +66,7 @@ class PopupReport implements PopupReportInterface
if (null !== $currencyId) {
/** @var CurrencyRepositoryInterface $repos */
$repos = app(CurrencyRepositoryInterface::class);
$currency = $repos->find((int)$currencyId);
$currency = $repos->find((int) $currencyId);
}
/** @var GroupCollectorInterface $collector */
@@ -98,7 +98,7 @@ class PopupReport implements PopupReportInterface
if (null !== $currencyId) {
/** @var CurrencyRepositoryInterface $repos */
$repos = app(CurrencyRepositoryInterface::class);
$currency = $repos->find((int)$currencyId);
$currency = $repos->find((int) $currencyId);
}
/** @var GroupCollectorInterface $collector */
@@ -135,7 +135,7 @@ class PopupReport implements PopupReportInterface
if (null !== $currencyId) {
/** @var CurrencyRepositoryInterface $repos */
$repos = app(CurrencyRepositoryInterface::class);
$currency = $repos->find((int)$currencyId);
$currency = $repos->find((int) $currencyId);
}
/** @var GroupCollectorInterface $collector */
@@ -174,7 +174,7 @@ class PopupReport implements PopupReportInterface
if (null !== $currencyId) {
/** @var CurrencyRepositoryInterface $repos */
$repos = app(CurrencyRepositoryInterface::class);
$currency = $repos->find((int)$currencyId);
$currency = $repos->find((int) $currencyId);
}
/** @var JournalRepositoryInterface $repository */

View File

@@ -128,7 +128,7 @@ class ReportHelper implements ReportHelperInterface
$currentEnd = clone $start;
$currentEnd->endOfMonth();
$months[$year]['months'][] = [
'formatted' => $start->isoFormat((string)trans('config.month_js')),
'formatted' => $start->isoFormat((string) trans('config.month_js')),
'start' => $start->format('Y-m-d'),
'end' => $currentEnd->format('Y-m-d'),
'month' => $start->month,

View File

@@ -43,7 +43,7 @@ trait UpdateTrait
/** @var UpdateRequestInterface $checker */
$checker = app(UpdateRequestInterface::class);
$channelConfig = app('fireflyconfig')->get('update_channel', 'stable');
$channel = (string)$channelConfig->data;
$channel = (string) $channelConfig->data;
return $checker->getUpdateInformation($channel);
}