apply more cs rules for php-cs

This commit is contained in:
2023-10-17 13:27:03 +02:00
parent 0b0cbed9db
commit bc2041cbdd
1485 changed files with 8169 additions and 9620 deletions

View File

@@ -24,29 +24,26 @@ use Chill\MainBundle\Entity\User;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Person;
use Chill\ThirdPartyBundle\Entity\ThirdParty;
use DateInterval;
use DateTimeImmutable;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\Criteria;
use Doctrine\Common\Collections\ReadableCollection;
use Doctrine\Common\Collections\Selectable;
use Doctrine\ORM\Mapping as ORM;
use LogicException;
use Symfony\Component\Serializer\Annotation as Serializer;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\Range;
use Symfony\Component\Validator\Mapping\ClassMetadata;
use function in_array;
/**
* @ORM\Table(
* name="chill_calendar.calendar",
* uniqueConstraints={@ORM\UniqueConstraint(name="idx_calendar_remote", columns={"remoteId"}, options={"where": "remoteId <> ''"})}
* )
*
* @ORM\Entity
*
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
* "chill_calendar_calendar": Calendar::class
* })
@@ -94,6 +91,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
/**
* @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod", inversedBy="calendars")
*
* @Serializer\Groups({"calendar:read", "read"})
*/
private ?AccompanyingPeriod $accompanyingPeriod = null;
@@ -105,6 +103,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
/**
* @ORM\OneToOne(targetEntity="CalendarRange", inversedBy="calendar")
*
* @Serializer\Groups({"calendar:read", "read"})
*/
private ?CalendarRange $calendarRange = null;
@@ -116,6 +115,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
/**
* @ORM\Embedded(class=CommentEmbeddable::class, columnPrefix="comment_")
*
* @Serializer\Groups({"calendar:read", "read", "docgen:read"})
*/
private CommentEmbeddable $comment;
@@ -127,21 +127,27 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
/**
* @var Collection<CalendarDoc>
*
* @ORM\OneToMany(targetEntity=CalendarDoc::class, mappedBy="calendar", orphanRemoval=true)
*/
private Collection $documents;
/**
* @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")
*/
private ?DateTimeImmutable $endDate = null;
private ?\DateTimeImmutable $endDate = null;
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*
* @Serializer\Groups({"calendar:read", "read", "calendar:light", "docgen:read"})
*/
private ?int $id = null;
@@ -153,60 +159,80 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
* orphanRemoval=true,
* cascade={"persist", "remove", "merge", "detach"}
* )
*
* @ORM\JoinTable(name="chill_calendar.calendar_to_invites")
*
* @Serializer\Groups({"read", "docgen:read"})
*
* @var Collection&Selectable<int, Invite>
*/
private Collection&Selectable $invites;
/**
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Location")
*
* @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")
*/
private ?User $mainUser = null;
/**
* @ORM\ManyToOne(targetEntity=Person::class)
*
* @ORM\JoinColumn(nullable=true)
*/
private ?Person $person = null;
/**
* @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\Person", inversedBy="calendars")
*
* @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>
*/
private Collection $persons;
/**
* @ORM\Embedded(class=PrivateCommentEmbeddable::class, columnPrefix="privateComment_")
*
* @Serializer\Groups({"calendar:read"})
*/
private PrivateCommentEmbeddable $privateComment;
/**
* @var Collection<ThirdParty>
*
* @ORM\ManyToMany(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdParty")
*
* @ORM\JoinTable(name="chill_calendar.calendar_to_thirdparties")
*
* @Serializer\Groups({"calendar:read", "read", "calendar:light", "docgen:read"})
*
* @Serializer\Context(normalizationContext={"read"}, groups={"calendar:light"})
*/
private Collection $professionals;
/**
* @ORM\Column(type="boolean", nullable=true)
*
* @Serializer\Groups({"docgen:read"})
*/
private ?bool $sendSMS = false;
@@ -218,21 +244,27 @@ 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")
*/
private ?DateTimeImmutable $startDate = null;
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"})
*/
private string $status = self::STATUS_VALID;
/**
* @ORM\Column(type="boolean", nullable=true)
*
* @Serializer\Groups({"docgen:read"})
*/
private ?bool $urgent = false;
@@ -265,7 +297,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
public function addInvite(Invite $invite): self
{
if ($invite->getCalendar() instanceof Calendar && $invite->getCalendar() !== $this) {
throw new LogicException('Not allowed to move an invitation to another Calendar');
throw new \LogicException('Not allowed to move an invitation to another Calendar');
}
$this->invites[] = $invite;
@@ -324,7 +356,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
return match ($this->getContext()) {
'person' => [$this->getPerson()->getCenter()],
'accompanying_period' => $this->getAccompanyingPeriod()->getCenters(),
default => throw new LogicException('context not supported: ' . $this->getContext()),
default => throw new \LogicException('context not supported: '.$this->getContext()),
};
}
@@ -338,11 +370,11 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
*/
public function getContext(): ?string
{
if ($this->getAccompanyingPeriod() !== null) {
if (null !== $this->getAccompanyingPeriod()) {
return 'accompanying_period';
}
if ($this->getPerson() !== null) {
if (null !== $this->getPerson()) {
return 'person';
}
@@ -365,16 +397,16 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
/**
* @Serializer\Groups({"docgen:read"})
*/
public function getDuration(): ?DateInterval
public function getDuration(): ?\DateInterval
{
if ($this->getStartDate() === null || $this->getEndDate() === null) {
if (null === $this->getStartDate() || null === $this->getEndDate()) {
return null;
}
return $this->getStartDate()->diff($this->getEndDate());
}
public function getEndDate(): ?DateTimeImmutable
public function getEndDate(): ?\DateTimeImmutable
{
return $this->endDate;
}
@@ -453,7 +485,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
$personsNotAssociated = [];
foreach ($this->persons as $person) {
if (!in_array($person, $this->getPersonsAssociated(), true)) {
if (!\in_array($person, $this->getPersonsAssociated(), true)) {
$personsNotAssociated[] = $person;
}
}
@@ -487,7 +519,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
return $this->smsStatus;
}
public function getStartDate(): ?DateTimeImmutable
public function getStartDate(): ?\DateTimeImmutable
{
return $this->startDate;
}
@@ -509,6 +541,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
/**
* @return ReadableCollection<(int|string), User>
*
* @Serializer\Groups({"calendar:read", "read"})
*/
public function getUsers(): ReadableCollection
@@ -558,7 +591,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
public function removeDocument(CalendarDoc $calendarDoc): self
{
if ($calendarDoc->getCalendar() !== $this) {
throw new LogicException('cannot remove document of another calendar');
throw new \LogicException('cannot remove document of another calendar');
}
return $this;
@@ -652,7 +685,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
return $this;
}
public function setEndDate(DateTimeImmutable $endDate): self
public function setEndDate(\DateTimeImmutable $endDate): self
{
if (null === $this->endDate || $this->endDate->getTimestamp() !== $endDate->getTimestamp()) {
$this->increaseaDatetimeVersion();
@@ -710,7 +743,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
return $this;
}
public function setStartDate(DateTimeImmutable $startDate): self
public function setStartDate(\DateTimeImmutable $startDate): self
{
if (null === $this->startDate || $this->startDate->getTimestamp() !== $startDate->getTimestamp()) {
$this->increaseaDatetimeVersion();
@@ -725,7 +758,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
{
$this->status = $status;
if (self::STATUS_CANCELED === $status && $this->getSmsStatus() === self::SMS_SENT) {
if (self::STATUS_CANCELED === $status && self::SMS_SENT === $this->getSmsStatus()) {
$this->setSmsStatus(self::SMS_CANCEL_PENDING);
}