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

@@ -31,5 +31,4 @@ namespace FireflyIII\Validation\Account;
*/
trait AccountValidatorProperties
{
}

View File

@@ -153,7 +153,7 @@ trait DepositValidation
$result = true;
// set the source to be a (dummy) revenue account.
$account = new Account;
$account = new Account();
$accountType = AccountType::whereType(AccountType::REVENUE)->first();
$account->accountType = $accountType;
$this->source = $account;

View File

@@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Validation\Account;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
use Log;
@@ -34,7 +33,6 @@ use Log;
*/
trait LiabilityValidation
{
/**
* @param array $array
*
@@ -89,7 +87,7 @@ trait LiabilityValidation
}
if (true === $result) {
// set the source to be a (dummy) revenue account.
$account = new Account;
$account = new Account();
$accountType = AccountType::whereType(AccountType::LIABILITY_CREDIT)->first();
$account->accountType = $accountType;
$this->source = $account;
@@ -97,5 +95,4 @@ trait LiabilityValidation
return $result;
}
}

View File

@@ -139,7 +139,7 @@ trait OBValidation
$result = true;
// set the source to be a (dummy) initial balance account.
$account = new Account;
$account = new Account();
$accountType = AccountType::whereType(AccountType::INITIAL_BALANCE)->first();
$account->accountType = $accountType;
$this->source = $account;

View File

@@ -86,7 +86,7 @@ trait ReconciliationValidation
// source to the asset account that is the destination.
if (null === $accountId && null === $accountName) {
Log::debug('The source is valid because ID and name are NULL.');
$this->source = new Account;
$this->source = new Account();
return true;
}
@@ -107,5 +107,4 @@ trait ReconciliationValidation
return true;
}
}

View File

@@ -42,7 +42,13 @@ use Log;
*/
class AccountValidator
{
use AccountValidatorProperties, WithdrawalValidation, DepositValidation, TransferValidation, ReconciliationValidation, OBValidation, LiabilityValidation;
use AccountValidatorProperties;
use WithdrawalValidation;
use DepositValidation;
use TransferValidation;
use ReconciliationValidation;
use OBValidation;
use LiabilityValidation;
public bool $createMode;
public string $destError;
@@ -258,5 +264,4 @@ class AccountValidator
return null;
}
}

View File

@@ -73,5 +73,4 @@ trait ValidatesBulkTransactionQuery
}
}
}
}

View File

@@ -67,7 +67,7 @@ trait ValidatesAutoBudgetRequest
$validator->errors()->add('auto_budget_amount', (string) trans('validation.require_currency_info'));
}
// too big amount
if((int)$amount > 268435456) {
if ((int)$amount > 268435456) {
$validator->errors()->add('auto_budget_amount', (string) trans('validation.amount_required_for_auto_budget'));
return;
}

View File

@@ -49,7 +49,8 @@ trait CurrencyValidation
if (array_key_exists('foreign_amount', $transaction)
&& !(array_key_exists('foreign_currency_id', $transaction)
|| array_key_exists(
'foreign_currency_code', $transaction
'foreign_currency_code',
$transaction
))
&& 0 !== bccomp('0', $transaction['foreign_amount'])
) {
@@ -61,7 +62,8 @@ trait CurrencyValidation
// if the currency is present, then the amount must be present as well.
if ((array_key_exists('foreign_currency_id', $transaction) || array_key_exists('foreign_currency_code', $transaction))
&& !array_key_exists(
'foreign_amount', $transaction
'foreign_amount',
$transaction
)) {
$validator->errors()->add(
'transactions.' . $index . '.foreign_amount',

View File

@@ -47,6 +47,7 @@ use PragmaRX\Google2FA\Exceptions\IncompatibleWithGoogleAuthenticatorException;
use PragmaRX\Google2FA\Exceptions\InvalidCharactersException;
use PragmaRX\Google2FA\Exceptions\SecretKeyTooShortException;
use ValueError;
use function is_string;
/**
@@ -54,7 +55,6 @@ use function is_string;
*/
class FireflyValidator extends Validator
{
/**
* @param mixed $attribute
* @param mixed $value
@@ -364,7 +364,7 @@ class FireflyValidator extends Validator
}
// check if it's an existing account.
if (in_array($triggerType, ['destination_account_id', 'source_account_id'])) {
if (in_array($triggerType, ['destination_account_id', 'source_account_id'], true)) {
return is_numeric($value) && (int) $value > 0;
}
@@ -382,7 +382,6 @@ class FireflyValidator extends Validator
try {
$parser->parseDate($value);
} catch (FireflyException $e) {
Log::error($e->getMessage());
return false;
@@ -390,7 +389,6 @@ class FireflyValidator extends Validator
}
return true;
}
/**
@@ -424,7 +422,6 @@ class FireflyValidator extends Validator
*/
public function validateUniqueAccountForUser($attribute, $value, $parameters): bool
{
// because a user does not have to be logged in (tests and what-not).
if (!auth()->check()) {
return $this->validateAccountAnonymously();
@@ -501,7 +498,6 @@ class FireflyValidator extends Validator
);
return null === $result;
}
/**
@@ -812,7 +808,6 @@ class FireflyValidator extends Validator
public function validateUniqueWebhook($value, $parameters): bool
{
if (auth()->check()) {
$triggers = Webhook::getTriggersForValidation();
$responses = Webhook::getResponsesForValidation();
$deliveries = Webhook::getDeliveriesForValidation();

View File

@@ -35,7 +35,6 @@ use Log;
*/
trait GroupValidation
{
/**
* @param Validator $validator
*
@@ -62,10 +61,12 @@ trait GroupValidation
// set errors:
if (false === $hasAccountInfo && !$hasJournalId) {
$validator->errors()->add(
sprintf('transactions.%d.source_id', $index), (string) trans('validation.generic_no_source')
sprintf('transactions.%d.source_id', $index),
(string) trans('validation.generic_no_source')
);
$validator->errors()->add(
sprintf('transactions.%d.destination_id', $index), (string) trans('validation.generic_no_destination')
sprintf('transactions.%d.destination_id', $index),
(string) trans('validation.generic_no_destination')
);
}
}
@@ -93,7 +94,8 @@ trait GroupValidation
// no valid descriptions?
if (0 === $validDescriptions) {
$validator->errors()->add(
'transactions.0.description', (string) trans('validation.filled', ['attribute' => (string) trans('validation.attributes.description')])
'transactions.0.description',
(string) trans('validation.filled', ['attribute' => (string) trans('validation.attributes.description')])
);
}
}