DX: rector rules upt to PHP 74

This commit is contained in:
2023-04-15 00:20:19 +02:00
parent a68190f0c6
commit 858ade467c
213 changed files with 433 additions and 1052 deletions

View File

@@ -41,7 +41,7 @@ abstract class AbstractElement
/**
* @ORM\Column(name="comment", type="text", nullable=true)
*/
private ?string $comment;
private ?string $comment = null;
/**
* @ORM\Column(name="endDate", type="datetime_immutable", nullable=true)
@@ -50,7 +50,7 @@ abstract class AbstractElement
* message="The budget element's end date must be after the start date"
* )
*/
private ?DateTimeImmutable $endDate;
private ?DateTimeImmutable $endDate = null;
/**
* @ORM\ManyToOne(

View File

@@ -52,9 +52,7 @@ class ChargeType extends AbstractType
'label' => 'Charge type',
'required' => true,
'placeholder' => $this->translator->trans('admin.form.Choose the type of charge'),
'choice_label' => function (ChargeKind $resource) {
return $this->translatableStringHelper->localize($resource->getName());
},
'choice_label' => fn(ChargeKind $resource) => $this->translatableStringHelper->localize($resource->getName()),
'attr' => ['class' => 'select2'],
])
->add('amount', MoneyType::class)

View File

@@ -51,9 +51,7 @@ class ResourceType extends AbstractType
'label' => 'Resource type',
'required' => true,
'placeholder' => $this->translator->trans('admin.form.Choose the type of resource'),
'choice_label' => function (ResourceKind $resource) {
return $this->translatableStringHelper->localize($resource->getName());
},
'choice_label' => fn(ResourceKind $resource) => $this->translatableStringHelper->localize($resource->getName()),
'attr' => ['class' => 'select2'],
])
->add('amount', MoneyType::class)

View File

@@ -66,9 +66,7 @@ final class SummaryBudget implements SummaryBudgetInterface
];
}
$personIds = $household->getCurrentPersons()->map(static function (Person $p) {
return $p->getId();
});
$personIds = $household->getCurrentPersons()->map(static fn(Person $p) => $p->getId());
$ids = implode(', ', array_fill(0, count($personIds), '?'));
$parameters = [...$personIds, $household->getId()];
@@ -127,18 +125,14 @@ final class SummaryBudget implements SummaryBudgetInterface
{
$keys = array_map(static fn (ChargeKind $kind) => $kind->getKind(), $this->chargeKindRepository->findAll());
return array_combine($keys, array_map(function ($kind) {
return ['sum' => 0.0, 'label' => $this->translatableStringHelper->localize($this->chargeKindRepository->findOneByKind($kind)->getName()), 'comment' => ''];
}, $keys));
return array_combine($keys, array_map(fn($kind) => ['sum' => 0.0, 'label' => $this->translatableStringHelper->localize($this->chargeKindRepository->findOneByKind($kind)->getName()), 'comment' => ''], $keys));
}
private function getEmptyResourceArray(): array
{
$keys = array_map(static fn (ResourceKind $kind) => $kind->getKind(), $this->resourceKindRepository->findAll());
return array_combine($keys, array_map(function ($kind) {
return ['sum' => 0.0, 'label' => $this->translatableStringHelper->localize($this->resourceKindRepository->findOneByKind($kind)->getName()), 'comment' => ''];
}, $keys));
return array_combine($keys, array_map(fn($kind) => ['sum' => 0.0, 'label' => $this->translatableStringHelper->localize($this->resourceKindRepository->findOneByKind($kind)->getName()), 'comment' => ''], $keys));
}
private function rowToArray(array $rows, string $kind): array

View File

@@ -50,9 +50,7 @@ final class SummaryBudgetTest extends TestCase
],
]);
$queryCharges->setParameters(Argument::type('array'))
->will(static function ($args, $query) {
return $query;
});
->will(static fn($args, $query) => $query);
$queryResources = $this->prophesize(AbstractQuery::class);
$queryResources->getResult()->willReturn([
@@ -63,9 +61,7 @@ final class SummaryBudgetTest extends TestCase
],
]);
$queryResources->setParameters(Argument::type('array'))
->will(static function ($args, $query) {
return $query;
});
->will(static fn($args, $query) => $query);
$em = $this->prophesize(EntityManagerInterface::class);
$em->createNativeQuery(Argument::type('string'), Argument::type(Query\ResultSetMapping::class))
@@ -100,9 +96,7 @@ final class SummaryBudgetTest extends TestCase
$resourceRepository->findOneByKind('misc')->willReturn($misc);
$translatableStringHelper = $this->prophesize(TranslatableStringHelperInterface::class);
$translatableStringHelper->localize(Argument::type('array'))->will(static function ($arg) {
return $arg[0]['fr'];
});
$translatableStringHelper->localize(Argument::type('array'))->will(static fn($arg) => $arg[0]['fr']);
$person = new Person();
$personReflection = new ReflectionClass($person);