Applied rector rules up to symfony 6.2

This commit is contained in:
Jan Böhmer 2023-05-28 01:21:05 +02:00
parent 88ea920dfb
commit a43af180a7
145 changed files with 563 additions and 889 deletions

View file

@ -57,9 +57,9 @@ class Project extends AbstractStructuralDBElement
/**
* @ORM\OneToMany(targetEntity="ProjectBOMEntry", mappedBy="project", cascade={"persist", "remove"}, orphanRemoval=true)
* @Assert\Valid()
* @Groups({"extended", "full"})
*/
#[Assert\Valid]
#[Groups(['extended', 'full'])]
protected Collection $bom_entries;
/**
@ -70,9 +70,9 @@ class Project extends AbstractStructuralDBElement
/**
* @var string|null The current status of the project
* @ORM\Column(type="string", length=64, nullable=true)
* @Assert\Choice({"draft","planning","in_production","finished","archived"})
* @Groups({"extended", "full"})
*/
#[Assert\Choice(['draft', 'planning', 'in_production', 'finished', 'archived'])]
#[Groups(['extended', 'full'])]
protected ?string $status = null;
@ -89,8 +89,8 @@ class Project extends AbstractStructuralDBElement
/**
* @ORM\Column(type="text", nullable=false)
* @Groups({"simple", "extended", "full"})
*/
#[Groups(['simple', 'extended', 'full'])]
protected string $description = '';
/**
@ -286,9 +286,7 @@ class Project extends AbstractStructuralDBElement
}
}
/**
* @Assert\Callback
*/
#[Assert\Callback]
public function validate(ExecutionContextInterface $context, $payload)
{
//If this project has subprojects, and these have builds part, they must be included in the BOM

View file

@ -40,9 +40,9 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
* @ORM\Table("project_bom_entries")
* @ORM\HasLifecycleCallbacks()
* @ORM\Entity()
* @UniqueEntity(fields={"part", "project"}, message="project.bom_entry.part_already_in_bom")
* @UniqueEntity(fields={"name", "project"}, message="project.bom_entry.name_already_in_bom", ignoreNull=true)
*/
#[UniqueEntity(fields: ['part', 'project'], message: 'project.bom_entry.part_already_in_bom')]
#[UniqueEntity(fields: ['name', 'project'], message: 'project.bom_entry.name_already_in_bom', ignoreNull: true)]
class ProjectBOMEntry extends AbstractDBElement
{
use TimestampTrait;
@ -50,8 +50,8 @@ class ProjectBOMEntry extends AbstractDBElement
/**
* @var float
* @ORM\Column(type="float", name="quantity")
* @Assert\Positive()
*/
#[Assert\Positive]
protected float $quantity;
/**
@ -63,11 +63,8 @@ class ProjectBOMEntry extends AbstractDBElement
/**
* @var string|null An optional name describing this BOM entry (useful for non-part entries)
* @ORM\Column(type="string", nullable=true)
* @Assert\Expression(
* "this.getPart() !== null or this.getName() !== null",
* message="validator.project.bom_entry.name_or_part_needed"
* )
*/
#[Assert\Expression('this.getPart() !== null or this.getName() !== null', message: 'validator.project.bom_entry.name_or_part_needed')]
protected ?string $name = null;
/**
@ -93,11 +90,8 @@ class ProjectBOMEntry extends AbstractDBElement
/**
* @var BigDecimal|null The price of this non-part BOM entry
* @ORM\Column(type="big_decimal", precision=11, scale=5, nullable=true)
* @Assert\AtLeastOneOf({
* @BigDecimalPositive(),
* @Assert\IsNull()
* })
*/
#[Assert\AtLeastOneOf([new BigDecimalPositive(), new Assert\IsNull()])]
protected ?BigDecimal $price;
/**
@ -269,9 +263,7 @@ class ProjectBOMEntry extends AbstractDBElement
return $this->part !== null;
}
/**
* @Assert\Callback
*/
#[Assert\Callback]
public function validate(ExecutionContextInterface $context, $payload): void
{
//Round quantity to whole numbers, if the part is not a decimal part