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

@@ -21,13 +21,11 @@ use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation as Serializer;
use Symfony\Component\Validator\Constraints as Assert;
use function array_fill_keys;
use function array_keys;
/**
* AbstractTask.
*
* @ORM\MappedSuperclass
*
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
* "single_task": SingleTask::class
* })
@@ -38,6 +36,7 @@ abstract class AbstractTask implements HasCenterInterface, HasScopeInterface
* @ORM\ManyToOne(
* targetEntity="\Chill\MainBundle\Entity\User"
* )
*
* @Serializer\Groups({"read"})
*/
private ?\Chill\MainBundle\Entity\User $assignee = null;
@@ -51,25 +50,28 @@ abstract class AbstractTask implements HasCenterInterface, HasScopeInterface
/**
* @ORM\Column(name="closed", type="boolean", options={ "default": false })
*
* @Serializer\Groups({"read"})
*/
private bool $closed = false;
/**
* @ORM\ManyToOne(targetEntity="\Chill\PersonBundle\Entity\AccompanyingPeriod")
*
* @Serializer\Groups({"read"})
*/
private ?\Chill\PersonBundle\Entity\AccompanyingPeriod $course = null;
/**
* @ORM\Column(name="current_states", type="json", options={"jsonb"=true, "default"="[]"})
*
* @Serializer\Groups({"read"})
*/
private array $currentStates = [];
/**
*
* @ORM\Column(name="description", type="text")
*
* @Serializer\Groups({"read"})
*/
private string $description = '';
@@ -78,21 +80,23 @@ abstract class AbstractTask implements HasCenterInterface, HasScopeInterface
* @ORM\ManyToOne(
* targetEntity="\Chill\PersonBundle\Entity\Person"
* )
*
* @Serializer\Groups({"read"})
*/
private ?\Chill\PersonBundle\Entity\Person $person = null;
/**
*
* @ORM\Column(name="title", type="text")
*
* @Assert\NotBlank
*
* @Serializer\Groups({"read"})
*/
private string $title = '';
/**
*
* @ORM\Column(name="type", type="string", length=255)
*
* @Serializer\Groups({"read"})
*/
private ?string $type = null;
@@ -137,7 +141,7 @@ abstract class AbstractTask implements HasCenterInterface, HasScopeInterface
*/
public function getCurrentStates()
{
return array_fill_keys($this->currentStates, 1);
return \array_fill_keys($this->currentStates, 1);
}
/**
@@ -185,7 +189,7 @@ abstract class AbstractTask implements HasCenterInterface, HasScopeInterface
return $this->closed;
}
public function setAssignee(?User $assignee = null)
public function setAssignee(User $assignee = null)
{
$this->assignee = $assignee;
@@ -216,13 +220,11 @@ abstract class AbstractTask implements HasCenterInterface, HasScopeInterface
*
* The current states are sorted in a single array, non associative.
*
* @param $currentStates
*
* @return AbstractTask
*/
public function setCurrentStates($currentStates)
{
$this->currentStates = array_keys($currentStates);
$this->currentStates = \array_keys($currentStates);
return $this;
}

View File

@@ -11,7 +11,6 @@ declare(strict_types=1);
namespace Chill\TaskBundle\Entity;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
@@ -20,6 +19,7 @@ use Doctrine\ORM\Mapping as ORM;
* RecurringTask.
*
* @ORM\Table(name="chill_task.recurring_task")
*
* @ORM\Entity(repositoryClass="Chill\TaskBundle\Repository\RecurringTaskRepository")
*/
class RecurringTask extends AbstractTask
@@ -30,10 +30,10 @@ class RecurringTask extends AbstractTask
private ?\DateTime $firstOccurenceEndDate = null;
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
*
* @ORM\Id
*
* @ORM\GeneratedValue(strategy="AUTO")
*/
private ?int $id = null;
@@ -44,20 +44,16 @@ class RecurringTask extends AbstractTask
private ?\DateTime $lastOccurenceEndDate = null;
/**
* @var string
*
* @ORM\Column(name="occurence_frequency", type="string", length=255)
*/
private ?string $occurenceFrequency = null;
/**
*
* @ORM\Column(name="occurence_start_date", type="dateinterval")
*/
private $occurenceStartDate;
/**
*
* @ORM\Column(name="occurence_warning_interval", type="dateinterval", nullable=true)
*/
private $occurenceWarningInterval;
@@ -80,7 +76,7 @@ class RecurringTask extends AbstractTask
/**
* Get firstOccurenceEndDate.
*
* @return DateTime
* @return \DateTime
*/
public function getFirstOccurenceEndDate()
{
@@ -100,7 +96,7 @@ class RecurringTask extends AbstractTask
/**
* Get lastOccurenceEndDate.
*
* @return DateTime
* @return \DateTime
*/
public function getLastOccurenceEndDate()
{
@@ -119,7 +115,6 @@ class RecurringTask extends AbstractTask
/**
* Get occurenceStartDate.
*
*/
public function getOccurenceStartDate()
{
@@ -128,7 +123,6 @@ class RecurringTask extends AbstractTask
/**
* Get occurenceWarningInterval.
*
*/
public function getOccurenceWarningInterval()
{
@@ -138,7 +132,7 @@ class RecurringTask extends AbstractTask
/**
* Set firstOccurenceEndDate.
*
* @param DateTime $firstOccurenceEndDate
* @param \DateTime $firstOccurenceEndDate
*
* @return RecurringTask
*/
@@ -152,7 +146,7 @@ class RecurringTask extends AbstractTask
/**
* Set lastOccurenceEndDate.
*
* @param DateTime $lastOccurenceEndDate
* @param \DateTime $lastOccurenceEndDate
*
* @return RecurringTask
*/
@@ -180,7 +174,6 @@ class RecurringTask extends AbstractTask
/**
* Set occurenceStartDate.
*
*
* @return RecurringTask
*/
public function setOccurenceStartDate(mixed $occurenceStartDate)
@@ -193,7 +186,6 @@ class RecurringTask extends AbstractTask
/**
* Set occurenceWarningInterval.
*
*
* @return RecurringTask
*/
public function setOccurenceWarningInterval(mixed $occurenceWarningInterval)

View File

@@ -13,8 +13,6 @@ namespace Chill\TaskBundle\Entity;
use Chill\TaskBundle\Entity\Task\SingleTaskPlaceEvent;
use DateInterval;
use DateTime;
use DateTimeImmutable;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
@@ -27,6 +25,7 @@ use Symfony\Component\Validator\Constraints as Assert;
* @ORM\Table(
* name="chill_task.single_task",
* indexes={
*
* @ORM\Index(
* name="by_type",
* columns={ "type" }
@@ -41,23 +40,27 @@ use Symfony\Component\Validator\Constraints as Assert;
* )
* }
* )
*
* @ORM\Entity(repositoryClass="Chill\TaskBundle\Repository\SingleTaskRepository")
*/
class SingleTask extends AbstractTask
{
/**
* @ORM\Column(name="end_date", type="date", nullable=true)
*
* @Assert\Date
*
* @Serializer\Groups({"read"})
*/
private ?\DateTime $endDate = null;
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
*
* @ORM\Id
*
* @ORM\GeneratedValue(strategy="AUTO")
*
* @Serializer\Groups({"read"})
*/
private ?int $id = null;
@@ -71,16 +74,16 @@ class SingleTask extends AbstractTask
private ?\Chill\TaskBundle\Entity\RecurringTask $recurringTask = null;
/**
*
* @ORM\Column(name="start_date", type="date", nullable=true)
*
* @Serializer\Groups({"read"})
*
* @Assert\Date
*
* @Assert\Expression(
* "value === null or this.getEndDate() === null or value < this.getEndDate()",
* message="The start date must be before the end date"
* )
*
* @Assert\Expression(
* "value === null or this.getWarningDate() === null or this.getWarningDate() > this.getStartDate()",
* message="The start date must be before warning date"
@@ -90,6 +93,7 @@ class SingleTask extends AbstractTask
/**
* @var Collection<SingleTaskPlaceEvent>
*
* @ORM\OneToMany(
* targetEntity="\Chill\TaskBundle\Entity\Task\SingleTaskPlaceEvent",
* mappedBy="task",
@@ -99,10 +103,11 @@ class SingleTask extends AbstractTask
private Collection $taskPlaceEvents;
/**
* @var DateInterval
* and this.getEndDate() === null
* @var \DateInterval
* and this.getEndDate() === null
*
* @ORM\Column(name="warning_interval", type="dateinterval", nullable=true)
*
* @Serializer\Groups({"read"})
*
* @Assert\Expression(
@@ -110,7 +115,7 @@ class SingleTask extends AbstractTask
* message="An end date is required if a warning interval is set"
* )
*/
private $warningInterval;
private null|\DateInterval $warningInterval = null;
public function __construct()
{
@@ -119,10 +124,8 @@ class SingleTask extends AbstractTask
/**
* Get endDate.
*
* @return DateTime
*/
public function getEndDate()
public function getEndDate(): null|\DateTime
{
return $this->endDate;
}
@@ -145,7 +148,7 @@ class SingleTask extends AbstractTask
/**
* Get startDate.
*
* @return DateTime
* @return \DateTime
*/
public function getStartDate()
{
@@ -163,29 +166,28 @@ class SingleTask extends AbstractTask
*
* Return null if warningDate or endDate is null
*
* @return DateTimeImmutable
* @return \DateTimeImmutable
*
* @Serializer\Groups({"read"})
*/
public function getWarningDate()
{
if ($this->getWarningInterval() === null) {
if (null === $this->getWarningInterval()) {
return null;
}
if ($this->getEndDate() === null) {
if (null === $this->getEndDate()) {
return null;
}
return DateTimeImmutable::createFromMutable($this->getEndDate())
return \DateTimeImmutable::createFromMutable($this->getEndDate())
->sub($this->getWarningInterval());
}
/**
* Get warningInterval.
*
* @return DateInterval
*/
public function getWarningInterval()
public function getWarningInterval(): null|\DateInterval
{
return $this->warningInterval;
}
@@ -193,7 +195,7 @@ class SingleTask extends AbstractTask
/**
* Set endDate.
*
* @param DateTime $endDate
* @param \DateTime $endDate
*
* @return SingleTask
*/
@@ -212,7 +214,7 @@ class SingleTask extends AbstractTask
/**
* Set startDate.
*
* @param DateTime $startDate
* @param \DateTime $startDate
*
* @return SingleTask
*/
@@ -233,11 +235,9 @@ class SingleTask extends AbstractTask
/**
* Set warningInterval.
*
* @param string $warningInterval
*
* @return SingleTask
*/
public function setWarningInterval($warningInterval)
public function setWarningInterval(null|\DateInterval $warningInterval)
{
$this->warningInterval = $warningInterval;

View File

@@ -12,7 +12,6 @@ declare(strict_types=1);
namespace Chill\TaskBundle\Entity\Task;
use Chill\MainBundle\Entity\User;
use DateTimeImmutable;
use Doctrine\ORM\Mapping as ORM;
/**
@@ -48,7 +47,7 @@ class AbstractTaskPlaceEvent
public function __construct()
{
$this->datetime = new DateTimeImmutable('now');
$this->datetime = new \DateTimeImmutable('now');
}
public function getAuthor(): User

View File

@@ -18,6 +18,7 @@ use Doctrine\ORM\Mapping as ORM;
* @ORM\Table(
* name="chill_task.single_task_place_event",
* indexes={
*
* @ORM\Index(
* name="transition_task_date",
* columns={"task_id", "transition", "datetime"}
@@ -27,19 +28,21 @@ use Doctrine\ORM\Mapping as ORM;
* columns={"task_id", "transition"}
* )
* })
*
* @ORM\Entity
*/
class SingleTaskPlaceEvent extends AbstractTaskPlaceEvent
{
/**
* @ORM\Column(name="id", type="integer")
*
* @ORM\Id
*
* @ORM\GeneratedValue(strategy="AUTO")
*/
private ?int $id = null;
/**
* @var SingleTask
* @ORM\ManyToOne(
* targetEntity="\Chill\TaskBundle\Entity\SingleTask",
* inversedBy="taskPlaceEvents"