Applied rector with PHP8.1 migration rules

This commit is contained in:
Jan Böhmer 2023-06-11 14:15:46 +02:00
parent dc6a67c2f0
commit 7ee01d9a05
303 changed files with 1228 additions and 3465 deletions

View file

@ -34,7 +34,7 @@ use Symfony\Component\Validator\Constraints as Assert;
/**
* Class AttachmentType.
*/
#[ORM\Entity(repositoryClass: 'App\Repository\Parts\CategoryRepository')]
#[ORM\Entity(repositoryClass: \App\Repository\Parts\CategoryRepository::class)]
#[ORM\Table(name: '`categories`')]
#[ORM\Index(name: 'category_idx_name', columns: ['name'])]
#[ORM\Index(name: 'category_idx_parent_name', columns: ['parent_id', 'name'])]
@ -112,7 +112,7 @@ class Category extends AbstractPartsContainingDBElement
*/
#[Assert\Valid]
#[Groups(['full'])]
#[ORM\OneToMany(targetEntity: 'App\Entity\Attachments\CategoryAttachment', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OneToMany(targetEntity: \App\Entity\Attachments\CategoryAttachment::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OrderBy(['name' => 'ASC'])]
protected Collection $attachments;
@ -120,7 +120,7 @@ class Category extends AbstractPartsContainingDBElement
*/
#[Assert\Valid]
#[Groups(['full'])]
#[ORM\OneToMany(targetEntity: 'App\Entity\Parameters\CategoryParameter', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OneToMany(targetEntity: \App\Entity\Parameters\CategoryParameter::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])]
protected Collection $parameters;
@ -129,9 +129,6 @@ class Category extends AbstractPartsContainingDBElement
return $this->partname_hint;
}
/**
* @return Category
*/
public function setPartnameHint(string $partname_hint): self
{
$this->partname_hint = $partname_hint;
@ -144,9 +141,6 @@ class Category extends AbstractPartsContainingDBElement
return $this->partname_regex;
}
/**
* @return Category
*/
public function setPartnameRegex(string $partname_regex): self
{
$this->partname_regex = $partname_regex;
@ -159,9 +153,6 @@ class Category extends AbstractPartsContainingDBElement
return $this->disable_footprints;
}
/**
* @return Category
*/
public function setDisableFootprints(bool $disable_footprints): self
{
$this->disable_footprints = $disable_footprints;
@ -174,9 +165,6 @@ class Category extends AbstractPartsContainingDBElement
return $this->disable_manufacturers;
}
/**
* @return Category
*/
public function setDisableManufacturers(bool $disable_manufacturers): self
{
$this->disable_manufacturers = $disable_manufacturers;
@ -189,9 +177,6 @@ class Category extends AbstractPartsContainingDBElement
return $this->disable_autodatasheets;
}
/**
* @return Category
*/
public function setDisableAutodatasheets(bool $disable_autodatasheets): self
{
$this->disable_autodatasheets = $disable_autodatasheets;
@ -204,9 +189,6 @@ class Category extends AbstractPartsContainingDBElement
return $this->disable_properties;
}
/**
* @return Category
*/
public function setDisableProperties(bool $disable_properties): self
{
$this->disable_properties = $disable_properties;
@ -219,9 +201,6 @@ class Category extends AbstractPartsContainingDBElement
return $this->default_description;
}
/**
* @return Category
*/
public function setDefaultDescription(string $default_description): self
{
$this->default_description = $default_description;
@ -234,9 +213,6 @@ class Category extends AbstractPartsContainingDBElement
return $this->default_comment;
}
/**
* @return Category
*/
public function setDefaultComment(string $default_comment): self
{
$this->default_comment = $default_comment;

View file

@ -32,7 +32,7 @@ use Symfony\Component\Validator\Constraints as Assert;
/**
* Class Footprint.
*/
#[ORM\Entity(repositoryClass: 'App\Repository\Parts\FootprintRepository')]
#[ORM\Entity(repositoryClass: \App\Repository\Parts\FootprintRepository::class)]
#[ORM\Table('`footprints`')]
#[ORM\Index(name: 'footprint_idx_name', columns: ['name'])]
#[ORM\Index(name: 'footprint_idx_parent_name', columns: ['parent_id', 'name'])]
@ -40,7 +40,7 @@ class Footprint extends AbstractPartsContainingDBElement
{
#[ORM\ManyToOne(targetEntity: 'Footprint', inversedBy: 'children')]
#[ORM\JoinColumn(name: 'parent_id')]
protected ?\App\Entity\Base\AbstractStructuralDBElement $parent;
protected ?\App\Entity\Base\AbstractStructuralDBElement $parent = null;
/**
* @var Collection
@ -53,21 +53,21 @@ class Footprint extends AbstractPartsContainingDBElement
* @var Collection<int, FootprintAttachment>
*/
#[Assert\Valid]
#[ORM\OneToMany(targetEntity: 'App\Entity\Attachments\FootprintAttachment', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OneToMany(targetEntity: \App\Entity\Attachments\FootprintAttachment::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OrderBy(['name' => 'ASC'])]
protected Collection $attachments;
/**
* @var FootprintAttachment|null
*/
#[ORM\ManyToOne(targetEntity: 'App\Entity\Attachments\FootprintAttachment')]
#[ORM\ManyToOne(targetEntity: \App\Entity\Attachments\FootprintAttachment::class)]
#[ORM\JoinColumn(name: 'id_footprint_3d')]
protected ?FootprintAttachment $footprint_3d = null;
/** @var Collection<int, FootprintParameter>
*/
#[Assert\Valid]
#[ORM\OneToMany(targetEntity: 'App\Entity\Parameters\FootprintParameter', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OneToMany(targetEntity: \App\Entity\Parameters\FootprintParameter::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])]
protected Collection $parameters;
@ -88,13 +88,10 @@ class Footprint extends AbstractPartsContainingDBElement
* Setters
*
*********************************************************************************/
/**
* Sets the 3D Model associated with this footprint.
*
* @param FootprintAttachment|null $new_attachment The new 3D Model
*
* @return Footprint
*/
public function setFootprint3d(?FootprintAttachment $new_attachment): self
{

View file

@ -32,7 +32,7 @@ use Symfony\Component\Validator\Constraints as Assert;
/**
* Class Manufacturer.
*/
#[ORM\Entity(repositoryClass: 'App\Repository\Parts\ManufacturerRepository')]
#[ORM\Entity(repositoryClass: \App\Repository\Parts\ManufacturerRepository::class)]
#[ORM\Table('`manufacturers`')]
#[ORM\Index(name: 'manufacturer_name', columns: ['name'])]
#[ORM\Index(name: 'manufacturer_idx_parent_name', columns: ['parent_id', 'name'])]
@ -40,7 +40,7 @@ class Manufacturer extends AbstractCompany
{
#[ORM\ManyToOne(targetEntity: 'Manufacturer', inversedBy: 'children')]
#[ORM\JoinColumn(name: 'parent_id')]
protected ?\App\Entity\Base\AbstractStructuralDBElement $parent;
protected ?\App\Entity\Base\AbstractStructuralDBElement $parent = null;
/**
* @var Collection
@ -53,14 +53,14 @@ class Manufacturer extends AbstractCompany
* @var Collection<int, ManufacturerAttachment>
*/
#[Assert\Valid]
#[ORM\OneToMany(targetEntity: 'App\Entity\Attachments\ManufacturerAttachment', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OneToMany(targetEntity: \App\Entity\Attachments\ManufacturerAttachment::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OrderBy(['name' => 'ASC'])]
protected Collection $attachments;
/** @var Collection<int, ManufacturerParameter>
*/
#[Assert\Valid]
#[ORM\OneToMany(targetEntity: 'App\Entity\Parameters\ManufacturerParameter', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OneToMany(targetEntity: \App\Entity\Parameters\ManufacturerParameter::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])]
protected Collection $parameters;
public function __construct()

View file

@ -36,7 +36,7 @@ use Symfony\Component\Validator\Constraints as Assert;
* This could be something like N, grams, meters, etc...
*/
#[UniqueEntity('unit')]
#[ORM\Entity(repositoryClass: 'App\Repository\Parts\MeasurementUnitRepository')]
#[ORM\Entity(repositoryClass: \App\Repository\Parts\MeasurementUnitRepository::class)]
#[ORM\Table(name: '`measurement_units`')]
#[ORM\Index(name: 'unit_idx_name', columns: ['name'])]
#[ORM\Index(name: 'unit_idx_parent_name', columns: ['parent_id', 'name'])]
@ -77,20 +77,20 @@ class MeasurementUnit extends AbstractPartsContainingDBElement
#[ORM\ManyToOne(targetEntity: 'MeasurementUnit', inversedBy: 'children')]
#[ORM\JoinColumn(name: 'parent_id')]
protected ?\App\Entity\Base\AbstractStructuralDBElement $parent;
protected ?\App\Entity\Base\AbstractStructuralDBElement $parent = null;
/**
* @var Collection<int, MeasurementUnitAttachment>
*/
#[Assert\Valid]
#[ORM\OneToMany(targetEntity: 'App\Entity\Attachments\MeasurementUnitAttachment', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OneToMany(targetEntity: \App\Entity\Attachments\MeasurementUnitAttachment::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OrderBy(['name' => 'ASC'])]
protected Collection $attachments;
/** @var Collection<int, MeasurementUnitParameter>
*/
#[Assert\Valid]
#[ORM\OneToMany(targetEntity: 'App\Entity\Parameters\MeasurementUnitParameter', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OneToMany(targetEntity: \App\Entity\Parameters\MeasurementUnitParameter::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])]
protected Collection $parameters;
@ -102,11 +102,6 @@ class MeasurementUnit extends AbstractPartsContainingDBElement
return $this->unit;
}
/**
* @param string|null $unit
*
* @return MeasurementUnit
*/
public function setUnit(?string $unit): self
{
$this->unit = $unit;
@ -119,9 +114,6 @@ class MeasurementUnit extends AbstractPartsContainingDBElement
return $this->is_integer;
}
/**
* @return MeasurementUnit
*/
public function setIsInteger(bool $isInteger): self
{
$this->is_integer = $isInteger;
@ -134,9 +126,6 @@ class MeasurementUnit extends AbstractPartsContainingDBElement
return $this->use_si_prefix;
}
/**
* @return MeasurementUnit
*/
public function setUseSIPrefix(bool $usesSIPrefixes): self
{
$this->use_si_prefix = $usesSIPrefixes;

View file

@ -49,7 +49,7 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
* Otherwise, this class would be too big, to be maintained.
*/
#[UniqueEntity(fields: ['ipn'], message: 'part.ipn.must_be_unique')]
#[ORM\Entity(repositoryClass: 'App\Repository\PartRepository')]
#[ORM\Entity(repositoryClass: \App\Repository\PartRepository::class)]
#[ORM\Table('`parts`')]
#[ORM\Index(name: 'parts_idx_datet_name_last_id_needs', columns: ['datetime_added', 'name', 'last_modified', 'id', 'needs_review'])]
#[ORM\Index(name: 'parts_idx_name', columns: ['name'])]
@ -69,7 +69,7 @@ class Part extends AttachmentContainingDBElement
*/
#[Assert\Valid]
#[Groups(['full'])]
#[ORM\OneToMany(targetEntity: 'App\Entity\Parameters\PartParameter', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OneToMany(targetEntity: \App\Entity\Parameters\PartParameter::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])]
protected Collection $parameters;
@ -89,7 +89,7 @@ class Part extends AttachmentContainingDBElement
*/
#[Assert\Valid]
#[Groups(['full'])]
#[ORM\OneToMany(targetEntity: 'App\Entity\Attachments\PartAttachment', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OneToMany(targetEntity: \App\Entity\Attachments\PartAttachment::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OrderBy(['name' => 'ASC'])]
protected Collection $attachments;
@ -97,7 +97,7 @@ class Part extends AttachmentContainingDBElement
* @var Attachment|null
*/
#[Assert\Expression('value == null or value.isPicture()', message: 'part.master_attachment.must_be_picture')]
#[ORM\ManyToOne(targetEntity: 'App\Entity\Attachments\Attachment')]
#[ORM\ManyToOne(targetEntity: \App\Entity\Attachments\Attachment::class)]
#[ORM\JoinColumn(name: 'id_preview_attachment', onDelete: 'SET NULL')]
protected ?Attachment $master_picture_attachment = null;
@ -142,15 +142,13 @@ class Part extends AttachmentContainingDBElement
public function validate(ExecutionContextInterface $context, $payload)
{
//Ensure that the part name fullfills the regex of the category
if ($this->category) {
if ($this->category instanceof \App\Entity\Parts\Category) {
$regex = $this->category->getPartnameRegex();
if (!empty($regex)) {
if (!preg_match($regex, $this->name)) {
$context->buildViolation('part.name.must_match_category_regex')
->atPath('name')
->setParameter('%regex%', $regex)
->addViolation();
}
if (!empty($regex) && !preg_match($regex, $this->name)) {
$context->buildViolation('part.name.must_match_category_regex')
->atPath('name')
->setParameter('%regex%', $regex)
->addViolation();
}
}
}

View file

@ -115,7 +115,7 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
/**
* @var User|null The owner of this part lot
*/
#[ORM\ManyToOne(targetEntity: 'App\Entity\UserSystem\User')]
#[ORM\ManyToOne(targetEntity: \App\Entity\UserSystem\User::class)]
#[ORM\JoinColumn(name: 'id_owner', onDelete: 'SET NULL')]
protected ?User $owner = null;
@ -137,7 +137,7 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
*/
public function isExpired(): ?bool
{
if (null === $this->expiration_date) {
if (!$this->expiration_date instanceof \DateTimeInterface) {
return null;
}
@ -155,8 +155,6 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
/**
* Sets the description of the part lot.
*
* @return PartLot
*/
public function setDescription(string $description): self
{
@ -175,8 +173,6 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
/**
* Sets the comment for this part lot.
*
* @return PartLot
*/
public function setComment(string $comment): self
{
@ -196,9 +192,7 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
/**
* Sets the expiration date for the part lot. Set to null, if the part lot does not expire.
*
* @param \DateTimeInterface|null $expiration_date
*
* @return PartLot
*/
public function setExpirationDate(?\DateTimeInterface $expiration_date): self
{
@ -219,8 +213,6 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
/**
* Sets the storage location, where this part lot is stored.
*
* @return PartLot
*/
public function setStorageLocation(?Storelocation $storage_location): self
{
@ -239,8 +231,6 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
/**
* Sets the part that is stored in this part lot.
*
* @return PartLot
*/
public function setPart(Part $part): self
{
@ -259,8 +249,6 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
/**
* Set the unknown instock status of this part lot.
*
* @return PartLot
*/
public function setInstockUnknown(bool $instock_unknown): self
{
@ -302,9 +290,6 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
return $this->needs_refill;
}
/**
* @return PartLot
*/
public function setNeedsRefill(bool $needs_refill): self
{
$this->needs_refill = $needs_refill;
@ -314,7 +299,6 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
/**
* Returns the owner of this part lot.
* @return User|null
*/
public function getOwner(): ?User
{
@ -323,8 +307,6 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
/**
* Sets the owner of this part lot.
* @param User|null $owner
* @return PartLot
*/
public function setOwner(?User $owner): PartLot
{
@ -349,14 +331,12 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
//When the storage location sets the owner must match, the part lot owner must match the storage location owner
if ($this->getStorageLocation() && $this->getStorageLocation()->isPartOwnerMustMatch()
&& $this->getStorageLocation()->getOwner() && $this->getOwner()) {
if ($this->getOwner() !== $this->getStorageLocation()->getOwner()
&& $this->owner->getID() !== $this->getStorageLocation()->getOwner()->getID()) {
$context->buildViolation('validator.part_lot.owner_must_match_storage_location_owner')
->setParameter('%owner_name%', $this->getStorageLocation()->getOwner()->getFullName(true))
->atPath('owner')
->addViolation();
}
&& $this->getStorageLocation()->getOwner() && $this->getOwner() && ($this->getOwner() !== $this->getStorageLocation()->getOwner()
&& $this->owner->getID() !== $this->getStorageLocation()->getOwner()->getID())) {
$context->buildViolation('validator.part_lot.owner_must_match_storage_location_owner')
->setParameter('%owner_name%', $this->getStorageLocation()->getOwner()->getFullName(true))
->atPath('owner')
->addViolation();
}
}
}

View file

@ -142,7 +142,6 @@ trait AdvancedPropertyTrait
/**
* Sets the internal part number of the part
* @param string $ipn The new IPN of the part
* @return Part
*/
public function setIpn(?string $ipn): Part
{

View file

@ -153,7 +153,6 @@ trait InstockTrait
/**
* Returns true, if the total instock amount of this part is less than the minimum amount.
* @return bool
*/
public function isNotEnoughInstock(): bool
{
@ -204,7 +203,6 @@ trait InstockTrait
/**
* Returns the summed amount of all part lots that are expired. If no part lots are expired 0 is returned.
* @return float
*/
public function getExpiredAmountSum(): float
{

View file

@ -39,7 +39,7 @@ trait OrderTrait
*/
#[Assert\Valid]
#[Groups(['extended', 'full', 'import'])]
#[ORM\OneToMany(targetEntity: 'App\Entity\PriceInformations\Orderdetail', mappedBy: 'part', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OneToMany(targetEntity: \App\Entity\PriceInformations\Orderdetail::class, mappedBy: 'part', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OrderBy(['supplierpartnr' => 'ASC'])]
protected \Doctrine\Common\Collections\Collection $orderdetails;
@ -58,7 +58,7 @@ trait OrderTrait
/**
* @var Orderdetail|null
*/
#[ORM\OneToOne(targetEntity: 'App\Entity\PriceInformations\Orderdetail')]
#[ORM\OneToOne(targetEntity: \App\Entity\PriceInformations\Orderdetail::class)]
#[ORM\JoinColumn(name: 'order_orderdetails_id')]
protected ?Orderdetail $order_orderdetail = null;
@ -105,9 +105,7 @@ trait OrderTrait
{
//If needed hide the obsolete entries
if ($hide_obsolete) {
return $this->orderdetails->filter(function (Orderdetail $orderdetail) {
return ! $orderdetail->getObsolete();
});
return $this->orderdetails->filter(fn(Orderdetail $orderdetail) => ! $orderdetail->getObsolete());
}
return $this->orderdetails;

View file

@ -13,13 +13,13 @@ trait ProjectTrait
/**
* @var \Doctrine\Common\Collections\Collection<\App\Entity\ProjectSystem\ProjectBOMEntry> $project_bom_entries
*/
#[ORM\OneToMany(targetEntity: 'App\Entity\ProjectSystem\ProjectBOMEntry', mappedBy: 'part', cascade: ['remove'], orphanRemoval: true)]
#[ORM\OneToMany(targetEntity: \App\Entity\ProjectSystem\ProjectBOMEntry::class, mappedBy: 'part', cascade: ['remove'], orphanRemoval: true)]
protected \Doctrine\Common\Collections\Collection $project_bom_entries;
/**
* @var Project|null If a project is set here, then this part is special and represents the builds of a project.
*/
#[ORM\OneToOne(targetEntity: 'App\Entity\ProjectSystem\Project', inversedBy: 'build_part')]
#[ORM\OneToOne(targetEntity: \App\Entity\ProjectSystem\Project::class, inversedBy: 'build_part')]
#[ORM\JoinColumn]
protected ?Project $built_project = null;
@ -43,7 +43,6 @@ trait ProjectTrait
/**
* Returns the project that this part represents the builds of, or null if it doesn't
* @return Project|null
*/
public function getBuiltProject(): ?Project
{

View file

@ -35,7 +35,7 @@ use Symfony\Component\Validator\Constraints as Assert;
/**
* Class Store location.
*/
#[ORM\Entity(repositoryClass: 'App\Repository\Parts\StorelocationRepository')]
#[ORM\Entity(repositoryClass: \App\Repository\Parts\StorelocationRepository::class)]
#[ORM\Table('`storelocations`')]
#[ORM\Index(name: 'location_idx_name', columns: ['name'])]
#[ORM\Index(name: 'location_idx_parent_name', columns: ['parent_id', 'name'])]
@ -50,7 +50,7 @@ class Storelocation extends AbstractPartsContainingDBElement
#[ORM\ManyToOne(targetEntity: 'Storelocation', inversedBy: 'children')]
#[ORM\JoinColumn(name: 'parent_id')]
protected ?AbstractStructuralDBElement $parent;
protected ?AbstractStructuralDBElement $parent = null;
/**
* @var MeasurementUnit|null The measurement unit, which parts can be stored in here
@ -62,7 +62,7 @@ class Storelocation extends AbstractPartsContainingDBElement
/** @var Collection<int, StorelocationParameter>
*/
#[Assert\Valid]
#[ORM\OneToMany(targetEntity: 'App\Entity\Parameters\StorelocationParameter', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OneToMany(targetEntity: \App\Entity\Parameters\StorelocationParameter::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])]
protected Collection $parameters;
@ -91,7 +91,7 @@ class Storelocation extends AbstractPartsContainingDBElement
* @var User|null The owner of this storage location
*/
#[Assert\Expression('this.getOwner() == null or this.getOwner().isAnonymousUser() === false', message: 'validator.part_lot.owner_must_not_be_anonymous')]
#[ORM\ManyToOne(targetEntity: 'App\Entity\UserSystem\User')]
#[ORM\ManyToOne(targetEntity: \App\Entity\UserSystem\User::class)]
#[ORM\JoinColumn(name: 'id_owner', onDelete: 'SET NULL')]
protected ?User $owner = null;
@ -105,7 +105,7 @@ class Storelocation extends AbstractPartsContainingDBElement
* @var Collection<int, StorelocationAttachment>
*/
#[Assert\Valid]
#[ORM\OneToMany(targetEntity: 'App\Entity\Attachments\StorelocationAttachment', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OneToMany(targetEntity: \App\Entity\Attachments\StorelocationAttachment::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
protected Collection $attachments;
/********************************************************************************
@ -135,9 +135,6 @@ class Storelocation extends AbstractPartsContainingDBElement
return $this->only_single_part;
}
/**
* @return Storelocation
*/
public function setOnlySinglePart(bool $only_single_part): self
{
$this->only_single_part = $only_single_part;
@ -153,9 +150,6 @@ class Storelocation extends AbstractPartsContainingDBElement
return $this->limit_to_existing_parts;
}
/**
* @return Storelocation
*/
public function setLimitToExistingParts(bool $limit_to_existing_parts): self
{
$this->limit_to_existing_parts = $limit_to_existing_parts;
@ -168,9 +162,6 @@ class Storelocation extends AbstractPartsContainingDBElement
return $this->storage_type;
}
/**
* @return Storelocation
*/
public function setStorageType(?MeasurementUnit $storage_type): self
{
$this->storage_type = $storage_type;
@ -180,7 +171,6 @@ class Storelocation extends AbstractPartsContainingDBElement
/**
* Returns the owner of this storage location
* @return User|null
*/
public function getOwner(): ?User
{
@ -189,8 +179,6 @@ class Storelocation extends AbstractPartsContainingDBElement
/**
* Sets the owner of this storage location
* @param User|null $owner
* @return Storelocation
*/
public function setOwner(?User $owner): Storelocation
{
@ -200,7 +188,6 @@ class Storelocation extends AbstractPartsContainingDBElement
/**
* If this is set to true, only parts lots, which are owned by the same user as the store location are allowed to be stored here.
* @return bool
*/
public function isPartOwnerMustMatch(): bool
{
@ -209,8 +196,6 @@ class Storelocation extends AbstractPartsContainingDBElement
/**
* If this is set to true, only parts lots, which are owned by the same user as the store location are allowed to be stored here.
* @param bool $part_owner_must_match
* @return Storelocation
*/
public function setPartOwnerMustMatch(bool $part_owner_must_match): Storelocation
{
@ -226,7 +211,6 @@ class Storelocation extends AbstractPartsContainingDBElement
* Setters
*
*********************************************************************************/
/**
* Change the "is full" attribute of this store location.
*
@ -235,8 +219,6 @@ class Storelocation extends AbstractPartsContainingDBElement
*
* @param bool $new_is_full * true means that the storelocation is full
* * false means that the storelocation isn't full
*
* @return Storelocation
*/
public function setIsFull(bool $new_is_full): self
{

View file

@ -38,7 +38,7 @@ use Symfony\Component\Validator\Constraints as Assert;
/**
* Class Supplier.
*/
#[ORM\Entity(repositoryClass: 'App\Repository\Parts\SupplierRepository')]
#[ORM\Entity(repositoryClass: \App\Repository\Parts\SupplierRepository::class)]
#[ORM\Table('`suppliers`')]
#[ORM\Index(name: 'supplier_idx_name', columns: ['name'])]
#[ORM\Index(name: 'supplier_idx_parent_name', columns: ['parent_id', 'name'])]
@ -53,12 +53,12 @@ class Supplier extends AbstractCompany
#[ORM\ManyToOne(targetEntity: 'Supplier', inversedBy: 'children')]
#[ORM\JoinColumn(name: 'parent_id')]
protected ?AbstractStructuralDBElement $parent;
protected ?AbstractStructuralDBElement $parent = null;
/**
* @var \Doctrine\Common\Collections\Collection<int, \App\Entity\PriceInformations\Orderdetail>|\App\Entity\PriceInformations\Orderdetail[]
*/
#[ORM\OneToMany(targetEntity: 'App\Entity\PriceInformations\Orderdetail', mappedBy: 'supplier')]
#[ORM\OneToMany(targetEntity: \App\Entity\PriceInformations\Orderdetail::class, mappedBy: 'supplier')]
protected Collection $orderdetails;
/**
@ -66,7 +66,7 @@ class Supplier extends AbstractCompany
* Set to null, to use global base currency.
* @Selectable()
*/
#[ORM\ManyToOne(targetEntity: 'App\Entity\PriceInformations\Currency')]
#[ORM\ManyToOne(targetEntity: \App\Entity\PriceInformations\Currency::class)]
#[ORM\JoinColumn(name: 'default_currency_id')]
protected ?Currency $default_currency = null;
@ -82,14 +82,14 @@ class Supplier extends AbstractCompany
* @var Collection<int, SupplierAttachment>
*/
#[Assert\Valid]
#[ORM\OneToMany(targetEntity: 'App\Entity\Attachments\SupplierAttachment', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OneToMany(targetEntity: \App\Entity\Attachments\SupplierAttachment::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OrderBy(['name' => 'ASC'])]
protected Collection $attachments;
/** @var Collection<int, SupplierParameter>
*/
#[Assert\Valid]
#[ORM\OneToMany(targetEntity: 'App\Entity\Parameters\SupplierParameter', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OneToMany(targetEntity: \App\Entity\Parameters\SupplierParameter::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])]
protected Collection $parameters;
@ -103,8 +103,6 @@ class Supplier extends AbstractCompany
/**
* Sets the default currency.
*
* @return Supplier
*/
public function setDefaultCurrency(?Currency $default_currency): self
{
@ -127,12 +125,10 @@ class Supplier extends AbstractCompany
* Sets the shipping costs for an order with this supplier.
*
* @param BigDecimal|null $shipping_costs a BigDecimal with the shipping costs
*
* @return Supplier
*/
public function setShippingCosts(?BigDecimal $shipping_costs): self
{
if (null === $shipping_costs) {
if (!$shipping_costs instanceof \Brick\Math\BigDecimal) {
$this->shipping_costs = null;
}