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

@@ -12,24 +12,23 @@ declare(strict_types=1);
namespace Chill\MainBundle\Entity;
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
use DateTimeImmutable;
use DateTimeInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use function count;
use function in_array;
/**
* @ORM\Entity
*
* @ORM\Table(
* name="chill_main_notification",
* indexes={
*
* @ORM\Index(name="chill_main_notification_related_entity_idx", columns={"relatedentityclass", "relatedentityid"})
* }
* )
*
* @ORM\HasLifecycleCallbacks
*/
class Notification implements TrackUpdateInterface
@@ -43,7 +42,9 @@ class Notification implements TrackUpdateInterface
/**
* @var Collection<User>
*
* @ORM\ManyToMany(targetEntity=User::class)
*
* @ORM\JoinTable(name="chill_main_notification_addresses_user")
*/
private Collection $addressees;
@@ -52,6 +53,7 @@ class Notification implements TrackUpdateInterface
* a list of destinee which will receive notifications.
*
* @var array|string[]
*
* @ORM\Column(type="json")
*/
private array $addressesEmails = [];
@@ -67,7 +69,9 @@ class Notification implements TrackUpdateInterface
/**
* @var Collection<NotificationComment>
*
* @ORM\OneToMany(targetEntity=NotificationComment::class, mappedBy="notification", orphanRemoval=true)
*
* @ORM\OrderBy({"createdAt": "ASC"})
*/
private Collection $comments;
@@ -75,11 +79,13 @@ class Notification implements TrackUpdateInterface
/**
* @ORM\Column(type="datetime_immutable")
*/
private DateTimeImmutable $date;
private \DateTimeImmutable $date;
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*/
private ?int $id = null;
@@ -103,19 +109,23 @@ class Notification implements TrackUpdateInterface
/**
* @ORM\ManyToOne(targetEntity=User::class)
*
* @ORM\JoinColumn(nullable=true)
*/
private ?User $sender = null;
/**
* @ORM\Column(type="text", options={"default": ""})
*
* @Assert\NotBlank(message="notification.Title must be defined")
*/
private string $title = '';
/**
* @var Collection<User>
*
* @ORM\ManyToMany(targetEntity=User::class)
*
* @ORM\JoinTable(name="chill_main_notification_addresses_unread")
*/
private Collection $unreadBy;
@@ -123,7 +133,7 @@ class Notification implements TrackUpdateInterface
/**
* @ORM\Column(type="datetime_immutable")
*/
private ?DateTimeImmutable $updatedAt = null;
private ?\DateTimeImmutable $updatedAt = null;
/**
* @ORM\ManyToOne(targetEntity=User::class)
@@ -135,7 +145,7 @@ class Notification implements TrackUpdateInterface
$this->addressees = new ArrayCollection();
$this->unreadBy = new ArrayCollection();
$this->comments = new ArrayCollection();
$this->setDate(new DateTimeImmutable());
$this->setDate(new \DateTimeImmutable());
$this->accessKey = bin2hex(openssl_random_pseudo_bytes(24));
}
@@ -151,7 +161,7 @@ class Notification implements TrackUpdateInterface
public function addAddressesEmail(string $email)
{
if (!in_array($email, $this->addressesEmails, true)) {
if (!\in_array($email, $this->addressesEmails, true)) {
$this->addressesEmails[] = $email;
$this->addressesEmailsAdded[] = $email;
}
@@ -183,7 +193,7 @@ class Notification implements TrackUpdateInterface
*/
public function assertCountAddresses(ExecutionContextInterface $context, $payload): void
{
if (0 === (count($this->getAddressesEmails()) + count($this->getAddressees()))) {
if (0 === (\count($this->getAddressesEmails()) + \count($this->getAddressees()))) {
$context->buildViolation('notification.At least one addressee')
->atPath('addressees')
->addViolation();
@@ -234,7 +244,7 @@ class Notification implements TrackUpdateInterface
return $this->comments;
}
public function getDate(): ?DateTimeImmutable
public function getDate(): ?\DateTimeImmutable
{
return $this->date;
}
@@ -274,7 +284,7 @@ class Notification implements TrackUpdateInterface
return $this->unreadBy;
}
public function getUpdatedAt(): ?DateTimeImmutable
public function getUpdatedAt(): ?\DateTimeImmutable
{
return $this->updatedAt;
}
@@ -347,7 +357,7 @@ class Notification implements TrackUpdateInterface
public function removeAddressesEmail(string $email)
{
if (in_array($email, $this->addressesEmails, true)) {
if (\in_array($email, $this->addressesEmails, true)) {
$this->addressesEmails = array_filter($this->addressesEmails, static fn ($e) => $e !== $email);
$this->addressesEmailsAdded = array_filter($this->addressesEmailsAdded, static fn ($e) => $e !== $email);
}
@@ -367,7 +377,7 @@ class Notification implements TrackUpdateInterface
return $this;
}
public function setDate(DateTimeImmutable $date): self
public function setDate(\DateTimeImmutable $date): self
{
$this->date = $date;
@@ -409,7 +419,7 @@ class Notification implements TrackUpdateInterface
return $this;
}
public function setUpdatedAt(DateTimeInterface $datetime): self
public function setUpdatedAt(\DateTimeInterface $datetime): self
{
$this->updatedAt = $datetime;