Declare nativeType of parent property explicitly as workaround for bug in symfony TypeInfo
Some checks are pending
Build assets artifact / Build assets artifact (push) Waiting to run
Docker Image Build / docker (push) Waiting to run
Docker Image Build (FrankenPHP) / docker (push) Waiting to run
Static analysis / Static analysis (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.2, mysql) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.3, mysql) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.4, mysql) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.5, mysql) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.2, postgres) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.3, postgres) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.4, postgres) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.5, postgres) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.2, sqlite) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.3, sqlite) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.4, sqlite) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.5, sqlite) (push) Waiting to run

Symfony/type-info returns an invalid property type for the parent property based on the @phpstan-var static phpdoc in the parent. It returns some App\Entity\Base\AttachmentType which does not exists.
Symfony issue: https://github.com/symfony/symfony/issues/62922
This commit is contained in:
Jan Böhmer 2026-01-03 00:47:49 +01:00
parent 402edf096d
commit 2f580c92d1
10 changed files with 30 additions and 10 deletions

View file

@ -47,6 +47,8 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\TypeInfo\Type\NullableType;
use Symfony\Component\TypeInfo\Type\ObjectType;
use Symfony\Component\Validator\Constraints as Assert;
/**
@ -93,7 +95,7 @@ class AttachmentType extends AbstractStructuralDBElement
#[ORM\ManyToOne(targetEntity: AttachmentType::class, inversedBy: 'children')]
#[ORM\JoinColumn(name: 'parent_id')]
#[Groups(['attachment_type:read', 'attachment_type:write'])]
#[ApiProperty(readableLink: true, writableLink: false)]
#[ApiProperty(readableLink: true, writableLink: false, nativeType: new NullableType(new ObjectType(self::class)))]
protected ?AbstractStructuralDBElement $parent = null;
/**

View file

@ -50,6 +50,8 @@ use App\Entity\Parameters\CategoryParameter;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\TypeInfo\Type\NullableType;
use Symfony\Component\TypeInfo\Type\ObjectType;
use Symfony\Component\Validator\Constraints as Assert;
/**
@ -98,7 +100,7 @@ class Category extends AbstractPartsContainingDBElement
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')]
#[ORM\JoinColumn(name: 'parent_id')]
#[Groups(['category:read', 'category:write'])]
#[ApiProperty(readableLink: false, writableLink: false)]
#[ApiProperty(readableLink: false, writableLink: false, nativeType: new NullableType(new ObjectType(self::class)))]
protected ?AbstractStructuralDBElement $parent = null;
#[Groups(['category:read', 'category:write'])]

View file

@ -49,6 +49,8 @@ use App\Entity\Parameters\FootprintParameter;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\TypeInfo\Type\NullableType;
use Symfony\Component\TypeInfo\Type\ObjectType;
use Symfony\Component\Validator\Constraints as Assert;
/**
@ -93,7 +95,7 @@ class Footprint extends AbstractPartsContainingDBElement
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')]
#[ORM\JoinColumn(name: 'parent_id')]
#[Groups(['footprint:read', 'footprint:write'])]
#[ApiProperty(readableLink: false, writableLink: false)]
#[ApiProperty(readableLink: false, writableLink: false, nativeType: new NullableType(new ObjectType(self::class)))]
protected ?AbstractStructuralDBElement $parent = null;
#[ORM\OneToMany(mappedBy: 'parent', targetEntity: self::class)]

View file

@ -48,6 +48,8 @@ use App\Entity\Parameters\ManufacturerParameter;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\TypeInfo\Type\NullableType;
use Symfony\Component\TypeInfo\Type\ObjectType;
use Symfony\Component\Validator\Constraints as Assert;
/**
@ -92,7 +94,7 @@ class Manufacturer extends AbstractCompany
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')]
#[ORM\JoinColumn(name: 'parent_id')]
#[Groups(['manufacturer:read', 'manufacturer:write'])]
#[ApiProperty(readableLink: false, writableLink: false)]
#[ApiProperty(readableLink: false, writableLink: false, nativeType: new NullableType(new ObjectType(self::class)))]
protected ?AbstractStructuralDBElement $parent = null;
#[ORM\OneToMany(mappedBy: 'parent', targetEntity: self::class)]

View file

@ -50,6 +50,8 @@ use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\TypeInfo\Type\NullableType;
use Symfony\Component\TypeInfo\Type\ObjectType;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Constraints\Length;
@ -130,7 +132,7 @@ class MeasurementUnit extends AbstractPartsContainingDBElement
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')]
#[ORM\JoinColumn(name: 'parent_id')]
#[Groups(['measurement_unit:read', 'measurement_unit:write'])]
#[ApiProperty(readableLink: false, writableLink: false)]
#[ApiProperty(readableLink: false, writableLink: false, nativeType: new NullableType(new ObjectType(self::class)))]
protected ?AbstractStructuralDBElement $parent = null;
/**

View file

@ -46,6 +46,8 @@ use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\TypeInfo\Type\NullableType;
use Symfony\Component\TypeInfo\Type\ObjectType;
use Symfony\Component\Validator\Constraints as Assert;
/**
@ -87,7 +89,7 @@ class PartCustomState extends AbstractPartsContainingDBElement
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')]
#[ORM\JoinColumn(name: 'parent_id')]
#[Groups(['part_custom_state:read', 'part_custom_state:write'])]
#[ApiProperty(readableLink: false, writableLink: false)]
#[ApiProperty(readableLink: false, writableLink: false, nativeType: new NullableType(new ObjectType(self::class)))]
protected ?AbstractStructuralDBElement $parent = null;
/**

View file

@ -50,6 +50,8 @@ use App\Entity\UserSystem\User;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\TypeInfo\Type\NullableType;
use Symfony\Component\TypeInfo\Type\ObjectType;
use Symfony\Component\Validator\Constraints as Assert;
/**
@ -97,7 +99,7 @@ class StorageLocation extends AbstractPartsContainingDBElement
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')]
#[ORM\JoinColumn(name: 'parent_id')]
#[Groups(['location:read', 'location:write'])]
#[ApiProperty(readableLink: false, writableLink: false)]
#[ApiProperty(readableLink: false, writableLink: false, nativeType: new NullableType(new ObjectType(self::class)))]
protected ?AbstractStructuralDBElement $parent = null;
#[Groups(['location:read', 'location:write'])]

View file

@ -53,6 +53,8 @@ use Brick\Math\BigDecimal;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\TypeInfo\Type\NullableType;
use Symfony\Component\TypeInfo\Type\ObjectType;
use Symfony\Component\Validator\Constraints as Assert;
/**
@ -99,7 +101,7 @@ class Supplier extends AbstractCompany
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')]
#[ORM\JoinColumn(name: 'parent_id')]
#[Groups(['supplier:read', 'supplier:write'])]
#[ApiProperty(readableLink: false, writableLink: false)]
#[ApiProperty(readableLink: false, writableLink: false, nativeType: new NullableType(new ObjectType(self::class)))]
protected ?AbstractStructuralDBElement $parent = null;
/**

View file

@ -52,6 +52,8 @@ use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\TypeInfo\Type\NullableType;
use Symfony\Component\TypeInfo\Type\ObjectType;
use Symfony\Component\Validator\Constraints as Assert;
/**
@ -125,7 +127,7 @@ class Currency extends AbstractStructuralDBElement
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')]
#[ORM\JoinColumn(name: 'parent_id')]
#[Groups(['currency:read', 'currency:write'])]
#[ApiProperty(readableLink: false, writableLink: false)]
#[ApiProperty(readableLink: false, writableLink: false, nativeType: new NullableType(new ObjectType(self::class)))]
protected ?AbstractStructuralDBElement $parent = null;
/**

View file

@ -49,6 +49,8 @@ use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use InvalidArgumentException;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\TypeInfo\Type\NullableType;
use Symfony\Component\TypeInfo\Type\ObjectType;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
@ -95,7 +97,7 @@ class Project extends AbstractStructuralDBElement
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')]
#[ORM\JoinColumn(name: 'parent_id')]
#[Groups(['project:read', 'project:write'])]
#[ApiProperty(readableLink: false, writableLink: false)]
#[ApiProperty(readableLink: false, writableLink: false, nativeType: new NullableType(new ObjectType(self::class)))]
protected ?AbstractStructuralDBElement $parent = null;
#[Groups(['project:read', 'project:write'])]