Fixed some psalm issues.

This commit is contained in:
Jan Böhmer 2020-03-29 23:13:25 +02:00
parent eb9b24d5d7
commit cb0aa7bc7a
32 changed files with 217 additions and 148 deletions

View file

@ -64,6 +64,7 @@
"phpstan/phpstan": "^0.12.8",
"phpstan/phpstan-doctrine": "^0.12.9",
"phpstan/phpstan-symfony": "^0.12.4",
"psalm/plugin-symfony": "^1.1",
"roave/security-advisories": "dev-master",
"symfony/debug-pack": "*",
"symfony/maker-bundle": "^1.13",

87
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "fd11975fb4135f47bdb119fec531a868",
"content-hash": "482b6aa7bcf3371c734025dc6f151ac1",
"packages": [
{
"name": "beberlei/assert",
@ -10465,6 +10465,55 @@
"description": "Symfony Framework extensions and rules for PHPStan",
"time": "2020-01-22T10:19:41+00:00"
},
{
"name": "psalm/plugin-symfony",
"version": "v1.1.3",
"source": {
"type": "git",
"url": "https://github.com/psalm/psalm-plugin-symfony.git",
"reference": "c2b2dd4ae70bf269023e22efd15b7b31f7efe51d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/psalm/psalm-plugin-symfony/zipball/c2b2dd4ae70bf269023e22efd15b7b31f7efe51d",
"reference": "c2b2dd4ae70bf269023e22efd15b7b31f7efe51d",
"shasum": ""
},
"require": {
"ext-simplexml": "*",
"php": "^7.1",
"symfony/framework-bundle": "^3.0 || ^4.0 || ^5.0",
"vimeo/psalm": "^3.7"
},
"require-dev": {
"codeception/base": "^2.5",
"phpunit/phpunit": "~7.5",
"weirdan/codeception-psalm-module": "^0.2.2"
},
"type": "psalm-plugin",
"extra": {
"psalm": {
"pluginClass": "Psalm\\SymfonyPsalmPlugin\\Plugin"
}
},
"autoload": {
"psr-4": {
"Psalm\\SymfonyPsalmPlugin\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Farhad Safarov",
"email": "farhad.safarov@gmail.com"
}
],
"description": "Psalm Plugin for Symfony",
"time": "2020-03-15T10:38:16+00:00"
},
{
"name": "roave/security-advisories",
"version": "dev-master",
@ -11353,12 +11402,12 @@
"source": {
"type": "git",
"url": "https://github.com/symplify/auto-bind-parameter.git",
"reference": "8b85fc72fddc953feda56c3d06252eb1fafb21ef"
"reference": "ac4d0fff0159becdf0044641b9eb48e89afe1480"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symplify/auto-bind-parameter/zipball/8b85fc72fddc953feda56c3d06252eb1fafb21ef",
"reference": "8b85fc72fddc953feda56c3d06252eb1fafb21ef",
"url": "https://api.github.com/repos/symplify/auto-bind-parameter/zipball/ac4d0fff0159becdf0044641b9eb48e89afe1480",
"reference": "ac4d0fff0159becdf0044641b9eb48e89afe1480",
"shasum": ""
},
"require": {
@ -11395,12 +11444,12 @@
"source": {
"type": "git",
"url": "https://github.com/symplify/autowire-array-parameter.git",
"reference": "53ae1541e9eca16bd5bae95d627a442092933585"
"reference": "e36a0d7e2e4b0a3764c192ac9cca1b2860255eda"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symplify/autowire-array-parameter/zipball/53ae1541e9eca16bd5bae95d627a442092933585",
"reference": "53ae1541e9eca16bd5bae95d627a442092933585",
"url": "https://api.github.com/repos/symplify/autowire-array-parameter/zipball/e36a0d7e2e4b0a3764c192ac9cca1b2860255eda",
"reference": "e36a0d7e2e4b0a3764c192ac9cca1b2860255eda",
"shasum": ""
},
"require": {
@ -11437,12 +11486,12 @@
"source": {
"type": "git",
"url": "https://github.com/symplify/coding-standard.git",
"reference": "084c7ba3b6cc62f8a271da3a4192f663bc12ff2e"
"reference": "3eebdd4e08ebac565461a06c29e28198996bf1c4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symplify/coding-standard/zipball/084c7ba3b6cc62f8a271da3a4192f663bc12ff2e",
"reference": "084c7ba3b6cc62f8a271da3a4192f663bc12ff2e",
"url": "https://api.github.com/repos/symplify/coding-standard/zipball/3eebdd4e08ebac565461a06c29e28198996bf1c4",
"reference": "3eebdd4e08ebac565461a06c29e28198996bf1c4",
"shasum": ""
},
"require": {
@ -11558,12 +11607,12 @@
"source": {
"type": "git",
"url": "https://github.com/symplify/package-builder.git",
"reference": "9d9b5f8f07058aaeb59ba53bfae52226b3b47236"
"reference": "1cddbbfa94c1d78a380c6b3996d09eb7c5710560"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symplify/package-builder/zipball/9d9b5f8f07058aaeb59ba53bfae52226b3b47236",
"reference": "9d9b5f8f07058aaeb59ba53bfae52226b3b47236",
"url": "https://api.github.com/repos/symplify/package-builder/zipball/1cddbbfa94c1d78a380c6b3996d09eb7c5710560",
"reference": "1cddbbfa94c1d78a380c6b3996d09eb7c5710560",
"shasum": ""
},
"require": {
@ -11604,12 +11653,12 @@
"source": {
"type": "git",
"url": "https://github.com/symplify/set-config-resolver.git",
"reference": "561486147349cb07b5692708748ece68c31bf041"
"reference": "03f58a1cfcb0018c833a0b8d7210ebf652b5d3f1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symplify/set-config-resolver/zipball/561486147349cb07b5692708748ece68c31bf041",
"reference": "561486147349cb07b5692708748ece68c31bf041",
"url": "https://api.github.com/repos/symplify/set-config-resolver/zipball/03f58a1cfcb0018c833a0b8d7210ebf652b5d3f1",
"reference": "03f58a1cfcb0018c833a0b8d7210ebf652b5d3f1",
"shasum": ""
},
"require": {
@ -11647,12 +11696,12 @@
"source": {
"type": "git",
"url": "https://github.com/symplify/smart-file-system.git",
"reference": "9f6320c3b22c81e85f51aabf66c927bbf4d8c20f"
"reference": "d81f1b5ffa083713c49e0308e0f94be7ff4b55fc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symplify/smart-file-system/zipball/9f6320c3b22c81e85f51aabf66c927bbf4d8c20f",
"reference": "9f6320c3b22c81e85f51aabf66c927bbf4d8c20f",
"url": "https://api.github.com/repos/symplify/smart-file-system/zipball/d81f1b5ffa083713c49e0308e0f94be7ff4b55fc",
"reference": "d81f1b5ffa083713c49e0308e0f94be7ff4b55fc",
"shasum": ""
},
"require": {

View file

@ -1,5 +1,6 @@
<?xml version="1.0"?>
<psalm
errorLevel="5"
totallyTyped="false"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@ -52,4 +53,4 @@
<InvalidStringClass errorLevel="info"/>
</issueHandlers>
</psalm>
<plugins><pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/></plugins></psalm>

View file

@ -43,7 +43,7 @@ declare(strict_types=1);
namespace App\DataFixtures;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Persistence\ObjectManager;
class AppFixtures extends Fixture
{

View file

@ -52,7 +52,7 @@ use App\Entity\Parts\MeasurementUnit;
use App\Entity\Parts\Storelocation;
use App\Entity\Parts\Supplier;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Persistence\ObjectManager;
use Doctrine\ORM\EntityManagerInterface;
use InvalidArgumentException;

View file

@ -44,7 +44,7 @@ namespace App\DataFixtures;
use App\Entity\UserSystem\Group;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Persistence\ObjectManager;
class GroupFixtures extends Fixture
{

View file

@ -44,7 +44,7 @@ namespace App\DataFixtures;
use App\Entity\UserSystem\User;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Persistence\ObjectManager;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;

View file

@ -98,7 +98,7 @@ class FetchJoinORMAdapter extends ORMAdapter
}
}
public function getCount(QueryBuilder $queryBuilder, $identifier)
public function getCount(QueryBuilder $queryBuilder, string $identifier)
{
$paginator = new Paginator($queryBuilder);

View file

@ -216,7 +216,7 @@ class ORMAdapter extends AbstractAdapter
*
* @return int
*/
protected function getCount(QueryBuilder $queryBuilder, $identifier)
protected function getCount(QueryBuilder $queryBuilder, string $identifier)
{
$qb = clone $queryBuilder;

View file

@ -56,13 +56,13 @@ class AttachmentType extends AbstractStructuralDBElement
*/
protected $filetype_filter = '';
/**
* @var Collection<AttachmentTypeAttachment>
* @var Collection<int, AttachmentTypeAttachment>
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\AttachmentTypeAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @Assert\Valid()
*/
protected $attachments;
/** @var Collection<AttachmentTypeParameter>
/** @var Collection<int, AttachmentTypeParameter>
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\AttachmentTypeParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
* @Assert\Valid()
@ -70,7 +70,7 @@ class AttachmentType extends AbstractStructuralDBElement
protected $parameters;
/**
* @var Collection|Attachment[]
* @var Collection<int, Attachment>
* @ORM\OneToMany(targetEntity="Attachment", mappedBy="attachment_type")
*/
protected $attachments_with_type;

View file

@ -93,12 +93,12 @@ class Device extends AbstractPartsContainingDBElement
*/
protected $order_only_missing_parts = false;
/**
* @var Collection<DeviceAttachment>
* @var Collection<int, DeviceAttachment>
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\DeviceAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
*/
protected $attachments;
/** @var Collection<DeviceParameter>
/** @var Collection<int, DeviceParameter>
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\DeviceParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
*/

View file

@ -39,9 +39,11 @@ trait ParametersTrait
/**
* Return all associated specifications.
*
* @return Collection<AbstractParameter>
* @return \Doctrine\Common\Collections\Collection
*
* @psalm-return \Doctrine\Common\Collections\Collection<int, PartParameter>
*/
public function getParameters(): Collection
public function getParameters(): \Doctrine\Common\Collections\Collection
{
return $this->parameters;
}

View file

@ -101,13 +101,13 @@ class Category extends AbstractPartsContainingDBElement
*/
protected $default_comment = '';
/**
* @var Collection|CategoryAttachment[]
* @var Collection<int, CategoryAttachment>
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\CategoryAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @Assert\Valid()
*/
protected $attachments;
/** @var Collection|CategoryParameter[]
/** @var Collection<int, CategoryParameter>
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\CategoryParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
* @Assert\Valid()

View file

@ -81,7 +81,7 @@ class Footprint extends AbstractPartsContainingDBElement
*/
protected $parts;
/**
* @var Collection<FootprintAttachment>
* @var Collection<int, FootprintAttachment>
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\FootprintAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @Assert\Valid()
*/
@ -94,7 +94,7 @@ class Footprint extends AbstractPartsContainingDBElement
*/
protected $footprint_3d;
/** @var Collection<FootprintParameter>
/** @var Collection<int, FootprintParameter>
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\FootprintParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})@ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
* @Assert\Valid()

View file

@ -81,13 +81,13 @@ class Manufacturer extends AbstractCompany
*/
protected $parts;
/**
* @var Collection<ManufacturerAttachment>
* @var Collection<int, ManufacturerAttachment>
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\ManufacturerAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @Assert\Valid()
*/
protected $attachments;
/** @var Collection<ManufacturerParameter>
/** @var Collection<int, ManufacturerParameter>
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\ManufacturerParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
* @Assert\Valid()

View file

@ -98,13 +98,13 @@ class MeasurementUnit extends AbstractPartsContainingDBElement
*/
protected $parts;
/**
* @var Collection<MeasurementUnitAttachment>
* @var Collection<int, MeasurementUnitAttachment>
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\MeasurementUnitAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @Assert\Valid()
*/
protected $attachments;
/** @var Collection<MeasurementUnitParameter>
/** @var Collection<int, MeasurementUnitParameter>
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\MeasurementUnitParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
* @Assert\Valid()

View file

@ -92,7 +92,7 @@ class Part extends AttachmentContainingDBElement
*/
protected $devices = [];
/** @var Collection<PartParameter>
/** @var Collection<int, PartParameter>
* @Assert\Valid()
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\PartParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
@ -119,7 +119,7 @@ class Part extends AttachmentContainingDBElement
protected $name = '';
/**
* @var Collection<PartAttachment>
* @var Collection<int, PartAttachment>
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\PartAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ColumnSecurity(type="collection", prefix="attachments")
* @Assert\Valid()

View file

@ -92,7 +92,7 @@ class Storelocation extends AbstractPartsContainingDBElement
*/
protected $parts;
/** @var Collection<StorelocationParameter>
/** @var Collection<int, StorelocationParameter>
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\StorelocationParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
* @Assert\Valid()
@ -117,7 +117,7 @@ class Storelocation extends AbstractPartsContainingDBElement
*/
protected $limit_to_existing_parts = false;
/**
* @var Collection<StorelocationAttachment>
* @var Collection<int, StorelocationAttachment>
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\StorelocationAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @Assert\Valid()
*/

View file

@ -109,13 +109,13 @@ class Supplier extends AbstractCompany
protected $parts;
/**
* @var Collection<SupplierAttachment>
* @var Collection<int, SupplierAttachment>
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\SupplierAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @Assert\Valid()
*/
protected $attachments;
/** @var Collection<SupplierParameter>
/** @var Collection<int, SupplierParameter>
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\SupplierParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
* @Assert\Valid()

View file

@ -88,13 +88,13 @@ class Currency extends AbstractStructuralDBElement
protected $parent;
/**
* @var Collection<CurrencyAttachment>
* @var Collection<int, CurrencyAttachment>
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\CurrencyAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @Assert\Valid()
*/
protected $attachments;
/** @var Collection<CurrencyParameter>
/** @var Collection<int, CurrencyParameter>
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\CurrencyParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
* @Assert\Valid()

View file

@ -138,9 +138,9 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
/**
* Get the orderdetail to which this pricedetail belongs to this pricedetails.
*
* @return Orderdetail the orderdetail this price belongs to
* @return Orderdetail|null the orderdetail this price belongs to
*/
public function getOrderdetail(): Orderdetail
public function getOrderdetail(): ?Orderdetail
{
return $this->orderdetail;
}
@ -165,9 +165,12 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
* You will get the price for $multiplier parts. If you want the price which is stored
* in the database, you have to pass the "price_related_quantity" count as $multiplier.
*
* @return string the price as a bcmath string
* @param float|string $multiplier The returned price (float or string) will be multiplied
* with this multiplier.
*
* @return null|string the price as a bcmath string
*/
public function getPricePerUnit($multiplier = 1.0): string
public function getPricePerUnit($multiplier = 1.0): ?string
{
$multiplier = (string) $multiplier;
$tmp = bcmul($this->price, $multiplier, static::PRICE_PRECISION);

View file

@ -81,7 +81,7 @@ class Group extends AbstractStructuralDBElement implements HasPermissionsInterfa
*/
protected $enforce2FA = false;
/**
* @var Collection<GroupAttachment>
* @var Collection<int, GroupAttachment>
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\ManufacturerAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @Assert\Valid()
*/
@ -93,7 +93,7 @@ class Group extends AbstractStructuralDBElement implements HasPermissionsInterfa
*/
protected $permissions;
/** @var Collection<GroupParameter>
/** @var Collection<int, GroupParameter>
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\GroupParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
* @Assert\Valid()

View file

@ -227,7 +227,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
protected $settings = [];
/**
* @var Collection|UserAttachment[]
* @var Collection<int, UserAttachment>
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\UserAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
*/
protected $attachments;
@ -237,7 +237,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
*/
protected $backupCodesGenerationDate;
/** @var Collection<TwoFactorKeyInterface>
/** @var Collection<int, TwoFactorKeyInterface>
* @ORM\OneToMany(targetEntity="App\Entity\UserSystem\U2FKey", mappedBy="user", cascade={"REMOVE"}, orphanRemoval=true)
*/
protected $u2fKeys;
@ -864,7 +864,9 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
/**
* Get all U2F Keys that are associated with this user.
*
* @return Collection<TwoFactorKeyInterface>
* @return Collection
*
* @psalm-return Collection<int, TwoFactorKeyInterface>
*/
public function getU2FKeys(): Collection
{

View file

@ -283,7 +283,7 @@ class EventLoggerSubscriber implements EventSubscriber
}, ARRAY_FILTER_USE_BOTH);
}
protected function saveChangeSet(AbstractDBElement $entity, AbstractLogEntry $logEntry, EntityManagerInterface $em, $element_deleted = false): void
protected function saveChangeSet(AbstractDBElement $entity, AbstractLogEntry $logEntry, EntityManagerInterface $em, bool $element_deleted = false): void
{
$uow = $em->getUnitOfWork();

View file

@ -191,7 +191,7 @@ class StructuralEntityType extends AbstractType
*
* @throws TransformationFailedException when the transformation fails
*/
public function transform($value, $options)
public function transform($value, array $options)
{
return $value;
}
@ -223,7 +223,7 @@ class StructuralEntityType extends AbstractType
*
* @throws TransformationFailedException when the transformation fails
*/
public function reverseTransform($value, $options)
public function reverseTransform($value, array $options)
{
/* This step is important in combination with the caching!
The elements deserialized from cache, are not known to Doctrinte ORM any more, so doctrine thinks,

View file

@ -50,7 +50,7 @@ class DBElementRepository extends EntityRepository
$this->setField($element, 'id', $new_id);
}
protected function setField(AbstractDBElement $element, string $field, $new_value): void
protected function setField(AbstractDBElement $element, string $field, int $new_value): void
{
$reflection = new \ReflectionClass(get_class($element));
$property = $reflection->getProperty($field);

View file

@ -65,11 +65,14 @@ class AmountFormatter
* @param MeasurementUnit|null $unit The measurement unit, whose unit symbol should be used for formatting.
* If set to null, it is assumed that the part amount is measured in pieces.
*
* @param MeasurementUnit|null $unit The measurement unit, whose unit symbol should be used for formatting.
* If set to null, it is assumed that the part amount is measured in pieces.
*
* @return string The formatted string
*
* @throws InvalidArgumentException thrown if $value is not numeric
*/
public function format($value, ?MeasurementUnit $unit = null, array $options = [])
public function format(float $value, ?MeasurementUnit $unit = null, array $options = [])
{
if (! is_numeric($value)) {
throw new InvalidArgumentException('$value must be an numeric value!');

View file

@ -61,7 +61,9 @@ class PartPreviewGenerator
*
* @param Part $part the part for which the attachments should be determined
*
* @return Attachment[]
* @return (Attachment|null)[]
*
* @psalm-return list<Attachment|null>
*/
public function getPreviewAttachments(Part $part): array
{

View file

@ -80,6 +80,7 @@ class EntityExporter
* Exports an Entity or an array of entities to multiple file formats.
*
* @param Request $request the request that should be used for option resolving
* @param AbstractNamedDBElement|object[] $entity
*
* @return Response the generated response containing the exported data
*

View file

@ -187,7 +187,7 @@ class EntityURLGenerator
throw new EntityNotSupportedException('The given entity is not supported yet!');
}
public function viewURL($entity): string
public function viewURL(Attachment $entity): ?string
{
if ($entity instanceof Attachment) {
if ($entity->isExternal()) { //For external attachments, return the link to external path
@ -201,7 +201,7 @@ class EntityURLGenerator
throw new EntityNotSupportedException('The given entity is not supported yet!');
}
public function downloadURL($entity): string
public function downloadURL($entity): ?string
{
if ($entity instanceof Attachment) {
if ($entity->isExternal()) { //For external attachments, return the link to external path

View file

@ -39,6 +39,8 @@ class HistoryHelper
* The returned array contains the given element.
*
* @return array
*
* @psalm-return array<\App\Entity\Parameters\AbstractParameter|array-key, mixed>
*/
public function getAssociatedElements(AbstractDBElement $element): array
{

View file

@ -209,6 +209,9 @@ class TimeTravel
return $property->getValue($element);
}
/**
* @param \DateTime|int|null $new_value
*/
protected function setField(AbstractDBElement $element, string $field, $new_value): void
{
$reflection = new \ReflectionClass(get_class($element));