mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-07-28 00:09:56 -07:00
Fix phpstan issues by adding properties.
This commit is contained in:
@@ -38,7 +38,6 @@ parameters:
|
||||
- identifier: method.deprecated
|
||||
- identifier: cast.useless
|
||||
- identifier: argument.type
|
||||
- identifier: assign.propertyType
|
||||
# all errors below I will (probably) never fix.
|
||||
- identifier: property.unusedType # one false positive
|
||||
- identifier: varTag.nativeType # dont even know what im supposed to fix.
|
||||
@@ -54,9 +53,6 @@ parameters:
|
||||
# - '#expects view-string, string given#'
|
||||
# - "#Parameter \\#[1-2] \\$num[1-2] of function bc[a-z]+ expects numeric-string, [a-z\\-|&]+ given#"
|
||||
- identifier: missingType.generics # not interesting enough to fix.
|
||||
-
|
||||
identifier: larastan.noEnvCallsOutsideOfConfig
|
||||
path: ../app/Console/Commands/System/CreatesDatabase.php
|
||||
- identifier: missingType.iterableValue # not interesting enough to fix.
|
||||
- identifier: varTag.type # needs a custom extension for every repository, not gonna happen.
|
||||
# - '#Dynamic call to static method Illuminate#'
|
||||
|
||||
@@ -32,7 +32,7 @@ use RuntimeException;
|
||||
abstract class AggregateFormRequest extends ApiRequest
|
||||
{
|
||||
/**
|
||||
* @var ApiRequest[]
|
||||
* @var Request[]
|
||||
*/
|
||||
protected array $requests = [];
|
||||
|
||||
|
||||
@@ -54,10 +54,10 @@ class CreatesDatabase extends Command
|
||||
}
|
||||
// try to set up a raw connection:
|
||||
$exists = false;
|
||||
$dsn = sprintf('mysql:host=%s;port=%d;charset=utf8mb4', env('DB_HOST'), env('DB_PORT'));
|
||||
$dsn = sprintf('mysql:host=%s;port=%d;charset=utf8mb4',config('database.connections.mysql.host'), config('database.connections.mysql.port'));
|
||||
|
||||
if ('' !== (string) env('DB_SOCKET')) {
|
||||
$dsn = sprintf('mysql:unix_socket=%s;charset=utf8mb4', env('DB_SOCKET'));
|
||||
if ('' !== (string) config('database.connections.mysql.unix_socket')) {
|
||||
$dsn = sprintf('mysql:unix_socket=%s;charset=utf8mb4', config('database.connections.mysql.unix_socket'));
|
||||
}
|
||||
$this->friendlyLine(sprintf('DSN is %s', $dsn));
|
||||
|
||||
@@ -69,7 +69,7 @@ class CreatesDatabase extends Command
|
||||
|
||||
// when it fails, display error
|
||||
try {
|
||||
$pdo = new PDO($dsn, (string) env('DB_USERNAME'), (string) env('DB_PASSWORD'), $options);
|
||||
$pdo = new PDO($dsn, (string) config('database.connections.mysql.username'), (string) config('database.connections.mysql.password'), $options);
|
||||
} catch (PDOException $e) {
|
||||
$this->friendlyError(sprintf('Error when connecting to DB: %s', $e->getMessage()));
|
||||
|
||||
@@ -83,19 +83,19 @@ class CreatesDatabase extends Command
|
||||
// slightly more complex but less error-prone.
|
||||
foreach ($stmt as $row) {
|
||||
$name = $row['Database'] ?? false;
|
||||
if ($name === env('DB_DATABASE')) {
|
||||
if ($name === config('database.connections.mysql.database')) {
|
||||
$exists = true;
|
||||
}
|
||||
}
|
||||
if (false === $exists) {
|
||||
$this->friendlyError(sprintf('Database "%s" does not exist.', env('DB_DATABASE')));
|
||||
$this->friendlyError(sprintf('Database "%s" does not exist.', config('database.connections.mysql.database')));
|
||||
|
||||
// try to create it.
|
||||
$pdo->exec(sprintf('CREATE DATABASE `%s` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;', env('DB_DATABASE')));
|
||||
$this->friendlyInfo(sprintf('Created database "%s"', env('DB_DATABASE')));
|
||||
$pdo->exec(sprintf('CREATE DATABASE `%s` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;', config('database.connections.mysql.database')));
|
||||
$this->friendlyInfo(sprintf('Created database "%s"', config('database.connections.mysql.database')));
|
||||
}
|
||||
if ($exists) {
|
||||
$this->friendlyInfo(sprintf('Database "%s" exists.', env('DB_DATABASE')));
|
||||
$this->friendlyInfo(sprintf('Database "%s" exists.', config('database.connections.mysql.database')));
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -44,6 +44,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* @property AccountType $accountType
|
||||
* @property User $user
|
||||
*/
|
||||
#[ObservedBy([DeletedAccountObserver::class])]
|
||||
class Account extends Model
|
||||
|
||||
@@ -32,6 +32,9 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* @property TransactionCurrency $transactionCurrency
|
||||
*/
|
||||
#[ObservedBy([AutoBudgetObserver::class])]
|
||||
class AutoBudget extends Model
|
||||
{
|
||||
|
||||
@@ -35,6 +35,10 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* @property User $user
|
||||
* @property TransactionCurrency $transactionCurrency
|
||||
*/
|
||||
#[ObservedBy([AvailableBudgetObserver::class])]
|
||||
class AvailableBudget extends Model
|
||||
{
|
||||
@@ -42,36 +46,37 @@ class AvailableBudget extends Model
|
||||
use ReturnsIntegerUserIdTrait;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'user_group_id',
|
||||
'transaction_currency_id',
|
||||
'amount',
|
||||
'start_date',
|
||||
'end_date',
|
||||
'start_date_tz',
|
||||
'end_date_tz',
|
||||
'native_amount',
|
||||
];
|
||||
protected $fillable
|
||||
= [
|
||||
'user_id',
|
||||
'user_group_id',
|
||||
'transaction_currency_id',
|
||||
'amount',
|
||||
'start_date',
|
||||
'end_date',
|
||||
'start_date_tz',
|
||||
'end_date_tz',
|
||||
'native_amount',
|
||||
];
|
||||
|
||||
/**
|
||||
* Route binder. Converts the key in the URL to the specified object (or throw 404).
|
||||
*
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public static function routeBinder(self|string $value): self
|
||||
public static function routeBinder(self | string $value): self
|
||||
{
|
||||
if ($value instanceof self) {
|
||||
$value = (int) $value->id;
|
||||
$value = (int)$value->id;
|
||||
}
|
||||
if (auth()->check()) {
|
||||
$availableBudgetId = (int) $value;
|
||||
$availableBudgetId = (int)$value;
|
||||
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
$user = auth()->user();
|
||||
|
||||
/** @var null|AvailableBudget $availableBudget */
|
||||
$availableBudget = $user->availableBudgets()->find($availableBudgetId);
|
||||
$availableBudget = $user->availableBudgets()->find($availableBudgetId);
|
||||
if (null !== $availableBudget) {
|
||||
return $availableBudget;
|
||||
}
|
||||
@@ -92,7 +97,7 @@ class AvailableBudget extends Model
|
||||
|
||||
protected function amount(): Attribute
|
||||
{
|
||||
return Attribute::make(get: static fn ($value): string => (string) $value);
|
||||
return Attribute::make(get: static fn($value): string => (string)$value);
|
||||
}
|
||||
|
||||
protected function casts(): array
|
||||
@@ -114,21 +119,21 @@ class AvailableBudget extends Model
|
||||
protected function endDate(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn (string $value): Carbon => Carbon::parse($value),
|
||||
set: static fn (Carbon $value): string => $value->format('Y-m-d')
|
||||
get: static fn(string $value): Carbon => Carbon::parse($value),
|
||||
set: static fn(Carbon $value): string => $value->format('Y-m-d')
|
||||
);
|
||||
}
|
||||
|
||||
protected function startDate(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn (string $value): Carbon => Carbon::parse($value),
|
||||
set: static fn (Carbon $value): string => $value->format('Y-m-d')
|
||||
get: static fn(string $value): Carbon => Carbon::parse($value),
|
||||
set: static fn(Carbon $value): string => $value->format('Y-m-d')
|
||||
);
|
||||
}
|
||||
|
||||
protected function transactionCurrencyId(): Attribute
|
||||
{
|
||||
return Attribute::make(get: static fn ($value): int => (int) $value);
|
||||
return Attribute::make(get: static fn($value): int => (int)$value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @property Carbon $date
|
||||
* @property null|Carbon $end_date
|
||||
* @property null|Carbon $extension_date
|
||||
* @property User $user
|
||||
* @property TransactionCurrency $transactionCurrency
|
||||
*/
|
||||
#[ObservedBy([BillObserver::class])]
|
||||
class Bill extends Model
|
||||
|
||||
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Casts\SeparateTimezoneCaster;
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;
|
||||
@@ -32,6 +33,9 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* @property Carbon $expires
|
||||
*/
|
||||
class InvitedUser extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
|
||||
@@ -15,6 +15,7 @@ use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
/**
|
||||
* @property Carbon $start
|
||||
* @property Carbon $end
|
||||
* @property string $amount
|
||||
*/
|
||||
class PeriodStatistic extends Model
|
||||
{
|
||||
|
||||
@@ -40,6 +40,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
/**
|
||||
* @property null|Carbon $target_date
|
||||
* @property null|Carbon $start_date
|
||||
* @property TransactionCurrency $transactionCurrency
|
||||
*/
|
||||
#[ObservedBy([PiggyBankObserver::class])]
|
||||
class PiggyBank extends Model
|
||||
|
||||
@@ -43,6 +43,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @property null|Carbon $first_date
|
||||
* @property null|Carbon $latest_date
|
||||
* @property null|Carbon $repeat_until
|
||||
* @property User $user
|
||||
*/
|
||||
#[ObservedBy([DeletedRecurrenceObserver::class])]
|
||||
class Recurrence extends Model
|
||||
|
||||
@@ -35,6 +35,13 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* @property Account|null $account
|
||||
* @property TransactionCurrency $transactionCurrency
|
||||
* @property TransactionCurrency|null $foreignCurrency
|
||||
* @property string|null $balance_before
|
||||
* @property string|null $balance_after
|
||||
*/
|
||||
#[ObservedBy([TransactionObserver::class])]
|
||||
class Transaction extends Model
|
||||
{
|
||||
|
||||
@@ -34,6 +34,9 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* @property array|string $message
|
||||
*/
|
||||
#[ObservedBy([DeletedWebhookMessageObserver::class])]
|
||||
class WebhookMessage extends Model
|
||||
{
|
||||
|
||||
@@ -75,6 +75,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* @property UserGroup|null $userGroup
|
||||
* @property bool $blocked
|
||||
*/
|
||||
class User extends Authenticatable
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user