mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-18 18:44:16 +00:00
More PHP8.4 updates
This commit is contained in:
@@ -42,14 +42,11 @@ use Illuminate\Contracts\Validation\ValidationRule;
|
||||
*/
|
||||
class BelongsUserGroup implements ValidationRule
|
||||
{
|
||||
private UserGroup $userGroup;
|
||||
|
||||
/**
|
||||
* Create a new rule instance.
|
||||
*/
|
||||
public function __construct(UserGroup $userGroup)
|
||||
public function __construct(private readonly UserGroup $userGroup)
|
||||
{
|
||||
$this->userGroup = $userGroup;
|
||||
}
|
||||
|
||||
public function validate(string $attribute, mixed $value, \Closure $fail): void
|
||||
|
@@ -35,14 +35,10 @@ use Illuminate\Support\Facades\Log;
|
||||
class IsAllowedGroupAction implements ValidationRule
|
||||
{
|
||||
private array $acceptedRoles;
|
||||
private string $className;
|
||||
private string $methodName;
|
||||
private UserGroupRepositoryInterface $repository;
|
||||
private readonly UserGroupRepositoryInterface $repository;
|
||||
|
||||
public function __construct(string $className, string $methodName)
|
||||
public function __construct(private readonly string $className, private readonly string $methodName)
|
||||
{
|
||||
$this->className = $className;
|
||||
$this->methodName = $methodName;
|
||||
// you need these roles to do anything with any endpoint.
|
||||
$this->acceptedRoles = [UserRoleEnum::OWNER, UserRoleEnum::FULL];
|
||||
$this->repository = app(UserGroupRepositoryInterface::class);
|
||||
|
@@ -34,11 +34,8 @@ use Illuminate\Contracts\Validation\ValidationRule;
|
||||
*/
|
||||
class IsDefaultUserGroupName implements ValidationRule
|
||||
{
|
||||
private UserGroup $userGroup;
|
||||
|
||||
public function __construct(UserGroup $userGroup)
|
||||
public function __construct(private readonly UserGroup $userGroup)
|
||||
{
|
||||
$this->userGroup = $userGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -28,13 +28,8 @@ use Illuminate\Contracts\Validation\ValidationRule;
|
||||
|
||||
class IsFilterValueIn implements ValidationRule
|
||||
{
|
||||
private string $key;
|
||||
private array $values;
|
||||
|
||||
public function __construct(string $key, array $values)
|
||||
public function __construct(private readonly string $key, private readonly array $values)
|
||||
{
|
||||
$this->key = $key;
|
||||
$this->values = $values;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -47,7 +47,7 @@ use Illuminate\Contracts\Validation\ValidationRule;
|
||||
*/
|
||||
class IsValidAttachmentModel implements ValidationRule
|
||||
{
|
||||
private string $model;
|
||||
private readonly string $model;
|
||||
|
||||
/**
|
||||
* IsValidAttachmentModel constructor.
|
||||
|
@@ -64,7 +64,7 @@ class IsValidBulkClause implements ValidationRule
|
||||
{
|
||||
try {
|
||||
$array = \Safe\json_decode($value, true, 8, JSON_THROW_ON_ERROR);
|
||||
} catch (\JsonException $e) {
|
||||
} catch (\JsonException) {
|
||||
$this->error = (string) trans('validation.json');
|
||||
|
||||
return false;
|
||||
|
@@ -32,11 +32,9 @@ use Illuminate\Support\Facades\Log;
|
||||
class IsValidZeroOrMoreAmount implements ValidationRule
|
||||
{
|
||||
use ValidatesAmountsTrait;
|
||||
private bool $nullable = false;
|
||||
|
||||
public function __construct(bool $nullable = false)
|
||||
public function __construct(private bool $nullable = false)
|
||||
{
|
||||
$this->nullable = $nullable;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -34,27 +34,22 @@ use Illuminate\Contracts\Validation\ValidationRule;
|
||||
*/
|
||||
class UniqueAccountNumber implements ValidationRule
|
||||
{
|
||||
private ?Account $account;
|
||||
private ?string $expectedType;
|
||||
|
||||
/**
|
||||
* Create a new rule instance.
|
||||
*/
|
||||
public function __construct(?Account $account, ?string $expectedType)
|
||||
public function __construct(private readonly ?Account $account, private ?string $expectedType)
|
||||
{
|
||||
app('log')
|
||||
->debug('Constructed UniqueAccountNumber')
|
||||
;
|
||||
$this->account = $account;
|
||||
$this->expectedType = $expectedType;
|
||||
// a very basic fix to make sure we get the correct account type:
|
||||
if ('expense' === $expectedType) {
|
||||
if ('expense' === $this->expectedType) {
|
||||
$this->expectedType = AccountTypeEnum::EXPENSE->value;
|
||||
}
|
||||
if ('revenue' === $expectedType) {
|
||||
if ('revenue' === $this->expectedType) {
|
||||
$this->expectedType = AccountTypeEnum::REVENUE->value;
|
||||
}
|
||||
if ('asset' === $expectedType) {
|
||||
if ('asset' === $this->expectedType) {
|
||||
$this->expectedType = AccountTypeEnum::ASSET->value;
|
||||
}
|
||||
app('log')->debug(sprintf('Expected type is "%s"', $this->expectedType));
|
||||
|
@@ -34,15 +34,13 @@ use Illuminate\Contracts\Validation\ValidationRule;
|
||||
*/
|
||||
class UniqueIban implements ValidationRule
|
||||
{
|
||||
private ?Account $account;
|
||||
private array $expectedTypes;
|
||||
|
||||
/**
|
||||
* Create a new rule instance.
|
||||
*/
|
||||
public function __construct(?Account $account, ?string $expectedType)
|
||||
public function __construct(private readonly ?Account $account, ?string $expectedType)
|
||||
{
|
||||
$this->account = $account;
|
||||
$this->expectedTypes = [];
|
||||
if (null === $expectedType) {
|
||||
return;
|
||||
|
Reference in New Issue
Block a user