mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-03 15:04:32 +02:00
Fixed some PHPStan level 5 issues
This commit is contained in:
parent
74051c5649
commit
19530a9102
35 changed files with 95 additions and 63 deletions
|
@ -110,7 +110,7 @@ abstract class Attachment extends AbstractNamedDBElement
|
|||
protected bool $show_in_table = false;
|
||||
|
||||
#[Assert\NotNull(message: 'validator.attachment.must_not_be_null')]
|
||||
#[ORM\ManyToOne(targetEntity: 'AttachmentType', inversedBy: 'attachments_with_type')]
|
||||
#[ORM\ManyToOne(targetEntity: AttachmentType::class, inversedBy: 'attachments_with_type')]
|
||||
#[ORM\JoinColumn(name: 'type_id', nullable: false)]
|
||||
#[Selectable()]
|
||||
protected ?AttachmentType $attachment_type = null;
|
||||
|
|
|
@ -43,11 +43,11 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||
#[ORM\Index(name: 'attachment_types_idx_parent_name', columns: ['parent_id', 'name'])]
|
||||
class AttachmentType extends AbstractStructuralDBElement
|
||||
{
|
||||
#[ORM\OneToMany(targetEntity: 'AttachmentType', mappedBy: 'parent', cascade: ['persist'])]
|
||||
#[ORM\OneToMany(targetEntity: AttachmentType::class, mappedBy: 'parent', cascade: ['persist'])]
|
||||
#[ORM\OrderBy(['name' => 'ASC'])]
|
||||
protected Collection $children;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: 'AttachmentType', inversedBy: 'children')]
|
||||
#[ORM\ManyToOne(targetEntity: AttachmentType::class, inversedBy: 'children')]
|
||||
#[ORM\JoinColumn(name: 'parent_id')]
|
||||
protected ?AbstractStructuralDBElement $parent = null;
|
||||
|
||||
|
@ -76,7 +76,7 @@ class AttachmentType extends AbstractStructuralDBElement
|
|||
/**
|
||||
* @var Collection<Attachment>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: 'Attachment', mappedBy: 'attachment_type')]
|
||||
#[ORM\OneToMany(targetEntity: Attachment::class, mappedBy: 'attachment_type')]
|
||||
protected Collection $attachments_with_type;
|
||||
|
||||
public function __construct()
|
||||
|
|
|
@ -22,6 +22,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Entity\Base;
|
||||
|
||||
use App\Repository\NamedDBElementRepository;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use App\Entity\Contracts\NamedElementInterface;
|
||||
use App\Entity\Contracts\TimeStampableInterface;
|
||||
|
@ -32,7 +33,7 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||
/**
|
||||
* All subclasses of this class have an attribute "name".
|
||||
*/
|
||||
#[ORM\MappedSuperclass(repositoryClass: 'App\Repository\NamedDBElement')]
|
||||
#[ORM\MappedSuperclass(repositoryClass: NamedDBElementRepository::class)]
|
||||
#[ORM\HasLifecycleCallbacks]
|
||||
abstract class AbstractNamedDBElement extends AbstractDBElement implements NamedElementInterface, TimeStampableInterface, \Stringable
|
||||
{
|
||||
|
|
|
@ -45,11 +45,11 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||
#[ORM\Index(name: 'category_idx_parent_name', columns: ['parent_id', 'name'])]
|
||||
class Category extends AbstractPartsContainingDBElement
|
||||
{
|
||||
#[ORM\OneToMany(targetEntity: 'Category', mappedBy: 'parent')]
|
||||
#[ORM\OneToMany(targetEntity: self::class, mappedBy: 'parent')]
|
||||
#[ORM\OrderBy(['name' => 'ASC'])]
|
||||
protected Collection $children;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: 'Category', inversedBy: 'children')]
|
||||
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')]
|
||||
#[ORM\JoinColumn(name: 'parent_id')]
|
||||
protected ?AbstractStructuralDBElement $parent = null;
|
||||
|
||||
|
|
|
@ -43,11 +43,11 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||
#[ORM\Index(name: 'footprint_idx_parent_name', columns: ['parent_id', 'name'])]
|
||||
class Footprint extends AbstractPartsContainingDBElement
|
||||
{
|
||||
#[ORM\ManyToOne(targetEntity: 'Footprint', inversedBy: 'children')]
|
||||
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')]
|
||||
#[ORM\JoinColumn(name: 'parent_id')]
|
||||
protected ?AbstractStructuralDBElement $parent = null;
|
||||
|
||||
#[ORM\OneToMany(targetEntity: 'Footprint', mappedBy: 'parent')]
|
||||
#[ORM\OneToMany(targetEntity: self::class, mappedBy: 'parent')]
|
||||
#[ORM\OrderBy(['name' => 'ASC'])]
|
||||
protected Collection $children;
|
||||
|
||||
|
|
|
@ -43,11 +43,11 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||
#[ORM\Index(name: 'manufacturer_idx_parent_name', columns: ['parent_id', 'name'])]
|
||||
class Manufacturer extends AbstractCompany
|
||||
{
|
||||
#[ORM\ManyToOne(targetEntity: 'Manufacturer', inversedBy: 'children')]
|
||||
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')]
|
||||
#[ORM\JoinColumn(name: 'parent_id')]
|
||||
protected ?AbstractStructuralDBElement $parent = null;
|
||||
|
||||
#[ORM\OneToMany(targetEntity: 'Manufacturer', mappedBy: 'parent')]
|
||||
#[ORM\OneToMany(targetEntity: self::class, mappedBy: 'parent')]
|
||||
#[ORM\OrderBy(['name' => 'ASC'])]
|
||||
protected Collection $children;
|
||||
|
||||
|
|
|
@ -74,11 +74,11 @@ class MeasurementUnit extends AbstractPartsContainingDBElement
|
|||
#[ORM\Column(type: Types::BOOLEAN, name: 'use_si_prefix')]
|
||||
protected bool $use_si_prefix = false;
|
||||
|
||||
#[ORM\OneToMany(targetEntity: 'MeasurementUnit', mappedBy: 'parent', cascade: ['persist'])]
|
||||
#[ORM\OneToMany(targetEntity: self::class, mappedBy: 'parent', cascade: ['persist'])]
|
||||
#[ORM\OrderBy(['name' => 'ASC'])]
|
||||
protected Collection $children;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: 'MeasurementUnit', inversedBy: 'children')]
|
||||
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')]
|
||||
#[ORM\JoinColumn(name: 'parent_id')]
|
||||
protected ?AbstractStructuralDBElement $parent = null;
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
|
|||
* @var Storelocation|null The storelocation of this lot
|
||||
*/
|
||||
#[Groups(['simple', 'extended', 'full', 'import'])]
|
||||
#[ORM\ManyToOne(targetEntity: 'Storelocation')]
|
||||
#[ORM\ManyToOne(targetEntity: Storelocation::class)]
|
||||
#[ORM\JoinColumn(name: 'id_store_location')]
|
||||
#[Selectable()]
|
||||
protected ?Storelocation $storage_location = null;
|
||||
|
@ -110,7 +110,7 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
|
|||
* @var Part The part that is stored in this lot
|
||||
*/
|
||||
#[Assert\NotNull]
|
||||
#[ORM\ManyToOne(targetEntity: 'Part', inversedBy: 'partLots')]
|
||||
#[ORM\ManyToOne(targetEntity: Part::class, inversedBy: 'partLots')]
|
||||
#[ORM\JoinColumn(name: 'id_part', nullable: false, onDelete: 'CASCADE')]
|
||||
protected Part $part;
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ trait BasicPropertyTrait
|
|||
#[Assert\NotNull(message: 'validator.select_valid_category')]
|
||||
#[Selectable()]
|
||||
#[Groups(['simple', 'extended', 'full', 'import'])]
|
||||
#[ORM\ManyToOne(targetEntity: 'Category')]
|
||||
#[ORM\ManyToOne(targetEntity: Category::class)]
|
||||
#[ORM\JoinColumn(name: 'id_category', nullable: false)]
|
||||
protected ?Category $category = null;
|
||||
|
||||
|
@ -74,7 +74,7 @@ trait BasicPropertyTrait
|
|||
* @var Footprint|null The footprint of this part (e.g. DIP8)
|
||||
*/
|
||||
#[Groups(['simple', 'extended', 'full', 'import'])]
|
||||
#[ORM\ManyToOne(targetEntity: 'Footprint')]
|
||||
#[ORM\ManyToOne(targetEntity: Footprint::class)]
|
||||
#[ORM\JoinColumn(name: 'id_footprint')]
|
||||
#[Selectable()]
|
||||
protected ?Footprint $footprint = null;
|
||||
|
|
|
@ -40,7 +40,7 @@ trait InstockTrait
|
|||
*/
|
||||
#[Assert\Valid]
|
||||
#[Groups(['extended', 'full', 'import'])]
|
||||
#[ORM\OneToMany(targetEntity: 'PartLot', mappedBy: 'part', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OneToMany(targetEntity: PartLot::class, mappedBy: 'part', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy(['amount' => 'DESC'])]
|
||||
protected Collection $partLots;
|
||||
|
||||
|
@ -57,7 +57,7 @@ trait InstockTrait
|
|||
* @var ?MeasurementUnit the unit in which the part's amount is measured
|
||||
*/
|
||||
#[Groups(['extended', 'full', 'import'])]
|
||||
#[ORM\ManyToOne(targetEntity: 'MeasurementUnit')]
|
||||
#[ORM\ManyToOne(targetEntity: MeasurementUnit::class)]
|
||||
#[ORM\JoinColumn(name: 'id_part_unit')]
|
||||
protected ?MeasurementUnit $partUnit = null;
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ trait ManufacturerTrait
|
|||
* @var Manufacturer|null The manufacturer of this part
|
||||
*/
|
||||
#[Groups(['simple', 'extended', 'full', 'import'])]
|
||||
#[ORM\ManyToOne(targetEntity: 'Manufacturer')]
|
||||
#[ORM\ManyToOne(targetEntity: Manufacturer::class)]
|
||||
#[ORM\JoinColumn(name: 'id_manufacturer')]
|
||||
#[Selectable()]
|
||||
protected ?Manufacturer $manufacturer = null;
|
||||
|
|
|
@ -98,7 +98,7 @@ trait OrderTrait
|
|||
*
|
||||
* @param bool $hide_obsolete If true, obsolete orderdetails will NOT be returned
|
||||
*
|
||||
* @return Collection|Orderdetail[] * all orderdetails as a one-dimensional array of Orderdetails objects
|
||||
* @return Collection<int, Orderdetail> * all orderdetails as a one-dimensional array of Orderdetails objects
|
||||
* (empty array if there are no ones)
|
||||
* * the array is sorted by the suppliers names / minimum order quantity
|
||||
*/
|
||||
|
|
|
@ -45,18 +45,18 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||
#[ORM\Index(name: 'location_idx_parent_name', columns: ['parent_id', 'name'])]
|
||||
class Storelocation extends AbstractPartsContainingDBElement
|
||||
{
|
||||
#[ORM\OneToMany(targetEntity: 'Storelocation', mappedBy: 'parent')]
|
||||
#[ORM\OneToMany(targetEntity: self::class, mappedBy: 'parent')]
|
||||
#[ORM\OrderBy(['name' => 'ASC'])]
|
||||
protected Collection $children;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: 'Storelocation', inversedBy: 'children')]
|
||||
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')]
|
||||
#[ORM\JoinColumn(name: 'parent_id')]
|
||||
protected ?AbstractStructuralDBElement $parent = null;
|
||||
|
||||
/**
|
||||
* @var MeasurementUnit|null The measurement unit, which parts can be stored in here
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: 'MeasurementUnit')]
|
||||
#[ORM\ManyToOne(targetEntity: MeasurementUnit::class)]
|
||||
#[ORM\JoinColumn(name: 'storage_type_id')]
|
||||
protected ?MeasurementUnit $storage_type = null;
|
||||
|
||||
|
|
|
@ -49,11 +49,11 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||
#[ORM\Index(name: 'supplier_idx_parent_name', columns: ['parent_id', 'name'])]
|
||||
class Supplier extends AbstractCompany
|
||||
{
|
||||
#[ORM\OneToMany(targetEntity: 'Supplier', mappedBy: 'parent')]
|
||||
#[ORM\OneToMany(targetEntity: self::class, mappedBy: 'parent')]
|
||||
#[ORM\OrderBy(['name' => 'ASC'])]
|
||||
protected Collection $children;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: 'Supplier', inversedBy: 'children')]
|
||||
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')]
|
||||
#[ORM\JoinColumn(name: 'parent_id')]
|
||||
protected ?AbstractStructuralDBElement $parent = null;
|
||||
|
||||
|
|
|
@ -66,11 +66,11 @@ class Currency extends AbstractStructuralDBElement
|
|||
#[ORM\Column(type: Types::STRING)]
|
||||
protected string $iso_code = "";
|
||||
|
||||
#[ORM\OneToMany(targetEntity: 'Currency', mappedBy: 'parent', cascade: ['persist'])]
|
||||
#[ORM\OneToMany(targetEntity: self::class, mappedBy: 'parent', cascade: ['persist'])]
|
||||
#[ORM\OrderBy(['name' => 'ASC'])]
|
||||
protected Collection $children;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: 'Currency', inversedBy: 'children')]
|
||||
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')]
|
||||
#[ORM\JoinColumn(name: 'parent_id')]
|
||||
protected ?AbstractStructuralDBElement $parent = null;
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N
|
|||
|
||||
#[Assert\Valid]
|
||||
#[Groups(['extended', 'full', 'import'])]
|
||||
#[ORM\OneToMany(targetEntity: 'Pricedetail', mappedBy: 'orderdetail', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OneToMany(targetEntity: Pricedetail::class, mappedBy: 'orderdetail', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy(['min_discount_quantity' => 'ASC'])]
|
||||
protected Collection $pricedetails;
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
|
|||
* If this is null, the global base unit is assumed
|
||||
*/
|
||||
#[Groups(['extended', 'full', 'import'])]
|
||||
#[ORM\ManyToOne(targetEntity: 'Currency', inversedBy: 'pricedetails')]
|
||||
#[ORM\ManyToOne(targetEntity: Currency::class, inversedBy: 'pricedetails')]
|
||||
#[ORM\JoinColumn(name: 'id_currency')]
|
||||
#[Selectable()]
|
||||
protected ?Currency $currency = null;
|
||||
|
@ -95,7 +95,7 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
|
|||
* @var Orderdetail|null
|
||||
*/
|
||||
#[Assert\NotNull]
|
||||
#[ORM\ManyToOne(targetEntity: 'Orderdetail', inversedBy: 'pricedetails')]
|
||||
#[ORM\ManyToOne(targetEntity: Orderdetail::class, inversedBy: 'pricedetails')]
|
||||
#[ORM\JoinColumn(name: 'orderdetails_id', nullable: false, onDelete: 'CASCADE')]
|
||||
protected ?Orderdetail $orderdetail = null;
|
||||
|
||||
|
|
|
@ -45,17 +45,17 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
|||
#[ORM\Table(name: 'projects')]
|
||||
class Project extends AbstractStructuralDBElement
|
||||
{
|
||||
#[ORM\OneToMany(targetEntity: 'Project', mappedBy: 'parent')]
|
||||
#[ORM\OneToMany(targetEntity: self::class, mappedBy: 'parent')]
|
||||
#[ORM\OrderBy(['name' => 'ASC'])]
|
||||
protected Collection $children;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: 'Project', inversedBy: 'children')]
|
||||
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')]
|
||||
#[ORM\JoinColumn(name: 'parent_id')]
|
||||
protected ?AbstractStructuralDBElement $parent = null;
|
||||
|
||||
#[Assert\Valid]
|
||||
#[Groups(['extended', 'full'])]
|
||||
#[ORM\OneToMany(targetEntity: 'ProjectBOMEntry', mappedBy: 'project', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OneToMany(targetEntity: ProjectBOMEntry::class, mappedBy: 'project', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
protected Collection $bom_entries;
|
||||
|
||||
#[ORM\Column(type: Types::INTEGER)]
|
||||
|
|
|
@ -76,7 +76,7 @@ class ProjectBOMEntry extends AbstractDBElement
|
|||
/**
|
||||
* @var Project|null
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: 'Project', inversedBy: 'bom_entries')]
|
||||
#[ORM\ManyToOne(targetEntity: Project::class, inversedBy: 'bom_entries')]
|
||||
#[ORM\JoinColumn(name: 'id_device')]
|
||||
protected ?Project $project = null;
|
||||
|
||||
|
|
|
@ -47,18 +47,18 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||
#[NoLockout()]
|
||||
class Group extends AbstractStructuralDBElement implements HasPermissionsInterface
|
||||
{
|
||||
#[ORM\OneToMany(targetEntity: 'Group', mappedBy: 'parent')]
|
||||
#[ORM\OneToMany(targetEntity: self::class, mappedBy: 'parent')]
|
||||
#[ORM\OrderBy(['name' => 'ASC'])]
|
||||
protected Collection $children;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: 'Group', inversedBy: 'children')]
|
||||
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')]
|
||||
#[ORM\JoinColumn(name: 'parent_id')]
|
||||
protected ?AbstractStructuralDBElement $parent = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, User>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: 'User', mappedBy: 'group')]
|
||||
#[ORM\OneToMany(targetEntity: User::class, mappedBy: 'group')]
|
||||
protected Collection $users;
|
||||
|
||||
/**
|
||||
|
@ -77,7 +77,7 @@ class Group extends AbstractStructuralDBElement implements HasPermissionsInterfa
|
|||
protected Collection $attachments;
|
||||
|
||||
#[Groups(['full'])]
|
||||
#[ORM\Embedded(class: 'PermissionData', columnPrefix: 'permissions_')]
|
||||
#[ORM\Embedded(class: PermissionData::class, columnPrefix: 'permissions_')]
|
||||
#[ValidPermission()]
|
||||
protected ?PermissionData $permissions = null;
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
|||
* DO NOT PUT A fetch eager here! Otherwise, you can not unset the group of a user! This seems to be some kind of bug in doctrine. Maybe this is fixed in future versions.
|
||||
*/
|
||||
#[Groups(['extended', 'full', 'import'])]
|
||||
#[ORM\ManyToOne(targetEntity: 'Group', inversedBy: 'users')]
|
||||
#[ORM\ManyToOne(targetEntity: Group::class, inversedBy: 'users')]
|
||||
#[ORM\JoinColumn(name: 'group_id')]
|
||||
#[Selectable]
|
||||
protected ?Group $group = null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue