diff --git a/src/Controller/AdminPages/BaseAdminController.php b/src/Controller/AdminPages/BaseAdminController.php index 11f49c92..92f6ee07 100644 --- a/src/Controller/AdminPages/BaseAdminController.php +++ b/src/Controller/AdminPages/BaseAdminController.php @@ -327,9 +327,8 @@ abstract class BaseAdminController extends AbstractController try { $errors = $importer->importFileAndPersistToDB($file, $options); - /** @var ConstraintViolationList $error */ foreach ($errors as $name => $error) { - foreach ($error['violations'] as $violation) { + foreach ($error as $violation) { $this->addFlash('error', $name.': '.$violation->getMessage()); } } diff --git a/src/DataTables/Filters/Constraints/EntityConstraint.php b/src/DataTables/Filters/Constraints/EntityConstraint.php index b0eed001..40293e02 100644 --- a/src/DataTables/Filters/Constraints/EntityConstraint.php +++ b/src/DataTables/Filters/Constraints/EntityConstraint.php @@ -40,8 +40,8 @@ class EntityConstraint extends AbstractConstraint * @param class-string $class * @param string $property * @param string|null $identifier - * @param null $value - * @param string $operator + * @param null|T $value + * @param string|null $operator */ public function __construct(protected ?NodesListBuilder $nodesListBuilder, protected string $class, @@ -82,9 +82,10 @@ class EntityConstraint extends AbstractConstraint } /** - * @param T|null $value + * @param AbstractDBElement|null $value + * @phpstan-param T|null $value */ - public function setValue(?AbstractDBElement $value): void + public function setValue(AbstractDBElement|null $value): void { if (!$value instanceof $this->class) { throw new \InvalidArgumentException('The value must be an instance of ' . $this->class); diff --git a/src/DataTables/Filters/Constraints/FilterTrait.php b/src/DataTables/Filters/Constraints/FilterTrait.php index 583fa98a..26707841 100644 --- a/src/DataTables/Filters/Constraints/FilterTrait.php +++ b/src/DataTables/Filters/Constraints/FilterTrait.php @@ -29,7 +29,7 @@ trait FilterTrait protected bool $useHaving = false; - public function useHaving($value = true): self + public function useHaving($value = true): static { $this->useHaving = $value; return $this; diff --git a/src/DataTables/Filters/PartFilter.php b/src/DataTables/Filters/PartFilter.php index 1419687a..3d4e8ad7 100644 --- a/src/DataTables/Filters/PartFilter.php +++ b/src/DataTables/Filters/PartFilter.php @@ -85,6 +85,7 @@ class PartFilter implements FilterInterface protected IntConstraint $attachmentsCount; protected EntityConstraint $attachmentType; protected TextConstraint $attachmentName; + /** @var ArrayCollection */ protected ArrayCollection $parameters; protected IntConstraint $parametersCount; diff --git a/src/Entity/Attachments/Attachment.php b/src/Entity/Attachments/Attachment.php index 003b7cd9..06e7fdd6 100644 --- a/src/Entity/Attachments/Attachment.php +++ b/src/Entity/Attachments/Attachment.php @@ -37,6 +37,7 @@ use LogicException; /** * Class Attachment. * @see \App\Tests\Entity\Attachments\AttachmentTest + * @template-covariant T of AttachmentContainingDBElement */ #[ORM\Entity(repositoryClass: AttachmentRepository::class)] #[ORM\InheritanceType('SINGLE_TABLE')] @@ -75,9 +76,9 @@ abstract class Attachment extends AbstractNamedDBElement /** * @var string The class of the element that can be passed to this attachment. Must be overridden in subclasses. - * + * @phpstan-var class-string */ - protected const ALLOWED_ELEMENT_CLASS = ''; + protected const ALLOWED_ELEMENT_CLASS = AttachmentContainingDBElement::class; /** * @var string|null the original filename the file had, when the user uploaded it @@ -101,6 +102,7 @@ abstract class Attachment extends AbstractNamedDBElement /** * ORM mapping is done in subclasses (like PartAttachment). + * @phpstan-param T|null $element */ protected ?AttachmentContainingDBElement $element = null; @@ -116,7 +118,7 @@ abstract class Attachment extends AbstractNamedDBElement public function __construct() { //parent::__construct(); - if ('' === static::ALLOWED_ELEMENT_CLASS) { + if (AttachmentContainingDBElement::class === static::ALLOWED_ELEMENT_CLASS) { throw new LogicException('An *Attachment class must override the ALLOWED_ELEMENT_CLASS const!'); } } diff --git a/src/Entity/Attachments/AttachmentContainingDBElement.php b/src/Entity/Attachments/AttachmentContainingDBElement.php index 340c5d77..e72276d8 100644 --- a/src/Entity/Attachments/AttachmentContainingDBElement.php +++ b/src/Entity/Attachments/AttachmentContainingDBElement.php @@ -31,13 +31,17 @@ use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Serializer\Annotation\Groups; +/** + * @template-covariant AT of Attachment + */ #[ORM\MappedSuperclass] abstract class AttachmentContainingDBElement extends AbstractNamedDBElement implements HasMasterAttachmentInterface, HasAttachmentsInterface { use MasterAttachmentTrait; /** - * @var Attachment[]|Collection + * @var Collection + * @phpstan-var Collection * ORM Mapping is done in subclasses (e.g. Part) */ #[Groups(['full'])] @@ -76,7 +80,7 @@ abstract class AttachmentContainingDBElement extends AbstractNamedDBElement impl /** * Gets all attachments associated with this element. * - * @return Attachment[]|Collection + * @return Collection */ public function getAttachments(): Collection { diff --git a/src/Entity/Attachments/AttachmentType.php b/src/Entity/Attachments/AttachmentType.php index 90e6baf7..72752a72 100644 --- a/src/Entity/Attachments/AttachmentType.php +++ b/src/Entity/Attachments/AttachmentType.php @@ -35,6 +35,7 @@ use Symfony\Component\Validator\Constraints as Assert; /** * Class AttachmentType. * @see \App\Tests\Entity\Attachments\AttachmentTypeTest + * @extends AbstractStructuralDBElement */ #[ORM\Entity(repositoryClass: StructuralDBElementRepository::class)] #[ORM\Table(name: '`attachment_types`')] diff --git a/src/Entity/Attachments/AttachmentTypeAttachment.php b/src/Entity/Attachments/AttachmentTypeAttachment.php index 3c81b464..31398595 100644 --- a/src/Entity/Attachments/AttachmentTypeAttachment.php +++ b/src/Entity/Attachments/AttachmentTypeAttachment.php @@ -27,6 +27,7 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; /** * A attachment attached to an attachmentType element. + * @extends Attachment */ #[UniqueEntity(['name', 'attachment_type', 'element'])] #[ORM\Entity] diff --git a/src/Entity/Attachments/CategoryAttachment.php b/src/Entity/Attachments/CategoryAttachment.php index ea987b64..63b4178d 100644 --- a/src/Entity/Attachments/CategoryAttachment.php +++ b/src/Entity/Attachments/CategoryAttachment.php @@ -28,6 +28,7 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; /** * An attachment attached to a category element. + * @extends Attachment */ #[UniqueEntity(['name', 'attachment_type', 'element'])] #[ORM\Entity] diff --git a/src/Entity/Base/AbstractCompany.php b/src/Entity/Base/AbstractCompany.php index 4d0678c4..ca6d1b88 100644 --- a/src/Entity/Base/AbstractCompany.php +++ b/src/Entity/Base/AbstractCompany.php @@ -22,6 +22,8 @@ declare(strict_types=1); namespace App\Entity\Base; +use App\Entity\Attachments\Attachment; +use App\Entity\Parameters\AbstractParameter; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Serializer\Annotation\Groups; @@ -30,6 +32,10 @@ use Symfony\Component\Validator\Constraints as Assert; /** * This abstract class is used for companies like suppliers or manufacturers. + * + * @template-covariant AT of Attachment + * @template-covariant PT of AbstractParameter + * @extends AbstractPartsContainingDBElement */ #[ORM\MappedSuperclass] abstract class AbstractCompany extends AbstractPartsContainingDBElement diff --git a/src/Entity/Base/AbstractPartsContainingDBElement.php b/src/Entity/Base/AbstractPartsContainingDBElement.php index 211340bc..108d3bbd 100644 --- a/src/Entity/Base/AbstractPartsContainingDBElement.php +++ b/src/Entity/Base/AbstractPartsContainingDBElement.php @@ -22,13 +22,19 @@ declare(strict_types=1); namespace App\Entity\Base; +use App\Entity\Attachments\Attachment; +use App\Entity\Attachments\AttachmentContainingDBElement; +use App\Entity\Parameters\AbstractParameter; +use App\Entity\Parameters\ParametersTrait; use App\Repository\AbstractPartsContainingRepository; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Serializer\Annotation\Groups; /** - * Class PartsContainingDBElement. + * @template-covariant AT of Attachment + * @template-covariant PT of AbstractParameter + * @extends AbstractStructuralDBElement */ #[ORM\MappedSuperclass(repositoryClass: AbstractPartsContainingRepository::class)] abstract class AbstractPartsContainingDBElement extends AbstractStructuralDBElement diff --git a/src/Entity/Base/AbstractStructuralDBElement.php b/src/Entity/Base/AbstractStructuralDBElement.php index 0a5b6765..f1e3794c 100644 --- a/src/Entity/Base/AbstractStructuralDBElement.php +++ b/src/Entity/Base/AbstractStructuralDBElement.php @@ -22,12 +22,16 @@ declare(strict_types=1); namespace App\Entity\Base; +use App\Entity\Attachments\Attachment; +use App\Entity\Parameters\AbstractParameter; use App\Repository\StructuralDBElementRepository; use App\EntityListeners\TreeCacheInvalidationListener; use Doctrine\DBAL\Types\Types; use App\Entity\Attachments\AttachmentContainingDBElement; use App\Entity\Parameters\ParametersTrait; use App\Validator\Constraints\NoneOfItsChildren; +use Symfony\Component\Validator\Constraints as Assert; +use Symfony\Component\Validator\Constraints\Valid; use function count; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; @@ -48,6 +52,12 @@ use Symfony\Component\Serializer\Annotation\Groups; * * * @see \App\Tests\Entity\Base\AbstractStructuralDBElementTest + * + * @template-covariant AT of Attachment + * @template-covariant PT of AbstractParameter + * @template-use ParametersTrait + * @extends AttachmentContainingDBElement + * @uses ParametersTrait */ #[UniqueEntity(fields: ['name', 'parent'], ignoreNull: false, message: 'structural.entity.unique_name')] #[ORM\MappedSuperclass(repositoryClass: StructuralDBElementRepository::class)] @@ -87,15 +97,29 @@ abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement * We can not define the mapping here, or we will get an exception. Unfortunately we have to do the mapping in the * subclasses. * - * @var Collection + * @var Collection + * @phpstan-var Collection */ #[Groups(['include_children'])] protected Collection $children; + /** + * @var AbstractStructuralDBElement|null + * @phpstan-var static|null + */ #[Groups(['include_parents', 'import'])] #[NoneOfItsChildren] protected ?AbstractStructuralDBElement $parent = null; + /** + * Mapping done in subclasses. + * + * @var Collection + * @phpstan-var Collection + */ + #[Assert\Valid()] + protected Collection $parameters; + /** @var string[] all names of all parent elements as an array of strings, * the last array element is the name of the element itself */ @@ -314,9 +338,8 @@ abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement /** * Sets the new parent object. * - * @param AbstractStructuralDBElement|null $new_parent The new parent object - * - * @return AbstractStructuralDBElement + * @param static|null $new_parent The new parent object + * @return $this */ public function setParent(?self $new_parent): self { @@ -325,6 +348,11 @@ abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement throw new \InvalidArgumentException('You can not use one of the element childs as parent!'); } */ + //Ensure that the parent is of the same type as this element + if (!$new_parent instanceof static) { + throw new \InvalidArgumentException('The parent must be of the same type as this element!'); + } + $this->parent = $new_parent; //Add this element as child to the new parent @@ -340,7 +368,7 @@ abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement * * @param string $new_comment the new comment * - * @return AbstractStructuralDBElement + * @return $this */ public function setComment(string $new_comment): self { diff --git a/src/Entity/LabelSystem/LabelProfile.php b/src/Entity/LabelSystem/LabelProfile.php index 9b13e165..30429985 100644 --- a/src/Entity/LabelSystem/LabelProfile.php +++ b/src/Entity/LabelSystem/LabelProfile.php @@ -52,6 +52,9 @@ use Doctrine\ORM\Mapping as ORM; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Component\Validator\Constraints as Assert; +/** + * @extends AttachmentContainingDBElement + */ #[UniqueEntity(['name', 'options.supported_element'])] #[ORM\Entity(repositoryClass: LabelProfileRepository::class)] #[ORM\EntityListeners([TreeCacheInvalidationListener::class])] diff --git a/src/Entity/LogSystem/PartStockChangedLogEntry.php b/src/Entity/LogSystem/PartStockChangedLogEntry.php index 9ffded62..e77ea482 100644 --- a/src/Entity/LogSystem/PartStockChangedLogEntry.php +++ b/src/Entity/LogSystem/PartStockChangedLogEntry.php @@ -86,7 +86,7 @@ class PartStockChangedLogEntry extends AbstractLogEntry * @param float $new_stock The new stock of the lot. * @param float $new_total_part_instock The new total instock of the part. * @param string $comment The comment associated with the change. - * @return static + * @return self */ public static function add(PartLot $lot, float $old_stock, float $new_stock, float $new_total_part_instock, string $comment): self { @@ -100,7 +100,7 @@ class PartStockChangedLogEntry extends AbstractLogEntry * @param float $new_stock The new stock of the lot. * @param float $new_total_part_instock The new total instock of the part. * @param string $comment The comment associated with the change. - * @return static + * @return self */ public static function withdraw(PartLot $lot, float $old_stock, float $new_stock, float $new_total_part_instock, string $comment): self { diff --git a/src/Entity/Parameters/ParametersTrait.php b/src/Entity/Parameters/ParametersTrait.php index 44cbe664..2ccaa763 100644 --- a/src/Entity/Parameters/ParametersTrait.php +++ b/src/Entity/Parameters/ParametersTrait.php @@ -44,20 +44,25 @@ namespace App\Entity\Parameters; use Doctrine\Common\Collections\Collection; use Symfony\Component\Validator\Constraints as Assert; +/** + * @template-covariant T of AbstractParameter + */ trait ParametersTrait { /** * Mapping done in subclasses. * * @var Collection + * @phpstan-var Collection */ #[Assert\Valid] protected Collection $parameters; /** * Return all associated specifications. + * @return Collection + * @phpstan-return Collection * - * @psalm-return Collection */ public function getParameters(): Collection { @@ -66,7 +71,7 @@ trait ParametersTrait /** * Add a new parameter information. - * + * @phpstan-param T $parameter * @return $this */ public function addParameter(AbstractParameter $parameter): self @@ -77,6 +82,9 @@ trait ParametersTrait return $this; } + /** + * @phpstan-param T $parameter + */ public function removeParameter(AbstractParameter $parameter): self { $this->parameters->removeElement($parameter); @@ -84,6 +92,10 @@ trait ParametersTrait return $this; } + /** + * @return array> + * @phpstan-return array> + */ public function getGroupedParameters(): array { $tmp = []; diff --git a/src/Entity/Parts/Category.php b/src/Entity/Parts/Category.php index 7ac0b209..2f4b2d08 100644 --- a/src/Entity/Parts/Category.php +++ b/src/Entity/Parts/Category.php @@ -35,7 +35,9 @@ use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Validator\Constraints as Assert; /** - * Class AttachmentType. + * This entity describes a category, a part can belong to, which is used to group parts by their function. + * + * @extends AbstractPartsContainingDBElement */ #[ORM\Entity(repositoryClass: CategoryRepository::class)] #[ORM\Table(name: '`categories`')] @@ -43,9 +45,6 @@ use Symfony\Component\Validator\Constraints as Assert; #[ORM\Index(name: 'category_idx_parent_name', columns: ['parent_id', 'name'])] class Category extends AbstractPartsContainingDBElement { - /** - * @var Collection - */ #[ORM\OneToMany(targetEntity: 'Category', mappedBy: 'parent')] #[ORM\OrderBy(['name' => 'ASC'])] protected Collection $children; diff --git a/src/Entity/Parts/Footprint.php b/src/Entity/Parts/Footprint.php index 13edd726..8ec1bc35 100644 --- a/src/Entity/Parts/Footprint.php +++ b/src/Entity/Parts/Footprint.php @@ -33,7 +33,9 @@ use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert; /** - * Class Footprint. + * This entity represents a footprint of a part (its physical dimensions and shape). + * + * @extends AbstractPartsContainingDBElement */ #[ORM\Entity(repositoryClass: FootprintRepository::class)] #[ORM\Table('`footprints`')] @@ -45,9 +47,6 @@ class Footprint extends AbstractPartsContainingDBElement #[ORM\JoinColumn(name: 'parent_id')] protected ?AbstractStructuralDBElement $parent = null; - /** - * @var Collection - */ #[ORM\OneToMany(targetEntity: 'Footprint', mappedBy: 'parent')] #[ORM\OrderBy(['name' => 'ASC'])] protected Collection $children; diff --git a/src/Entity/Parts/Manufacturer.php b/src/Entity/Parts/Manufacturer.php index ee595c38..c5b45bcd 100644 --- a/src/Entity/Parts/Manufacturer.php +++ b/src/Entity/Parts/Manufacturer.php @@ -33,7 +33,9 @@ use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert; /** - * Class Manufacturer. + * This entity represents a manufacturer of a part (The company that produces the part). + * + * @extends AbstractCompany */ #[ORM\Entity(repositoryClass: ManufacturerRepository::class)] #[ORM\Table('`manufacturers`')] @@ -45,9 +47,6 @@ class Manufacturer extends AbstractCompany #[ORM\JoinColumn(name: 'parent_id')] protected ?AbstractStructuralDBElement $parent = null; - /** - * @var Collection - */ #[ORM\OneToMany(targetEntity: 'Manufacturer', mappedBy: 'parent')] #[ORM\OrderBy(['name' => 'ASC'])] protected Collection $children; diff --git a/src/Entity/Parts/MeasurementUnit.php b/src/Entity/Parts/MeasurementUnit.php index 10259ace..62a3dd82 100644 --- a/src/Entity/Parts/MeasurementUnit.php +++ b/src/Entity/Parts/MeasurementUnit.php @@ -38,6 +38,8 @@ use Symfony\Component\Validator\Constraints as Assert; /** * This unit represents the unit in which the amount of parts in stock are measured. * This could be something like N, grams, meters, etc... + * + * @extends AbstractPartsContainingDBElement */ #[UniqueEntity('unit')] #[ORM\Entity(repositoryClass: MeasurementUnitRepository::class)] @@ -72,9 +74,6 @@ class MeasurementUnit extends AbstractPartsContainingDBElement #[ORM\Column(type: Types::BOOLEAN, name: 'use_si_prefix')] protected bool $use_si_prefix = false; - /** - * @var Collection - */ #[ORM\OneToMany(targetEntity: 'MeasurementUnit', mappedBy: 'parent', cascade: ['persist'])] #[ORM\OrderBy(['name' => 'ASC'])] protected Collection $children; diff --git a/src/Entity/Parts/Storelocation.php b/src/Entity/Parts/Storelocation.php index 15eef200..205735d4 100644 --- a/src/Entity/Parts/Storelocation.php +++ b/src/Entity/Parts/Storelocation.php @@ -36,7 +36,8 @@ use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Validator\Constraints as Assert; /** - * Class Store location. + * This entity represents a storage location, where parts can be stored. + * @extends AbstractPartsContainingDBElement */ #[ORM\Entity(repositoryClass: StorelocationRepository::class)] #[ORM\Table('`storelocations`')] @@ -44,9 +45,6 @@ use Symfony\Component\Validator\Constraints as Assert; #[ORM\Index(name: 'location_idx_parent_name', columns: ['parent_id', 'name'])] class Storelocation extends AbstractPartsContainingDBElement { - /** - * @var Collection - */ #[ORM\OneToMany(targetEntity: 'Storelocation', mappedBy: 'parent')] #[ORM\OrderBy(['name' => 'ASC'])] protected Collection $children; diff --git a/src/Entity/Parts/Supplier.php b/src/Entity/Parts/Supplier.php index 85fe6db4..f7c56b2e 100644 --- a/src/Entity/Parts/Supplier.php +++ b/src/Entity/Parts/Supplier.php @@ -39,7 +39,9 @@ use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Validator\Constraints as Assert; /** - * Class Supplier. + * This entity represents a supplier of parts (the company that sells the parts). + * + * @extends AbstractCompany */ #[ORM\Entity(repositoryClass: SupplierRepository::class)] #[ORM\Table('`suppliers`')] @@ -47,9 +49,6 @@ use Symfony\Component\Validator\Constraints as Assert; #[ORM\Index(name: 'supplier_idx_parent_name', columns: ['parent_id', 'name'])] class Supplier extends AbstractCompany { - /** - * @var Collection - */ #[ORM\OneToMany(targetEntity: 'Supplier', mappedBy: 'parent')] #[ORM\OrderBy(['name' => 'ASC'])] protected Collection $children; diff --git a/src/Entity/PriceInformations/Currency.php b/src/Entity/PriceInformations/Currency.php index ac41acf2..171f5693 100644 --- a/src/Entity/PriceInformations/Currency.php +++ b/src/Entity/PriceInformations/Currency.php @@ -38,6 +38,8 @@ use Symfony\Component\Validator\Constraints as Assert; /** * This entity describes a currency that can be used for price information. + * + * @extends AbstractStructuralDBElement */ #[UniqueEntity('iso_code')] #[ORM\Entity] diff --git a/src/Entity/ProjectSystem/Project.php b/src/Entity/ProjectSystem/Project.php index 24cc2b25..966d19c1 100644 --- a/src/Entity/ProjectSystem/Project.php +++ b/src/Entity/ProjectSystem/Project.php @@ -37,15 +37,14 @@ use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Context\ExecutionContextInterface; /** - * Class AttachmentType. + * This class represents a project in the database. + * + * @extends AbstractStructuralDBElement */ #[ORM\Entity(repositoryClass: DeviceRepository::class)] #[ORM\Table(name: 'projects')] class Project extends AbstractStructuralDBElement { - /** - * @var Collection - */ #[ORM\OneToMany(targetEntity: 'Project', mappedBy: 'parent')] #[ORM\OrderBy(['name' => 'ASC'])] protected Collection $children; diff --git a/src/Entity/UserSystem/Group.php b/src/Entity/UserSystem/Group.php index b8647847..f833fdfc 100644 --- a/src/Entity/UserSystem/Group.php +++ b/src/Entity/UserSystem/Group.php @@ -37,6 +37,8 @@ use Symfony\Component\Validator\Constraints as Assert; /** * This entity represents a user group. + * + * @extends AbstractStructuralDBElement */ #[ORM\Entity] #[ORM\Table('`groups`')] @@ -45,9 +47,6 @@ use Symfony\Component\Validator\Constraints as Assert; #[NoLockout()] class Group extends AbstractStructuralDBElement implements HasPermissionsInterface { - /** - * @var Collection - */ #[ORM\OneToMany(targetEntity: 'Group', mappedBy: 'parent')] #[ORM\OrderBy(['name' => 'ASC'])] protected Collection $children; diff --git a/src/Entity/UserSystem/User.php b/src/Entity/UserSystem/User.php index d92b0d91..614f01e5 100644 --- a/src/Entity/UserSystem/User.php +++ b/src/Entity/UserSystem/User.php @@ -59,6 +59,8 @@ use Jbtronics\TFAWebauthn\Model\TwoFactorInterface as WebauthnTwoFactorInterface * This entity represents a user, which can log in and have permissions. * Also, this entity is able to save some information about the user, like the names, email-address and other info. * @see \App\Tests\Entity\UserSystem\UserTest + * + * @extends AttachmentContainingDBElement */ #[UniqueEntity('name', message: 'validator.user.username_already_used')] #[ORM\Entity(repositoryClass: UserRepository::class)] diff --git a/src/Repository/DBElementRepository.php b/src/Repository/DBElementRepository.php index 1f1fe7ee..3c626df0 100644 --- a/src/Repository/DBElementRepository.php +++ b/src/Repository/DBElementRepository.php @@ -52,6 +52,7 @@ class DBElementRepository extends EntityRepository * You should only use it to undelete former existing elements, everything else is most likely a bad idea! * * @param AbstractDBElement $element The element whose ID should be changed + * @phpstan-param TEntityClass $element * @param int $new_id The new ID */ public function changeID(AbstractDBElement $element, int $new_id): void @@ -73,6 +74,7 @@ class DBElementRepository extends EntityRepository * Find all elements that match a list of IDs. * * @return AbstractDBElement[] + * @phpstan-return list */ public function getElementsFromIDArray(array $ids): array { diff --git a/src/Services/ImportExportSystem/EntityImporter.php b/src/Services/ImportExportSystem/EntityImporter.php index 1aa50db5..0b4e0f17 100644 --- a/src/Services/ImportExportSystem/EntityImporter.php +++ b/src/Services/ImportExportSystem/EntityImporter.php @@ -26,6 +26,8 @@ use App\Entity\Base\AbstractNamedDBElement; use App\Entity\Base\AbstractStructuralDBElement; use App\Entity\Parts\Category; use App\Entity\Parts\Part; +use Composer\Semver\Constraint\Constraint; +use Symfony\Component\Validator\ConstraintViolationList; use Symplify\EasyCodingStandard\ValueObject\Option; use function count; use Doctrine\ORM\EntityManagerInterface; @@ -238,7 +240,7 @@ class EntityImporter * @param array $options options for the import process * @param AbstractNamedDBElement[] $entities The imported entities are returned in this array * - * @return array An associative array containing an ConstraintViolationList and the entity name as key are returned, + * @return array An associative array containing an ConstraintViolationList and the entity name as key are returned, * if an error happened during validation. When everything was successfully, the array should be empty. */ public function importFileAndPersistToDB(File $file, array $options = [], array &$entities = []): array diff --git a/src/Twig/EntityExtension.php b/src/Twig/EntityExtension.php index a3737c08..ee53847d 100644 --- a/src/Twig/EntityExtension.php +++ b/src/Twig/EntityExtension.php @@ -123,6 +123,6 @@ final class EntityExtension extends AbstractExtension } } - return false; + return null; } } diff --git a/src/Twig/TwigCoreExtension.php b/src/Twig/TwigCoreExtension.php index 2ff6911a..d9a35882 100644 --- a/src/Twig/TwigCoreExtension.php +++ b/src/Twig/TwigCoreExtension.php @@ -54,7 +54,7 @@ final class TwigCoreExtension extends AbstractExtension */ new TwigTest('instanceof', static fn($var, $instance) => $var instanceof $instance), /* Checks if a given variable is an object. E.g. `x is object` */ - new TwigTest('object', static fn($var): object => is_object($var)), + new TwigTest('object', static fn($var): bool => is_object($var)), ]; }