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

@@ -14,8 +14,6 @@ namespace Chill\BudgetBundle\Entity;
use Chill\PersonBundle\Entity\Household\Household;
use Chill\PersonBundle\Entity\Person;
use DateTime;
use DateTimeImmutable;
use DateTimeInterface;
use Doctrine\ORM\Mapping as ORM;
use Ramsey\Uuid\Type\Decimal;
use Symfony\Component\Validator\Constraints as Assert;
@@ -29,9 +27,11 @@ abstract class AbstractElement
{
/**
* @ORM\Column(name="amount", type="decimal", precision=10, scale=2)
*
* @Assert\GreaterThan(
* value=0
* )
*
* @Assert\NotNull(
* message="The amount cannot be empty"
* )
@@ -45,12 +45,13 @@ abstract class AbstractElement
/**
* @ORM\Column(name="endDate", type="datetime_immutable", nullable=true)
*
* @Assert\GreaterThan(
* propertyPath="startDate",
* message="The budget element's end date must be after the start date"
* )
*/
private ?DateTimeImmutable $endDate = null;
private ?\DateTimeImmutable $endDate = null;
/**
* @ORM\ManyToOne(
@@ -68,16 +69,17 @@ abstract class AbstractElement
/**
* @ORM\Column(name="startDate", type="datetime_immutable")
*
* @Assert\Date
*/
private DateTimeImmutable $startDate;
private \DateTimeImmutable $startDate;
/**
* @ORM\Column(name="type", type="string", length=255)
*/
private string $type = '';
/*Getters and Setters */
/* Getters and Setters */
public function getAmount(): float
{
@@ -89,7 +91,7 @@ abstract class AbstractElement
return $this->comment;
}
public function getEndDate(): ?DateTimeImmutable
public function getEndDate(): ?\DateTimeImmutable
{
return $this->endDate;
}
@@ -104,7 +106,7 @@ abstract class AbstractElement
return $this->person;
}
public function getStartDate(): DateTimeImmutable
public function getStartDate(): \DateTimeImmutable
{
return $this->startDate;
}
@@ -130,17 +132,17 @@ abstract class AbstractElement
return $this;
}
public function setComment(?string $comment = null): self
public function setComment(string $comment = null): self
{
$this->comment = $comment;
return $this;
}
public function setEndDate(?DateTimeInterface $endDate = null): self
public function setEndDate(\DateTimeInterface $endDate = null): self
{
if ($endDate instanceof DateTime) {
$this->endDate = DateTimeImmutable::createFromMutable($endDate);
if ($endDate instanceof \DateTime) {
$this->endDate = \DateTimeImmutable::createFromMutable($endDate);
} elseif (null === $endDate) {
$this->endDate = null;
} else {
@@ -164,10 +166,10 @@ abstract class AbstractElement
return $this;
}
public function setStartDate(DateTimeInterface $startDate): self
public function setStartDate(\DateTimeInterface $startDate): self
{
if ($startDate instanceof DateTime) {
$this->startDate = DateTimeImmutable::createFromMutable($startDate);
if ($startDate instanceof \DateTime) {
$this->startDate = \DateTimeImmutable::createFromMutable($startDate);
} elseif (null === $startDate) {
$this->startDate = null;
} else {

View File

@@ -13,13 +13,13 @@ namespace Chill\BudgetBundle\Entity;
use Chill\MainBundle\Entity\HasCentersInterface;
use Chill\PersonBundle\Entity\Person;
use DateTimeImmutable;
use Doctrine\ORM\Mapping as ORM;
/**
* Charge.
*
* @ORM\Table(name="chill_budget.charge")
*
* @ORM\Entity(repositoryClass="Chill\BudgetBundle\Repository\ChargeRepository")
*/
class Charge extends AbstractElement implements HasCentersInterface
@@ -41,6 +41,7 @@ class Charge extends AbstractElement implements HasCentersInterface
/**
* @ORM\ManyToOne(targetEntity=ChargeKind::class, inversedBy="AbstractElement")
*
* @ORM\JoinColumn
*/
private ?ChargeKind $charge = null;
@@ -52,14 +53,16 @@ class Charge extends AbstractElement implements HasCentersInterface
/**
* @ORM\Column(name="id", type="integer")
*
* @ORM\Id
*
* @ORM\GeneratedValue(strategy="AUTO")
*/
private ?int $id = null;
public function __construct()
{
$this->setStartDate(new DateTimeImmutable('today'));
$this->setStartDate(new \DateTimeImmutable('today'));
}
public function getCenters(): array

View File

@@ -21,14 +21,18 @@ use Symfony\Component\Validator\Constraints as Assert;
* @ORM\Table(name="chill_budget.charge_type",
* uniqueConstraints={@ORM\UniqueConstraint(name="charge_kind_unique_type_idx", fields={"kind"})}
* )
*
* @ORM\Entity
*
* @UniqueEntity(fields={"kind"})
*/
class ChargeKind
{
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*/
private ?int $id = null;
@@ -40,7 +44,9 @@ class ChargeKind
/**
* @ORM\Column(type="string", length=255, options={"default": ""}, nullable=false)
*
* @Assert\Regex(pattern="/^[a-z0-9\-_]{1,}$/", message="budget.admin.form.kind.only_alphanumeric")
*
* @Assert\Length(min=3)
*/
private string $kind = '';

View File

@@ -13,33 +13,36 @@ namespace Chill\BudgetBundle\Entity;
use Chill\MainBundle\Entity\HasCentersInterface;
use Chill\PersonBundle\Entity\Person;
use DateTimeImmutable;
use Doctrine\ORM\Mapping as ORM;
/**
* Resource.
*
* @ORM\Table(name="chill_budget.resource")
*
* @ORM\Entity(repositoryClass="Chill\BudgetBundle\Repository\ResourceRepository")
*/
class Resource extends AbstractElement implements HasCentersInterface
{
/**
* @ORM\Column(name="id", type="integer")
*
* @ORM\Id
*
* @ORM\GeneratedValue(strategy="AUTO")
*/
private ?int $id = null;
/**
* @ORM\ManyToOne(targetEntity=ResourceKind::class, inversedBy="AbstractElement")
*
* @ORM\JoinColumn
*/
private ?ResourceKind $resource = null;
public function __construct()
{
$this->setStartDate(new DateTimeImmutable('today'));
$this->setStartDate(new \DateTimeImmutable('today'));
}
public function getCenters(): array

View File

@@ -19,16 +19,21 @@ use Symfony\Component\Validator\Constraints as Assert;
* Type of resource.
*
* @ORM\Table(name="chill_budget.resource_type", uniqueConstraints={
*
* @ORM\UniqueConstraint(name="resource_kind_unique_type_idx", fields={"kind"})
* })
*
* @ORM\Entity
*
* @UniqueEntity(fields={"kind"})
*/
class ResourceKind
{
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*/
private ?int $id = null;
@@ -40,7 +45,9 @@ class ResourceKind
/**
* @ORM\Column(type="string", length=255, nullable=false, options={"default": ""})
*
* @Assert\Regex(pattern="/^[a-z0-9\-_]{1,}$/", message="budget.admin.form.kind.only_alphanumeric")
*
* @Assert\Length(min=3)
*/
private string $kind = '';