Fixed code style.

This commit is contained in:
Jan Böhmer 2020-08-21 21:36:22 +02:00
parent 2853e471c4
commit d0b1024d80
212 changed files with 495 additions and 1005 deletions

View file

@ -72,7 +72,7 @@ class AmountFormatter
*/
public function format($value, ?MeasurementUnit $unit = null, array $options = [])
{
if (! is_numeric($value)) {
if (!is_numeric($value)) {
throw new InvalidArgumentException('$value must be an numeric value!');
}
$value = (float) $value;
@ -94,7 +94,7 @@ class AmountFormatter
}
//Otherwise just output it
if (! empty($options['unit'])) {
if (!empty($options['unit'])) {
$format_string = '%.'.$options['decimals'].'f '.$options['unit'];
} else { //Dont add space after number if no unit was specified
$format_string = '%.'.$options['decimals'].'f';

View file

@ -72,7 +72,7 @@ class AttachmentManager
*/
public function attachmentToFile(Attachment $attachment): ?SplFileInfo
{
if ($attachment->isExternal() || ! $this->isFileExisting($attachment)) {
if ($attachment->isExternal() || !$this->isFileExisting($attachment)) {
return null;
}
@ -150,7 +150,7 @@ class AttachmentManager
return null;
}
if (! $this->isFileExisting($attachment)) {
if (!$this->isFileExisting($attachment)) {
return null;
}

View file

@ -203,7 +203,7 @@ class AttachmentPathResolver
}
//If the new string does not begin with a placeholder, it is invalid
if (! preg_match('#^%\w+%#', $real_path)) {
if (!preg_match('#^%\w+%#', $real_path)) {
return null;
}

View file

@ -58,7 +58,6 @@ use App\Entity\Attachments\StorelocationAttachment;
use App\Entity\Attachments\SupplierAttachment;
use App\Entity\Attachments\UserAttachment;
use App\Exceptions\AttachmentDownloadException;
use Symfony\Component\Form\FormInterface;
use const DIRECTORY_SEPARATOR;
use function get_class;
use InvalidArgumentException;
@ -82,7 +81,6 @@ class AttachmentSubmitHandler
protected $mimeTypes;
protected $filterTools;
public function __construct(AttachmentPathResolver $pathResolver, bool $allow_attachments_downloads,
HttpClientInterface $httpClient, MimeTypesInterface $mimeTypes,
FileTypeFilterTools $filterTools)
@ -114,9 +112,6 @@ class AttachmentSubmitHandler
/**
* Check if the extension of the uploaded file is allowed for the given attachment type.
* Returns true, if the file is allowed, false if not.
* @param AttachmentType $attachment_type
* @param UploadedFile $uploadedFile
* @return bool
*/
public function isValidFileExtension(AttachmentType $attachment_type, UploadedFile $uploadedFile): bool
{
@ -174,7 +169,7 @@ class AttachmentSubmitHandler
}
//Ensure the given attachment class is known to mapping
if (! isset($this->folder_mapping[get_class($attachment)])) {
if (!isset($this->folder_mapping[get_class($attachment)])) {
throw new InvalidArgumentException('The given attachment class is not known! The passed class was: '.get_class($attachment));
}
//Ensure the attachment has an assigned element
@ -260,13 +255,13 @@ class AttachmentSubmitHandler
//Determine the old filepath
$old_path = $this->pathResolver->placeholderToRealPath($attachment->getPath());
if (! file_exists($old_path)) {
if (!file_exists($old_path)) {
return $attachment;
}
$filename = basename($old_path);
//If the basename is not one of the new unique on, we have to save the old filename
if (! preg_match('#\w+-\w{13}\.#', $filename)) {
if (!preg_match('#\w+-\w{13}\.#', $filename)) {
//Save filename to attachment field
$attachment->setFilename($attachment->getFilename());
}
@ -298,7 +293,7 @@ class AttachmentSubmitHandler
protected function downloadURL(Attachment $attachment, array $options): Attachment
{
//Check if we are allowed to download files
if (! $this->allow_attachments_downloads) {
if (!$this->allow_attachments_downloads) {
throw new RuntimeException('Download of attachments is not allowed!');
}
@ -348,7 +343,7 @@ class AttachmentSubmitHandler
//Check if we have a extension given
$pathinfo = pathinfo($filename);
if (! empty($pathinfo['extension'])) {
if (!empty($pathinfo['extension'])) {
$new_ext = $pathinfo['extension'];
} else { //Otherwise we have to guess the extension for the new file, based on its content
$new_ext = $this->mimeTypes->getExtensions($this->mimeTypes->guessMimeType($tmp_path))[0] ?? 'tmp';

View file

@ -106,13 +106,12 @@ class AttachmentURLGenerator
/**
* Converts a placeholder path to a path to a image path.
*
* @param string $placeholder_path the placeholder path that should be converted
*
* @return string|null
* @param string $placeholder_path the placeholder path that should be converted
*/
public function placeholderPathToAssetPath(string $placeholder_path): ?string
{
$absolute_path = $this->pathResolver->placeholderToRealPath($placeholder_path);
return $this->absolutePathToAssetPath($absolute_path);
}
@ -142,11 +141,11 @@ class AttachmentURLGenerator
*/
public function getThumbnailURL(Attachment $attachment, string $filter_name = 'thumbnail_sm'): string
{
if (! $attachment->isPicture()) {
if (!$attachment->isPicture()) {
throw new InvalidArgumentException('Thumbnail creation only works for picture attachments!');
}
if ($attachment->isExternal() && ! empty($attachment->getURL())) {
if ($attachment->isExternal() && !empty($attachment->getURL())) {
return $attachment->getURL();
}
@ -165,7 +164,7 @@ class AttachmentURLGenerator
//because the footprints images are small and highly optimized already.
if (('thumbnail_md' === $filter_name && $attachment->isBuiltIn())
//GD can not work with SVG, so serve it directly...
|| $attachment->getExtension() === 'svg') {
|| 'svg' === $attachment->getExtension()) {
return $this->assets->getUrl($asset_path);
}

View file

@ -91,9 +91,9 @@ class FileTypeFilterTools
//Check for each element if it is valid:
foreach ($elements as $element) {
$element = trim($element);
if (! preg_match('#^\.\w+$#', $element) // .ext is allowed
&& ! preg_match('#^[-\w.]+\/[-\w.]+#', $element) //Explicit MIME type is allowed
&& ! in_array($element, static::ALLOWED_MIME_PLACEHOLDERS, false)) { //image/* is allowed
if (!preg_match('#^\.\w+$#', $element) // .ext is allowed
&& !preg_match('#^[-\w.]+\/[-\w.]+#', $element) //Explicit MIME type is allowed
&& !in_array($element, static::ALLOWED_MIME_PLACEHOLDERS, false)) { //image/* is allowed
return false;
}
}
@ -139,7 +139,7 @@ class FileTypeFilterTools
$element = 'video/*';
} elseif ('audio' === $element || 'audio/' === $element) {
$element = 'audio/*';
} elseif (! preg_match('#^[-\w.]+\/[-\w.*]+#', $element) && 0 !== strpos($element, '.')) {
} elseif (!preg_match('#^[-\w.]+\/[-\w.*]+#', $element) && 0 !== strpos($element, '.')) {
//Convert jpg to .jpg
$element = '.'.$element;
}

View file

@ -54,7 +54,7 @@ final class CustomEnvVarProcessor implements EnvVarProcessorInterface
try {
$env = $getEnv($name);
return ! empty($env) && 'null://null' !== $env;
return !empty($env) && 'null://null' !== $env;
} catch (EnvNotFoundException $envNotFoundException) {
return false;
}

View file

@ -91,13 +91,13 @@ class EntityExporter
$format = $request->get('format') ?? 'json';
//Check if we have one of the supported formats
if (! in_array($format, ['json', 'csv', 'yaml', 'xml'], true)) {
if (!in_array($format, ['json', 'csv', 'yaml', 'xml'], true)) {
throw new InvalidArgumentException('Given format is not supported!');
}
//Check export verbosity level
$level = $request->get('level') ?? 'extended';
if (! in_array($level, ['simple', 'extended', 'full'], true)) {
if (!in_array($level, ['simple', 'extended', 'full'], true)) {
throw new InvalidArgumentException('Given level is not supported!');
}
@ -145,7 +145,7 @@ class EntityExporter
$response->headers->set('Content-Type', $content_type);
//If view option is not specified, then download the file.
if (! $request->get('view')) {
if (!$request->get('view')) {
if ($entity instanceof AbstractNamedDBElement) {
$entity_name = $entity->getName();
} elseif (is_array($entity)) {

View file

@ -81,10 +81,10 @@ class EntityImporter
//Expand every line to a single entry:
$names = explode("\n", $lines);
if (! is_a($class_name, AbstractStructuralDBElement::class, true)) {
if (!is_a($class_name, AbstractStructuralDBElement::class, true)) {
throw new InvalidArgumentException('$class_name must be a StructuralDBElement type!');
}
if (null !== $parent && ! is_a($parent, $class_name)) {
if (null !== $parent && !is_a($parent, $class_name)) {
throw new InvalidArgumentException('$parent must have the same type as specified in $class_name!');
}
@ -201,7 +201,7 @@ class EntityImporter
]);
//Ensure we have an array of entitity elements.
if (! is_array($entities)) {
if (!is_array($entities)) {
$entities = [$entities];
}

View file

@ -127,8 +127,6 @@ class EntityURLGenerator
/**
* Gets the URL to view the given element at a given timestamp.
*
* @return string
*/
public function timeTravelURL(AbstractDBElement $entity, \DateTime $dateTime): string
{
@ -398,7 +396,7 @@ class EntityURLGenerator
$class = get_class($entity);
//Check if we have an direct mapping for the given class
if (! array_key_exists($class, $map)) {
if (!array_key_exists($class, $map)) {
//Check if we need to check inheritance by looping through our map
foreach (array_keys($map) as $key) {
if (is_a($entity, $key)) {

View file

@ -1,9 +1,7 @@
<?php
namespace App\Services;
use App\Entity\PriceInformations\Currency;
use Brick\Math\BigDecimal;
use Swap\Swap;
@ -21,14 +19,12 @@ class ExchangeRateUpdater
/**
* Updates the exchange rate of the given currency using the globally configured providers.
* @param Currency $currency
* @return Currency
*/
public function update(Currency $currency): Currency
{
$rate = $this->swap->latest($currency->getIsoCode().'/'.$this->base_currency);
$currency->setExchangeRate(BigDecimal::of($rate->getValue()));
return $currency;
}
}
}

View file

@ -93,7 +93,7 @@ class FAIconGenerator
*
* @param string $icon_class The icon which should be shown (e.g. fa-file-text)
* @param string $style The style of the icon 'fas'
* @param string $options Any other css class attributes like size, etc.
* @param string $options any other css class attributes like size, etc
*
* @return string The final html
*/

View file

@ -64,7 +64,7 @@ class GitVersionInfo
$git = file($this->project_dir.'/.git/HEAD');
$head = explode('/', $git[0], 3);
if (! isset($head[2])) {
if (!isset($head[2])) {
return null;
}
@ -89,7 +89,7 @@ class GitVersionInfo
if (is_file($filename)) {
$head = file($filename);
if (! isset($head[0])) {
if (!isset($head[0])) {
return null;
}

View file

@ -51,8 +51,6 @@ final class BarcodeContentGenerator
/**
* Generates a fixed URL to the given Element that can be embedded in a 2D code (e.g. QR code).
*
* @return string
*/
public function getURLContent(AbstractDBElement $target): string
{
@ -68,8 +66,6 @@ final class BarcodeContentGenerator
/**
* Returns a Code that can be used in a 1D barcode.
* The return value has a format of "L0123".
*
* @return string
*/
public function get1DBarcodeContent(AbstractDBElement $target): string
{

View file

@ -102,7 +102,7 @@ final class BarcodeExampleElementsGenerator
private function getStructuralData(string $class): AbstractStructuralDBElement
{
if (! is_a($class, AbstractStructuralDBElement::class, true)) {
if (!is_a($class, AbstractStructuralDBElement::class, true)) {
throw new \InvalidArgumentException('$class must be an child of AbstractStructuralDBElement');
}

View file

@ -34,8 +34,6 @@ final class BarcodeNormalizer
/**
* Parses barcode content and normalizes it.
* Returns an array in the format ['part', 1]: First entry contains element type, second the ID of the element.
*
* @return array
*/
public function normalizeBarcodeContent(string $input): array
{
@ -55,7 +53,7 @@ final class BarcodeNormalizer
$prefix = $matches[1];
$id = (int) $matches[2];
if (! isset(self::PREFIX_TYPE_MAP[$prefix])) {
if (!isset(self::PREFIX_TYPE_MAP[$prefix])) {
throw new \InvalidArgumentException('Unknown prefix '.$prefix);
}
@ -67,7 +65,7 @@ final class BarcodeNormalizer
$prefix = $matches[1];
$id = (int) $matches[2];
if (! isset(self::PREFIX_TYPE_MAP[$prefix])) {
if (!isset(self::PREFIX_TYPE_MAP[$prefix])) {
throw new \InvalidArgumentException('Unknown prefix '.$prefix);
}

View file

@ -45,7 +45,7 @@ final class BarcodeRedirector
* @param string $type The type of the element that was scanned (e.g. 'part', 'lot', etc.)
* @param int $id The ID of the element that was scanned
*
* @return string The URL to which should be redirected.
* @return string the URL to which should be redirected
*
* @throws EntityNotFoundException
*/

View file

@ -48,21 +48,19 @@ final class LabelGenerator
/**
* @param object|object[] $elements An element or an array of elements for which labels should be generated
*
* @return string
*/
public function generateLabel(LabelOptions $options, $elements): string
{
if (! is_array($elements) && ! is_object($elements)) {
if (!is_array($elements) && !is_object($elements)) {
throw new \InvalidArgumentException('$element must be an object or an array of objects!');
}
if (! is_array($elements)) {
if (!is_array($elements)) {
$elements = [$elements];
}
foreach ($elements as $element) {
if (! $this->supports($options, $element)) {
if (!$this->supports($options, $element)) {
throw new \InvalidArgumentException('The given options are not compatible with the given element!');
}
}
@ -83,7 +81,7 @@ final class LabelGenerator
public function supports(LabelOptions $options, object $element)
{
$supported_type = $options->getSupportedElement();
if (! isset(static::CLASS_SUPPORT_MAPPING[$supported_type])) {
if (!isset(static::CLASS_SUPPORT_MAPPING[$supported_type])) {
throw new \InvalidArgumentException('Supported type name of the Label options not known!');
}

View file

@ -43,7 +43,7 @@ final class LabelTextReplacer
* If the given string is not a placeholder or the placeholder is not known, it will be returned unchanged.
*
* @param string $placeholder The placeholder that should be replaced. (e.g. '%%PLACEHOLDER%%')
* @param object $target The object that should be used for the placeholder info source.
* @param object $target the object that should be used for the placeholder info source
*
* @return string If the placeholder was valid, the replaced info. Otherwise the passed string.
*/
@ -64,9 +64,9 @@ final class LabelTextReplacer
* Replaces all placeholders in the input lines.
*
* @param string $lines The input lines that should be replaced
* @param object $target The object that should be used as source for the informations.
* @param object $target the object that should be used as source for the informations
*
* @return string The Lines with replaced informations.
* @return string the Lines with replaced informations
*/
public function replace(string $lines, object $target): string
{

View file

@ -40,7 +40,7 @@ final class PartProvider implements PlaceholderProviderInterface
public function replace(string $placeholder, object $part, array $options = []): ?string
{
if (! $part instanceof Part) {
if (!$part instanceof Part) {
return null;
}

View file

@ -31,9 +31,9 @@ interface PlaceholderProviderInterface
*
* @param string $placeholder The placeholder (e.g. "%%PLACEHOLDER%%") that should be replaced
* @param object $label_target The object that is targeted by the label
* @param array $options A list of options that can be used to specify the generated output further.
* @param array $options a list of options that can be used to specify the generated output further
*
* @return string|null The real value of this placeholder, null if not supported.
* @return string|null the real value of this placeholder, null if not supported
*/
public function replace(string $placeholder, object $label_target, array $options = []): ?string;
}

View file

@ -51,8 +51,6 @@ class EventCommentHelper
/**
* Returns the currently set message, or null if no message is set yet.
*
* @return string|null
*/
public function getMessage(): ?string
{
@ -69,8 +67,6 @@ class EventCommentHelper
/**
* Check if a message is currently set.
*
* @return bool
*/
public function isMessageSet(): bool
{

View file

@ -68,7 +68,7 @@ class EventLogger
* Adds the given log entry to the Log, if the entry fullfills the global configured criterias.
* The change will not be flushed yet.
*
* @return bool Returns true, if the event was added to log.
* @return bool returns true, if the event was added to log
*/
public function log(AbstractLogEntry $logEntry): bool
{
@ -99,7 +99,7 @@ class EventLogger
/**
* Adds the given log entry to the Log, if the entry fullfills the global configured criterias and flush afterwards.
*
* @return bool Returns true, if the event was added to log.
* @return bool returns true, if the event was added to log
*/
public function logAndFlush(AbstractLogEntry $logEntry): bool
{
@ -126,12 +126,12 @@ class EventLogger
}
//Check if the event type is black listed
if (! empty($blacklist) && $this->isObjectClassInArray($logEntry, $blacklist)) {
if (!empty($blacklist) && $this->isObjectClassInArray($logEntry, $blacklist)) {
return false;
}
//Check for whitelisting
if (! empty($whitelist) && ! $this->isObjectClassInArray($logEntry, $whitelist)) {
if (!empty($whitelist) && !$this->isObjectClassInArray($logEntry, $whitelist)) {
return false;
}
@ -143,9 +143,7 @@ class EventLogger
* Check if the object type is given in the classes array. This also works for inherited types.
*
* @param object $object The object which should be checked
* @param string[] $classes The list of class names that should be used for checking.
*
* @return bool
* @param string[] $classes the list of class names that should be used for checking
*/
protected function isObjectClassInArray(object $object, array $classes): bool
{

View file

@ -43,7 +43,7 @@ class EventUndoHelper
public function setMode(string $mode): void
{
if (! in_array($mode, self::ALLOWED_MODES, true)) {
if (!in_array($mode, self::ALLOWED_MODES, true)) {
throw new \InvalidArgumentException('Invalid mode passed!');
}
$this->mode = $mode;
@ -65,8 +65,6 @@ class EventUndoHelper
/**
* Returns event that is currently undone.
*
* @return AbstractLogEntry|null
*/
public function getUndoneEvent(): ?AbstractLogEntry
{
@ -83,8 +81,6 @@ class EventUndoHelper
/**
* Check if a event is undone.
*
* @return bool
*/
public function isUndo(): bool
{

View file

@ -38,8 +38,6 @@ class HistoryHelper
* 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

View file

@ -77,8 +77,6 @@ class LogEntryExtraFormatter
/**
* Return an user viewable representation of the extra data in a log entry, styled for console output.
*
* @return string
*/
public function formatConsole(AbstractLogEntry $logEntry): string
{
@ -92,7 +90,7 @@ class LogEntryExtraFormatter
$str .= '<error>'.$this->translator->trans($key).'</error>: ';
}
$str .= $value;
if (! empty($str)) {
if (!empty($str)) {
$tmp[] = $str;
}
}
@ -102,8 +100,6 @@ class LogEntryExtraFormatter
/**
* Return a HTML formatted string containing a user viewable form of the Extra data.
*
* @return string
*/
public function format(AbstractLogEntry $context): string
{
@ -117,7 +113,7 @@ class LogEntryExtraFormatter
$str .= '<b>'.$this->translator->trans($key).'</b>: ';
}
$str .= $value;
if (! empty($str)) {
if (!empty($str)) {
$tmp[] = $str;
}
}
@ -187,7 +183,7 @@ class LogEntryExtraFormatter
'%s <i class="fas fa-long-arrow-alt-right"></i> %s (%s)',
$context->getOldInstock(),
$context->getNewInstock(),
(! $context->isWithdrawal() ? '+' : '-').$context->getDifference(true)
(!$context->isWithdrawal() ? '+' : '-').$context->getDifference(true)
);
$array['log.instock_changed.comment'] = htmlspecialchars($context->getComment());
}

View file

@ -52,9 +52,7 @@ class TimeTravel
* Undeletes the element with the given ID.
*
* @param string $class The class name of the element that should be undeleted
* @param int $id The ID of the element that should be undeleted.
*
* @return AbstractDBElement
* @param int $id the ID of the element that should be undeleted
*/
public function undeleteEntity(string $class, int $id): AbstractDBElement
{
@ -80,7 +78,7 @@ class TimeTravel
*/
public function revertEntityToTimestamp(AbstractDBElement $element, \DateTime $timestamp, array $reverted_elements = []): void
{
if (! $element instanceof TimeStampableInterface) {
if (!$element instanceof TimeStampableInterface) {
throw new \InvalidArgumentException('$element must have a Timestamp!');
}
@ -154,7 +152,7 @@ class TimeTravel
foreach ($target_elements as $target_element) {
if (null !== $target_element && $element->getLastModified() >= $timestamp) {
//Remove the element from collection, if it did not existed at $timestamp
if (! $this->repo->getElementExistedAtTimestamp($target_element, $timestamp)) {
if (!$this->repo->getElementExistedAtTimestamp($target_element, $timestamp)) {
if ($target_elements instanceof Collection) {
$target_elements->removeElement($target_element);
}
@ -174,10 +172,10 @@ class TimeTravel
public function applyEntry(AbstractDBElement $element, TimeTravelInterface $logEntry): void
{
//Skip if this does not provide any info...
if (! $logEntry->hasOldDataInformations()) {
if (!$logEntry->hasOldDataInformations()) {
return;
}
if (! $element instanceof TimeStampableInterface) {
if (!$element instanceof TimeStampableInterface) {
return;
}
$metadata = $this->em->getClassMetadata(get_class($element));
@ -185,8 +183,7 @@ class TimeTravel
foreach ($old_data as $field => $data) {
if ($metadata->hasField($field)) {
if ($metadata->getFieldMapping($field)['type'] === 'big_decimal') {
if ('big_decimal' === $metadata->getFieldMapping($field)['type']) {
//We need to convert the string to a BigDecimal first
if (!$data instanceof BigDecimal) {
$data = BigDecimal::of($data);
@ -227,7 +224,6 @@ class TimeTravel
$property = $reflection->getProperty($field);
$property->setAccessible(true);
$property->setValue($element, $new_value);
}
}

View file

@ -66,7 +66,7 @@ class RangeParser
*
* @param string $range_str The string that should be checked
*
* @return bool True if the string is valid, false if not.
* @return bool true if the string is valid, false if not
*/
public function isValidRange(string $range_str): bool
{

View file

@ -70,7 +70,7 @@ class MoneyFormatter
public function format($value, ?Currency $currency = null, $decimals = 5, bool $show_all_digits = false)
{
$iso_code = $this->base_currency;
if (null !== $currency && ! empty($currency->getIsoCode())) {
if (null !== $currency && !empty($currency->getIsoCode())) {
$iso_code = $currency->getIsoCode();
}

View file

@ -40,7 +40,7 @@ class ParameterExtractor
*/
public function extractParameters(string $input, string $class = PartParameter::class): array
{
if (! is_a($class, AbstractParameter::class, true)) {
if (!is_a($class, AbstractParameter::class, true)) {
throw new \InvalidArgumentException('$class must be a child class of AbstractParameter!');
}
@ -68,7 +68,7 @@ class ParameterExtractor
$matches = [];
\preg_match($regex, $input, $matches);
if (! empty($matches)) {
if (!empty($matches)) {
[, $name, $value] = $matches;
$value = trim($value);

View file

@ -20,7 +20,6 @@
namespace App\Services\Parts;
use App\Entity\Parts\Category;
use App\Entity\Parts\Footprint;
use App\Entity\Parts\Manufacturer;
@ -43,8 +42,10 @@ final class PartsTableActionHandler
}
/**
* Converts the given array to an array of Parts
* @param string $ids A comma separated list of Part IDs.
* Converts the given array to an array of Parts.
*
* @param string $ids a comma separated list of Part IDs
*
* @return Part[]
*/
public function idStringToArray(string $ids): array
@ -53,13 +54,12 @@ final class PartsTableActionHandler
/** @var DBElementRepository $repo */
$repo = $this->entityManager->getRepository(Part::class);
return $repo->getElementsFromIDArray($id_array);
}
/**
* @param string $action
* @param Part[] $selected_parts
* @param int|null $target_id
* @param Part[] $selected_parts
*/
public function handleAction(string $action, array $selected_parts, ?int $target_id): void
{
@ -89,19 +89,19 @@ final class PartsTableActionHandler
break;
case 'change_footprint':
$this->denyAccessUnlessGranted('footprint.edit', $part);
$part->setFootprint($target_id === null ? null : $this->entityManager->find(Footprint::class, $target_id));
$part->setFootprint(null === $target_id ? null : $this->entityManager->find(Footprint::class, $target_id));
break;
case 'change_manufacturer':
$this->denyAccessUnlessGranted('manufacturer.edit', $part);
$part->setManufacturer($target_id === null ? null : $this->entityManager->find(Manufacturer::class, $target_id));
$part->setManufacturer(null === $target_id ? null : $this->entityManager->find(Manufacturer::class, $target_id));
break;
case 'change_unit':
$this->denyAccessUnlessGranted('unit.edit', $part);
$part->setPartUnit($target_id === null ? null : $this->entityManager->find(MeasurementUnit::class, $target_id));
$part->setPartUnit(null === $target_id ? null : $this->entityManager->find(MeasurementUnit::class, $target_id));
break;
default:
throw new \InvalidArgumentException('The given action is unknown! (' . $action . ')');
throw new \InvalidArgumentException('The given action is unknown! ('.$action.')');
}
}
}
@ -122,4 +122,4 @@ final class PartsTableActionHandler
throw $exception;
}
}
}
}

View file

@ -91,7 +91,7 @@ class PasswordResetManager
$expiration_date->add(date_interval_create_from_date_string('1 day'));
$user->setPwResetExpires($expiration_date);
if (! empty($user->getEmail())) {
if (!empty($user->getEmail())) {
$address = new Address($user->getEmail(), $user->getFullName());
$mail = new TemplatedEmail();
$mail->to($address);
@ -139,7 +139,7 @@ class PasswordResetManager
}
//Check if token is valid
if (! $this->passwordEncoder->isPasswordValid($user->getPwResetToken(), $token, null)) {
if (!$this->passwordEncoder->isPasswordValid($user->getPwResetToken(), $token, null)) {
return false;
}

View file

@ -171,7 +171,7 @@ class PermissionResolver
*/
public function listOperationsForPermission(string $permission): array
{
if (! $this->isValidPermission($permission)) {
if (!$this->isValidPermission($permission)) {
throw new \InvalidArgumentException(sprintf('A permission with that name is not existing! Got %s.', $permission));
}
$operations = $this->permission_structure['perms'][$permission]['operations'];
@ -210,7 +210,7 @@ class PermissionResolver
$cache = new ConfigCache($this->cache_file, $this->is_debug);
//Check if the cache is fresh, else regenerate it.
if (! $cache->isFresh()) {
if (!$cache->isFresh()) {
$permission_file = __DIR__.'/../../config/permissions.yaml';
//Read the permission config file...

View file

@ -150,7 +150,7 @@ class PricedetailHelper
* @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
* price for the given
*/
public function calculateAvgPrice(Part $part, ?float $amount = null, ?Currency $currency = null): ?BigDecimal
{
@ -200,7 +200,7 @@ class PricedetailHelper
* Set to null, to use global base currency.
*
* @return BigDecimal|null The value in $targetCurrency given as bcmath string.
* Returns null, if it was not possible to convert between both values (e.g. when the exchange rates are missing)
* Returns null, if it was not possible to convert between both values (e.g. when the exchange rates are missing)
*/
public function convertMoneyToCurrency(BigDecimal $value, ?Currency $originCurrency = null, ?Currency $targetCurrency = null): ?BigDecimal
{
@ -213,7 +213,7 @@ class PricedetailHelper
//Convert value to base currency
if (null !== $originCurrency) {
//Without an exchange rate we can not calculate the exchange rate
if ($originCurrency->getExchangeRate() === null || $originCurrency->getExchangeRate()->isZero()) {
if (null === $originCurrency->getExchangeRate() || $originCurrency->getExchangeRate()->isZero()) {
return null;
}

View file

@ -61,8 +61,6 @@ class StatisticsHelper
/**
* Returns the summed instocked over all parts (only parts without a measurement unit).
*
* @return float
*
* @throws \Doctrine\ORM\NoResultException
* @throws \Doctrine\ORM\NonUniqueResultException
*/
@ -74,8 +72,6 @@ class StatisticsHelper
/**
* Returns the number of all parts which have price informations.
*
* @return int
*
* @throws \Doctrine\ORM\NoResultException
* @throws \Doctrine\ORM\NonUniqueResultException
*/
@ -86,8 +82,6 @@ class StatisticsHelper
/**
* Returns the number of datastructures for the given type.
*
* @return int
*/
public function getDataStructuresCount(string $type): int
{
@ -103,7 +97,7 @@ class StatisticsHelper
'currency' => Currency::class,
];
if (! isset($arr[$type])) {
if (!isset($arr[$type])) {
throw new \InvalidArgumentException('No count for the given type available!');
}
@ -115,8 +109,6 @@ class StatisticsHelper
/**
* Gets the count of all attachments.
*
* @return int
*/
public function getAttachmentsCount(): int
{
@ -125,8 +117,6 @@ class StatisticsHelper
/**
* Gets the count of all private/secure attachments.
*
* @return int
*/
public function getPrivateAttachmentsCount(): int
{
@ -136,8 +126,6 @@ class StatisticsHelper
/**
* Gets the count of all external (only containing an URL) attachments.
*
* @return int
*
* @throws \Doctrine\ORM\NoResultException
* @throws \Doctrine\ORM\NonUniqueResultException
*/
@ -149,8 +137,6 @@ class StatisticsHelper
/**
* Gets the count of all attachments where the user uploaded an file.
*
* @return int
*
* @throws \Doctrine\ORM\NoResultException
* @throws \Doctrine\ORM\NonUniqueResultException
*/

View file

@ -76,7 +76,7 @@ class StructuralElementRecursionHelper
$children = $element->getChildren();
//If we should call from top we execute the func here.
if (! $call_from_bottom) {
if (!$call_from_bottom) {
$func($element);
}

View file

@ -53,8 +53,8 @@ class BackupCodeGenerator
/**
* BackupCodeGenerator constructor.
*
* @param int $code_length How many characters a single code should have.
* @param int $code_count How many codes are generated for a whole backup set.
* @param int $code_length how many characters a single code should have
* @param int $code_count how many codes are generated for a whole backup set
*/
public function __construct(int $code_length, int $code_count)
{
@ -75,7 +75,7 @@ class BackupCodeGenerator
*
* @return string The generated backup code (e.g. 1f3870be2)
*
* @throws \Exception If no entropy source is available.
* @throws \Exception if no entropy source is available
*/
public function generateSingleCode(): string
{
@ -87,7 +87,7 @@ class BackupCodeGenerator
/**
* Returns a full backup code set. The code count can be configured in the constructor.
*
* @return string[] An array containing different backup codes.
* @return string[] an array containing different backup codes
*/
public function generateCodeSet(): array
{

View file

@ -68,7 +68,7 @@ final class PermissionExtractor implements ExtractorInterface
*/
public function extract($resource, MessageCatalogue $catalogue): void
{
if (! $this->finished) {
if (!$this->finished) {
//Extract for every group...
foreach ($this->permission_structure['groups'] as $group) {
if (isset($group['label'])) {

View file

@ -69,10 +69,10 @@ class NodesListBuilder
* Gets a flattened hierachical tree. Useful for generating option lists.
* In difference to the Repository Function, the results here are cached.
*
* @param string $class_name The class name of the entity you want to retrieve.
* @param string $class_name the class name of the entity you want to retrieve
* @param AbstractStructuralDBElement|null $parent This entity will be used as root element. Set to null, to use global root
*
* @return AbstractStructuralDBElement[] A flattened list containing the tree elements.
* @return AbstractStructuralDBElement[] a flattened list containing the tree elements
*/
public function typeToNodesList(string $class_name, ?AbstractStructuralDBElement $parent = null): array
{

View file

@ -94,7 +94,7 @@ class ToolsTreeBuilder
* Generates the tree for the tools menu.
* The result is cached.
*
* @return TreeViewNode[] The array containing all Nodes for the tools menu.
* @return TreeViewNode[] the array containing all Nodes for the tools menu
*/
public function getTree(): array
{
@ -264,8 +264,6 @@ class ToolsTreeBuilder
/**
* This function creates the tree entries for the "system" node of the tools tree.
*
* @return array
*/
protected function getSystemNodes(): array
{

View file

@ -82,7 +82,7 @@ class TreeViewGenerator
* Set to empty string, to disable href field.
* @param AbstractDBElement|null $selectedElement The element that should be selected. If set to null, no element will be selected.
*
* @return TreeViewNode[] An array of TreeViewNode[] elements of the root elements.
* @return TreeViewNode[] an array of TreeViewNode[] elements of the root elements
*/
public function getTreeView(string $class, ?AbstractStructuralDBElement $parent = null, string $href_type = 'list_parts', ?AbstractDBElement $selectedElement = null): array
{
@ -114,11 +114,11 @@ class TreeViewGenerator
$item->setSelected(true);
}
if (! empty($item->getNodes())) {
if (!empty($item->getNodes())) {
$item->addTag((string) \count($item->getNodes()));
}
if (! empty($href_type) && null !== $item->getId()) {
if (!empty($href_type) && null !== $item->getId()) {
$entity = $this->em->getPartialReference($class, $item->getId());
$item->setHref($this->urlGenerator->getURL($entity, $href_type));
}
@ -138,16 +138,16 @@ class TreeViewGenerator
* The treeview is generic, that means the href are null and ID values are set.
*
* @param string $class The class for which the tree should be generated
* @param AbstractStructuralDBElement|null $parent The parent the root elements should have.
* @param AbstractStructuralDBElement|null $parent the parent the root elements should have
*
* @return TreeViewNode[]
*/
public function getGenericTree(string $class, ?AbstractStructuralDBElement $parent = null): array
{
if (! is_a($class, AbstractNamedDBElement::class, true)) {
if (!is_a($class, AbstractNamedDBElement::class, true)) {
throw new \InvalidArgumentException('$class must be a class string that implements StructuralDBElement or NamedDBElement!');
}
if (null !== $parent && ! is_a($parent, $class)) {
if (null !== $parent && !is_a($parent, $class)) {
throw new \InvalidArgumentException('$parent must be of the type $class!');
}