Fix various code things.

This commit is contained in:
James Cole 2023-11-04 19:20:07 +01:00
parent e51fef3037
commit 688f50ee3f
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80
16 changed files with 32 additions and 28 deletions

View File

@ -1836,5 +1836,5 @@
"prefer-lowest": false,
"platform": [],
"platform-dev": [],
"plugin-api-version": "2.3.0"
"plugin-api-version": "2.6.0"
}

View File

@ -49,7 +49,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @property Carbon|null $first_date
* @property Carbon|null $repeat_until
* @property Carbon|null $latest_date
* @property int $repetitions
* @property int|string $repetitions
* @property bool $apply_rules
* @property bool $active
* @property-read Collection|Attachment[] $attachments

View File

@ -40,8 +40,8 @@ use Carbon\Carbon;
* @property int|string $recurrence_id
* @property string $repetition_type
* @property string $repetition_moment
* @property int $repetition_skip
* @property int $weekend
* @property int|string $repetition_skip
* @property int|string $weekend
* @property-read Recurrence $recurrence
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceRepetition newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceRepetition newQuery()

View File

@ -42,7 +42,7 @@ use Carbon\Carbon;
* @property Carbon|null $deleted_at
* @property int|string $recurrence_id
* @property int|string $transaction_currency_id
* @property int|null $foreign_currency_id
* @property int|string|null $foreign_currency_id
* @property int|string $source_id
* @property int|string $destination_id
* @property string|float $amount

View File

@ -42,7 +42,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
* @property int|string $user_id
* @property string $title
* @property string|null $title
* @property string|null $description
* @property int $order
* @property bool $active

View File

@ -37,7 +37,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* FireflyIII\Models\TransactionCurrency
*
* @property int|string $id
* @property int|string $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
@ -47,7 +47,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @property string $code
* @property string $name
* @property string $symbol
* @property int|string $decimal_places
* @property int|string $decimal_places
* @property-read Collection|BudgetLimit[] $budgetLimits
* @property-read int|null $budget_limits_count
* @property-read Collection|TransactionJournal[] $transactionJournals
@ -79,6 +79,9 @@ class TransactionCurrency extends Model
{
use SoftDeletes;
public bool $userEnabled;
public bool $userDefault;
/**
* The attributes that should be casted to native types.
*

View File

@ -36,7 +36,7 @@ use Carbon\Carbon;
* @property int|string $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property int $transaction_journal_id
* @property int|string $transaction_journal_id
* @property string $name
* @property mixed $data
* @property string $hash

View File

@ -40,7 +40,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @property Carbon|null $updated_at
* @property string|null $deleted_at
* @property int|string $webhook_message_id
* @property int $status_code
* @property int|string $status_code
* @property string|null $logs
* @property string|null $response
* @property-read WebhookMessage $webhookMessage

View File

@ -57,8 +57,8 @@ class CurrencyUpdateService
if (array_key_exists('decimal_places', $data) && is_int($data['decimal_places'])) {
$currency->decimal_places = (int)$data['decimal_places'];
}
unset($currency->userEnabled);
unset($currency->userDefault);
$currency->userEnabled = null;
$currency->userDefault = null;
$currency->save();
return $currency;

View File

@ -355,7 +355,7 @@ trait ConvertsDataTypes
foreach ($fields as $field => $info) {
if ($this->has($info[0])) {
$method = $info[1];
$return[$field] = $this->$method($info[0]);
$return[$field] = $this->$method($info[0]); // @phpstan-ignore-line
}
}
@ -383,7 +383,7 @@ trait ConvertsDataTypes
{
$result = null;
try {
$result = $this->get($field) ? new Carbon($this->get($field), config('app.timezone')) : null;
$result = '' !== (string) $this->get($field) ? new Carbon((string)$this->get($field), config('app.timezone')) : null;
} catch (InvalidFormatException $e) {
// @ignoreException
}

View File

@ -920,7 +920,7 @@ class OperatorQuerySearch implements SearchInterface
case 'amount_is':
// strip comma's, make dots.
app('log')->debug(sprintf('Original value "%s"', $value));
$value = str_replace(',', '.', (string)$value);
$value = str_replace(',', '.', $value);
$amount = app('steam')->positive($value);
app('log')->debug(sprintf('Set "%s" using collector with value "%s"', $operator, $amount));
$this->collector->amountIs($amount);
@ -928,7 +928,7 @@ class OperatorQuerySearch implements SearchInterface
case '-amount_is':
// strip comma's, make dots.
app('log')->debug(sprintf('Original value "%s"', $value));
$value = str_replace(',', '.', (string)$value);
$value = str_replace(',', '.', $value);
$amount = app('steam')->positive($value);
app('log')->debug(sprintf('Set "%s" using collector with value "%s"', $operator, $amount));
$this->collector->amountIsNot($amount);
@ -936,7 +936,7 @@ class OperatorQuerySearch implements SearchInterface
case 'foreign_amount_is':
// strip comma's, make dots.
$value = str_replace(',', '.', (string)$value);
$value = str_replace(',', '.', $value);
$amount = app('steam')->positive($value);
app('log')->debug(sprintf('Set "%s" using collector with value "%s"', $operator, $amount));
@ -945,7 +945,7 @@ class OperatorQuerySearch implements SearchInterface
case '-foreign_amount_is':
// strip comma's, make dots.
$value = str_replace(',', '.', (string)$value);
$value = str_replace(',', '.', $value);
$amount = app('steam')->positive($value);
app('log')->debug(sprintf('Set "%s" using collector with value "%s"', $operator, $amount));
@ -954,7 +954,7 @@ class OperatorQuerySearch implements SearchInterface
case '-amount_more':
case 'amount_less':
// strip comma's, make dots.
$value = str_replace(',', '.', (string)$value);
$value = str_replace(',', '.', $value);
$amount = app('steam')->positive($value);
app('log')->debug(sprintf('Set "%s" using collector with value "%s"', $operator, $amount));
@ -963,7 +963,7 @@ class OperatorQuerySearch implements SearchInterface
case '-foreign_amount_more':
case 'foreign_amount_less':
// strip comma's, make dots.
$value = str_replace(',', '.', (string)$value);
$value = str_replace(',', '.', $value);
$amount = app('steam')->positive($value);
app('log')->debug(sprintf('Set "%s" using collector with value "%s"', $operator, $amount));
@ -973,7 +973,7 @@ class OperatorQuerySearch implements SearchInterface
case 'amount_more':
app('log')->debug(sprintf('Now handling operator "%s"', $operator));
// strip comma's, make dots.
$value = str_replace(',', '.', (string)$value);
$value = str_replace(',', '.', $value);
$amount = app('steam')->positive($value);
app('log')->debug(sprintf('Set "%s" using collector with value "%s"', $operator, $amount));
$this->collector->amountMore($amount);
@ -982,7 +982,7 @@ class OperatorQuerySearch implements SearchInterface
case 'foreign_amount_more':
app('log')->debug(sprintf('Now handling operator "%s"', $operator));
// strip comma's, make dots.
$value = str_replace(',', '.', (string)$value);
$value = str_replace(',', '.', $value);
$amount = app('steam')->positive($value);
app('log')->debug(sprintf('Set "%s" using collector with value "%s"', $operator, $amount));
$this->collector->foreignAmountMore($amount);
@ -1492,7 +1492,7 @@ class OperatorQuerySearch implements SearchInterface
$filtered = $accounts->filter(
static function (Account $account) use ($value, $stringMethod) {
// either IBAN or account number
$ibanMatch = $stringMethod(strtolower((string)$account->iban), strtolower((string)$value));
$ibanMatch = $stringMethod(strtolower((string)$account->iban), strtolower($value));
$accountNrMatch = false;
/** @var AccountMeta $meta */
foreach ($account->accountMeta as $meta) {
@ -1561,7 +1561,7 @@ class OperatorQuerySearch implements SearchInterface
app('log')->debug(sprintf('Could not parse date "%s", will return empty array.', $value));
$this->invalidOperators[] = [
'type' => $type,
'value' => (string)$value,
'value' => $value,
];
return [];
}

View File

@ -253,7 +253,7 @@ class TransactionGroupTransformer extends AbstractTransformer
}
if (null !== $default) {
return (string)$default;
return $default;
}
return null;

View File

@ -80,6 +80,7 @@ class PiggyBankTransformer extends AbstractTransformer
$piggyBanks = $objects->pluck('id')->toArray();
$accountInfo = Account::whereIn('id', $objects->pluck('account_id')->toArray())->get();
$currencyPreferences = AccountMeta::where('name', '"currency_id"')->whereIn('account_id', $objects->pluck('account_id')->toArray())->get();
$currencies = [];
/** @var Account $account */
foreach ($accountInfo as $account) {
$id = (int)$account->id;

View File

@ -24,7 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Transformers;
use FireflyIII\Models\WebhookMessage;
use Jsonexception;
use JsonException;
/**
* Class WebhookMessageTransformer

View File

@ -541,7 +541,7 @@ class User extends Authenticatable
public function routeNotificationFor($driver, $notification = null)
{
if (method_exists($this, $method = 'routeNotificationFor' . Str::studly($driver))) {
return $this->{$method}($notification);
return $this->{$method}($notification); // @phpstan-ignore-line
}
$email = $this->email;
// see if user has alternative email address:

View File

@ -57,7 +57,7 @@ return [
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'cluster' => env('PUSHER_APP_CLUSTER'),
'host' => env('PUSHER_HOST') ?: 'api-' . env('PUSHER_APP_CLUSTER', 'mt1') . '.pusher.com',
'host' => null !== env('PUSHER_HOST') ? env('PUSHER_HOST') : 'api-' . env('PUSHER_APP_CLUSTER', 'mt1') . '.pusher.com',
'port' => env('PUSHER_PORT', 443),
'scheme' => env('PUSHER_SCHEME', 'https'),
'encrypted' => true,