Fix various code things.

This commit is contained in:
James Cole
2023-11-04 19:20:07 +01:00
parent e51fef3037
commit 688f50ee3f
16 changed files with 32 additions and 28 deletions

View File

@@ -1836,5 +1836,5 @@
"prefer-lowest": false, "prefer-lowest": false,
"platform": [], "platform": [],
"platform-dev": [], "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 $first_date
* @property Carbon|null $repeat_until * @property Carbon|null $repeat_until
* @property Carbon|null $latest_date * @property Carbon|null $latest_date
* @property int $repetitions * @property int|string $repetitions
* @property bool $apply_rules * @property bool $apply_rules
* @property bool $active * @property bool $active
* @property-read Collection|Attachment[] $attachments * @property-read Collection|Attachment[] $attachments

View File

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

View File

@@ -42,7 +42,7 @@ use Carbon\Carbon;
* @property Carbon|null $deleted_at * @property Carbon|null $deleted_at
* @property int|string $recurrence_id * @property int|string $recurrence_id
* @property int|string $transaction_currency_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 $source_id
* @property int|string $destination_id * @property int|string $destination_id
* @property string|float $amount * @property string|float $amount

View File

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

View File

@@ -79,6 +79,9 @@ class TransactionCurrency extends Model
{ {
use SoftDeletes; use SoftDeletes;
public bool $userEnabled;
public bool $userDefault;
/** /**
* The attributes that should be casted to native types. * The attributes that should be casted to native types.
* *

View File

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

View File

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

View File

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

View File

@@ -355,7 +355,7 @@ trait ConvertsDataTypes
foreach ($fields as $field => $info) { foreach ($fields as $field => $info) {
if ($this->has($info[0])) { if ($this->has($info[0])) {
$method = $info[1]; $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; $result = null;
try { 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) { } catch (InvalidFormatException $e) {
// @ignoreException // @ignoreException
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -57,7 +57,7 @@ return [
'app_id' => env('PUSHER_APP_ID'), 'app_id' => env('PUSHER_APP_ID'),
'options' => [ 'options' => [
'cluster' => env('PUSHER_APP_CLUSTER'), '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), 'port' => env('PUSHER_PORT', 443),
'scheme' => env('PUSHER_SCHEME', 'https'), 'scheme' => env('PUSHER_SCHEME', 'https'),
'encrypted' => true, 'encrypted' => true,