Various code cleanup and phpstan suggestions

This commit is contained in:
James Cole
2022-11-02 06:25:37 +01:00
parent 74610a5d55
commit 8d8f81c27d
45 changed files with 147 additions and 27 deletions

View File

@@ -153,7 +153,7 @@ class AccountFactory
// try with type:
if (null === $result) {
$types = config(sprintf('firefly.accountTypeByIdentifier.%s', $accountTypeName)) ?? [];
if (!empty($types)) {
if (0 !== count($types)) {
$result = AccountType::whereIn('type', $types)->first();
}
}

View File

@@ -24,9 +24,9 @@ declare(strict_types=1);
namespace FireflyIII\Factory;
use Exception;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountMeta;
use Illuminate\Database\QueryException;
use Log;
/**
@@ -64,7 +64,7 @@ class AccountMetaFactory
if ('' === $value && null !== $entry) {
try {
$entry->delete();
} catch (Exception $e) {
} catch (QueryException $e) {
Log::debug(sprintf('Could not delete entry: %s', $e->getMessage()));
}

View File

@@ -45,6 +45,7 @@ use FireflyIII\Services\Internal\Support\JournalServiceTrait;
use FireflyIII\Support\NullArrayObject;
use FireflyIII\User;
use FireflyIII\Validation\AccountValidator;
use Illuminate\Database\QueryException;
use Illuminate\Support\Collection;
use JsonException;
use Log;
@@ -108,7 +109,7 @@ class TransactionJournalFactory
Log::debug('Start of TransactionJournalFactory::create()');
$collection = new Collection();
$transactions = $dataObject['transactions'] ?? [];
if (empty($transactions)) {
if (0 === count($transactions)) {
Log::error('There are no transactions in the array, the TransactionJournalFactory cannot continue.');
return new Collection();
@@ -510,7 +511,7 @@ class TransactionJournalFactory
{
try {
$transaction->delete();
} catch (Exception $e) {
} catch (QueryException $e) {
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
Log::error('Could not delete negative transaction.');

View File

@@ -26,6 +26,7 @@ namespace FireflyIII\Factory;
use Carbon\Carbon;
use Exception;
use FireflyIII\Models\TransactionJournalMeta;
use Illuminate\Database\QueryException;
use Log;
/**
@@ -48,7 +49,7 @@ class TransactionJournalMetaFactory
//Log::debug('Value is empty, delete meta value.');
try {
$entry->delete();
} catch (Exception $e) {
} catch (QueryException $e) {
Log::error(sprintf('Could not delete transaction journal meta: %s', $e->getMessage()));
}
@@ -66,7 +67,7 @@ class TransactionJournalMetaFactory
Log::debug('Will not store empty strings, delete meta value');
try {
$entry->delete();
} catch (Exception $e) {
} catch (QueryException $e) {
Log::error(sprintf('Could not delete transaction journal meta: %s', $e->getMessage()));
}
}