Various code cleanup.

This commit is contained in:
James Cole
2021-05-24 08:50:17 +02:00
parent 3ec9753808
commit 815fd5ff6b
135 changed files with 643 additions and 582 deletions

View File

@@ -131,6 +131,7 @@ class AccountFactory
* @param array $data
*
* @return AccountType|null
* @throws FireflyException
*/
protected function getAccountType(array $data): ?AccountType
{
@@ -175,9 +176,11 @@ class AccountFactory
}
/**
* @param array $data
* @param AccountType $type
* @param array $data
*
* @return Account
* @throws \JsonException
*/
private function createAccount(AccountType $type, array $data): Account
{
@@ -244,6 +247,7 @@ class AccountFactory
* @param array $data
*
* @return array
* @throws \JsonException
*/
private function cleanMetaDataArray(Account $account, array $data): array
{

View File

@@ -46,7 +46,7 @@ class AttachmentFactory
public function create(array $data): ?Attachment
{
// append if necessary.
$model = false === strpos($data['attachable_type'], 'FireflyIII') ? sprintf('FireflyIII\\Models\\%s', $data['attachable_type'])
$model = !str_contains($data['attachable_type'], 'FireflyIII') ? sprintf('FireflyIII\\Models\\%s', $data['attachable_type'])
: $data['attachable_type'];
// get journal instead of transaction.

View File

@@ -19,8 +19,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/** @noinspection PhpDynamicAsStaticMethodCallInspection */
/** @noinspection PhpUndefinedMethodInspection */
/** @noinspection MultipleReturnStatementsInspection */
declare(strict_types=1);

View File

@@ -178,7 +178,7 @@ class TransactionFactory
}
/**
* @param TransactionCurrency $foreignCurrency |null
* @param TransactionCurrency|null $foreignCurrency |null
*
* @codeCoverageIgnore
*/

View File

@@ -56,6 +56,7 @@ class TransactionGroupFactory
*
* @return TransactionGroup
* @throws DuplicateTransactionException
* @throws FireflyException
*/
public function create(array $data): TransactionGroup
{

View File

@@ -146,6 +146,7 @@ class TransactionJournalFactory
* @return TransactionJournal|null
* @throws DuplicateTransactionException
* @throws FireflyException
* @throws \JsonException
*/
private function createJournal(NullArrayObject $row): ?TransactionJournal
{
@@ -294,16 +295,17 @@ class TransactionJournalFactory
* @param NullArrayObject $row
*
* @return string
* @throws \JsonException
*/
private function hashArray(NullArrayObject $row): string
{
$dataRow = $row->getArrayCopy();
unset($dataRow['import_hash_v2'], $dataRow['original_source']);
$json = json_encode($dataRow, JSON_THROW_ON_ERROR, 512);
$json = json_encode($dataRow, JSON_THROW_ON_ERROR);
if (false === $json) {
$json = json_encode((string)microtime(), JSON_THROW_ON_ERROR, 512);
$json = json_encode((string)microtime(), JSON_THROW_ON_ERROR);
Log::error(sprintf('Could not hash the original row! %s', json_last_error_msg()), $dataRow);
}
@@ -319,6 +321,7 @@ class TransactionJournalFactory
* @param string $hash
*
* @throws DuplicateTransactionException
* @throws \JsonException
*/
private function errorIfDuplicate(string $hash): void
{
@@ -417,7 +420,7 @@ class TransactionJournalFactory
/**
* Set foreign currency to NULL if it's the same as the normal currency:
*
* @param TransactionCurrency $currency
* @param TransactionCurrency|null $currency
* @param TransactionCurrency|null $foreignCurrency
*
* @return TransactionCurrency|null

View File

@@ -19,7 +19,6 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/** @noinspection PhpUndefinedMethodInspection */
declare(strict_types=1);