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,19 +74,15 @@ 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':
return static function ($value) use ($key) {
if ('_header' === $value) { if ('_header' === $value) {
return 'export.aside_activity.' . $key; return 'export.aside_activity.' . $key;
} }
return $value ?? ''; return $value ?? '';
}; },
'duration' => static function ($value) use ($key) {
case 'duration':
return static function ($value) use ($key) {
if ('_header' === $value) { if ('_header' === $value) {
return 'export.aside_activity.' . $key; return 'export.aside_activity.' . $key;
} }
@ -124,19 +96,10 @@ final class ListAsideActivity implements ListInterface, GroupedExportInterface
} }
return $value; return $value;
}; },
'createdAt', 'updatedAt', 'date' => $this->dateTimeHelper->getLabel('export.aside_activity.' . $key),
case 'createdAt': 'agent_id', 'creator_id' => $this->userHelper->getLabel($key, $values, 'export.aside_activity.' . $key),
case 'updatedAt': 'aside_activity_type' => function ($value) {
case 'date':
return $this->dateTimeHelper->getLabel('export.aside_activity.' . $key);
case 'agent_id':
case 'creator_id':
return $this->userHelper->getLabel($key, $values, 'export.aside_activity.' . $key);
case 'aside_activity_type':
return function ($value) {
if ('_header' === $value) { if ('_header' === $value) {
return 'export.aside_activity.aside_activity_type'; return 'export.aside_activity.aside_activity_type';
} }
@ -146,10 +109,8 @@ final class ListAsideActivity implements ListInterface, GroupedExportInterface
} }
return $this->categoryRender->renderString($c, []); return $this->categoryRender->renderString($c, []);
}; },
'location' => function ($value) {
case 'location':
return function ($value) {
if ('_header' === $value) { if ('_header' === $value) {
return 'export.aside_activity.location'; return 'export.aside_activity.location';
} }
@ -159,10 +120,8 @@ final class ListAsideActivity implements ListInterface, GroupedExportInterface
} }
return $l->getName(); return $l->getName();
}; },
'main_scope' => function ($value) {
case 'main_scope':
return function ($value) {
if ('_header' === $value) { if ('_header' === $value) {
return 'export.aside_activity.main_scope'; return 'export.aside_activity.main_scope';
} }
@ -172,10 +131,8 @@ final class ListAsideActivity implements ListInterface, GroupedExportInterface
} }
return $this->translatableStringHelper->localize($c->getName()); return $this->translatableStringHelper->localize($c->getName());
}; },
'main_center' => function ($value) {
case 'main_center':
return function ($value) {
if ('_header' === $value) { if ('_header' === $value) {
return 'export.aside_activity.main_center'; return 'export.aside_activity.main_center';
} }
@ -186,11 +143,9 @@ final class ListAsideActivity implements ListInterface, GroupedExportInterface
} }
return $c->getName(); return $c->getName();
},
default => throw new LogicException('this key is not supported : ' . $key),
}; };
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(