From 8e6bc25d2e84beba314e073714d82a247936f3ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 14 Aug 2022 19:39:07 +0200 Subject: [PATCH] Fixed some inspection issues. --- composer.json | 2 +- src/Controller/UserController.php | 12 ++++++------ src/Doctrine/Purger/ResetAutoIncrementORMPurger.php | 4 ++-- src/Entity/Base/AbstractStructuralDBElement.php | 4 ++-- src/Entity/LogSystem/AbstractLogEntry.php | 2 +- src/Entity/Parameters/AbstractParameter.php | 2 +- src/Entity/Parts/MeasurementUnit.php | 2 +- src/Entity/Parts/PartLot.php | 2 +- src/Entity/Parts/PartTraits/BasicPropertyTrait.php | 4 ++-- src/Entity/PriceInformations/Currency.php | 2 +- src/Entity/UserSystem/User.php | 8 ++++---- src/Form/CollectionTypeExtension.php | 1 - src/Helpers/Trees/TreeViewNode.php | 4 ++-- src/Repository/AbstractPartsContainingRepository.php | 9 +++++---- src/Repository/LogEntryRepository.php | 3 --- src/Repository/Parts/StorelocationRepository.php | 4 +++- src/Services/Misc/RangeParser.php | 6 +++--- src/Services/PricedetailHelper.php | 6 +++--- src/Twig/AppExtension.php | 2 +- 19 files changed, 39 insertions(+), 40 deletions(-) diff --git a/composer.json b/composer.json index 6c8e654f..5ffddbce 100644 --- a/composer.json +++ b/composer.json @@ -81,7 +81,7 @@ "phpstan/phpstan-doctrine": "^1.2.11", "phpstan/phpstan-symfony": "^1.1.7", "psalm/plugin-symfony": "^3.0.3", - "roave/security-advisories": "dev-master", + "roave/security-advisories": "dev-latest", "symfony/browser-kit": "^5.2", "symfony/css-selector": "^5.2", "symfony/debug-bundle": "^5.2", diff --git a/src/Controller/UserController.php b/src/Controller/UserController.php index 292a14ca..020a5e33 100644 --- a/src/Controller/UserController.php +++ b/src/Controller/UserController.php @@ -252,12 +252,12 @@ class UserController extends AdminPages\BaseAdminController /** * Get either a Gravatar URL or complete image tag for a specified email address. * - * @param string $email The email address - * @param int $s Size in pixels, defaults to 80px [ 1 - 2048 ] - * @param string $d Default imageset to use [ 404 | mm | identicon | monsterid | wavatar ] - * @param string $r Maximum rating (inclusive) [ g | pg | r | x ] - * @param bool $img True to return a complete IMG tag False for just the URL - * @param array $atts Optional, additional key/value attributes to include in the IMG tag + * @param string|null $email The email address + * @param int $s Size in pixels, defaults to 80px [ 1 - 2048 ] + * @param string $d Default imageset to use [ 404 | mm | identicon | monsterid | wavatar ] + * @param string $r Maximum rating (inclusive) [ g | pg | r | x ] + * @param bool $img True to return a complete IMG tag False for just the URL + * @param array $atts Optional, additional key/value attributes to include in the IMG tag * * @return string containing either just a URL or a complete image tag * @source https://gravatar.com/site/implement/images/php/ diff --git a/src/Doctrine/Purger/ResetAutoIncrementORMPurger.php b/src/Doctrine/Purger/ResetAutoIncrementORMPurger.php index 0555394c..05d0a987 100644 --- a/src/Doctrine/Purger/ResetAutoIncrementORMPurger.php +++ b/src/Doctrine/Purger/ResetAutoIncrementORMPurger.php @@ -52,8 +52,8 @@ class ResetAutoIncrementORMPurger implements PurgerInterface, ORMPurgerInterface /** * Construct new purger instance. * - * @param EntityManagerInterface $em EntityManagerInterface instance used for persistence. - * @param string[] $excluded array of table/view names to be excluded from purge + * @param EntityManagerInterface|null $em EntityManagerInterface instance used for persistence. + * @param string[] $excluded array of table/view names to be excluded from purge */ public function __construct(?EntityManagerInterface $em = null, array $excluded = []) { diff --git a/src/Entity/Base/AbstractStructuralDBElement.php b/src/Entity/Base/AbstractStructuralDBElement.php index 7f5e9dc2..efc9c34c 100644 --- a/src/Entity/Base/AbstractStructuralDBElement.php +++ b/src/Entity/Base/AbstractStructuralDBElement.php @@ -297,7 +297,7 @@ abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement /** * Sets the new parent object. * - * @param self $new_parent The new parent object + * @param AbstractStructuralDBElement|null $new_parent The new parent object * * @return AbstractStructuralDBElement */ @@ -316,7 +316,7 @@ abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement /** * Set the comment. * - * @param string $new_comment the new comment + * @param string|null $new_comment the new comment * * @return AbstractStructuralDBElement */ diff --git a/src/Entity/LogSystem/AbstractLogEntry.php b/src/Entity/LogSystem/AbstractLogEntry.php index 834ccbcb..4496a77a 100644 --- a/src/Entity/LogSystem/AbstractLogEntry.php +++ b/src/Entity/LogSystem/AbstractLogEntry.php @@ -342,7 +342,7 @@ abstract class AbstractLogEntry extends AbstractDBElement /** * Sets the target element associated with this element. * - * @param AbstractDBElement $element the element that should be associated with this element + * @param AbstractDBElement|null $element the element that should be associated with this element * * @return $this */ diff --git a/src/Entity/Parameters/AbstractParameter.php b/src/Entity/Parameters/AbstractParameter.php index 3ac0b080..ba13f623 100644 --- a/src/Entity/Parameters/AbstractParameter.php +++ b/src/Entity/Parameters/AbstractParameter.php @@ -302,7 +302,7 @@ abstract class AbstractParameter extends AbstractNamedDBElement /** * Sets the typical value of this property. * - * @param float $value_typical + * @param float|null $value_typical * * @return $this */ diff --git a/src/Entity/Parts/MeasurementUnit.php b/src/Entity/Parts/MeasurementUnit.php index f848f7a0..d8c97756 100644 --- a/src/Entity/Parts/MeasurementUnit.php +++ b/src/Entity/Parts/MeasurementUnit.php @@ -119,7 +119,7 @@ class MeasurementUnit extends AbstractPartsContainingDBElement } /** - * @param string $unit + * @param string|null $unit * * @return MeasurementUnit */ diff --git a/src/Entity/Parts/PartLot.php b/src/Entity/Parts/PartLot.php index d04d54b6..1bbfbe87 100644 --- a/src/Entity/Parts/PartLot.php +++ b/src/Entity/Parts/PartLot.php @@ -197,7 +197,7 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named /** * Sets the expiration date for the part lot. Set to null, if the part lot does not expires. * - * @param DateTime $expiration_date + * @param DateTime|null $expiration_date * * @return PartLot */ diff --git a/src/Entity/Parts/PartTraits/BasicPropertyTrait.php b/src/Entity/Parts/PartTraits/BasicPropertyTrait.php index 77409b2c..f30a1abb 100644 --- a/src/Entity/Parts/PartTraits/BasicPropertyTrait.php +++ b/src/Entity/Parts/PartTraits/BasicPropertyTrait.php @@ -166,7 +166,7 @@ trait BasicPropertyTrait /** * Sets the description of this part. * - * @param string $new_description the new description + * @param string|null $new_description the new description * * @return $this */ @@ -195,7 +195,7 @@ trait BasicPropertyTrait * Set the category of this Part. * The category property is required for every part, so you can not pass null like the other properties (footprints). * - * @param Category $category The new category of this part + * @param Category|null $category The new category of this part * * @return $this */ diff --git a/src/Entity/PriceInformations/Currency.php b/src/Entity/PriceInformations/Currency.php index d05239a6..f6dd87de 100644 --- a/src/Entity/PriceInformations/Currency.php +++ b/src/Entity/PriceInformations/Currency.php @@ -134,7 +134,7 @@ class Currency extends AbstractStructuralDBElement } /** - * @param string $iso_code + * @param string|null $iso_code * * @return Currency */ diff --git a/src/Entity/UserSystem/User.php b/src/Entity/UserSystem/User.php index 505feae8..86d7866f 100644 --- a/src/Entity/UserSystem/User.php +++ b/src/Entity/UserSystem/User.php @@ -537,7 +537,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe /** * Change the first name of the user. * - * @param string $first_name The new first name + * @param string|null $first_name The new first name * * @return $this */ @@ -559,7 +559,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe /** * Change the last name of the user. * - * @param string $last_name The new last name + * @param string|null $last_name The new last name * * @return $this */ @@ -583,7 +583,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe /** * Change the department of the user. * - * @param string $department The new department + * @param string|null $department The new department * * @return User */ @@ -607,7 +607,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe /** * Change the email of the user. * - * @param string $email The new email adress + * @param string|null $email The new email adress * * @return $this */ diff --git a/src/Form/CollectionTypeExtension.php b/src/Form/CollectionTypeExtension.php index 697f9533..1777a634 100644 --- a/src/Form/CollectionTypeExtension.php +++ b/src/Form/CollectionTypeExtension.php @@ -106,7 +106,6 @@ class CollectionTypeExtension extends AbstractTypeExtension * Set the option of the form. * This a bit hacky cause we access private properties.... * - * @throws ReflectionException */ public function setOption(FormBuilder $builder, string $option, $value): void { diff --git a/src/Helpers/Trees/TreeViewNode.php b/src/Helpers/Trees/TreeViewNode.php index bfbce903..5190b930 100644 --- a/src/Helpers/Trees/TreeViewNode.php +++ b/src/Helpers/Trees/TreeViewNode.php @@ -276,11 +276,11 @@ final class TreeViewNode implements JsonSerializable $ret['state'] = $this->state; } - if ($this->href == null) { + if ($this->href === null) { $ret['selectable'] = false; } - if ($this->icon != null) { + if ($this->icon !== null) { $ret['icon'] = $this->icon; } diff --git a/src/Repository/AbstractPartsContainingRepository.php b/src/Repository/AbstractPartsContainingRepository.php index 83e6c215..adb7c828 100644 --- a/src/Repository/AbstractPartsContainingRepository.php +++ b/src/Repository/AbstractPartsContainingRepository.php @@ -30,17 +30,18 @@ abstract class AbstractPartsContainingRepository extends StructuralDBElementRepo /** * Returns all parts associated with this element. * - * @param AbstractPartsContainingDBElement $element the element for which the parts should be determined - * @param array $order_by The order of the parts. Format ['name' => 'ASC'] + * @param object $element the element for which the parts should be determined + * @param array $order_by The order of the parts. Format ['name' => 'ASC'] * - * @return Part[] + * @return Part */ abstract public function getParts(object $element, array $order_by = ['name' => 'ASC']): array; /** * Gets the count of the parts associated with this element. * - * @param AbstractPartsContainingDBElement $element the element for which the parts should be determined + * @param object $element the element for which the parts should be determined + * @return int */ abstract public function getPartsCount(object $element): int; diff --git a/src/Repository/LogEntryRepository.php b/src/Repository/LogEntryRepository.php index eb0bb82c..4e52daa4 100644 --- a/src/Repository/LogEntryRepository.php +++ b/src/Repository/LogEntryRepository.php @@ -195,9 +195,6 @@ class LogEntryRepository extends DBElementRepository * @return AbstractDBElement|null returns the associated DBElement or null if the log either has no target or the element * was deleted from DB * - * @throws ORMException - * @throws OptimisticLockException - * @throws TransactionRequiredException */ public function getTargetElement(AbstractLogEntry $logEntry): ?AbstractDBElement { diff --git a/src/Repository/Parts/StorelocationRepository.php b/src/Repository/Parts/StorelocationRepository.php index 92ad482d..ef81728f 100644 --- a/src/Repository/Parts/StorelocationRepository.php +++ b/src/Repository/Parts/StorelocationRepository.php @@ -29,7 +29,9 @@ use InvalidArgumentException; class StorelocationRepository extends AbstractPartsContainingRepository { /** - * @param Storelocation $element + * @param object $element + * @param array $order_by + * @return array */ public function getParts(object $element, array $order_by = ['name' => 'ASC']): array { diff --git a/src/Services/Misc/RangeParser.php b/src/Services/Misc/RangeParser.php index 13fb2ba9..665755de 100644 --- a/src/Services/Misc/RangeParser.php +++ b/src/Services/Misc/RangeParser.php @@ -81,10 +81,10 @@ class RangeParser } } - protected function generateMinMaxRange(string $min, string $max): array + protected function generateMinMaxRange(string $min_, string $max_): array { - $min = (int) $min; - $max = (int) $max; + $min = (int) $min_; + $max = (int) $max_; //Ensure that $max > $min if ($min > $max) { diff --git a/src/Services/PricedetailHelper.php b/src/Services/PricedetailHelper.php index b7ea933f..6d76276a 100644 --- a/src/Services/PricedetailHelper.php +++ b/src/Services/PricedetailHelper.php @@ -146,10 +146,10 @@ class PricedetailHelper /** * Calculates the average price of a part, when ordering the amount $amount. * - * @param Part $part the part for which the average price should be calculated - * @param float $amount The order amount for which the average price should be calculated. + * @param Part $part the part for which the average price should be calculated + * @param float|null $amount The order amount for which the average price should be calculated. * If set to null, the mininmum order amount for the part is used. - * @param Currency|null $currency The currency in which the average price should be calculated + * @param Currency|null $currency The currency in which the average price should be calculated * * @return BigDecimal|null The Average price as bcmath string. Returns null, if it was not possible to calculate the * price for the given diff --git a/src/Twig/AppExtension.php b/src/Twig/AppExtension.php index 8ded6aca..578984f4 100644 --- a/src/Twig/AppExtension.php +++ b/src/Twig/AppExtension.php @@ -132,7 +132,7 @@ class AppExtension extends AbstractExtension { $tree = $this->treeBuilder->getTreeView(get_class($element), null, $type, $element); - return json_encode($tree); + return json_encode($tree, JSON_THROW_ON_ERROR); } /**