diff --git a/src/Command/SetPasswordCommand.php b/src/Command/SetPasswordCommand.php index 8603c17e..8fc08d9d 100644 --- a/src/Command/SetPasswordCommand.php +++ b/src/Command/SetPasswordCommand.php @@ -51,7 +51,6 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; -use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface; diff --git a/src/Controller/AdminPages/BaseAdminController.php b/src/Controller/AdminPages/BaseAdminController.php index 80084aff..43fb8e6e 100644 --- a/src/Controller/AdminPages/BaseAdminController.php +++ b/src/Controller/AdminPages/BaseAdminController.php @@ -222,7 +222,7 @@ abstract class BaseAdminController extends AbstractController protected function _new(Request $request, EntityManagerInterface $em, EntityImporter $importer, ?AbstractNamedDBElement $entity = null) { $master_picture_backup = null; - if ($entity === null) { + if (null === $entity) { /** @var AbstractStructuralDBElement|User $new_entity */ $new_entity = new $this->entity_class(); } else { diff --git a/src/Controller/PartController.php b/src/Controller/PartController.php index 12edefcb..506df24a 100644 --- a/src/Controller/PartController.php +++ b/src/Controller/PartController.php @@ -45,6 +45,7 @@ namespace App\Controller; use App\DataTables\LogDataTable; use App\Entity\Parts\Category; use App\Entity\Parts\Footprint; +use App\Entity\Parts\Manufacturer; use App\Entity\Parts\Part; use App\Entity\Parts\PartLot; use App\Entity\Parts\Storelocation; @@ -52,7 +53,6 @@ use App\Entity\Parts\Supplier; use App\Entity\PriceInformations\Orderdetail; use App\Exceptions\AttachmentDownloadException; use App\Form\Part\PartBaseType; -use App\Services\Attachments\AttachmentManager; use App\Services\Attachments\AttachmentSubmitHandler; use App\Services\Attachments\PartPreviewGenerator; use App\Services\LogSystem\EventCommentHelper; @@ -62,7 +62,6 @@ use App\Services\Parameters\ParameterExtractor; use App\Services\PricedetailHelper; use Doctrine\ORM\EntityManagerInterface; use Omines\DataTablesBundle\DataTableFactory; -use App\Entity\Parts\Manufacturer; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\RedirectResponse; @@ -256,7 +255,7 @@ class PartController extends AbstractController } $store_id = $request->get('storelocation', null); - $storelocation = $store_id ? $em->find(Storelocation::class, $store_id): null; + $storelocation = $store_id ? $em->find(Storelocation::class, $store_id) : null; if (null !== $storelocation && $new_part->getPartLots()->isEmpty()) { $partLot = new PartLot(); $partLot->setStorageLocation($storelocation); @@ -265,14 +264,13 @@ class PartController extends AbstractController } $supplier_id = $request->get('supplier', null); - $supplier = $supplier_id ? $em->find(Supplier::class, $supplier_id): null; + $supplier = $supplier_id ? $em->find(Supplier::class, $supplier_id) : null; if (null !== $supplier && $new_part->getOrderdetails()->isEmpty()) { $orderdetail = new Orderdetail(); $orderdetail->setSupplier($supplier); $new_part->addOrderdetail($orderdetail); } - $form = $this->createForm(PartBaseType::class, $new_part); $form->handleRequest($request); diff --git a/src/Controller/TypeaheadController.php b/src/Controller/TypeaheadController.php index 22a31e12..59ca4c6e 100644 --- a/src/Controller/TypeaheadController.php +++ b/src/Controller/TypeaheadController.php @@ -46,7 +46,6 @@ use App\Services\Attachments\BuiltinAttachmentsFinder; use App\Services\TagFinder; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\JsonResponse; -use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Serializer\Encoder\JsonEncoder; use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; @@ -62,8 +61,6 @@ class TypeaheadController extends AbstractController /** * @Route("/builtInResources/search/{query}", name="typeahead_builtInRessources", requirements={"query"= ".+"}) * - * @param string $query - * @param BuiltinAttachmentsFinder $finder * @return JsonResponse */ public function builtInResources(string $query, BuiltinAttachmentsFinder $finder) diff --git a/src/Controller/UserController.php b/src/Controller/UserController.php index 928b56d9..68b1ed4d 100644 --- a/src/Controller/UserController.php +++ b/src/Controller/UserController.php @@ -56,7 +56,6 @@ use Doctrine\ORM\EntityManagerInterface; use InvalidArgumentException; use Omines\DataTablesBundle\DataTableFactory; use Symfony\Component\Asset\Packages; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; @@ -194,7 +193,6 @@ class UserController extends AdminPages\BaseAdminController return $table->getResponse(); } - if ($this->getParameter('use_gravatar')) { $avatar = $this->getGravatar($user->getEmail(), 200, 'identicon'); } else { diff --git a/src/DataFixtures/DataStructureFixtures.php b/src/DataFixtures/DataStructureFixtures.php index f7106615..8100c8b7 100644 --- a/src/DataFixtures/DataStructureFixtures.php +++ b/src/DataFixtures/DataStructureFixtures.php @@ -52,8 +52,8 @@ use App\Entity\Parts\MeasurementUnit; use App\Entity\Parts\Storelocation; use App\Entity\Parts\Supplier; use Doctrine\Bundle\FixturesBundle\Fixture; -use Doctrine\Persistence\ObjectManager; use Doctrine\ORM\EntityManagerInterface; +use Doctrine\Persistence\ObjectManager; use InvalidArgumentException; class DataStructureFixtures extends Fixture diff --git a/src/DataFixtures/UserFixtures.php b/src/DataFixtures/UserFixtures.php index 52ce2f4a..825701b3 100644 --- a/src/DataFixtures/UserFixtures.php +++ b/src/DataFixtures/UserFixtures.php @@ -44,8 +44,8 @@ namespace App\DataFixtures; use App\Entity\UserSystem\User; use Doctrine\Bundle\FixturesBundle\Fixture; -use Doctrine\Persistence\ObjectManager; use Doctrine\ORM\EntityManagerInterface; +use Doctrine\Persistence\ObjectManager; use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface; class UserFixtures extends Fixture diff --git a/src/DataTables/LogDataTable.php b/src/DataTables/LogDataTable.php index 5995f895..ce0eaa7c 100644 --- a/src/DataTables/LogDataTable.php +++ b/src/DataTables/LogDataTable.php @@ -103,9 +103,10 @@ class LogDataTable implements DataTableTypeInterface $optionsResolver->setAllowedTypes('mode', 'string'); $optionsResolver->setNormalizer('filter_elements', function (Options $options, $value) { - if (!is_array($value)) { + if (! is_array($value)) { return [$value]; } + return $value; }); diff --git a/src/Entity/LogSystem/SecurityEventLogEntry.php b/src/Entity/LogSystem/SecurityEventLogEntry.php index ae2b8d05..9fdca9f7 100644 --- a/src/Entity/LogSystem/SecurityEventLogEntry.php +++ b/src/Entity/LogSystem/SecurityEventLogEntry.php @@ -1,4 +1,7 @@ extra['e'] = $key; + return $this; } @@ -84,7 +88,8 @@ class SecurityEventLogEntry extends AbstractLogEntry } /** - * Return what event this log entry represents (e.g. password_reset) + * Return what event this log entry represents (e.g. password_reset). + * * @return string */ public function getEventType(): string @@ -121,6 +126,7 @@ class SecurityEventLogEntry extends AbstractLogEntry $ip = IpUtils::anonymize($ip); } $this->extra['i'] = $ip; + return $this; } -} \ No newline at end of file +} diff --git a/src/Entity/LogSystem/UserNotAllowedLogEntry.php b/src/Entity/LogSystem/UserNotAllowedLogEntry.php index 18100b66..8d9d607f 100644 --- a/src/Entity/LogSystem/UserNotAllowedLogEntry.php +++ b/src/Entity/LogSystem/UserNotAllowedLogEntry.php @@ -42,7 +42,6 @@ declare(strict_types=1); namespace App\Entity\LogSystem; -use App\Exceptions\LogEntryObsoleteException; use Doctrine\ORM\Mapping as ORM; /** @@ -62,6 +61,7 @@ class UserNotAllowedLogEntry extends AbstractLogEntry /** * Returns the path the user tried to accessed and what was denied. + * * @return string */ public function getPath(): string diff --git a/src/Entity/Parts/PartLot.php b/src/Entity/Parts/PartLot.php index e2f85d0b..b2d4ea35 100644 --- a/src/Entity/Parts/PartLot.php +++ b/src/Entity/Parts/PartLot.php @@ -306,13 +306,13 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named /** * Sets the amount of parts in the part lot. * If null is passed, amount will be set to unknown. - * @param float|null $new_amount + * * @return $this */ public function setAmount(?float $new_amount): self { //Treat null like unknown amount - if ($new_amount === null) { + if (null === $new_amount) { $this->instock_unknown = true; $new_amount = 0.0; } diff --git a/src/Entity/Parts/PartTraits/OrderTrait.php b/src/Entity/Parts/PartTraits/OrderTrait.php index 60c23056..7f6ec2d5 100644 --- a/src/Entity/Parts/PartTraits/OrderTrait.php +++ b/src/Entity/Parts/PartTraits/OrderTrait.php @@ -44,9 +44,9 @@ namespace App\Entity\Parts\PartTraits; use App\Entity\PriceInformations\Orderdetail; use App\Security\Annotations\ColumnSecurity; -use Doctrine\ORM\Mapping as ORM; use function count; use Doctrine\Common\Collections\Collection; +use Doctrine\ORM\Mapping as ORM; /** * This trait collects all aspects of a part related to orders and priceinformations. diff --git a/src/Entity/PriceInformations/Pricedetail.php b/src/Entity/PriceInformations/Pricedetail.php index 883bed59..0a5b87d8 100644 --- a/src/Entity/PriceInformations/Pricedetail.php +++ b/src/Entity/PriceInformations/Pricedetail.php @@ -164,11 +164,10 @@ 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. - * * @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 + * @return string|null the price as a bcmath string */ public function getPricePerUnit($multiplier = 1.0): ?string { diff --git a/src/Entity/UserSystem/U2FKey.php b/src/Entity/UserSystem/U2FKey.php index f9dd301f..84669865 100644 --- a/src/Entity/UserSystem/U2FKey.php +++ b/src/Entity/UserSystem/U2FKey.php @@ -61,13 +61,16 @@ class U2FKey implements TwoFactorKeyInterface /** * We have to restrict the length here, as InnoDB only supports key index with max. 767 Bytes. * Max length of keyhandles should be 128. (According to U2F_MAX_KH_SIZE in FIDO example C code). + * * @ORM\Column(type="string", length=128) + * * @var string **/ public $keyHandle; /** * @ORM\Column(type="string") + * * @var string **/ public $publicKey; diff --git a/src/Entity/UserSystem/User.php b/src/Entity/UserSystem/User.php index ac5d9558..ccf57f3d 100644 --- a/src/Entity/UserSystem/User.php +++ b/src/Entity/UserSystem/User.php @@ -508,7 +508,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe { $tmp = $this->getFirstName(); //Dont add a space, if the name has only one part (it would look strange) - if (!empty($this->getFirstName()) && !empty($this->getLastName())) { + if (! empty($this->getFirstName()) && ! empty($this->getLastName())) { $tmp .= ' '; } $tmp .= $this->getLastName(); diff --git a/src/EntityListeners/AttachmentDeleteListener.php b/src/EntityListeners/AttachmentDeleteListener.php index 14735384..5b09667f 100644 --- a/src/EntityListeners/AttachmentDeleteListener.php +++ b/src/EntityListeners/AttachmentDeleteListener.php @@ -87,7 +87,7 @@ class AttachmentDeleteListener $real_path = $this->pathResolver->placeholderToRealPath($old_path); //If the attachment does not point to a valid file, ignore it! - if ($real_path === null) { + if (null === $real_path) { return; } diff --git a/src/EventSubscriber/LogSystem/EventLoggerSubscriber.php b/src/EventSubscriber/LogSystem/EventLoggerSubscriber.php index 9be5ca86..bf53115b 100644 --- a/src/EventSubscriber/LogSystem/EventLoggerSubscriber.php +++ b/src/EventSubscriber/LogSystem/EventLoggerSubscriber.php @@ -67,7 +67,6 @@ use Symfony\Component\Serializer\SerializerInterface; /** * This event subscriber write to event log when entities are changed, removed, created. - * @package App\EventSubscriber\LogSystem */ class EventLoggerSubscriber implements EventSubscriber { diff --git a/src/EventSubscriber/LogSystem/LogAccessDeniedSubscriber.php b/src/EventSubscriber/LogSystem/LogAccessDeniedSubscriber.php index 5e08f178..950fe34b 100644 --- a/src/EventSubscriber/LogSystem/LogAccessDeniedSubscriber.php +++ b/src/EventSubscriber/LogSystem/LogAccessDeniedSubscriber.php @@ -1,4 +1,7 @@ logger = $logger; } - public function onKernelException(ExceptionEvent $event) + public function onKernelException(ExceptionEvent $event): void { $throwable = $event->getThrowable(); if ($throwable instanceof AccessDeniedHttpException) { $throwable = $throwable->getPrevious(); } //Ignore everything except AccessDeniedExceptions - if (!$throwable instanceof AccessDeniedException) { + if (! $throwable instanceof AccessDeniedException) { return; } @@ -57,11 +58,8 @@ class LogAccessDeniedSubscriber implements EventSubscriberInterface $this->logger->logAndFlush($log_entry); } - /** - * @inheritDoc - */ public static function getSubscribedEvents() { return ['kernel.exception' => 'onKernelException']; } -} \ No newline at end of file +} diff --git a/src/EventSubscriber/LogSystem/LogDBMigrationSubscriber.php b/src/EventSubscriber/LogSystem/LogDBMigrationSubscriber.php index 1e51d518..a339fb4f 100644 --- a/src/EventSubscriber/LogSystem/LogDBMigrationSubscriber.php +++ b/src/EventSubscriber/LogSystem/LogDBMigrationSubscriber.php @@ -50,7 +50,6 @@ use Doctrine\Migrations\Events; /** * This subscriber logs databaseMigrations to Event log. - * @package App\EventSubscriber */ class LogDBMigrationSubscriber implements EventSubscriber { diff --git a/src/EventSubscriber/LogSystem/LogoutLoggerHandler.php b/src/EventSubscriber/LogSystem/LogoutLoggerHandler.php index f6c91451..260f3f6f 100644 --- a/src/EventSubscriber/LogSystem/LogoutLoggerHandler.php +++ b/src/EventSubscriber/LogSystem/LogoutLoggerHandler.php @@ -52,7 +52,6 @@ use Symfony\Component\Security\Http\Logout\LogoutHandlerInterface; /** * This handler logs to event log, if a user logs out. - * @package App\EventSubscriber\LogSystem */ class LogoutLoggerHandler implements LogoutHandlerInterface { diff --git a/src/EventSubscriber/LogSystem/SecurityEventLoggerSubscriber.php b/src/EventSubscriber/LogSystem/SecurityEventLoggerSubscriber.php index c7252089..aca7bd83 100644 --- a/src/EventSubscriber/LogSystem/SecurityEventLoggerSubscriber.php +++ b/src/EventSubscriber/LogSystem/SecurityEventLoggerSubscriber.php @@ -1,4 +1,7 @@ eventLogger = $eventLogger; } - protected function addLog(string $type, SecurityEvent $event): void - { - $anonymize = $this->gpdr_compliant; - - $request = $this->requestStack->getCurrentRequest(); - if ($request !== null) { - $ip = $request->getClientIp() ?? 'unknown'; - } else { - $ip = "Console"; - //Dont try to apply IP filter rules to non numeric string - $anonymize = false; - } - - $log = new SecurityEventLogEntry($type, $ip, $anonymize); - $log->setTargetElement($event->getTargetUser()); - $this->eventLogger->logAndFlush($log); - } - - /** - * @inheritDoc - */ public static function getSubscribedEvents() { return [ @@ -127,4 +105,22 @@ final class SecurityEventLoggerSubscriber implements EventSubscriberInterface { $this->addLog(SecurityEvents::TRUSTED_DEVICE_RESET, $event); } -} \ No newline at end of file + + private function addLog(string $type, SecurityEvent $event): void + { + $anonymize = $this->gpdr_compliant; + + $request = $this->requestStack->getCurrentRequest(); + if (null !== $request) { + $ip = $request->getClientIp() ?? 'unknown'; + } else { + $ip = 'Console'; + //Dont try to apply IP filter rules to non numeric string + $anonymize = false; + } + + $log = new SecurityEventLogEntry($type, $ip, $anonymize); + $log->setTargetElement($event->getTargetUser()); + $this->eventLogger->logAndFlush($log); + } +} diff --git a/src/EventSubscriber/SetMailFromSubscriber.php b/src/EventSubscriber/SetMailFromSubscriber.php index 71d96a03..59d2e654 100644 --- a/src/EventSubscriber/SetMailFromSubscriber.php +++ b/src/EventSubscriber/SetMailFromSubscriber.php @@ -49,7 +49,6 @@ use Symfony\Component\Mime\Email; /** * This subscriber set the "From" field for all sent email, based on the global configured sender name and email. - * @package App\EventSubscriber */ final class SetMailFromSubscriber implements EventSubscriberInterface { diff --git a/src/EventSubscriber/SymfonyDebugToolbarSubscriber.php b/src/EventSubscriber/SymfonyDebugToolbarSubscriber.php index 377c9633..1d597c86 100644 --- a/src/EventSubscriber/SymfonyDebugToolbarSubscriber.php +++ b/src/EventSubscriber/SymfonyDebugToolbarSubscriber.php @@ -42,14 +42,11 @@ declare(strict_types=1); namespace App\EventSubscriber; -use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; use Symfony\Component\HttpKernel\Event\ResponseEvent; /** * This subscriber sets an Header in Debug mode that signals the Symfony Profiler to also update on Ajax requests. - * @package App\EventSubscriber */ final class SymfonyDebugToolbarSubscriber implements EventSubscriberInterface { diff --git a/src/EventSubscriber/UserSystem/LogoutDisabledUserSubscriber.php b/src/EventSubscriber/UserSystem/LogoutDisabledUserSubscriber.php index 565aa907..adcd7573 100644 --- a/src/EventSubscriber/UserSystem/LogoutDisabledUserSubscriber.php +++ b/src/EventSubscriber/UserSystem/LogoutDisabledUserSubscriber.php @@ -53,7 +53,6 @@ use Symfony\Component\Security\Core\Security; /** * This subscriber is used to log out a disabled user, as soon as he to do an request. * It is not possible for him to login again, afterwards. - * @package App\EventSubscriber\UserSystem */ final class LogoutDisabledUserSubscriber implements EventSubscriberInterface { diff --git a/src/EventSubscriber/UserSystem/RegisterU2FSubscriber.php b/src/EventSubscriber/UserSystem/RegisterU2FSubscriber.php index 3e520ecf..a6c986f5 100644 --- a/src/EventSubscriber/UserSystem/RegisterU2FSubscriber.php +++ b/src/EventSubscriber/UserSystem/RegisterU2FSubscriber.php @@ -57,7 +57,6 @@ use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; /** * This subscriber is used to write U2F keys to DB, after user added them via GUI. - * @package App\EventSubscriber\UserSystem */ final class RegisterU2FSubscriber implements EventSubscriberInterface { diff --git a/src/Events/SecurityEvent.php b/src/Events/SecurityEvent.php index 618a5f11..efdb9029 100644 --- a/src/Events/SecurityEvent.php +++ b/src/Events/SecurityEvent.php @@ -1,4 +1,7 @@ targetUser; } -} \ No newline at end of file +} diff --git a/src/Events/SecurityEvents.php b/src/Events/SecurityEvents.php index dfdacbdb..ee9b1415 100644 --- a/src/Events/SecurityEvents.php +++ b/src/Events/SecurityEvents.php @@ -1,4 +1,7 @@ false, 'label' => 'attachment.edit.secure_file', 'mapped' => false, - 'disabled' => !$this->security->isGranted('@parts_attachments.show_private'), + 'disabled' => ! $this->security->isGranted('@parts_attachments.show_private'), 'attr' => [ 'class' => 'form-control-sm', ], diff --git a/src/Form/CollectionTypeExtension.php b/src/Form/CollectionTypeExtension.php index 01bc6a89..1ca9fb8f 100644 --- a/src/Form/CollectionTypeExtension.php +++ b/src/Form/CollectionTypeExtension.php @@ -1,4 +1,7 @@ setDefault('error_mapping', function (Options $options) { $options-> });*/ $resolver->setDefaults([ - 'reindex_enable' => false, - 'reindex_prefix' => 'db_', - 'reindex_path' => 'id', - ]); + 'reindex_enable' => false, + 'reindex_prefix' => 'db_', + 'reindex_path' => 'id', + ]); $resolver->setAllowedTypes('reindex_enable', 'bool'); $resolver->setAllowedTypes('reindex_prefix', 'string'); $resolver->setAllowedTypes('reindex_path', 'string'); } - public function buildForm(FormBuilderInterface $builder, array $options) + public function buildForm(FormBuilderInterface $builder, array $options): void { - $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($options) { + $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($options): void { $data = $event->getData(); $config = $event->getForm()->getConfig(); //If enabled do a reindexing of the collection @@ -86,8 +87,8 @@ class CollectionTypeExtension extends AbstractTypeExtension foreach ($data->toArray() as $key => $item) { $id = $this->propertyAccess->getValue($item, $options['reindex_path']); //If element has an ID then use it. otherwise use default key - $index = $id === null ? $key : $options['reindex_prefix'] . $id; - $error_mapping['[' . $key . ']'] = $index; + $index = null === $id ? $key : $options['reindex_prefix'].$id; + $error_mapping['['.$key.']'] = $index; $reindexed_data->set($index, $item); } $event->setData($reindexed_data); @@ -103,9 +104,7 @@ class CollectionTypeExtension extends AbstractTypeExtension /** * Set the option of the form. * This a bit hacky cause we access private properties.... - * @param FormBuilder $builder - * @param string $option - * @param mixed $value + * * @throws \ReflectionException */ public function setOption(FormBuilder $builder, string $option, $value): void @@ -119,4 +118,4 @@ class CollectionTypeExtension extends AbstractTypeExtension $property->setValue($builder, $tmp); $property->setAccessible(false); } -} \ No newline at end of file +} diff --git a/src/Form/Type/MasterPictureAttachmentType.php b/src/Form/Type/MasterPictureAttachmentType.php index 2f3c8979..69268807 100644 --- a/src/Form/Type/MasterPictureAttachmentType.php +++ b/src/Form/Type/MasterPictureAttachmentType.php @@ -45,9 +45,6 @@ namespace App\Form\Type; use App\Entity\Attachments\Attachment; use App\Entity\Attachments\AttachmentContainingDBElement; use App\Entity\Contracts\HasMasterAttachmentInterface; -use Doctrine\ORM\EntityRepository; -use ReflectionClass; -use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\ChoiceList\Loader\CallbackChoiceLoader; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; @@ -62,36 +59,37 @@ class MasterPictureAttachmentType extends AbstractType $resolver->setAllowedTypes('entity', HasMasterAttachmentInterface::class); $resolver->setDefaults([ - 'filter' => 'picture', - 'choice_translation_domain' => false, - 'attr' => [ - 'class' => 'selectpicker', - ], - 'choice_attr' => function (Options $options) { - return function ($choice, $key, $value) use ($options) { - /** @var Attachment $choice */ - $tmp = ['data-subtext' => $choice->getFilename() ?? 'URL']; + 'filter' => 'picture', + 'choice_translation_domain' => false, + 'attr' => [ + 'class' => 'selectpicker', + ], + 'choice_attr' => function (Options $options) { + return function ($choice, $key, $value) use ($options) { + /** @var Attachment $choice */ + $tmp = ['data-subtext' => $choice->getFilename() ?? 'URL']; - if ('picture' === $options['filter'] && ! $choice->isPicture()) { - $tmp += ['disabled' => 'disabled']; - } elseif ('3d_model' === $options['filter'] && ! $choice->is3DModel()) { - $tmp += ['disabled' => 'disabled']; - } + if ('picture' === $options['filter'] && ! $choice->isPicture()) { + $tmp += ['disabled' => 'disabled']; + } elseif ('3d_model' === $options['filter'] && ! $choice->is3DModel()) { + $tmp += ['disabled' => 'disabled']; + } - return $tmp; - }; - }, - 'choice_label' => 'name', - 'choice_loader' => function (Options $options) { - return new CallbackChoiceLoader(function () use ($options) { - $entity = $options['entity']; - if (!$entity instanceof AttachmentContainingDBElement) { - throw new \RuntimeException('$entity must have Attachments! (be of type AttachmentContainingDBElement)'); - } - return $entity->getAttachments()->toArray(); - }); - } - ]); + return $tmp; + }; + }, + 'choice_label' => 'name', + 'choice_loader' => function (Options $options) { + return new CallbackChoiceLoader(function () use ($options) { + $entity = $options['entity']; + if (! $entity instanceof AttachmentContainingDBElement) { + throw new \RuntimeException('$entity must have Attachments! (be of type AttachmentContainingDBElement)'); + } + + return $entity->getAttachments()->toArray(); + }); + }, + ]); $resolver->setAllowedValues('filter', ['', 'picture', '3d_model']); } diff --git a/src/Form/Type/StructuralEntityType.php b/src/Form/Type/StructuralEntityType.php index 87606379..bee6742c 100644 --- a/src/Form/Type/StructuralEntityType.php +++ b/src/Form/Type/StructuralEntityType.php @@ -85,35 +85,35 @@ class StructuralEntityType extends AbstractType function ($value) use ($options) { return $this->transform($value, $options); }, function ($value) use ($options) { - return $this->reverseTransform($value, $options); - })); + return $this->reverseTransform($value, $options); + })); } public function configureOptions(OptionsResolver $resolver): void { $resolver->setRequired(['class']); $resolver->setDefaults([ - 'show_fullpath_in_subtext' => true, //When this is enabled, the full path will be shown in subtext - 'subentities_of' => null, //Only show entities with the given parent class - 'disable_not_selectable' => false, //Disable entries with not selectable property - 'choice_value' => 'id', //Use the element id as option value and for comparing items - 'choice_loader' => function (Options $options) { - return new CallbackChoiceLoader(function () use ($options) { - return $this->getEntries($options); - }); - }, - 'choice_label' => function (Options $options) { - return function ($choice, $key, $value) use ($options) { - return $this->generateChoiceLabels($choice, $key, $value, $options); - }; - }, - 'choice_attr' => function (Options $options) { - return function ($choice, $key, $value) use ($options) { - return $this->generateChoiceAttr($choice, $key, $value, $options); - }; - }, - 'choice_translation_domain' => false, //Don't translate the entity names - ]); + 'show_fullpath_in_subtext' => true, //When this is enabled, the full path will be shown in subtext + 'subentities_of' => null, //Only show entities with the given parent class + 'disable_not_selectable' => false, //Disable entries with not selectable property + 'choice_value' => 'id', //Use the element id as option value and for comparing items + 'choice_loader' => function (Options $options) { + return new CallbackChoiceLoader(function () use ($options) { + return $this->getEntries($options); + }); + }, + 'choice_label' => function (Options $options) { + return function ($choice, $key, $value) use ($options) { + return $this->generateChoiceLabels($choice, $key, $value, $options); + }; + }, + 'choice_attr' => function (Options $options) { + return function ($choice, $key, $value) use ($options) { + return $this->generateChoiceAttr($choice, $key, $value, $options); + }; + }, + 'choice_translation_domain' => false, //Don't translate the entity names + ]); $resolver->setDefault('empty_message', null); diff --git a/src/Migrations/Version20200409130946.php b/src/Migrations/Version20200409130946.php index 64bf246f..8f218708 100644 --- a/src/Migrations/Version20200409130946.php +++ b/src/Migrations/Version20200409130946.php @@ -12,23 +12,23 @@ use Doctrine\Migrations\AbstractMigration; */ final class Version20200409130946 extends AbstractMigration { - public function getDescription() : string + public function getDescription(): string { return ''; } - public function up(Schema $schema) : void + public function up(Schema $schema): void { // this up() migration is auto-generated, please modify it to your needs - $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + $this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.'); $this->addSql('ALTER TABLE u2f_keys CHANGE key_handle key_handle VARCHAR(128) NOT NULL'); } - public function down(Schema $schema) : void + public function down(Schema $schema): void { // this down() migration is auto-generated, please modify it to your needs - $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + $this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.'); $this->addSql('ALTER TABLE u2f_keys CHANGE key_handle key_handle VARCHAR(64) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`'); } diff --git a/src/Security/Voter/StructureVoter.php b/src/Security/Voter/StructureVoter.php index f3ebfabe..0a9d6d98 100644 --- a/src/Security/Voter/StructureVoter.php +++ b/src/Security/Voter/StructureVoter.php @@ -52,7 +52,6 @@ use App\Entity\Parts\Storelocation; use App\Entity\Parts\Supplier; use App\Entity\PriceInformations\Currency; use App\Entity\UserSystem\User; - use function get_class; use function is_object; diff --git a/src/Services/AmountFormatter.php b/src/Services/AmountFormatter.php index c679e035..2dae342a 100644 --- a/src/Services/AmountFormatter.php +++ b/src/Services/AmountFormatter.php @@ -63,8 +63,8 @@ class AmountFormatter * Formats the given value using the measurement unit and options. * * @param float|string|int $value - * @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 * diff --git a/src/Services/Attachments/AttachmentURLGenerator.php b/src/Services/Attachments/AttachmentURLGenerator.php index ebbb0e76..6f7d15ac 100644 --- a/src/Services/Attachments/AttachmentURLGenerator.php +++ b/src/Services/Attachments/AttachmentURLGenerator.php @@ -130,7 +130,7 @@ class AttachmentURLGenerator 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(); } diff --git a/src/Services/Attachments/BuiltinAttachmentsFinder.php b/src/Services/Attachments/BuiltinAttachmentsFinder.php index 5c7338b8..92df4a9f 100644 --- a/src/Services/Attachments/BuiltinAttachmentsFinder.php +++ b/src/Services/Attachments/BuiltinAttachmentsFinder.php @@ -43,10 +43,10 @@ declare(strict_types=1); namespace App\Services\Attachments; use App\Entity\Attachments\Attachment; +use Psr\Cache\InvalidArgumentException; use Symfony\Component\Finder\Finder; use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Contracts\Cache\CacheInterface; -use Psr\Cache\InvalidArgumentException; /** * This service is used to find builtin attachment ressources. diff --git a/src/Services/ElementTypeNameGenerator.php b/src/Services/ElementTypeNameGenerator.php index 797919ab..56ac883b 100644 --- a/src/Services/ElementTypeNameGenerator.php +++ b/src/Services/ElementTypeNameGenerator.php @@ -44,7 +44,6 @@ namespace App\Services; use App\Entity\Attachments\Attachment; use App\Entity\Attachments\AttachmentType; -use App\Entity\Base\AbstractDBElement; use App\Entity\Contracts\NamedElementInterface; use App\Entity\Devices\Device; use App\Entity\Parameters\AbstractParameter; diff --git a/src/Services/EntityExporter.php b/src/Services/EntityExporter.php index a07c5b0d..587b20b4 100644 --- a/src/Services/EntityExporter.php +++ b/src/Services/EntityExporter.php @@ -79,7 +79,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 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 87c10b0c..076926e0 100644 --- a/src/Services/EntityURLGenerator.php +++ b/src/Services/EntityURLGenerator.php @@ -94,7 +94,7 @@ class EntityURLGenerator * @param mixed $entity The element for which the page should be generated * @param string $type The page type. Currently supported: 'info', 'edit', 'create', 'clone', 'list'/'list_parts' * - * @return null|string the link to the desired page + * @return string|null the link to the desired page * * @throws EntityNotSupportedException thrown if the entity is not supported for the given type * @throws InvalidArgumentException thrown if the givent type is not existing diff --git a/src/Services/PermissionResolver.php b/src/Services/PermissionResolver.php index b547a5d6..65ca59f3 100644 --- a/src/Services/PermissionResolver.php +++ b/src/Services/PermissionResolver.php @@ -49,7 +49,6 @@ use App\Security\Interfaces\HasPermissionsInterface; use Symfony\Component\Config\ConfigCache; use Symfony\Component\Config\Definition\Processor; use Symfony\Component\Config\Resource\FileResource; -use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\Yaml\Yaml; class PermissionResolver diff --git a/src/Services/PricedetailHelper.php b/src/Services/PricedetailHelper.php index c4a24a6b..ac480c14 100644 --- a/src/Services/PricedetailHelper.php +++ b/src/Services/PricedetailHelper.php @@ -176,7 +176,7 @@ class PricedetailHelper $converted = $this->convertMoneyToCurrency($pricedetail->getPricePerUnit(), $pricedetail->getCurrency(), $currency); //Ignore price informations that can not be converted to base currency. - if ($converted !== null) { + if (null !== $converted) { $avg = bcadd($avg, $converted, Pricedetail::PRICE_PRECISION); ++$count; }