diff --git a/src/Command/Attachments/CleanAttachmentsCommand.php b/src/Command/Attachments/CleanAttachmentsCommand.php index 9c95b590..5db8e500 100644 --- a/src/Command/Attachments/CleanAttachmentsCommand.php +++ b/src/Command/Attachments/CleanAttachmentsCommand.php @@ -146,9 +146,9 @@ class CleanAttachmentsCommand extends Command /** * This function removes all empty folders inside $path. Taken from https://stackoverflow.com/a/1833681. * - * @param string $path The path in which the empty folders should be deleted + * @param string $path The path in which the empty folders should be deleted */ - protected function removeEmptySubFolders($path): bool + protected function removeEmptySubFolders(string $path): bool { $empty = true; foreach (glob($path.DIRECTORY_SEPARATOR.'*') as $file) { diff --git a/src/Command/Logs/ShowEventLogCommand.php b/src/Command/Logs/ShowEventLogCommand.php index 00efffaf..7da5a6b7 100644 --- a/src/Command/Logs/ShowEventLogCommand.php +++ b/src/Command/Logs/ShowEventLogCommand.php @@ -76,7 +76,7 @@ class ShowEventLogCommand extends Command parent::__construct(); } - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); diff --git a/src/Command/User/UserListCommand.php b/src/Command/User/UserListCommand.php index ed8ceb53..08289e9c 100644 --- a/src/Command/User/UserListCommand.php +++ b/src/Command/User/UserListCommand.php @@ -31,7 +31,7 @@ class UserListCommand extends Command ; } - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); diff --git a/src/Controller/AdminPages/ManufacturerController.php b/src/Controller/AdminPages/ManufacturerController.php index 4fbb0535..4cf9c48f 100644 --- a/src/Controller/AdminPages/ManufacturerController.php +++ b/src/Controller/AdminPages/ManufacturerController.php @@ -71,7 +71,7 @@ class ManufacturerController extends BaseAdminController * * @return \Symfony\Component\HttpFoundation\RedirectResponse */ - public function delete(Request $request, Manufacturer $entity, StructuralElementRecursionHelper $recursionHelper) + public function delete(Request $request, Manufacturer $entity, StructuralElementRecursionHelper $recursionHelper): \Symfony\Component\HttpFoundation\RedirectResponse { return $this->_delete($request, $entity, $recursionHelper); } diff --git a/src/Controller/UserSettingsController.php b/src/Controller/UserSettingsController.php index 7920b6b5..3428163d 100644 --- a/src/Controller/UserSettingsController.php +++ b/src/Controller/UserSettingsController.php @@ -59,6 +59,7 @@ use Symfony\Component\Form\Extension\Core\Type\PasswordType; use Symfony\Component\Form\Extension\Core\Type\RepeatedType; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\TextType; +use Symfony\Component\Form\FormFactoryInterface; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface; @@ -200,7 +201,7 @@ class UserSettingsController extends AbstractController * * @return RedirectResponse|\Symfony\Component\HttpFoundation\Response */ - public function userSettings(Request $request, EntityManagerInterface $em, UserPasswordHasherInterface $passwordEncoder, GoogleAuthenticator $googleAuthenticator, BackupCodeManager $backupCodeManager) + public function userSettings(Request $request, EntityManagerInterface $em, UserPasswordHasherInterface $passwordEncoder, GoogleAuthenticator $googleAuthenticator, BackupCodeManager $backupCodeManager, FormFactoryInterface $formFactory) { /** @var User */ $user = $this->getUser(); @@ -330,7 +331,8 @@ class UserSettingsController extends AbstractController return $this->redirectToRoute('user_settings'); } - $backup_form = $this->get('form.factory')->createNamedBuilder('backup_codes')->add('reset_codes', SubmitType::class, [ + + $backup_form = $formFactory->createNamedBuilder('backup_codes')->add('reset_codes', SubmitType::class, [ 'label' => 'tfa_backup.regenerate_codes', 'attr' => [ 'class' => 'btn-danger', diff --git a/src/DataTables/Column/EntityColumn.php b/src/DataTables/Column/EntityColumn.php index 37ba7ea1..ea32440f 100644 --- a/src/DataTables/Column/EntityColumn.php +++ b/src/DataTables/Column/EntityColumn.php @@ -66,6 +66,7 @@ class EntityColumn extends AbstractColumn * The normalize function is responsible for converting parsed and processed data to a datatables-appropriate type. * * @param mixed $value The single value of the column + * @return mixed */ public function normalize($value) { @@ -73,7 +74,7 @@ class EntityColumn extends AbstractColumn return $value; } - public function configureOptions(OptionsResolver $resolver) + public function configureOptions(OptionsResolver $resolver): self { parent::configureOptions($resolver); diff --git a/src/DataTables/Column/IconLinkColumn.php b/src/DataTables/Column/IconLinkColumn.php index f97196f4..932b36a7 100644 --- a/src/DataTables/Column/IconLinkColumn.php +++ b/src/DataTables/Column/IconLinkColumn.php @@ -28,12 +28,16 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class IconLinkColumn extends AbstractColumn { + /** + * @param $value + * @return mixed + */ public function normalize($value) { return $value; } - public function configureOptions(OptionsResolver $resolver) + public function configureOptions(OptionsResolver $resolver): self { parent::configureOptions($resolver); $resolver->setDefaults([ @@ -51,7 +55,7 @@ class IconLinkColumn extends AbstractColumn return $this; } - public function render($value, $context) + public function render($value, $context): string { $href = $this->getHref($value, $context); $icon = $this->getIcon($value, $context); diff --git a/src/DataTables/Column/LocaleDateTimeColumn.php b/src/DataTables/Column/LocaleDateTimeColumn.php index c22311ed..87e7fd96 100644 --- a/src/DataTables/Column/LocaleDateTimeColumn.php +++ b/src/DataTables/Column/LocaleDateTimeColumn.php @@ -55,7 +55,12 @@ use Symfony\Component\OptionsResolver\OptionsResolver; */ class LocaleDateTimeColumn extends AbstractColumn { - public function normalize($value) + /** + * @param $value + * @return bool|mixed|string + * @throws \Exception + */ + public function normalize($value): string { if (null === $value) { return $this->options['nullValue']; @@ -81,7 +86,7 @@ class LocaleDateTimeColumn extends AbstractColumn return $formatter->format($value->getTimestamp()); } - protected function configureOptions(OptionsResolver $resolver) + protected function configureOptions(OptionsResolver $resolver): self { parent::configureOptions($resolver); diff --git a/src/DataTables/Column/LogEntryExtraColumn.php b/src/DataTables/Column/LogEntryExtraColumn.php index ee14d2b2..6e215479 100644 --- a/src/DataTables/Column/LogEntryExtraColumn.php +++ b/src/DataTables/Column/LogEntryExtraColumn.php @@ -57,12 +57,16 @@ class LogEntryExtraColumn extends AbstractColumn $this->formatter = $formatter; } + /** + * @param $value + * @return mixed + */ public function normalize($value) { return $value; } - public function render($value, $context) + public function render($value, $context): string { return $this->formatter->format($context); } diff --git a/src/DataTables/Column/LogEntryTargetColumn.php b/src/DataTables/Column/LogEntryTargetColumn.php index 1314900f..b4d4a849 100644 --- a/src/DataTables/Column/LogEntryTargetColumn.php +++ b/src/DataTables/Column/LogEntryTargetColumn.php @@ -78,12 +78,16 @@ class LogEntryTargetColumn extends AbstractColumn $this->translator = $translator; } + /** + * @param $value + * @return mixed + */ public function normalize($value) { return $value; } - public function configureOptions(OptionsResolver $resolver) + public function configureOptions(OptionsResolver $resolver): self { parent::configureOptions($resolver); $resolver->setDefault('show_associated', true); @@ -92,7 +96,7 @@ class LogEntryTargetColumn extends AbstractColumn return $this; } - public function render($value, $context) + public function render($value, $context): string { if ($context instanceof UserNotAllowedLogEntry && $this->options['showAccessDeniedPath']) { return htmlspecialchars($context->getPath()); diff --git a/src/DataTables/Column/MarkdownColumn.php b/src/DataTables/Column/MarkdownColumn.php index 20294f64..e20e22c2 100644 --- a/src/DataTables/Column/MarkdownColumn.php +++ b/src/DataTables/Column/MarkdownColumn.php @@ -58,6 +58,7 @@ class MarkdownColumn extends AbstractColumn * The normalize function is responsible for converting parsed and processed data to a datatables-appropriate type. * * @param mixed $value The single value of the column + * @return mixed */ public function normalize($value) { diff --git a/src/DataTables/Column/PartAttachmentsColumn.php b/src/DataTables/Column/PartAttachmentsColumn.php index 885ac6dc..4692c74b 100644 --- a/src/DataTables/Column/PartAttachmentsColumn.php +++ b/src/DataTables/Column/PartAttachmentsColumn.php @@ -68,13 +68,14 @@ class PartAttachmentsColumn extends AbstractColumn * The normalize function is responsible for converting parsed and processed data to a datatables-appropriate type. * * @param mixed $value The single value of the column + * @return mixed */ public function normalize($value) { return $value; } - public function render($value, $context) + public function render($value, $context): string { if (!$context instanceof Part) { throw new RuntimeException('$context must be a Part object!'); @@ -107,7 +108,7 @@ class PartAttachmentsColumn extends AbstractColumn return $tmp; } - public function configureOptions(OptionsResolver $resolver) + public function configureOptions(OptionsResolver $resolver): self { parent::configureOptions($resolver); diff --git a/src/DataTables/Column/RevertLogColumn.php b/src/DataTables/Column/RevertLogColumn.php index bd730d89..09db18fb 100644 --- a/src/DataTables/Column/RevertLogColumn.php +++ b/src/DataTables/Column/RevertLogColumn.php @@ -42,12 +42,16 @@ class RevertLogColumn extends AbstractColumn $this->security = $security; } + /** + * @param $value + * @return mixed + */ public function normalize($value) { return $value; } - public function render($value, $context) + public function render($value, $context): string { if ( $context instanceof CollectionElementDeleted diff --git a/src/DataTables/Column/TagsColumn.php b/src/DataTables/Column/TagsColumn.php index 678a151c..b0364cd7 100644 --- a/src/DataTables/Column/TagsColumn.php +++ b/src/DataTables/Column/TagsColumn.php @@ -58,6 +58,7 @@ class TagsColumn extends AbstractColumn * The normalize function is responsible for converting parsed and processed data to a datatables-appropriate type. * * @param mixed $value The single value of the column + * @return mixed */ public function normalize($value) { @@ -68,7 +69,7 @@ class TagsColumn extends AbstractColumn return explode(',', $value); } - public function render($tags, $context) + public function render($tags, $context): string { $html = ''; $count = 10; diff --git a/src/Doctrine/Purger/ResetAutoIncrementORMPurger.php b/src/Doctrine/Purger/ResetAutoIncrementORMPurger.php index 527958af..f5d79b61 100644 --- a/src/Doctrine/Purger/ResetAutoIncrementORMPurger.php +++ b/src/Doctrine/Purger/ResetAutoIncrementORMPurger.php @@ -64,11 +64,11 @@ class ResetAutoIncrementORMPurger implements PurgerInterface, ORMPurgerInterface /** * Set the purge mode * - * @param int $mode + * @param int $mode * * @return void */ - public function setPurgeMode($mode) + public function setPurgeMode(int $mode): void { $this->purgeMode = $mode; } @@ -78,13 +78,13 @@ class ResetAutoIncrementORMPurger implements PurgerInterface, ORMPurgerInterface * * @return int */ - public function getPurgeMode() + public function getPurgeMode(): int { return $this->purgeMode; } /** @inheritDoc */ - public function setEntityManager(EntityManagerInterface $em) + public function setEntityManager(EntityManagerInterface $em): void { $this->em = $em; } @@ -94,13 +94,13 @@ class ResetAutoIncrementORMPurger implements PurgerInterface, ORMPurgerInterface * * @return EntityManagerInterface */ - public function getObjectManager() + public function getObjectManager(): ?EntityManagerInterface { return $this->em; } /** @inheritDoc */ - public function purge() + public function purge(): void { $classes = []; @@ -199,7 +199,7 @@ class ResetAutoIncrementORMPurger implements PurgerInterface, ORMPurgerInterface * * @return ClassMetadata[] */ - private function getCommitOrder(EntityManagerInterface $em, array $classes) + private function getCommitOrder(EntityManagerInterface $em, array $classes): array { $sorter = new TopologicalSorter(); @@ -258,7 +258,7 @@ class ResetAutoIncrementORMPurger implements PurgerInterface, ORMPurgerInterface * * @return array */ - private function getAssociationTables(array $classes, AbstractPlatform $platform) + private function getAssociationTables(array $classes, AbstractPlatform $platform): array { $associationTables = []; diff --git a/src/Entity/Base/AbstractCompany.php b/src/Entity/Base/AbstractCompany.php index e9912b9b..3ff32987 100644 --- a/src/Entity/Base/AbstractCompany.php +++ b/src/Entity/Base/AbstractCompany.php @@ -150,12 +150,12 @@ abstract class AbstractCompany extends AbstractPartsContainingDBElement /** * Get the link to the website of an article. * - * @param string $partnr * NULL for returning the URL with a placeholder for the part number + * @param string|null $partnr * NULL for returning the URL with a placeholder for the part number * * or the part number for returning the direct URL to the article * * @return string the link to the article */ - public function getAutoProductUrl($partnr = null): string + public function getAutoProductUrl(string $partnr = null): string { if (is_string($partnr)) { return str_replace('%PARTNUMBER%', $partnr, $this->auto_product_url); diff --git a/src/Entity/UserSystem/U2FKey.php b/src/Entity/UserSystem/U2FKey.php index 000c062b..b7f8f6da 100644 --- a/src/Entity/UserSystem/U2FKey.php +++ b/src/Entity/UserSystem/U2FKey.php @@ -120,11 +120,12 @@ class U2FKey implements TwoFactorKeyInterface $this->counter = $data->counter; } - public function getKeyHandle() + public function getKeyHandle(): string { return $this->keyHandle; } + public function setKeyHandle($keyHandle): self { $this->keyHandle = $keyHandle; @@ -132,7 +133,7 @@ class U2FKey implements TwoFactorKeyInterface return $this; } - public function getPublicKey() + public function getPublicKey(): string { return $this->publicKey; } @@ -144,7 +145,7 @@ class U2FKey implements TwoFactorKeyInterface return $this; } - public function getCertificate() + public function getCertificate(): string { return $this->certificate; } @@ -156,7 +157,7 @@ class U2FKey implements TwoFactorKeyInterface return $this; } - public function getCounter() + public function getCounter(): int { return $this->counter; } @@ -168,7 +169,7 @@ class U2FKey implements TwoFactorKeyInterface return $this; } - public function getName() + public function getName(): string { return $this->name; } diff --git a/src/EventSubscriber/LogSystem/EventLoggerSubscriber.php b/src/EventSubscriber/LogSystem/EventLoggerSubscriber.php index 1fb8ea7d..e12ba158 100644 --- a/src/EventSubscriber/LogSystem/EventLoggerSubscriber.php +++ b/src/EventSubscriber/LogSystem/EventLoggerSubscriber.php @@ -213,7 +213,7 @@ class EventLoggerSubscriber implements EventSubscriber return true; } - public function getSubscribedEvents() + public function getSubscribedEvents(): array { return[ Events::onFlush, diff --git a/src/EventSubscriber/LogSystem/LogAccessDeniedSubscriber.php b/src/EventSubscriber/LogSystem/LogAccessDeniedSubscriber.php index 70eade97..ae3e5e0f 100644 --- a/src/EventSubscriber/LogSystem/LogAccessDeniedSubscriber.php +++ b/src/EventSubscriber/LogSystem/LogAccessDeniedSubscriber.php @@ -58,7 +58,7 @@ class LogAccessDeniedSubscriber implements EventSubscriberInterface $this->logger->logAndFlush($log_entry); } - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return ['kernel.exception' => 'onKernelException']; } diff --git a/src/EventSubscriber/LogSystem/LogDBMigrationSubscriber.php b/src/EventSubscriber/LogSystem/LogDBMigrationSubscriber.php index ac63f63a..ee6f5c3c 100644 --- a/src/EventSubscriber/LogSystem/LogDBMigrationSubscriber.php +++ b/src/EventSubscriber/LogSystem/LogDBMigrationSubscriber.php @@ -102,7 +102,7 @@ class LogDBMigrationSubscriber implements EventSubscriber } } - public function getSubscribedEvents() + public function getSubscribedEvents(): array { return [ Events::onMigrationsMigrated, diff --git a/src/Form/AttachmentFormType.php b/src/Form/AttachmentFormType.php index ef8a1c6d..22368f46 100644 --- a/src/Form/AttachmentFormType.php +++ b/src/Form/AttachmentFormType.php @@ -185,7 +185,7 @@ class AttachmentFormType extends AbstractType ]); } - public function getBlockPrefix() + public function getBlockPrefix(): string { return 'attachment'; } diff --git a/src/Form/Permissions/PermissionsMapper.php b/src/Form/Permissions/PermissionsMapper.php index 321754bb..657c68ea 100644 --- a/src/Form/Permissions/PermissionsMapper.php +++ b/src/Form/Permissions/PermissionsMapper.php @@ -72,7 +72,7 @@ final class PermissionsMapper implements DataMapperInterface * @param mixed $viewData View data of the compound form being initialized * @param FormInterface[]|Traversable $forms A list of {@link FormInterface} instances */ - public function mapDataToForms($viewData, $forms) + public function mapDataToForms($viewData, $forms): void { foreach ($forms as $form) { if ($this->inherit) { diff --git a/src/Form/Type/BigDecimalMoneyType.php b/src/Form/Type/BigDecimalMoneyType.php index 0d77abaa..9ad368af 100644 --- a/src/Form/Type/BigDecimalMoneyType.php +++ b/src/Form/Type/BigDecimalMoneyType.php @@ -33,12 +33,12 @@ class BigDecimalMoneyType extends AbstractType implements DataTransformerInterfa $builder->addModelTransformer($this); } - public function getParent() + public function getParent(): string { return MoneyType::class; } - public function transform($value) + public function transform($value): ?string { if (null === $value) { return null; @@ -51,7 +51,7 @@ class BigDecimalMoneyType extends AbstractType implements DataTransformerInterfa return $value; } - public function reverseTransform($value) + public function reverseTransform($value): ?BigDecimal { if (null === $value) { return null; diff --git a/src/Form/Type/BigDecimalNumberType.php b/src/Form/Type/BigDecimalNumberType.php index 00863914..3ea9db78 100644 --- a/src/Form/Type/BigDecimalNumberType.php +++ b/src/Form/Type/BigDecimalNumberType.php @@ -33,12 +33,12 @@ class BigDecimalNumberType extends AbstractType implements DataTransformerInterf $builder->addModelTransformer($this); } - public function getParent() + public function getParent(): string { return NumberType::class; } - public function transform($value) + public function transform($value): ?string { if (null === $value) { return null; @@ -51,7 +51,7 @@ class BigDecimalNumberType extends AbstractType implements DataTransformerInterf return $value; } - public function reverseTransform($value) + public function reverseTransform($value): ?BigDecimal { if (null === $value) { return null; diff --git a/src/Form/Type/MasterPictureAttachmentType.php b/src/Form/Type/MasterPictureAttachmentType.php index d4b3af9f..725dd90b 100644 --- a/src/Form/Type/MasterPictureAttachmentType.php +++ b/src/Form/Type/MasterPictureAttachmentType.php @@ -96,7 +96,7 @@ class MasterPictureAttachmentType extends AbstractType $resolver->setAllowedValues('filter', ['', 'picture', '3d_model']); } - public function getParent() + public function getParent(): string { return ChoiceType::class; } diff --git a/src/Form/Type/RichTextEditorType.php b/src/Form/Type/RichTextEditorType.php index 3424b8a0..651b3eb9 100644 --- a/src/Form/Type/RichTextEditorType.php +++ b/src/Form/Type/RichTextEditorType.php @@ -21,7 +21,7 @@ class RichTextEditorType extends AbstractType } - public function getBlockPrefix() + public function getBlockPrefix(): string { return 'rich_text_editor'; } @@ -33,7 +33,7 @@ class RichTextEditorType extends AbstractType parent::finishView($view, $form, $options); // TODO: Change the autogenerated stub } - protected function optionsToAttrArray(array $options) + protected function optionsToAttrArray(array $options): array { $tmp = []; @@ -49,7 +49,7 @@ class RichTextEditorType extends AbstractType return $tmp; } - public function getParent() + public function getParent(): string { return TextareaType::class; } diff --git a/src/Form/Type/SIUnitType.php b/src/Form/Type/SIUnitType.php index d0ae852c..ba1dc7f4 100644 --- a/src/Form/Type/SIUnitType.php +++ b/src/Form/Type/SIUnitType.php @@ -176,7 +176,7 @@ final class SIUnitType extends AbstractType implements DataMapperInterface * * @throws Exception\UnexpectedTypeException if the type of the data parameter is not supported */ - public function mapDataToForms($viewData, $forms) + public function mapDataToForms($viewData, $forms): void { $forms = iterator_to_array($forms); diff --git a/src/Form/Type/StructuralEntityType.php b/src/Form/Type/StructuralEntityType.php index 60911e4d..dd233d18 100644 --- a/src/Form/Type/StructuralEntityType.php +++ b/src/Form/Type/StructuralEntityType.php @@ -148,7 +148,7 @@ class StructuralEntityType extends AbstractType parent::buildView($view, $form, $options); } - public function getParent() + public function getParent(): string { return ChoiceType::class; } diff --git a/src/Form/Type/TriStateCheckboxType.php b/src/Form/Type/TriStateCheckboxType.php index 17c15a58..87bdc473 100644 --- a/src/Form/Type/TriStateCheckboxType.php +++ b/src/Form/Type/TriStateCheckboxType.php @@ -68,7 +68,7 @@ final class TriStateCheckboxType extends AbstractType implements DataTransformer ]); } - public function getBlockPrefix() + public function getBlockPrefix(): string { return 'tristate'; } diff --git a/src/Helpers/BigDecimalType.php b/src/Helpers/BigDecimalType.php index 4934e543..d953dfb0 100644 --- a/src/Helpers/BigDecimalType.php +++ b/src/Helpers/BigDecimalType.php @@ -28,7 +28,7 @@ class BigDecimalType extends Type { public const BIG_DECIMAL = 'big_decimal'; - public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) + public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform): string { return $platform->getDecimalTypeDeclarationSQL($fieldDeclaration); } @@ -50,7 +50,7 @@ class BigDecimalType extends Type /** * @param BigDecimal|null $value */ - public function convertToDatabaseValue($value, AbstractPlatform $platform) + public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string { if (null === $value) { return null; @@ -59,12 +59,12 @@ class BigDecimalType extends Type return (string) $value; } - public function getName() + public function getName(): string { return self::BIG_DECIMAL; } - public function requiresSQLCommentHint(AbstractPlatform $platform) + public function requiresSQLCommentHint(AbstractPlatform $platform): bool { return true; } diff --git a/src/Helpers/LabelResponse.php b/src/Helpers/LabelResponse.php index 8561852c..c9b763b8 100644 --- a/src/Helpers/LabelResponse.php +++ b/src/Helpers/LabelResponse.php @@ -33,7 +33,7 @@ class LabelResponse extends Response parent::__construct($content, $status, $headers); } - public function setContent($content) + public function setContent($content): self { parent::setContent($content); @@ -43,7 +43,7 @@ class LabelResponse extends Response return $this; } - public function prepare(Request $request) + public function prepare(Request $request): self { parent::prepare($request); @@ -81,13 +81,13 @@ class LabelResponse extends Response /** * Sets the Content-Disposition header with the given filename. * - * @param string $disposition ResponseHeaderBag::DISPOSITION_INLINE or ResponseHeaderBag::DISPOSITION_ATTACHMENT - * @param string $filename Optionally use this UTF-8 encoded filename instead of the real name of the file - * @param string $filenameFallback A fallback filename, containing only ASCII characters. Defaults to an automatically encoded filename + * @param string $disposition ResponseHeaderBag::DISPOSITION_INLINE or ResponseHeaderBag::DISPOSITION_ATTACHMENT + * @param string $filename Optionally use this UTF-8 encoded filename instead of the real name of the file + * @param string $filenameFallback A fallback filename, containing only ASCII characters. Defaults to an automatically encoded filename * * @return $this */ - public function setContentDisposition($disposition, $filename, $filenameFallback = ''): self + public function setContentDisposition(string $disposition, string $filename, string $filenameFallback = ''): self { if ('' === $filenameFallback && (!preg_match('/^[\x20-\x7e]*$/', $filename) || false !== strpos($filename, '%'))) { $encoding = mb_detect_encoding($filename, null, true) ?: '8bit'; diff --git a/src/Helpers/Trees/TreeViewNodeState.php b/src/Helpers/Trees/TreeViewNodeState.php index 3fa33758..9019e950 100644 --- a/src/Helpers/Trees/TreeViewNodeState.php +++ b/src/Helpers/Trees/TreeViewNodeState.php @@ -94,7 +94,7 @@ final class TreeViewNodeState implements JsonSerializable return $this; } - public function jsonSerialize() + public function jsonSerialize(): array { $ret = []; if (null !== $this->selected) { diff --git a/src/Helpers/UTCDateTimeType.php b/src/Helpers/UTCDateTimeType.php index d6a02f2a..73e83f2b 100644 --- a/src/Helpers/UTCDateTimeType.php +++ b/src/Helpers/UTCDateTimeType.php @@ -56,7 +56,7 @@ class UTCDateTimeType extends DateTimeType { private static $utc_timezone; - public function convertToDatabaseValue($value, AbstractPlatform $platform) + public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string { if (!self::$utc_timezone) { self::$utc_timezone = new DateTimeZone('UTC'); @@ -69,7 +69,7 @@ class UTCDateTimeType extends DateTimeType return parent::convertToDatabaseValue($value, $platform); } - public function convertToPHPValue($value, AbstractPlatform $platform) + public function convertToPHPValue($value, AbstractPlatform $platform): ?DateTime { if (!self::$utc_timezone) { self::$utc_timezone = new DateTimeZone('UTC'); diff --git a/src/Repository/LogEntryRepository.php b/src/Repository/LogEntryRepository.php index 8e8c2e27..8f973425 100644 --- a/src/Repository/LogEntryRepository.php +++ b/src/Repository/LogEntryRepository.php @@ -52,7 +52,7 @@ use App\Entity\UserSystem\User; class LogEntryRepository extends DBElementRepository { - public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null) + public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array { //Emulate a target element criteria by splitting it manually in the needed criterias if (isset($criteria['target']) && $criteria['target'] instanceof AbstractDBElement) { @@ -70,13 +70,13 @@ class LogEntryRepository extends DBElementRepository * Find log entries associated with the given element (the history of the element). * * @param AbstractDBElement $element The element for which the history should be generated - * @param string $order By default newest entries are shown first. Change this to ASC to show oldest entries first. + * @param string $order By default newest entries are shown first. Change this to ASC to show oldest entries first. * @param null $limit * @param null $offset * * @return AbstractLogEntry[] */ - public function getElementHistory(AbstractDBElement $element, $order = 'DESC', $limit = null, $offset = null): array + public function getElementHistory(AbstractDBElement $element, string $order = 'DESC', $limit = null, $offset = null): array { return $this->findBy(['element' => $element], ['timestamp' => $order], $limit, $offset); } @@ -175,11 +175,11 @@ class LogEntryRepository extends DBElementRepository /** * Gets the last log entries ordered by timestamp. * - * @param string $order + * @param string $order * @param null $limit * @param null $offset */ - public function getLogsOrderedByTimestamp($order = 'DESC', $limit = null, $offset = null): array + public function getLogsOrderedByTimestamp(string $order = 'DESC', $limit = null, $offset = null): array { return $this->findBy([], ['timestamp' => $order], $limit, $offset); } @@ -226,7 +226,7 @@ class LogEntryRepository extends DBElementRepository return $this->getLastUser($element, ElementCreatedLogEntry::class); } - protected function getLastUser(AbstractDBElement $element, string $class) + protected function getLastUser(AbstractDBElement $element, string $class): ?User { $qb = $this->createQueryBuilder('log'); $qb->select('log') diff --git a/src/Security/Voter/AttachmentVoter.php b/src/Security/Voter/AttachmentVoter.php index 6493147f..b5b7b7ba 100644 --- a/src/Security/Voter/AttachmentVoter.php +++ b/src/Security/Voter/AttachmentVoter.php @@ -52,9 +52,9 @@ class AttachmentVoter extends ExtendedVoter * Similar to voteOnAttribute, but checking for the anonymous user is already done. * The current user (or the anonymous user) is passed by $user. * - * @param string $attribute + * @param string $attribute */ - protected function voteOnUser($attribute, $subject, User $user): bool + protected function voteOnUser(string $attribute, $subject, User $user): bool { return $this->resolver->inherit($user, 'parts_attachments', $attribute) ?? false; } @@ -62,12 +62,12 @@ class AttachmentVoter extends ExtendedVoter /** * Determines if the attribute and subject are supported by this voter. * - * @param string $attribute An attribute + * @param string $attribute An attribute * @param mixed $subject The subject to secure, e.g. an object the user wants to access or any other PHP type * * @return bool True if the attribute and subject are supported, false otherwise */ - protected function supports($attribute, $subject) + protected function supports(string $attribute, $subject): bool { if (is_a($subject, Attachment::class, true)) { return in_array($attribute, $this->resolver->listOperationsForPermission('parts_attachments'), false); diff --git a/src/Security/Voter/ExtendedVoter.php b/src/Security/Voter/ExtendedVoter.php index d7545b42..279e9d63 100644 --- a/src/Security/Voter/ExtendedVoter.php +++ b/src/Security/Voter/ExtendedVoter.php @@ -92,7 +92,7 @@ abstract class ExtendedVoter extends Voter * Similar to voteOnAttribute, but checking for the anonymous user is already done. * The current user (or the anonymous user) is passed by $user. * - * @param string $attribute + * @param string $attribute */ - abstract protected function voteOnUser($attribute, $subject, User $user): bool; + abstract protected function voteOnUser(string $attribute, $subject, User $user): bool; } diff --git a/src/Security/Voter/GroupVoter.php b/src/Security/Voter/GroupVoter.php index 5c507145..a1fa190f 100644 --- a/src/Security/Voter/GroupVoter.php +++ b/src/Security/Voter/GroupVoter.php @@ -51,9 +51,9 @@ class GroupVoter extends ExtendedVoter * Similar to voteOnAttribute, but checking for the anonymous user is already done. * The current user (or the anonymous user) is passed by $user. * - * @param string $attribute + * @param string $attribute */ - protected function voteOnUser($attribute, $subject, User $user): bool + protected function voteOnUser(string $attribute, $subject, User $user): bool { return $this->resolver->inherit($user, 'groups', $attribute) ?? false; } @@ -61,12 +61,12 @@ class GroupVoter extends ExtendedVoter /** * Determines if the attribute and subject are supported by this voter. * - * @param string $attribute An attribute + * @param string $attribute An attribute * @param mixed $subject The subject to secure, e.g. an object the user wants to access or any other PHP type * * @return bool True if the attribute and subject are supported, false otherwise */ - protected function supports($attribute, $subject) + protected function supports(string $attribute, $subject): bool { if (is_a($subject, Group::class, true)) { return $this->resolver->isValidOperation('groups', $attribute); diff --git a/src/Security/Voter/LabelProfileVoter.php b/src/Security/Voter/LabelProfileVoter.php index 5526cdb1..37823ec6 100644 --- a/src/Security/Voter/LabelProfileVoter.php +++ b/src/Security/Voter/LabelProfileVoter.php @@ -37,12 +37,12 @@ class LabelProfileVoter extends ExtendedVoter 'revert_element' => 'revert_element', ]; - protected function voteOnUser($attribute, $subject, User $user): bool + protected function voteOnUser(string $attribute, $subject, User $user): bool { return $this->resolver->inherit($user, 'labels', self::MAPPING[$attribute]) ?? false; } - protected function supports($attribute, $subject) + protected function supports($attribute, $subject): bool { if ($subject instanceof LabelProfile) { if (!isset(self::MAPPING[$attribute])) { diff --git a/src/Security/Voter/LogEntryVoter.php b/src/Security/Voter/LogEntryVoter.php index 24fe857a..bc9b6db8 100644 --- a/src/Security/Voter/LogEntryVoter.php +++ b/src/Security/Voter/LogEntryVoter.php @@ -49,7 +49,7 @@ class LogEntryVoter extends ExtendedVoter { public const ALLOWED_OPS = ['read', 'delete']; - protected function voteOnUser($attribute, $subject, User $user): bool + protected function voteOnUser(string $attribute, $subject, User $user): bool { if ('delete' === $attribute) { return $this->resolver->inherit($user, 'system', 'delete_logs') ?? false; @@ -70,7 +70,7 @@ class LogEntryVoter extends ExtendedVoter return false; } - protected function supports($attribute, $subject) + protected function supports($attribute, $subject): bool { if ($subject instanceof AbstractLogEntry) { return in_array($subject, static::ALLOWED_OPS, true); diff --git a/src/Security/Voter/OrderdetailVoter.php b/src/Security/Voter/OrderdetailVoter.php index 0d54d391..84a2b739 100644 --- a/src/Security/Voter/OrderdetailVoter.php +++ b/src/Security/Voter/OrderdetailVoter.php @@ -33,7 +33,7 @@ class OrderdetailVoter extends ExtendedVoter */ protected const PART_PERMS = ['show_history', 'revert_element']; - protected function voteOnUser($attribute, $subject, User $user): bool + protected function voteOnUser(string $attribute, $subject, User $user): bool { if (in_array($attribute, self::PART_PERMS, true)) { return $this->resolver->inherit($user, 'parts', $attribute) ?? false; @@ -42,7 +42,7 @@ class OrderdetailVoter extends ExtendedVoter return $this->resolver->inherit($user, 'parts_orderdetails', $attribute) ?? false; } - protected function supports($attribute, $subject) + protected function supports($attribute, $subject): bool { if (is_a($subject, Orderdetail::class, true)) { return in_array($attribute, array_merge( diff --git a/src/Security/Voter/PartLotVoter.php b/src/Security/Voter/PartLotVoter.php index 035d25b5..2fc8f608 100644 --- a/src/Security/Voter/PartLotVoter.php +++ b/src/Security/Voter/PartLotVoter.php @@ -33,7 +33,7 @@ class PartLotVoter extends ExtendedVoter */ protected const PART_PERMS = ['show_history', 'revert_element']; - protected function voteOnUser($attribute, $subject, User $user): bool + protected function voteOnUser(string $attribute, $subject, User $user): bool { if (in_array($attribute, self::PART_PERMS, true)) { return $this->resolver->inherit($user, 'parts', $attribute) ?? false; @@ -42,7 +42,7 @@ class PartLotVoter extends ExtendedVoter return $this->resolver->inherit($user, 'parts_lots', $attribute) ?? false; } - protected function supports($attribute, $subject) + protected function supports($attribute, $subject): bool { if (is_a($subject, PartLot::class, true)) { return in_array($attribute, array_merge( diff --git a/src/Security/Voter/PartVoter.php b/src/Security/Voter/PartVoter.php index 75de92fa..cfbc66be 100644 --- a/src/Security/Voter/PartVoter.php +++ b/src/Security/Voter/PartVoter.php @@ -54,7 +54,7 @@ class PartVoter extends ExtendedVoter { public const READ = 'read'; - protected function supports($attribute, $subject) + protected function supports($attribute, $subject): bool { if (is_a($subject, Part::class, true)) { //Check if a sub permission should be checked -> $attribute has format name.edit @@ -71,7 +71,7 @@ class PartVoter extends ExtendedVoter return false; } - protected function voteOnUser($attribute, $subject, User $user): bool + protected function voteOnUser(string $attribute, $subject, User $user): bool { //Check for sub permissions if (false !== strpos($attribute, '.')) { diff --git a/src/Security/Voter/PermissionVoter.php b/src/Security/Voter/PermissionVoter.php index 32383a80..7632d39d 100644 --- a/src/Security/Voter/PermissionVoter.php +++ b/src/Security/Voter/PermissionVoter.php @@ -55,9 +55,9 @@ class PermissionVoter extends ExtendedVoter * Similar to voteOnAttribute, but checking for the anonymous user is already done. * The current user (or the anonymous user) is passed by $user. * - * @param string $attribute + * @param string $attribute */ - protected function voteOnUser($attribute, $subject, User $user): bool + protected function voteOnUser(string $attribute, $subject, User $user): bool { $attribute = ltrim($attribute, '@'); [$perm, $op] = explode('.', $attribute); @@ -68,12 +68,12 @@ class PermissionVoter extends ExtendedVoter /** * Determines if the attribute and subject are supported by this voter. * - * @param string $attribute An attribute + * @param string $attribute An attribute * @param mixed $subject The subject to secure, e.g. an object the user wants to access or any other PHP type * * @return bool True if the attribute and subject are supported, false otherwise */ - protected function supports($attribute, $subject) + protected function supports(string $attribute, $subject): bool { //Check if the attribute has the form @permission.operation if (preg_match('#^@\\w+\\.\\w+$#', $attribute)) { diff --git a/src/Security/Voter/PricedetailVoter.php b/src/Security/Voter/PricedetailVoter.php index c6a9cbdc..b21b367f 100644 --- a/src/Security/Voter/PricedetailVoter.php +++ b/src/Security/Voter/PricedetailVoter.php @@ -33,7 +33,7 @@ class PricedetailVoter extends ExtendedVoter */ protected const PART_PERMS = ['show_history', 'revert_element']; - protected function voteOnUser($attribute, $subject, User $user): bool + protected function voteOnUser(string $attribute, $subject, User $user): bool { if (in_array($attribute, self::PART_PERMS, true)) { return $this->resolver->inherit($user, 'parts', $attribute) ?? false; @@ -42,7 +42,7 @@ class PricedetailVoter extends ExtendedVoter return $this->resolver->inherit($user, 'parts_prices', $attribute) ?? false; } - protected function supports($attribute, $subject) + protected function supports($attribute, $subject): bool { if (is_a($subject, Pricedetail::class, true)) { return in_array($attribute, array_merge( diff --git a/src/Security/Voter/StructureVoter.php b/src/Security/Voter/StructureVoter.php index 0161667f..3b5bc330 100644 --- a/src/Security/Voter/StructureVoter.php +++ b/src/Security/Voter/StructureVoter.php @@ -72,12 +72,12 @@ class StructureVoter extends ExtendedVoter /** * Determines if the attribute and subject are supported by this voter. * - * @param string $attribute An attribute + * @param string $attribute An attribute * @param mixed $subject The subject to secure, e.g. an object the user wants to access or any other PHP type * * @return bool True if the attribute and subject are supported, false otherwise */ - protected function supports($attribute, $subject) + protected function supports(string $attribute, $subject): bool { if (is_object($subject) || is_string($subject)) { $permission_name = $this->instanceToPermissionName($subject); @@ -121,9 +121,9 @@ class StructureVoter extends ExtendedVoter * Similar to voteOnAttribute, but checking for the anonymous user is already done. * The current user (or the anonymous user) is passed by $user. * - * @param string $attribute + * @param string $attribute */ - protected function voteOnUser($attribute, $subject, User $user): bool + protected function voteOnUser(string $attribute, $subject, User $user): bool { $permission_name = $this->instanceToPermissionName($subject); //Just resolve the permission diff --git a/src/Security/Voter/UserVoter.php b/src/Security/Voter/UserVoter.php index ecdd186d..af2d6700 100644 --- a/src/Security/Voter/UserVoter.php +++ b/src/Security/Voter/UserVoter.php @@ -50,12 +50,12 @@ class UserVoter extends ExtendedVoter /** * Determines if the attribute and subject are supported by this voter. * - * @param string $attribute An attribute + * @param string $attribute An attribute * @param mixed $subject The subject to secure, e.g. an object the user wants to access or any other PHP type * * @return bool True if the attribute and subject are supported, false otherwise */ - protected function supports($attribute, $subject) + protected function supports(string $attribute, $subject): bool { if (is_a($subject, User::class, true)) { return in_array($attribute, array_merge( @@ -72,9 +72,9 @@ class UserVoter extends ExtendedVoter * Similar to voteOnAttribute, but checking for the anonymous user is already done. * The current user (or the anonymous user) is passed by $user. * - * @param string $attribute + * @param string $attribute */ - protected function voteOnUser($attribute, $subject, User $user): bool + protected function voteOnUser(string $attribute, $subject, User $user): bool { //Check if the checked user is the user itself if (($subject instanceof User) && $subject->getID() === $user->getID() && diff --git a/src/Services/Attachments/AttachmentManager.php b/src/Services/Attachments/AttachmentManager.php index 66c8d7df..dccaa781 100644 --- a/src/Services/Attachments/AttachmentManager.php +++ b/src/Services/Attachments/AttachmentManager.php @@ -163,11 +163,11 @@ class AttachmentManager * Returns a human readable version of the attachment file size. * For external attachments, null is returned. * - * @param int $decimals The number of decimals numbers that should be printed + * @param int $decimals The number of decimals numbers that should be printed * * @return string|null A string like 1.3M */ - public function getHumanFileSize(Attachment $attachment, $decimals = 2): ?string + public function getHumanFileSize(Attachment $attachment, int $decimals = 2): ?string { $bytes = $this->getFileSize($attachment); diff --git a/src/Services/CustomEnvVarProcessor.php b/src/Services/CustomEnvVarProcessor.php index 62f32c11..cd8e3c7e 100644 --- a/src/Services/CustomEnvVarProcessor.php +++ b/src/Services/CustomEnvVarProcessor.php @@ -48,7 +48,7 @@ use Symfony\Component\DependencyInjection\Exception\EnvNotFoundException; final class CustomEnvVarProcessor implements EnvVarProcessorInterface { - public function getEnv($prefix, $name, Closure $getEnv) + public function getEnv($prefix, $name, Closure $getEnv): bool { if ('validMailDSN' === $prefix) { try { diff --git a/src/Services/EntityImporter.php b/src/Services/EntityImporter.php index 7f214900..577282c5 100644 --- a/src/Services/EntityImporter.php +++ b/src/Services/EntityImporter.php @@ -228,9 +228,9 @@ class EntityImporter * This functions corrects the parent setting based on the children value of the parent. * * @param iterable $entities the list of entities that should be fixed - * @param AbstractStructuralDBElement|null $parent the parent, to which the entity should be set + * @param AbstractStructuralDBElement|null $parent the parent, to which the entity should be set */ - protected function correctParentEntites(iterable $entities, $parent = null): void + protected function correctParentEntites(iterable $entities, AbstractStructuralDBElement $parent = null): void { foreach ($entities as $entity) { /** @var AbstractStructuralDBElement $entity */ diff --git a/src/Services/MoneyFormatter.php b/src/Services/MoneyFormatter.php index b3c0e2c3..ca3e70c3 100644 --- a/src/Services/MoneyFormatter.php +++ b/src/Services/MoneyFormatter.php @@ -62,10 +62,10 @@ class MoneyFormatter * * @param string|float $value the value that should be formatted * @param Currency|null $currency The currency that should be used for formatting. If null the global one is used - * @param int $decimals the number of decimals that should be shown + * @param int $decimals the number of decimals that should be shown * @param bool $show_all_digits if set to true, all digits are shown, even if they are null */ - public function format($value, ?Currency $currency = null, $decimals = 5, bool $show_all_digits = false): string + public function format($value, ?Currency $currency = null, int $decimals = 5, bool $show_all_digits = false): string { $iso_code = $this->base_currency; if (null !== $currency && !empty($currency->getIsoCode())) { diff --git a/src/Services/StructuralElementRecursionHelper.php b/src/Services/StructuralElementRecursionHelper.php index 140c696f..1b04717c 100644 --- a/src/Services/StructuralElementRecursionHelper.php +++ b/src/Services/StructuralElementRecursionHelper.php @@ -62,10 +62,10 @@ class StructuralElementRecursionHelper * $func has the signature function(StructuralDBElement $element) : void * @param int $max_depth The maximum depth for which should be recursivly called. So if this is set to 5, after the * 5th level the execution is stopped. - * @param bool $call_from_bottom If set to true the bottom elements (elements with high level) will be called first. + * @param bool $call_from_bottom If set to true the bottom elements (elements with high level) will be called first. * Set to false if you want to call the top elements first. */ - public function execute(AbstractStructuralDBElement $element, callable $func, int $max_depth = -1, $call_from_bottom = true): void + public function execute(AbstractStructuralDBElement $element, callable $func, int $max_depth = -1, bool $call_from_bottom = true): void { //Cancel if we reached our maximal allowed level. Must be zero because -1 is infinity levels if (0 === $max_depth) { diff --git a/src/Services/TranslationExtractor/PermissionExtractor.php b/src/Services/TranslationExtractor/PermissionExtractor.php index 8010fac8..f5605fdf 100644 --- a/src/Services/TranslationExtractor/PermissionExtractor.php +++ b/src/Services/TranslationExtractor/PermissionExtractor.php @@ -103,9 +103,9 @@ final class PermissionExtractor implements ExtractorInterface /** * Sets the prefix that should be used for new found messages. * - * @param string $prefix The prefix + * @param string $prefix The prefix */ - public function setPrefix($prefix) + public function setPrefix(string $prefix): string { return ''; } diff --git a/src/Twig/AppExtension.php b/src/Twig/AppExtension.php index 5e6585d6..5f021546 100644 --- a/src/Twig/AppExtension.php +++ b/src/Twig/AppExtension.php @@ -93,7 +93,7 @@ class AppExtension extends AbstractExtension $this->translator = $translator; } - public function getFilters() + public function getFilters(): array { return [ new TwigFilter('entityURL', [$this, 'generateEntityURL']), @@ -108,7 +108,7 @@ class AppExtension extends AbstractExtension ]; } - public function getTests() + public function getTests(): array { return [ new TwigTest('instanceof', static function ($var, $instance) { @@ -117,7 +117,7 @@ class AppExtension extends AbstractExtension ]; } - public function getFunctions() + public function getFunctions(): array { return [ new TwigFunction('generateTreeData', [$this, 'treeData']), diff --git a/src/Twig/BarcodeExtension.php b/src/Twig/BarcodeExtension.php index 5a4fa88e..b61b874e 100644 --- a/src/Twig/BarcodeExtension.php +++ b/src/Twig/BarcodeExtension.php @@ -26,7 +26,7 @@ use Twig\TwigFilter; class BarcodeExtension extends AbstractExtension { - public function getFilters() + public function getFilters(): array { return [ new TwigFilter('barcodeSVG', static function (string $content, string $type = 'QRCODE') { diff --git a/src/Twig/LastUserExtension.php b/src/Twig/LastUserExtension.php index 1d9a5fd3..159909ed 100644 --- a/src/Twig/LastUserExtension.php +++ b/src/Twig/LastUserExtension.php @@ -38,7 +38,7 @@ class LastUserExtension extends AbstractExtension $this->repo = $em->getRepository(AbstractLogEntry::class); } - public function getFunctions() + public function getFunctions(): array { return [ new TwigFunction('getLastEditingUser', [$this->repo, 'getLastEditingUser']), diff --git a/src/Validator/Constraints/BigDecimal/BigDecimalGreaterThanValidator.php b/src/Validator/Constraints/BigDecimal/BigDecimalGreaterThanValidator.php index 49d15fb8..12962142 100644 --- a/src/Validator/Constraints/BigDecimal/BigDecimalGreaterThanValidator.php +++ b/src/Validator/Constraints/BigDecimal/BigDecimalGreaterThanValidator.php @@ -35,7 +35,7 @@ class BigDecimalGreaterThanValidator extends AbstractComparisonValidator /** * {@inheritdoc} */ - protected function compareValues($value1, $value2) + protected function compareValues($value1, $value2): bool { if ($value1 instanceof BigDecimal) { $value1 = (string) $value1; @@ -51,7 +51,7 @@ class BigDecimalGreaterThanValidator extends AbstractComparisonValidator /** * {@inheritdoc} */ - protected function getErrorCode() + protected function getErrorCode(): ?string { return GreaterThan::TOO_LOW_ERROR; } diff --git a/src/Validator/Constraints/BigDecimal/BigDecimalGreaterThenOrEqualValidator.php b/src/Validator/Constraints/BigDecimal/BigDecimalGreaterThenOrEqualValidator.php index bc88027b..f889e0ae 100644 --- a/src/Validator/Constraints/BigDecimal/BigDecimalGreaterThenOrEqualValidator.php +++ b/src/Validator/Constraints/BigDecimal/BigDecimalGreaterThenOrEqualValidator.php @@ -35,7 +35,7 @@ class BigDecimalGreaterThenOrEqualValidator extends AbstractComparisonValidator /** * {@inheritdoc} */ - protected function compareValues($value1, $value2) + protected function compareValues($value1, $value2): bool { if ($value1 instanceof BigDecimal) { $value1 = (string) $value1; @@ -51,7 +51,7 @@ class BigDecimalGreaterThenOrEqualValidator extends AbstractComparisonValidator /** * {@inheritdoc} */ - protected function getErrorCode() + protected function getErrorCode(): ?string { return GreaterThanOrEqual::TOO_LOW_ERROR; } diff --git a/src/Validator/Constraints/ValidPartLot.php b/src/Validator/Constraints/ValidPartLot.php index 2cf1de97..97605e31 100644 --- a/src/Validator/Constraints/ValidPartLot.php +++ b/src/Validator/Constraints/ValidPartLot.php @@ -52,7 +52,7 @@ use Symfony\Component\Validator\Constraint; */ class ValidPartLot extends Constraint { - public function getTargets() + public function getTargets(): string { return self::CLASS_CONSTRAINT; } diff --git a/tests/Services/Attachments/AttachmentPathResolverTest.php b/tests/Services/Attachments/AttachmentPathResolverTest.php index 78387882..5a0d61a0 100644 --- a/tests/Services/Attachments/AttachmentPathResolverTest.php +++ b/tests/Services/Attachments/AttachmentPathResolverTest.php @@ -49,61 +49,63 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; class AttachmentPathResolverTest extends WebTestCase { - public static $media_path; - public static $footprint_path; - protected static $projectDir_orig; - protected static $projectDir; + protected $media_path; + protected $footprint_path; + protected $projectDir_orig; + protected $projectDir; /** * @var AmountFormatter */ - protected static $service; + protected $service; - public function __construct($name = null, array $data = [], $dataName = '') + public function setUp(): void { - parent::__construct($name, $data, $dataName); - - self::bootKernel(); - self::$projectDir_orig = realpath(self::$kernel->getProjectDir()); - self::$projectDir = str_replace('\\', '/', self::$projectDir_orig); - self::$media_path = self::$projectDir.'/public/media'; - self::$footprint_path = self::$projectDir.'/public/img/footprints'; - } - - public static function setUpBeforeClass(): void - { - parent::setUpBeforeClass(); + parent::setUp(); //Get an service instance. self::bootKernel(); - self::$service = self::$container->get(AttachmentPathResolver::class); + + $this->projectDir_orig = realpath(self::$kernel->getProjectDir()); + $this->projectDir = str_replace('\\', '/', $this->projectDir_orig); + $this->media_path = $this->projectDir.'/public/media'; + $this->footprint_path = $this->projectDir.'/public/img/footprints'; + + $this->service = self::getContainer()->get(AttachmentPathResolver::class); } public function testParameterToAbsolutePath(): void { //If null is passed, null must be returned - $this->assertNull(self::$service->parameterToAbsolutePath(null)); + $this->assertNull($this->service->parameterToAbsolutePath(null)); //Absolute path should be returned like they are (we use projectDir here, because we know that this dir exists) - $this->assertSame(self::$projectDir_orig, self::$service->parameterToAbsolutePath(self::$projectDir)); + $this->assertSame($this->projectDir_orig, $this->service->parameterToAbsolutePath($this->projectDir)); //Relative pathes should be resolved - $expected = str_replace('\\', '/', self::$projectDir_orig.DIRECTORY_SEPARATOR.'src'); - $this->assertSame($expected, self::$service->parameterToAbsolutePath('src')); - $this->assertSame($expected, self::$service->parameterToAbsolutePath('./src')); + $expected = str_replace('\\', '/', $this->projectDir_orig.DIRECTORY_SEPARATOR.'src'); + $this->assertSame($expected, $this->service->parameterToAbsolutePath('src')); + $this->assertSame($expected, $this->service->parameterToAbsolutePath('./src')); //Invalid pathes should return null - $this->assertNull(self::$service->parameterToAbsolutePath('/this/path/does/not/exist')); - $this->assertNull(self::$service->parameterToAbsolutePath('/./this/one/too')); + $this->assertNull($this->service->parameterToAbsolutePath('/this/path/does/not/exist')); + $this->assertNull($this->service->parameterToAbsolutePath('/./this/one/too')); } public function placeholderDataProvider(): array { + //We need to do initialization (again), as dataprovider is called before setUp() + self::bootKernel(); + $this->projectDir_orig = realpath(self::$kernel->getProjectDir()); + $this->projectDir = str_replace('\\', '/', $this->projectDir_orig); + $this->media_path = $this->projectDir.'/public/media'; + $this->footprint_path = $this->projectDir.'/public/img/footprints'; + return [ - ['%FOOTPRINTS%/test/test.jpg', self::$footprint_path.'/test/test.jpg'], - ['%FOOTPRINTS%/test/', self::$footprint_path.'/test/'], - ['%MEDIA%/test', self::$media_path.'/test'], - ['%MEDIA%', self::$media_path], - ['%FOOTPRINTS%', self::$footprint_path], + ['%FOOTPRINTS%/test/test.jpg', $this->footprint_path.'/test/test.jpg'], + ['%FOOTPRINTS%/test/', $this->footprint_path.'/test/'], + ['%MEDIA%/test', $this->media_path.'/test'], + ['%MEDIA%', $this->media_path], + ['%FOOTPRINTS%', $this->footprint_path], //Footprints 3D are disabled ['%FOOTPRINTS_3D%', null], //Check that invalid pathes return null @@ -120,18 +122,25 @@ class AttachmentPathResolverTest extends WebTestCase public function realPathDataProvider(): array { + //We need to do initialization (again), as dataprovider is called before setUp() + self::bootKernel(); + $this->projectDir_orig = realpath(self::$kernel->getProjectDir()); + $this->projectDir = str_replace('\\', '/', $this->projectDir_orig); + $this->media_path = $this->projectDir.'/public/media'; + $this->footprint_path = $this->projectDir.'/public/img/footprints'; + return [ - [self::$media_path.'/test/img.jpg', '%MEDIA%/test/img.jpg'], - [self::$media_path.'/test/img.jpg', '%BASE%/data/media/test/img.jpg', true], - [self::$footprint_path.'/foo.jpg', '%FOOTPRINTS%/foo.jpg'], - [self::$footprint_path.'/foo.jpg', '%FOOTPRINTS%/foo.jpg', true], + [$this->media_path.'/test/img.jpg', '%MEDIA%/test/img.jpg'], + [$this->media_path.'/test/img.jpg', '%BASE%/data/media/test/img.jpg', true], + [$this->footprint_path.'/foo.jpg', '%FOOTPRINTS%/foo.jpg'], + [$this->footprint_path.'/foo.jpg', '%FOOTPRINTS%/foo.jpg', true], //Every kind of absolute path, that is not based with our placeholder dirs must be invald ['/etc/passwd', null], ['C:\\not\\existing.txt', null], //More then one placeholder is not allowed - [self::$footprint_path.'/test/'.self::$footprint_path, null], + [$this->footprint_path.'/test/'.$this->footprint_path, null], //Path must begin with path - ['/not/root'.self::$footprint_path, null], + ['/not/root'.$this->footprint_path, null], ]; } @@ -140,7 +149,7 @@ class AttachmentPathResolverTest extends WebTestCase */ public function testPlaceholderToRealPath($param, $expected): void { - $this->assertSame($expected, self::$service->placeholderToRealPath($param)); + $this->assertSame($expected, $this->service->placeholderToRealPath($param)); } /** @@ -148,6 +157,6 @@ class AttachmentPathResolverTest extends WebTestCase */ public function testRealPathToPlaceholder($param, $expected, $old_method = false): void { - $this->assertSame($expected, self::$service->realPathToPlaceholder($param, $old_method)); + $this->assertSame($expected, $this->service->realPathToPlaceholder($param, $old_method)); } }