Fix a lot of phpstan things

This commit is contained in:
James Cole
2023-11-26 12:10:42 +01:00
parent a6c355c7b8
commit 68f01d932e
53 changed files with 214 additions and 120 deletions

View File

@@ -25,7 +25,9 @@ namespace FireflyIII\Models;
use Carbon\Carbon;
use Eloquent;
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
@@ -33,7 +35,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\Builder;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
/**
* FireflyIII\Models\TransactionCurrency
*
@@ -47,7 +49,7 @@ use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
* @property string $code
* @property string $name
* @property string $symbol
* @property int|string $decimal_places
* @property int $decimal_places
* @property-read Collection|BudgetLimit[] $budgetLimits
* @property-read int|null $budget_limits_count
* @property-read Collection|TransactionJournal[] $transactionJournals
@@ -82,7 +84,7 @@ class TransactionCurrency extends Model
public ?bool $userDefault;
public ?bool $userEnabled;
protected $casts
protected $casts
= [
'created_at' => 'datetime',
'updated_at' => 'datetime',
@@ -170,4 +172,14 @@ class TransactionCurrency extends Model
{
return $this->belongsToMany(User::class)->withTimestamps()->withPivot('user_default');
}
/**
* @return Attribute
*/
protected function decimalPlaces(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
);
}
}