diff --git a/composer.json b/composer.json index fe3f211a..3f4c520f 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/composer.lock b/composer.lock index ab403135..a93aea1d 100644 --- a/composer.lock +++ b/composer.lock @@ -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": { diff --git a/psalm.xml b/psalm.xml index 42f355b2..24e2813d 100644 --- a/psalm.xml +++ b/psalm.xml @@ -1,5 +1,6 @@ - + - + - + - - - - - - - + + + + + + + - - - + + + - - - - - + + + + + - - - - + + + + - + - - + + - + - + - + - + diff --git a/src/DataFixtures/AppFixtures.php b/src/DataFixtures/AppFixtures.php index 141013f0..7a1e1ce1 100644 --- a/src/DataFixtures/AppFixtures.php +++ b/src/DataFixtures/AppFixtures.php @@ -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 { diff --git a/src/DataFixtures/DataStructureFixtures.php b/src/DataFixtures/DataStructureFixtures.php index f2ea23e6..f7106615 100644 --- a/src/DataFixtures/DataStructureFixtures.php +++ b/src/DataFixtures/DataStructureFixtures.php @@ -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; diff --git a/src/DataFixtures/GroupFixtures.php b/src/DataFixtures/GroupFixtures.php index 6c667222..9707ab6a 100644 --- a/src/DataFixtures/GroupFixtures.php +++ b/src/DataFixtures/GroupFixtures.php @@ -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 { diff --git a/src/DataFixtures/UserFixtures.php b/src/DataFixtures/UserFixtures.php index 2d277d86..52ce2f4a 100644 --- a/src/DataFixtures/UserFixtures.php +++ b/src/DataFixtures/UserFixtures.php @@ -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; diff --git a/src/DataTables/Adapter/FetchJoinORMAdapter.php b/src/DataTables/Adapter/FetchJoinORMAdapter.php index a1fc27f2..9714dd36 100644 --- a/src/DataTables/Adapter/FetchJoinORMAdapter.php +++ b/src/DataTables/Adapter/FetchJoinORMAdapter.php @@ -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); diff --git a/src/DataTables/Adapter/ORMAdapter.php b/src/DataTables/Adapter/ORMAdapter.php index be6513ac..157ce4f0 100644 --- a/src/DataTables/Adapter/ORMAdapter.php +++ b/src/DataTables/Adapter/ORMAdapter.php @@ -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; diff --git a/src/Entity/Attachments/AttachmentType.php b/src/Entity/Attachments/AttachmentType.php index 6d0c4804..dfb08385 100644 --- a/src/Entity/Attachments/AttachmentType.php +++ b/src/Entity/Attachments/AttachmentType.php @@ -56,13 +56,13 @@ class AttachmentType extends AbstractStructuralDBElement */ protected $filetype_filter = ''; /** - * @var Collection + * @var Collection * @ORM\OneToMany(targetEntity="App\Entity\Attachments\AttachmentTypeAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) * @Assert\Valid() */ protected $attachments; - /** @var Collection + /** @var Collection * @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 * @ORM\OneToMany(targetEntity="Attachment", mappedBy="attachment_type") */ protected $attachments_with_type; diff --git a/src/Entity/Devices/Device.php b/src/Entity/Devices/Device.php index 45b2ef57..8a1dfd0f 100644 --- a/src/Entity/Devices/Device.php +++ b/src/Entity/Devices/Device.php @@ -93,12 +93,12 @@ class Device extends AbstractPartsContainingDBElement */ protected $order_only_missing_parts = false; /** - * @var Collection + * @var Collection * @ORM\OneToMany(targetEntity="App\Entity\Attachments\DeviceAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) */ protected $attachments; - /** @var Collection + /** @var Collection * @ORM\OneToMany(targetEntity="App\Entity\Parameters\DeviceParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) * @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"}) */ diff --git a/src/Entity/Parameters/ParametersTrait.php b/src/Entity/Parameters/ParametersTrait.php index e543eff0..5ff81c12 100644 --- a/src/Entity/Parameters/ParametersTrait.php +++ b/src/Entity/Parameters/ParametersTrait.php @@ -37,11 +37,13 @@ trait ParametersTrait protected $parameters; /** - * Return all associated specifications. + * Return all associated specifications. * - * @return Collection + * @return \Doctrine\Common\Collections\Collection + * + * @psalm-return \Doctrine\Common\Collections\Collection */ - public function getParameters(): Collection + public function getParameters(): \Doctrine\Common\Collections\Collection { return $this->parameters; } diff --git a/src/Entity/Parts/Category.php b/src/Entity/Parts/Category.php index a2e903e2..c40b7066 100644 --- a/src/Entity/Parts/Category.php +++ b/src/Entity/Parts/Category.php @@ -101,13 +101,13 @@ class Category extends AbstractPartsContainingDBElement */ protected $default_comment = ''; /** - * @var Collection|CategoryAttachment[] + * @var Collection * @ORM\OneToMany(targetEntity="App\Entity\Attachments\CategoryAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) * @Assert\Valid() */ protected $attachments; - /** @var Collection|CategoryParameter[] + /** @var Collection * @ORM\OneToMany(targetEntity="App\Entity\Parameters\CategoryParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) * @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"}) * @Assert\Valid() diff --git a/src/Entity/Parts/Footprint.php b/src/Entity/Parts/Footprint.php index 1a32271a..90042889 100644 --- a/src/Entity/Parts/Footprint.php +++ b/src/Entity/Parts/Footprint.php @@ -81,7 +81,7 @@ class Footprint extends AbstractPartsContainingDBElement */ protected $parts; /** - * @var Collection + * @var Collection * @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 + /** @var Collection * @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() diff --git a/src/Entity/Parts/Manufacturer.php b/src/Entity/Parts/Manufacturer.php index 6d72b3e4..f61a33d0 100644 --- a/src/Entity/Parts/Manufacturer.php +++ b/src/Entity/Parts/Manufacturer.php @@ -81,13 +81,13 @@ class Manufacturer extends AbstractCompany */ protected $parts; /** - * @var Collection + * @var Collection * @ORM\OneToMany(targetEntity="App\Entity\Attachments\ManufacturerAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) * @Assert\Valid() */ protected $attachments; - /** @var Collection + /** @var Collection * @ORM\OneToMany(targetEntity="App\Entity\Parameters\ManufacturerParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) * @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"}) * @Assert\Valid() diff --git a/src/Entity/Parts/MeasurementUnit.php b/src/Entity/Parts/MeasurementUnit.php index 295b04ca..5f9008f7 100644 --- a/src/Entity/Parts/MeasurementUnit.php +++ b/src/Entity/Parts/MeasurementUnit.php @@ -98,13 +98,13 @@ class MeasurementUnit extends AbstractPartsContainingDBElement */ protected $parts; /** - * @var Collection + * @var Collection * @ORM\OneToMany(targetEntity="App\Entity\Attachments\MeasurementUnitAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) * @Assert\Valid() */ protected $attachments; - /** @var Collection + /** @var Collection * @ORM\OneToMany(targetEntity="App\Entity\Parameters\MeasurementUnitParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) * @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"}) * @Assert\Valid() diff --git a/src/Entity/Parts/Part.php b/src/Entity/Parts/Part.php index 9f0b3511..3ee74d6d 100644 --- a/src/Entity/Parts/Part.php +++ b/src/Entity/Parts/Part.php @@ -92,7 +92,7 @@ class Part extends AttachmentContainingDBElement */ protected $devices = []; - /** @var Collection + /** @var Collection * @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 + * @var Collection * @ORM\OneToMany(targetEntity="App\Entity\Attachments\PartAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) * @ColumnSecurity(type="collection", prefix="attachments") * @Assert\Valid() diff --git a/src/Entity/Parts/Storelocation.php b/src/Entity/Parts/Storelocation.php index c0a69768..d7e5d25a 100644 --- a/src/Entity/Parts/Storelocation.php +++ b/src/Entity/Parts/Storelocation.php @@ -92,7 +92,7 @@ class Storelocation extends AbstractPartsContainingDBElement */ protected $parts; - /** @var Collection + /** @var Collection * @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 + * @var Collection * @ORM\OneToMany(targetEntity="App\Entity\Attachments\StorelocationAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) * @Assert\Valid() */ diff --git a/src/Entity/Parts/Supplier.php b/src/Entity/Parts/Supplier.php index cf1bd3c4..a5b02781 100644 --- a/src/Entity/Parts/Supplier.php +++ b/src/Entity/Parts/Supplier.php @@ -109,13 +109,13 @@ class Supplier extends AbstractCompany protected $parts; /** - * @var Collection + * @var Collection * @ORM\OneToMany(targetEntity="App\Entity\Attachments\SupplierAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) * @Assert\Valid() */ protected $attachments; - /** @var Collection + /** @var Collection * @ORM\OneToMany(targetEntity="App\Entity\Parameters\SupplierParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) * @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"}) * @Assert\Valid() diff --git a/src/Entity/PriceInformations/Currency.php b/src/Entity/PriceInformations/Currency.php index 0456c214..d6d8b49e 100644 --- a/src/Entity/PriceInformations/Currency.php +++ b/src/Entity/PriceInformations/Currency.php @@ -88,13 +88,13 @@ class Currency extends AbstractStructuralDBElement protected $parent; /** - * @var Collection + * @var Collection * @ORM\OneToMany(targetEntity="App\Entity\Attachments\CurrencyAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) * @Assert\Valid() */ protected $attachments; - /** @var Collection + /** @var Collection * @ORM\OneToMany(targetEntity="App\Entity\Parameters\CurrencyParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) * @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"}) * @Assert\Valid() diff --git a/src/Entity/PriceInformations/Pricedetail.php b/src/Entity/PriceInformations/Pricedetail.php index 2ecf5cf8..41ee9309 100644 --- a/src/Entity/PriceInformations/Pricedetail.php +++ b/src/Entity/PriceInformations/Pricedetail.php @@ -136,11 +136,11 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface *********************************************************************************/ /** - * Get the orderdetail to which this pricedetail belongs to this pricedetails. + * 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; } @@ -157,17 +157,20 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface } /** - * Get the price for a single unit in the currency associated with this price detail. + * Get the price for a single unit in the currency associated with this price detail. + * + * @param float|string $multiplier The returned price (float or string) will be multiplied + * with this multiplier. + * + * 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. * * @param float|string $multiplier The returned price (float or string) will be multiplied * with this multiplier. * - * 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 + * @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); diff --git a/src/Entity/UserSystem/Group.php b/src/Entity/UserSystem/Group.php index 21de2bd7..36278e7b 100644 --- a/src/Entity/UserSystem/Group.php +++ b/src/Entity/UserSystem/Group.php @@ -81,7 +81,7 @@ class Group extends AbstractStructuralDBElement implements HasPermissionsInterfa */ protected $enforce2FA = false; /** - * @var Collection + * @var Collection * @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 + /** @var Collection * @ORM\OneToMany(targetEntity="App\Entity\Parameters\GroupParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) * @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"}) * @Assert\Valid() diff --git a/src/Entity/UserSystem/User.php b/src/Entity/UserSystem/User.php index 641f0657..db504219 100644 --- a/src/Entity/UserSystem/User.php +++ b/src/Entity/UserSystem/User.php @@ -227,7 +227,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe protected $settings = []; /** - * @var Collection|UserAttachment[] + * @var Collection * @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 + /** @var Collection * @ORM\OneToMany(targetEntity="App\Entity\UserSystem\U2FKey", mappedBy="user", cascade={"REMOVE"}, orphanRemoval=true) */ protected $u2fKeys; @@ -862,9 +862,11 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe } /** - * Get all U2F Keys that are associated with this user. + * Get all U2F Keys that are associated with this user. * - * @return Collection + * @return Collection + * + * @psalm-return Collection */ public function getU2FKeys(): Collection { diff --git a/src/EventSubscriber/EventLoggerSubscriber.php b/src/EventSubscriber/EventLoggerSubscriber.php index f737c98b..8a888ecb 100644 --- a/src/EventSubscriber/EventLoggerSubscriber.php +++ b/src/EventSubscriber/EventLoggerSubscriber.php @@ -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(); diff --git a/src/Form/Type/StructuralEntityType.php b/src/Form/Type/StructuralEntityType.php index 51d8ff6c..2e7dc5be 100644 --- a/src/Form/Type/StructuralEntityType.php +++ b/src/Form/Type/StructuralEntityType.php @@ -153,37 +153,37 @@ class StructuralEntityType extends AbstractType } /** - * Transforms a value from the original representation to a transformed representation. + * Transforms a value from the original representation to a transformed representation. * - * This method is called when the form field is initialized with its default data, on - * two occasions for two types of transformers: + * This method is called when the form field is initialized with its default data, on + * two occasions for two types of transformers: * - * 1. Model transformers which normalize the model data. - * This is mainly useful when the same form type (the same configuration) - * has to handle different kind of underlying data, e.g The DateType can - * deal with strings or \DateTime objects as input. + * 1. Model transformers which normalize the model data. + * This is mainly useful when the same form type (the same configuration) + * has to handle different kind of underlying data, e.g The DateType can + * deal with strings or \DateTime objects as input. * - * 2. View transformers which adapt the normalized data to the view format. - * a/ When the form is simple, the value returned by convention is used - * directly in the view and thus can only be a string or an array. In - * this case the data class should be null. + * 2. View transformers which adapt the normalized data to the view format. + * a/ When the form is simple, the value returned by convention is used + * directly in the view and thus can only be a string or an array. In + * this case the data class should be null. * - * b/ When the form is compound the returned value should be an array or - * an object to be mapped to the children. Each property of the compound - * data will be used as model data by each child and will be transformed - * too. In this case data class should be the class of the object, or null - * when it is an array. + * b/ When the form is compound the returned value should be an array or + * an object to be mapped to the children. Each property of the compound + * data will be used as model data by each child and will be transformed + * too. In this case data class should be the class of the object, or null + * when it is an array. * - * All transformers are called in a configured order from model data to view value. - * At the end of this chain the view data will be validated against the data class - * setting. + * All transformers are called in a configured order from model data to view value. + * At the end of this chain the view data will be validated against the data class + * setting. * - * This method must be able to deal with empty values. Usually this will - * be NULL, but depending on your implementation other empty values are - * possible as well (such as empty strings). The reasoning behind this is - * that data transformers must be chainable. If the transform() method - * of the first data transformer outputs NULL, the second must be able to - * process that value. + * This method must be able to deal with empty values. Usually this will + * be NULL, but depending on your implementation other empty values are + * possible as well (such as empty strings). The reasoning behind this is + * that data transformers must be chainable. If the transform() method + * of the first data transformer outputs NULL, the second must be able to + * process that value. * * @param mixed $value The value in the original representation * @@ -191,31 +191,31 @@ class StructuralEntityType extends AbstractType * * @throws TransformationFailedException when the transformation fails */ - public function transform($value, $options) + public function transform($value, array $options) { return $value; } /** - * Transforms a value from the transformed representation to its original - * representation. + * Transforms a value from the transformed representation to its original + * representation. * - * This method is called when {@link Form::submit()} is called to transform the requests tainted data - * into an acceptable format. + * This method is called when {@link Form::submit()} is called to transform the requests tainted data + * into an acceptable format. * - * The same transformers are called in the reverse order so the responsibility is to - * return one of the types that would be expected as input of transform(). + * The same transformers are called in the reverse order so the responsibility is to + * return one of the types that would be expected as input of transform(). * - * This method must be able to deal with empty values. Usually this will - * be an empty string, but depending on your implementation other empty - * values are possible as well (such as NULL). The reasoning behind - * this is that value transformers must be chainable. If the - * reverseTransform() method of the first value transformer outputs an - * empty string, the second value transformer must be able to process that - * value. + * This method must be able to deal with empty values. Usually this will + * be an empty string, but depending on your implementation other empty + * values are possible as well (such as NULL). The reasoning behind + * this is that value transformers must be chainable. If the + * reverseTransform() method of the first value transformer outputs an + * empty string, the second value transformer must be able to process that + * value. * - * By convention, reverseTransform() should return NULL if an empty string - * is passed. + * By convention, reverseTransform() should return NULL if an empty string + * is passed. * * @param mixed $value The value in the transformed representation * @@ -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, diff --git a/src/Repository/DBElementRepository.php b/src/Repository/DBElementRepository.php index 9c3e8b4f..41d8c058 100644 --- a/src/Repository/DBElementRepository.php +++ b/src/Repository/DBElementRepository.php @@ -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); diff --git a/src/Services/AmountFormatter.php b/src/Services/AmountFormatter.php index 65056301..7a2f3c5b 100644 --- a/src/Services/AmountFormatter.php +++ b/src/Services/AmountFormatter.php @@ -60,7 +60,10 @@ class AmountFormatter } /** - * Formats the given value using the measurement unit and options. + * Formats the given value using the measurement unit and options. + * + * @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. @@ -69,7 +72,7 @@ class AmountFormatter * * @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!'); diff --git a/src/Services/Attachments/PartPreviewGenerator.php b/src/Services/Attachments/PartPreviewGenerator.php index 335d2e8c..45b33a15 100644 --- a/src/Services/Attachments/PartPreviewGenerator.php +++ b/src/Services/Attachments/PartPreviewGenerator.php @@ -55,13 +55,15 @@ class PartPreviewGenerator } /** - * Returns a list of attachments that can be used for previewing the part ordered by priority. - * The priority is: Part MasterAttachment -> Footprint MasterAttachment -> Category MasterAttachment - * -> Storelocation Attachment -> MeasurementUnit Attachment -> ManufacturerAttachment. + * Returns a list of attachments that can be used for previewing the part ordered by priority. + * The priority is: Part MasterAttachment -> Footprint MasterAttachment -> Category MasterAttachment + * -> Storelocation Attachment -> MeasurementUnit Attachment -> ManufacturerAttachment. * * @param Part $part the part for which the attachments should be determined * - * @return Attachment[] + * @return (Attachment|null)[] + * + * @psalm-return list */ public function getPreviewAttachments(Part $part): array { diff --git a/src/Services/EntityExporter.php b/src/Services/EntityExporter.php index 8afb3b8e..a07c5b0d 100644 --- a/src/Services/EntityExporter.php +++ b/src/Services/EntityExporter.php @@ -77,9 +77,10 @@ class EntityExporter } /** - * Exports an Entity or an array of entities to multiple file formats. + * 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 * diff --git a/src/Services/EntityURLGenerator.php b/src/Services/EntityURLGenerator.php index 652ea14e..bedad20d 100644 --- a/src/Services/EntityURLGenerator.php +++ b/src/Services/EntityURLGenerator.php @@ -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 diff --git a/src/Services/LogSystem/HistoryHelper.php b/src/Services/LogSystem/HistoryHelper.php index 88a209e4..193c891d 100644 --- a/src/Services/LogSystem/HistoryHelper.php +++ b/src/Services/LogSystem/HistoryHelper.php @@ -35,10 +35,12 @@ class HistoryHelper } /** - * Returns an array containing all elements that are associated with the argument. - * The returned array contains the given element. + * Returns an array containing all elements that are associated with the argument. + * 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 { diff --git a/src/Services/LogSystem/TimeTravel.php b/src/Services/LogSystem/TimeTravel.php index f8548e83..6a5ab500 100644 --- a/src/Services/LogSystem/TimeTravel.php +++ b/src/Services/LogSystem/TimeTravel.php @@ -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));