DX: apply rector rules up to php8.0

This commit is contained in:
2023-04-15 01:05:37 +02:00
parent d8870e906f
commit dde3002100
714 changed files with 2348 additions and 9263 deletions

View File

@@ -49,12 +49,6 @@ use function uniqid;
class ReportList implements ExportElementValidatedInterface, ListInterface
{
protected CustomFieldProvider $customFieldProvider;
protected CustomFieldsGroup $customfieldsGroup;
protected EntityManagerInterface $em;
protected array $fields = [
'person_id', 'person_firstName', 'person_lastName', 'person_birthdate',
'person_placeOfBirth', 'person_gender', 'person_memo', 'person_email', 'person_phonenumber',
@@ -66,22 +60,8 @@ class ReportList implements ExportElementValidatedInterface, ListInterface
protected array $slugs = [];
protected TranslatableStringHelper $translatableStringHelper;
protected TranslatorInterface $translator;
public function __construct(
CustomFieldsGroup $customfieldsGroup,
TranslatableStringHelper $translatableStringHelper,
TranslatorInterface $translator,
CustomFieldProvider $customFieldProvider,
EntityManagerInterface $em
) {
$this->customfieldsGroup = $customfieldsGroup;
$this->translatableStringHelper = $translatableStringHelper;
$this->translator = $translator;
$this->customFieldProvider = $customFieldProvider;
$this->em = $em;
public function __construct(protected CustomFieldsGroup $customfieldsGroup, protected TranslatableStringHelper $translatableStringHelper, protected TranslatorInterface $translator, protected CustomFieldProvider $customFieldProvider, protected EntityManagerInterface $em)
{
}
public function buildForm(FormBuilderInterface $builder)
@@ -102,26 +82,19 @@ class ReportList implements ExportElementValidatedInterface, ListInterface
'label' => 'Fields to include in export',
'choice_attr' => static function ($val, $key, $index) {
// add a 'data-display-target' for address fields
if (substr($val, 0, 8) === 'address_') {
if (str_starts_with($val, 'address_')) {
return ['data-display-target' => 'address_date'];
}
return [];
},
'choice_label' => function (string $key, string $label): string {
switch (substr($key, 0, 7)) {
case 'person_':
return $this->translator->trans(substr($key, 7, strlen($key) - 7)) .
' (' . $this->translator->trans('Person') . ')';
case 'report_':
return $this->translator->trans(ucfirst(substr($key, 7, strlen($key) - 7))) .
' (' . $this->translator->trans('Report') . ')';
default:
return $label .
' (' . $this->translator->trans("Report's question") . ')';
}
'choice_label' => fn (string $key, string $label): string => match (substr($key, 0, 7)) {
'person_' => $this->translator->trans(substr($key, 7, strlen($key) - 7)) .
' (' . $this->translator->trans('Person') . ')',
'report_' => $this->translator->trans(ucfirst(substr($key, 7, strlen($key) - 7))) .
' (' . $this->translator->trans('Report') . ')',
default => $label .
' (' . $this->translator->trans("Report's question") . ')',
},
'constraints' => [new Callback([
'callback' => static function ($selected, ExecutionContextInterface $context) {
@@ -391,21 +364,13 @@ class ReportList implements ExportElementValidatedInterface, ListInterface
$prefix = substr($f, 0, 7);
$suffix = substr($f, 7);
switch ($prefix) {
case 'person_':
$qb->addSelect(sprintf('person.%s as %s', $suffix, $f));
break;
case 'report_':
$qb->addSelect(sprintf('report.%s as %s', $suffix, $f));
break;
default:
throw new LogicException("this prefix {$prefix} should "
. "not be encountered. Full field: {$f}");
}
match ($prefix) {
'person_' => $qb->addSelect(sprintf('person.%s as %s', $suffix, $f)),
'report_' => $qb->addSelect(sprintf('report.%s as %s', $suffix, $f)),
// no break
default => throw new LogicException("this prefix {$prefix} should "
. "not be encountered. Full field: {$f}"),
};
}
}
@@ -470,7 +435,7 @@ class ReportList implements ExportElementValidatedInterface, ListInterface
// get the field starting with address_
$addressFields = array_filter(
$this->fields,
static fn (string $el): bool => substr($el, 0, 8) === 'address_'
static fn (string $el): bool => str_starts_with($el, 'address_')
);
// check if there is one field starting with address in data

View File

@@ -19,12 +19,8 @@ use Doctrine\ORM\Query\Expr;
class ReportDateFilter implements FilterInterface
{
private RollingDateConverterInterface $rollingDateConverter;
public function __construct(
RollingDateConverterInterface $rollingDateConverter
) {
$this->rollingDateConverter = $rollingDateConverter;
public function __construct(private RollingDateConverterInterface $rollingDateConverter)
{
}
public function addRole(): ?string