Apply rector rules: symfony up to 54

This commit is contained in:
2024-04-04 23:30:25 +02:00
parent 1ee3b9e2f0
commit 579bd829f8
204 changed files with 974 additions and 2346 deletions

View File

@@ -43,11 +43,8 @@ use Symfony\Component\Validator\Mapping\ClassMetadata;
* )
*
* @ORM\Entity
*
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
* "chill_calendar_calendar": Calendar::class
* })
*/
#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['chill_calendar_calendar' => Calendar::class])]
class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCentersInterface
{
use RemoteCalendarTrait;
@@ -91,9 +88,8 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
/**
* @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod", inversedBy="calendars")
*
* @Serializer\Groups({"calendar:read", "read"})
*/
#[Serializer\Groups(['calendar:read', 'read'])]
private ?AccompanyingPeriod $accompanyingPeriod = null;
/**
@@ -103,9 +99,8 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
/**
* @ORM\OneToOne(targetEntity="CalendarRange", inversedBy="calendar")
*
* @Serializer\Groups({"calendar:read", "read"})
*/
#[Serializer\Groups(['calendar:read', 'read'])]
private ?CalendarRange $calendarRange = null;
/**
@@ -115,9 +110,8 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
/**
* @ORM\Embedded(class=CommentEmbeddable::class, columnPrefix="comment_")
*
* @Serializer\Groups({"calendar:read", "read", "docgen:read"})
*/
#[Serializer\Groups(['calendar:read', 'read', 'docgen:read'])]
private CommentEmbeddable $comment;
/**
@@ -134,11 +128,9 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
/**
* @ORM\Column(type="datetime_immutable", nullable=false)
*
* @Serializer\Groups({"calendar:read", "read", "calendar:light", "docgen:read"})
*
* @Assert\NotNull(message="calendar.An end date is required")
*/
#[Serializer\Groups(['calendar:read', 'read', 'calendar:light', 'docgen:read'])]
#[Assert\NotNull(message: 'calendar.An end date is required')]
private ?\DateTimeImmutable $endDate = null;
/**
@@ -147,9 +139,8 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*
* @Serializer\Groups({"calendar:read", "read", "calendar:light", "docgen:read"})
*/
#[Serializer\Groups(['calendar:read', 'read', 'calendar:light', 'docgen:read'])]
private ?int $id = null;
/**
@@ -162,30 +153,25 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
*
* @ORM\JoinTable(name="chill_calendar.calendar_to_invites")
*
* @Serializer\Groups({"read", "docgen:read"})
*
* @var Collection&Selectable<int, Invite>
*/
#[Serializer\Groups(['read', 'docgen:read'])]
private Collection&Selectable $invites;
/**
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Location")
*
* @Serializer\Groups({"read", "docgen:read"})
*
* @Assert\NotNull(message="calendar.A location is required")
*/
#[Serializer\Groups(['read', 'docgen:read'])]
#[Assert\NotNull(message: 'calendar.A location is required')]
private ?Location $location = null;
/**
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
*
* @Serializer\Groups({"calendar:read", "read", "calendar:light", "docgen:read"})
*
* @Serializer\Context(normalizationContext={"read"}, groups={"calendar:light"})
*
* @Assert\NotNull(message="calendar.A main user is mandatory")
*/
#[Serializer\Groups(['calendar:read', 'read', 'calendar:light', 'docgen:read'])]
#[Assert\NotNull(message: 'calendar.A main user is mandatory')]
private ?User $mainUser = null;
/**
@@ -200,21 +186,18 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
*
* @ORM\JoinTable(name="chill_calendar.calendar_to_persons")
*
* @Serializer\Groups({"calendar:read", "read", "calendar:light", "docgen:read"})
*
* @Serializer\Context(normalizationContext={"read"}, groups={"calendar:light"})
*
* @Assert\Count(min=1, minMessage="calendar.At least {{ limit }} person is required.")
*
* @var Collection<Person>
*/
#[Serializer\Groups(['calendar:read', 'read', 'calendar:light', 'docgen:read'])]
#[Assert\Count(min: 1, minMessage: 'calendar.At least {{ limit }} person is required.')]
private Collection $persons;
/**
* @ORM\Embedded(class=PrivateCommentEmbeddable::class, columnPrefix="privateComment_")
*
* @Serializer\Groups({"calendar:read"})
*/
#[Serializer\Groups(['calendar:read'])]
private PrivateCommentEmbeddable $privateComment;
/**
@@ -224,17 +207,15 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
*
* @ORM\JoinTable(name="chill_calendar.calendar_to_thirdparties")
*
* @Serializer\Groups({"calendar:read", "read", "calendar:light", "docgen:read"})
*
* @Serializer\Context(normalizationContext={"read"}, groups={"calendar:light"})
*/
#[Serializer\Groups(['calendar:read', 'read', 'calendar:light', 'docgen:read'])]
private Collection $professionals;
/**
* @ORM\Column(type="boolean", nullable=true)
*
* @Serializer\Groups({"docgen:read"})
*/
#[Serializer\Groups(['docgen:read'])]
private ?bool $sendSMS = false;
/**
@@ -245,28 +226,24 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
/**
* @ORM\Column(type="datetime_immutable", nullable=false)
*
* @Serializer\Groups({"calendar:read", "read", "calendar:light", "docgen:read"})
*
* @Serializer\Context(normalizationContext={"read"}, groups={"calendar:light"})
*
* @Assert\NotNull(message="calendar.A start date is required")
*/
#[Serializer\Groups(['calendar:read', 'read', 'calendar:light', 'docgen:read'])]
#[Assert\NotNull(message: 'calendar.A start date is required')]
private ?\DateTimeImmutable $startDate = null;
/**
* @ORM\Column(type="string", length=255, nullable=false, options={"default": "valid"})
*
* @Serializer\Groups({"calendar:read", "read", "calendar:light"})
*
* @Serializer\Context(normalizationContext={"read"}, groups={"calendar:light"})
*/
#[Serializer\Groups(['calendar:read', 'read', 'calendar:light'])]
private string $status = self::STATUS_VALID;
/**
* @ORM\Column(type="boolean", nullable=true)
*
* @Serializer\Groups({"docgen:read"})
*/
#[Serializer\Groups(['docgen:read'])]
private ?bool $urgent = false;
public function __construct()
@@ -394,9 +371,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
return $this->documents;
}
/**
* @Serializer\Groups({"docgen:read"})
*/
#[Serializer\Groups(['docgen:read'])]
public function getDuration(): ?\DateInterval
{
if (null === $this->getStartDate() || null === $this->getEndDate()) {
@@ -541,9 +516,8 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
/**
* @return ReadableCollection<(int|string), User>
*
* @Serializer\Groups({"calendar:read", "read"})
*/
#[Serializer\Groups(['calendar:read', 'read'])]
public function getUsers(): ReadableCollection
{
return $this->getInvites()->map(static fn (Invite $i) => $i->getUser());

View File

@@ -16,17 +16,11 @@ use Symfony\Component\Validator\Constraints as Assert;
class CalendarDocCreateDTO
{
/**
* @Assert\NotNull
*
* @Assert\Valid
*/
#[Assert\NotNull]
#[Assert\Valid]
public ?StoredObject $doc = null;
/**
* @Assert\NotBlank
*
* @Assert\NotNull
*/
#[Assert\NotBlank]
#[Assert\NotNull]
public ?string $title = '';
}

View File

@@ -17,16 +17,11 @@ use Symfony\Component\Validator\Constraints as Assert;
class CalendarDocEditDTO
{
/**
* @Assert\Valid
*/
#[Assert\Valid]
public ?StoredObject $doc = null;
/**
* @Assert\NotBlank
*
* @Assert\NotNull
*/
#[Assert\NotBlank]
#[Assert\NotNull]
public ?string $title = '';
public function __construct(CalendarDoc $calendarDoc)

View File

@@ -44,11 +44,9 @@ class CalendarRange implements TrackCreationInterface, TrackUpdateInterface
/**
* @ORM\Column(type="datetime_immutable", nullable=false)
*
* @Groups({"read", "write", "calendar:read"})
*
* @Assert\NotNull
*/
#[Groups(['read', 'write', 'calendar:read'])]
#[Assert\NotNull]
private ?\DateTimeImmutable $endDate = null;
/**
@@ -57,38 +55,31 @@ class CalendarRange implements TrackCreationInterface, TrackUpdateInterface
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*
* @Groups({"read"})
*/
#[Groups(['read'])]
private ?int $id = null;
/**
* @ORM\ManyToOne(targetEntity=Location::class)
*
* @ORM\JoinColumn(nullable=false)
*
* @Groups({"read", "write", "calendar:read"})
*
* @Assert\NotNull
*/
#[Groups(['read', 'write', 'calendar:read'])]
#[Assert\NotNull]
private ?Location $location = null;
/**
* @ORM\Column(type="datetime_immutable", nullable=false)
*
* @groups({"read", "write", "calendar:read"})
*
* @Assert\NotNull
*/
#[Groups(['read', 'write', 'calendar:read'])]
#[Assert\NotNull]
private ?\DateTimeImmutable $startDate = null;
/**
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
*
* @Groups({"read", "write", "calendar:read"})
*
* @Assert\NotNull
*/
#[Groups(['read', 'write', 'calendar:read'])]
#[Assert\NotNull]
private ?User $user = null;
public function getCalendar(): ?Calendar

View File

@@ -69,25 +69,22 @@ class Invite implements TrackUpdateInterface, TrackCreationInterface
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*
* @Serializer\Groups(groups={"calendar:read", "read"})
*/
#[Serializer\Groups(groups: ['calendar:read', 'read'])]
private ?int $id = null;
/**
* @ORM\Column(type="text", nullable=false, options={"default": "pending"})
*
* @Serializer\Groups(groups={"calendar:read", "read", "docgen:read"})
*/
#[Serializer\Groups(groups: ['calendar:read', 'read', 'docgen:read'])]
private string $status = self::PENDING;
/**
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
*
* @ORM\JoinColumn(nullable=false)
*
* @Serializer\Groups(groups={"calendar:read", "read", "docgen:read"})
*/
#[Serializer\Groups(groups: ['calendar:read', 'read', 'docgen:read'])]
private ?User $user = null;
public function getCalendar(): ?Calendar