Use PSR-12 code style

This commit is contained in:
James Cole
2022-10-30 14:24:37 +01:00
parent f53923f16c
commit f52675068b
151 changed files with 251 additions and 403 deletions

View File

@@ -118,8 +118,8 @@ trait AccountServiceTrait
// remove currency_id if necessary.
$type = $account->accountType->type;
$list = config('firefly.valid_currency_account_types');
if(!in_array($type, $list, true)) {
$pos = array_search('currency_id', $fields);
if (!in_array($type, $list, true)) {
$pos = array_search('currency_id', $fields, true);
if ($pos !== false) {
unset($fields[$pos]);
}
@@ -147,7 +147,6 @@ trait AccountServiceTrait
// if the field is set but NULL, skip it.
// if the field is set but "", update it.
if (array_key_exists($field, $data) && null !== $data[$field]) {
// convert boolean value:
if (is_bool($data[$field]) && false === $data[$field]) {
$data[$field] = 0;
@@ -184,7 +183,7 @@ trait AccountServiceTrait
}
$dbNote = $account->notes()->first();
if (null === $dbNote) {
$dbNote = new Note;
$dbNote = new Note();
$dbNote->noteable()->associate($account);
}
$dbNote->text = trim($note);

View File

@@ -36,7 +36,6 @@ use Log;
*/
trait BillServiceTrait
{
/**
* @param Bill $bill
* @param string $oldName
@@ -90,5 +89,4 @@ trait BillServiceTrait
return true;
}
}

View File

@@ -22,10 +22,8 @@
declare(strict_types=1);
namespace FireflyIII\Services\Internal\Support;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Factory\AccountMetaFactory;
use FireflyIII\Models\Account;
@@ -110,11 +108,11 @@ class CreditRecalculateService
// destination or source must be liability.
$valid = config('firefly.valid_liabilities');
if (in_array($destination->accountType->type, $valid)) {
if (in_array($destination->accountType->type, $valid, true)) {
Log::debug(sprintf('Dest account type is "%s", include it.', $destination->accountType->type));
$this->work[] = $destination;
}
if (in_array($source->accountType->type, $valid)) {
if (in_array($source->accountType->type, $valid, true)) {
Log::debug(sprintf('Src account type is "%s", include it.', $source->accountType->type));
$this->work[] = $source;
}
@@ -170,7 +168,7 @@ class CreditRecalculateService
private function processAccount(): void
{
$valid = config('firefly.valid_liabilities');
if (in_array($this->account->accountType->type, $valid)) {
if (in_array($this->account->accountType->type, $valid, true)) {
Log::debug(sprintf('Account type is "%s", include it.', $this->account->accountType->type));
$this->work[] = $this->account;
}
@@ -290,6 +288,4 @@ class CreditRecalculateService
{
$this->group = $group;
}
}

View File

@@ -206,13 +206,13 @@ trait JournalServiceTrait
Log::debug(
sprintf(
'Was given %s account #%d ("%s") so will simply return that.',
$account->accountType->type, $account->id, $account->name
$account->accountType->type,
$account->id,
$account->name
)
);
}
if (null === $account) {
// final attempt, create it.
if (AccountType::ASSET === $preferredType) {
throw new FireflyException(sprintf('TransactionFactory: Cannot create asset account with these values: %s', json_encode($data)));
@@ -258,7 +258,6 @@ trait JournalServiceTrait
$metaFactory = app(AccountMetaFactory::class);
$metaFactory->create(['account_id' => $account->id, 'name' => 'account_number', 'data' => $data['number']]);
}
}
return $account;
@@ -385,7 +384,7 @@ trait JournalServiceTrait
$note = $journal->notes()->first();
if ('' !== $notes) {
if (null === $note) {
$note = new Note;
$note = new Note();
$note->noteable()->associate($journal);
}
$note->text = $notes;

View File

@@ -42,7 +42,7 @@ trait LocationServiceTrait
{
$data['store_location'] = $data['store_location'] ?? false;
if ($data['store_location']) {
$location = new Location;
$location = new Location();
$location->latitude = $data['latitude'] ?? config('firefly.default_location.latitude');
$location->longitude = $data['longitude'] ?? config('firefly.default_location.longitude');
$location->zoom_level = $data['zoom_level'] ?? config('firefly.default_location.zoom_level');
@@ -54,5 +54,4 @@ trait LocationServiceTrait
return null;
}
}

View File

@@ -97,7 +97,6 @@ trait RecurringTransactionTrait
'weekend' => $array['weekend'] ?? 1,
]
);
}
}
@@ -181,7 +180,6 @@ trait RecurringTransactionTrait
if (array_key_exists('tags', $array) && is_array($array['tags'])) {
$this->updateTags($transaction, $array['tags']);
}
}
}
@@ -226,11 +224,9 @@ trait RecurringTransactionTrait
if (!in_array($expectedType, $cannotCreate, true)) {
try {
$result = $factory->findOrCreate($accountName, $expectedType);
} catch (FireflyException $e) {
Log::error($e->getMessage());
}
}
}
@@ -252,7 +248,7 @@ trait RecurringTransactionTrait
$meta = $transaction->recurrenceTransactionMeta()->where('name', 'budget_id')->first();
if (null === $meta) {
$meta = new RecurrenceTransactionMeta;
$meta = new RecurrenceTransactionMeta();
$meta->rt_id = $transaction->id;
$meta->name = 'budget_id';
}
@@ -275,7 +271,7 @@ trait RecurringTransactionTrait
$meta = $transaction->recurrenceTransactionMeta()->where('name', 'bill_id')->first();
if (null === $meta) {
$meta = new RecurrenceTransactionMeta;
$meta = new RecurrenceTransactionMeta();
$meta->rt_id = $transaction->id;
$meta->name = 'bill_id';
}
@@ -304,7 +300,7 @@ trait RecurringTransactionTrait
$meta = $transaction->recurrenceTransactionMeta()->where('name', 'category_id')->first();
if (null === $meta) {
$meta = new RecurrenceTransactionMeta;
$meta = new RecurrenceTransactionMeta();
$meta->rt_id = $transaction->id;
$meta->name = 'category_id';
}