Upgrade changes from master to last rector rules

This commit is contained in:
Julien Fastré 2023-09-12 15:31:20 +02:00
parent 9375d50112
commit 899ed5d0a4
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
4 changed files with 80 additions and 124 deletions

View File

@ -35,7 +35,7 @@ class AsideActivity implements TrackCreationInterface, TrackUpdateInterface
/** /**
* @ORM\Column(type="datetime") * @ORM\Column(type="datetime")
*/ */
private $createdAt; private ?\DateTimeInterface $createdAt = null;
/** /**
* @ORM\ManyToOne(targetEntity=User::class) * @ORM\ManyToOne(targetEntity=User::class)
@ -46,7 +46,7 @@ class AsideActivity implements TrackCreationInterface, TrackUpdateInterface
/** /**
* @ORM\Column(type="datetime") * @ORM\Column(type="datetime")
*/ */
private $date; private ?\DateTimeInterface $date = null;
/** /**
* @ORM\Column(type="time", nullable=true) * @ORM\Column(type="time", nullable=true)
@ -69,18 +69,18 @@ class AsideActivity implements TrackCreationInterface, TrackUpdateInterface
/** /**
* @ORM\Column(type="text", nullable=true) * @ORM\Column(type="text", nullable=true)
*/ */
private $note; private ?string $note = null;
/** /**
* @ORM\ManyToOne(targetEntity=AsideActivityCategory::class, inversedBy="asideActivities") * @ORM\ManyToOne(targetEntity=AsideActivityCategory::class, inversedBy="asideActivities")
* @ORM\JoinColumn(nullable=false) * @ORM\JoinColumn(nullable=false)
*/ */
private $type; private ?\Chill\AsideActivityBundle\Entity\AsideActivityCategory $type = null;
/** /**
* @ORM\Column(type="datetime", nullable=true) * @ORM\Column(type="datetime", nullable=true)
*/ */
private $updatedAt; private ?\DateTimeInterface $updatedAt = null;
/** /**
* @ORM\ManyToOne(targetEntity=User::class) * @ORM\ManyToOne(targetEntity=User::class)

View File

@ -20,7 +20,7 @@ use Symfony\Component\Form\FormBuilderInterface;
class ByLocationAggregator implements AggregatorInterface class ByLocationAggregator implements AggregatorInterface
{ {
public function __construct(private LocationRepository $locationRepository) public function __construct(private readonly LocationRepository $locationRepository)
{ {
} }

View File

@ -33,43 +33,19 @@ use Doctrine\ORM\QueryBuilder;
use LogicException; use LogicException;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
final class ListAsideActivity implements ListInterface, GroupedExportInterface final readonly class ListAsideActivity implements ListInterface, GroupedExportInterface
{ {
private AsideActivityCategoryRepository $asideActivityCategoryRepository;
private CategoryRender $categoryRender;
private CenterRepositoryInterface $centerRepository;
private DateTimeHelper $dateTimeHelper;
private EntityManagerInterface $em;
private ScopeRepositoryInterface $scopeRepository;
private TranslatableStringHelperInterface $translatableStringHelper;
private UserHelper $userHelper;
public function __construct( public function __construct(
EntityManagerInterface $em, private EntityManagerInterface $em,
DateTimeHelper $dateTimeHelper, private DateTimeHelper $dateTimeHelper,
UserHelper $userHelper, private UserHelper $userHelper,
ScopeRepositoryInterface $scopeRepository, private ScopeRepositoryInterface $scopeRepository,
CenterRepositoryInterface $centerRepository, private CenterRepositoryInterface $centerRepository,
AsideActivityCategoryRepository $asideActivityCategoryRepository, private AsideActivityCategoryRepository $asideActivityCategoryRepository,
CategoryRender $categoryRender, private CategoryRender $categoryRender,
private LocationRepository $locationRepository, private LocationRepository $locationRepository,
TranslatableStringHelperInterface $translatableStringHelper private TranslatableStringHelperInterface $translatableStringHelper
) { ) {
$this->em = $em;
$this->dateTimeHelper = $dateTimeHelper;
$this->userHelper = $userHelper;
$this->scopeRepository = $scopeRepository;
$this->centerRepository = $centerRepository;
$this->asideActivityCategoryRepository = $asideActivityCategoryRepository;
$this->categoryRender = $categoryRender;
$this->translatableStringHelper = $translatableStringHelper;
} }
public function buildForm(FormBuilderInterface $builder) public function buildForm(FormBuilderInterface $builder)
@ -98,99 +74,78 @@ final class ListAsideActivity implements ListInterface, GroupedExportInterface
public function getLabels($key, array $values, $data) public function getLabels($key, array $values, $data)
{ {
switch ($key) { return match ($key) {
case 'id': 'id', 'note' => static function ($value) use ($key) {
case 'note': if ('_header' === $value) {
return static function ($value) use ($key) { return 'export.aside_activity.' . $key;
if ('_header' === $value) { }
return 'export.aside_activity.' . $key;
}
return $value ?? ''; return $value ?? '';
}; },
'duration' => static function ($value) use ($key) {
if ('_header' === $value) {
return 'export.aside_activity.' . $key;
}
case 'duration': if (null === $value) {
return static function ($value) use ($key) { return '';
if ('_header' === $value) { }
return 'export.aside_activity.' . $key;
}
if (null === $value) { if ($value instanceof DateTimeInterface) {
return ''; return $value->format('H:i:s');
} }
if ($value instanceof DateTimeInterface) { return $value;
return $value->format('H:i:s'); },
} 'createdAt', 'updatedAt', 'date' => $this->dateTimeHelper->getLabel('export.aside_activity.' . $key),
'agent_id', 'creator_id' => $this->userHelper->getLabel($key, $values, 'export.aside_activity.' . $key),
'aside_activity_type' => function ($value) {
if ('_header' === $value) {
return 'export.aside_activity.aside_activity_type';
}
return $value; if (null === $value || '' === $value || null === $c = $this->asideActivityCategoryRepository->find($value)) {
}; return '';
}
case 'createdAt': return $this->categoryRender->renderString($c, []);
case 'updatedAt': },
case 'date': 'location' => function ($value) {
return $this->dateTimeHelper->getLabel('export.aside_activity.' . $key); if ('_header' === $value) {
return 'export.aside_activity.location';
}
case 'agent_id': if (null === $value || '' === $value || null === $l = $this->locationRepository->find($value)) {
case 'creator_id': return '';
return $this->userHelper->getLabel($key, $values, 'export.aside_activity.' . $key); }
case 'aside_activity_type': return $l->getName();
return function ($value) { },
if ('_header' === $value) { 'main_scope' => function ($value) {
return 'export.aside_activity.aside_activity_type'; if ('_header' === $value) {
} return 'export.aside_activity.main_scope';
}
if (null === $value || '' === $value || null === $c = $this->asideActivityCategoryRepository->find($value)) { if (null === $value || '' === $value || null === $c = $this->scopeRepository->find($value)) {
return ''; return '';
} }
return $this->categoryRender->renderString($c, []); return $this->translatableStringHelper->localize($c->getName());
}; },
'main_center' => function ($value) {
if ('_header' === $value) {
return 'export.aside_activity.main_center';
}
case 'location': if (null === $value || '' === $value || null === $c = $this->centerRepository->find($value)) {
return function ($value) { /** @var Center $c */
if ('_header' === $value) { return '';
return 'export.aside_activity.location'; }
}
if (null === $value || '' === $value || null === $l = $this->locationRepository->find($value)) { return $c->getName();
return ''; },
} default => throw new LogicException('this key is not supported : ' . $key),
};
return $l->getName();
};
case 'main_scope':
return function ($value) {
if ('_header' === $value) {
return 'export.aside_activity.main_scope';
}
if (null === $value || '' === $value || null === $c = $this->scopeRepository->find($value)) {
return '';
}
return $this->translatableStringHelper->localize($c->getName());
};
case 'main_center':
return function ($value) {
if ('_header' === $value) {
return 'export.aside_activity.main_center';
}
if (null === $value || '' === $value || null === $c = $this->centerRepository->find($value)) {
/** @var Center $c */
return '';
}
return $c->getName();
};
default:
throw new LogicException('this key is not supported : ' . $key);
}
} }
public function getQueryKeys($data) public function getQueryKeys($data)

View File

@ -42,8 +42,11 @@ class MembersEditor
private array $persistables = []; private array $persistables = [];
public function __construct(private readonly ValidatorInterface $validator, private readonly ?\Chill\PersonBundle\Entity\Household\Household $household, private readonly EventDispatcherInterface $eventDispatcher) public function __construct(
{ private readonly ValidatorInterface $validator,
private readonly ?\Chill\PersonBundle\Entity\Household\Household $household,
private readonly EventDispatcherInterface $eventDispatcher
) {
} }
/** /**
@ -160,8 +163,6 @@ class MembersEditor
* *
* Makes a person leave the household **associated with this editor**. * Makes a person leave the household **associated with this editor**.
* *
* @param DateTimeImmutable $date
* @param Person $person
* @return $this * @return $this
*/ */
public function leaveMovement( public function leaveMovement(