Fixed some deprecations.

This commit is contained in:
Jan Böhmer 2022-08-14 19:09:07 +02:00
parent 4fa8eef1bf
commit 5fd608f42a
59 changed files with 202 additions and 165 deletions

View file

@ -148,7 +148,7 @@ class CleanAttachmentsCommand extends Command
* *
* @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; $empty = true;
foreach (glob($path.DIRECTORY_SEPARATOR.'*') as $file) { foreach (glob($path.DIRECTORY_SEPARATOR.'*') as $file) {

View file

@ -76,7 +76,7 @@ class ShowEventLogCommand extends Command
parent::__construct(); parent::__construct();
} }
public function execute(InputInterface $input, OutputInterface $output) public function execute(InputInterface $input, OutputInterface $output): int
{ {
$io = new SymfonyStyle($input, $output); $io = new SymfonyStyle($input, $output);

View file

@ -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); $io = new SymfonyStyle($input, $output);

View file

@ -71,7 +71,7 @@ class ManufacturerController extends BaseAdminController
* *
* @return \Symfony\Component\HttpFoundation\RedirectResponse * @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); return $this->_delete($request, $entity, $recursionHelper);
} }

View file

@ -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\RepeatedType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface; use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
@ -200,7 +201,7 @@ class UserSettingsController extends AbstractController
* *
* @return RedirectResponse|\Symfony\Component\HttpFoundation\Response * @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 */ /** @var User */
$user = $this->getUser(); $user = $this->getUser();
@ -330,7 +331,8 @@ class UserSettingsController extends AbstractController
return $this->redirectToRoute('user_settings'); 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', 'label' => 'tfa_backup.regenerate_codes',
'attr' => [ 'attr' => [
'class' => 'btn-danger', 'class' => 'btn-danger',

View file

@ -66,6 +66,7 @@ class EntityColumn extends AbstractColumn
* The normalize function is responsible for converting parsed and processed data to a datatables-appropriate type. * 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 * @param mixed $value The single value of the column
* @return mixed
*/ */
public function normalize($value) public function normalize($value)
{ {
@ -73,7 +74,7 @@ class EntityColumn extends AbstractColumn
return $value; return $value;
} }
public function configureOptions(OptionsResolver $resolver) public function configureOptions(OptionsResolver $resolver): self
{ {
parent::configureOptions($resolver); parent::configureOptions($resolver);

View file

@ -28,12 +28,16 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class IconLinkColumn extends AbstractColumn class IconLinkColumn extends AbstractColumn
{ {
/**
* @param $value
* @return mixed
*/
public function normalize($value) public function normalize($value)
{ {
return $value; return $value;
} }
public function configureOptions(OptionsResolver $resolver) public function configureOptions(OptionsResolver $resolver): self
{ {
parent::configureOptions($resolver); parent::configureOptions($resolver);
$resolver->setDefaults([ $resolver->setDefaults([
@ -51,7 +55,7 @@ class IconLinkColumn extends AbstractColumn
return $this; return $this;
} }
public function render($value, $context) public function render($value, $context): string
{ {
$href = $this->getHref($value, $context); $href = $this->getHref($value, $context);
$icon = $this->getIcon($value, $context); $icon = $this->getIcon($value, $context);

View file

@ -55,7 +55,12 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
*/ */
class LocaleDateTimeColumn extends AbstractColumn class LocaleDateTimeColumn extends AbstractColumn
{ {
public function normalize($value) /**
* @param $value
* @return bool|mixed|string
* @throws \Exception
*/
public function normalize($value): string
{ {
if (null === $value) { if (null === $value) {
return $this->options['nullValue']; return $this->options['nullValue'];
@ -81,7 +86,7 @@ class LocaleDateTimeColumn extends AbstractColumn
return $formatter->format($value->getTimestamp()); return $formatter->format($value->getTimestamp());
} }
protected function configureOptions(OptionsResolver $resolver) protected function configureOptions(OptionsResolver $resolver): self
{ {
parent::configureOptions($resolver); parent::configureOptions($resolver);

View file

@ -57,12 +57,16 @@ class LogEntryExtraColumn extends AbstractColumn
$this->formatter = $formatter; $this->formatter = $formatter;
} }
/**
* @param $value
* @return mixed
*/
public function normalize($value) public function normalize($value)
{ {
return $value; return $value;
} }
public function render($value, $context) public function render($value, $context): string
{ {
return $this->formatter->format($context); return $this->formatter->format($context);
} }

View file

@ -78,12 +78,16 @@ class LogEntryTargetColumn extends AbstractColumn
$this->translator = $translator; $this->translator = $translator;
} }
/**
* @param $value
* @return mixed
*/
public function normalize($value) public function normalize($value)
{ {
return $value; return $value;
} }
public function configureOptions(OptionsResolver $resolver) public function configureOptions(OptionsResolver $resolver): self
{ {
parent::configureOptions($resolver); parent::configureOptions($resolver);
$resolver->setDefault('show_associated', true); $resolver->setDefault('show_associated', true);
@ -92,7 +96,7 @@ class LogEntryTargetColumn extends AbstractColumn
return $this; return $this;
} }
public function render($value, $context) public function render($value, $context): string
{ {
if ($context instanceof UserNotAllowedLogEntry && $this->options['showAccessDeniedPath']) { if ($context instanceof UserNotAllowedLogEntry && $this->options['showAccessDeniedPath']) {
return htmlspecialchars($context->getPath()); return htmlspecialchars($context->getPath());

View file

@ -58,6 +58,7 @@ class MarkdownColumn extends AbstractColumn
* The normalize function is responsible for converting parsed and processed data to a datatables-appropriate type. * 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 * @param mixed $value The single value of the column
* @return mixed
*/ */
public function normalize($value) public function normalize($value)
{ {

View file

@ -68,13 +68,14 @@ class PartAttachmentsColumn extends AbstractColumn
* The normalize function is responsible for converting parsed and processed data to a datatables-appropriate type. * 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 * @param mixed $value The single value of the column
* @return mixed
*/ */
public function normalize($value) public function normalize($value)
{ {
return $value; return $value;
} }
public function render($value, $context) public function render($value, $context): string
{ {
if (!$context instanceof Part) { if (!$context instanceof Part) {
throw new RuntimeException('$context must be a Part object!'); throw new RuntimeException('$context must be a Part object!');
@ -107,7 +108,7 @@ class PartAttachmentsColumn extends AbstractColumn
return $tmp; return $tmp;
} }
public function configureOptions(OptionsResolver $resolver) public function configureOptions(OptionsResolver $resolver): self
{ {
parent::configureOptions($resolver); parent::configureOptions($resolver);

View file

@ -42,12 +42,16 @@ class RevertLogColumn extends AbstractColumn
$this->security = $security; $this->security = $security;
} }
/**
* @param $value
* @return mixed
*/
public function normalize($value) public function normalize($value)
{ {
return $value; return $value;
} }
public function render($value, $context) public function render($value, $context): string
{ {
if ( if (
$context instanceof CollectionElementDeleted $context instanceof CollectionElementDeleted

View file

@ -58,6 +58,7 @@ class TagsColumn extends AbstractColumn
* The normalize function is responsible for converting parsed and processed data to a datatables-appropriate type. * 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 * @param mixed $value The single value of the column
* @return mixed
*/ */
public function normalize($value) public function normalize($value)
{ {
@ -68,7 +69,7 @@ class TagsColumn extends AbstractColumn
return explode(',', $value); return explode(',', $value);
} }
public function render($tags, $context) public function render($tags, $context): string
{ {
$html = ''; $html = '';
$count = 10; $count = 10;

View file

@ -68,7 +68,7 @@ class ResetAutoIncrementORMPurger implements PurgerInterface, ORMPurgerInterface
* *
* @return void * @return void
*/ */
public function setPurgeMode($mode) public function setPurgeMode(int $mode): void
{ {
$this->purgeMode = $mode; $this->purgeMode = $mode;
} }
@ -78,13 +78,13 @@ class ResetAutoIncrementORMPurger implements PurgerInterface, ORMPurgerInterface
* *
* @return int * @return int
*/ */
public function getPurgeMode() public function getPurgeMode(): int
{ {
return $this->purgeMode; return $this->purgeMode;
} }
/** @inheritDoc */ /** @inheritDoc */
public function setEntityManager(EntityManagerInterface $em) public function setEntityManager(EntityManagerInterface $em): void
{ {
$this->em = $em; $this->em = $em;
} }
@ -94,13 +94,13 @@ class ResetAutoIncrementORMPurger implements PurgerInterface, ORMPurgerInterface
* *
* @return EntityManagerInterface * @return EntityManagerInterface
*/ */
public function getObjectManager() public function getObjectManager(): ?EntityManagerInterface
{ {
return $this->em; return $this->em;
} }
/** @inheritDoc */ /** @inheritDoc */
public function purge() public function purge(): void
{ {
$classes = []; $classes = [];
@ -199,7 +199,7 @@ class ResetAutoIncrementORMPurger implements PurgerInterface, ORMPurgerInterface
* *
* @return ClassMetadata[] * @return ClassMetadata[]
*/ */
private function getCommitOrder(EntityManagerInterface $em, array $classes) private function getCommitOrder(EntityManagerInterface $em, array $classes): array
{ {
$sorter = new TopologicalSorter(); $sorter = new TopologicalSorter();
@ -258,7 +258,7 @@ class ResetAutoIncrementORMPurger implements PurgerInterface, ORMPurgerInterface
* *
* @return array * @return array
*/ */
private function getAssociationTables(array $classes, AbstractPlatform $platform) private function getAssociationTables(array $classes, AbstractPlatform $platform): array
{ {
$associationTables = []; $associationTables = [];

View file

@ -150,12 +150,12 @@ abstract class AbstractCompany extends AbstractPartsContainingDBElement
/** /**
* Get the link to the website of an article. * 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 * * or the part number for returning the direct URL to the article
* *
* @return string the link 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)) { if (is_string($partnr)) {
return str_replace('%PARTNUMBER%', $partnr, $this->auto_product_url); return str_replace('%PARTNUMBER%', $partnr, $this->auto_product_url);

View file

@ -120,11 +120,12 @@ class U2FKey implements TwoFactorKeyInterface
$this->counter = $data->counter; $this->counter = $data->counter;
} }
public function getKeyHandle() public function getKeyHandle(): string
{ {
return $this->keyHandle; return $this->keyHandle;
} }
public function setKeyHandle($keyHandle): self public function setKeyHandle($keyHandle): self
{ {
$this->keyHandle = $keyHandle; $this->keyHandle = $keyHandle;
@ -132,7 +133,7 @@ class U2FKey implements TwoFactorKeyInterface
return $this; return $this;
} }
public function getPublicKey() public function getPublicKey(): string
{ {
return $this->publicKey; return $this->publicKey;
} }
@ -144,7 +145,7 @@ class U2FKey implements TwoFactorKeyInterface
return $this; return $this;
} }
public function getCertificate() public function getCertificate(): string
{ {
return $this->certificate; return $this->certificate;
} }
@ -156,7 +157,7 @@ class U2FKey implements TwoFactorKeyInterface
return $this; return $this;
} }
public function getCounter() public function getCounter(): int
{ {
return $this->counter; return $this->counter;
} }
@ -168,7 +169,7 @@ class U2FKey implements TwoFactorKeyInterface
return $this; return $this;
} }
public function getName() public function getName(): string
{ {
return $this->name; return $this->name;
} }

View file

@ -213,7 +213,7 @@ class EventLoggerSubscriber implements EventSubscriber
return true; return true;
} }
public function getSubscribedEvents() public function getSubscribedEvents(): array
{ {
return[ return[
Events::onFlush, Events::onFlush,

View file

@ -58,7 +58,7 @@ class LogAccessDeniedSubscriber implements EventSubscriberInterface
$this->logger->logAndFlush($log_entry); $this->logger->logAndFlush($log_entry);
} }
public static function getSubscribedEvents() public static function getSubscribedEvents(): array
{ {
return ['kernel.exception' => 'onKernelException']; return ['kernel.exception' => 'onKernelException'];
} }

View file

@ -102,7 +102,7 @@ class LogDBMigrationSubscriber implements EventSubscriber
} }
} }
public function getSubscribedEvents() public function getSubscribedEvents(): array
{ {
return [ return [
Events::onMigrationsMigrated, Events::onMigrationsMigrated,

View file

@ -185,7 +185,7 @@ class AttachmentFormType extends AbstractType
]); ]);
} }
public function getBlockPrefix() public function getBlockPrefix(): string
{ {
return 'attachment'; return 'attachment';
} }

View file

@ -72,7 +72,7 @@ final class PermissionsMapper implements DataMapperInterface
* @param mixed $viewData View data of the compound form being initialized * @param mixed $viewData View data of the compound form being initialized
* @param FormInterface[]|Traversable $forms A list of {@link FormInterface} instances * @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) { foreach ($forms as $form) {
if ($this->inherit) { if ($this->inherit) {

View file

@ -33,12 +33,12 @@ class BigDecimalMoneyType extends AbstractType implements DataTransformerInterfa
$builder->addModelTransformer($this); $builder->addModelTransformer($this);
} }
public function getParent() public function getParent(): string
{ {
return MoneyType::class; return MoneyType::class;
} }
public function transform($value) public function transform($value): ?string
{ {
if (null === $value) { if (null === $value) {
return null; return null;
@ -51,7 +51,7 @@ class BigDecimalMoneyType extends AbstractType implements DataTransformerInterfa
return $value; return $value;
} }
public function reverseTransform($value) public function reverseTransform($value): ?BigDecimal
{ {
if (null === $value) { if (null === $value) {
return null; return null;

View file

@ -33,12 +33,12 @@ class BigDecimalNumberType extends AbstractType implements DataTransformerInterf
$builder->addModelTransformer($this); $builder->addModelTransformer($this);
} }
public function getParent() public function getParent(): string
{ {
return NumberType::class; return NumberType::class;
} }
public function transform($value) public function transform($value): ?string
{ {
if (null === $value) { if (null === $value) {
return null; return null;
@ -51,7 +51,7 @@ class BigDecimalNumberType extends AbstractType implements DataTransformerInterf
return $value; return $value;
} }
public function reverseTransform($value) public function reverseTransform($value): ?BigDecimal
{ {
if (null === $value) { if (null === $value) {
return null; return null;

View file

@ -96,7 +96,7 @@ class MasterPictureAttachmentType extends AbstractType
$resolver->setAllowedValues('filter', ['', 'picture', '3d_model']); $resolver->setAllowedValues('filter', ['', 'picture', '3d_model']);
} }
public function getParent() public function getParent(): string
{ {
return ChoiceType::class; return ChoiceType::class;
} }

View file

@ -21,7 +21,7 @@ class RichTextEditorType extends AbstractType
} }
public function getBlockPrefix() public function getBlockPrefix(): string
{ {
return 'rich_text_editor'; return 'rich_text_editor';
} }
@ -33,7 +33,7 @@ class RichTextEditorType extends AbstractType
parent::finishView($view, $form, $options); // TODO: Change the autogenerated stub parent::finishView($view, $form, $options); // TODO: Change the autogenerated stub
} }
protected function optionsToAttrArray(array $options) protected function optionsToAttrArray(array $options): array
{ {
$tmp = []; $tmp = [];
@ -49,7 +49,7 @@ class RichTextEditorType extends AbstractType
return $tmp; return $tmp;
} }
public function getParent() public function getParent(): string
{ {
return TextareaType::class; return TextareaType::class;
} }

View file

@ -176,7 +176,7 @@ final class SIUnitType extends AbstractType implements DataMapperInterface
* *
* @throws Exception\UnexpectedTypeException if the type of the data parameter is not supported * @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); $forms = iterator_to_array($forms);

View file

@ -148,7 +148,7 @@ class StructuralEntityType extends AbstractType
parent::buildView($view, $form, $options); parent::buildView($view, $form, $options);
} }
public function getParent() public function getParent(): string
{ {
return ChoiceType::class; return ChoiceType::class;
} }

View file

@ -68,7 +68,7 @@ final class TriStateCheckboxType extends AbstractType implements DataTransformer
]); ]);
} }
public function getBlockPrefix() public function getBlockPrefix(): string
{ {
return 'tristate'; return 'tristate';
} }

View file

@ -28,7 +28,7 @@ class BigDecimalType extends Type
{ {
public const BIG_DECIMAL = 'big_decimal'; 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); return $platform->getDecimalTypeDeclarationSQL($fieldDeclaration);
} }
@ -50,7 +50,7 @@ class BigDecimalType extends Type
/** /**
* @param BigDecimal|null $value * @param BigDecimal|null $value
*/ */
public function convertToDatabaseValue($value, AbstractPlatform $platform) public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string
{ {
if (null === $value) { if (null === $value) {
return null; return null;
@ -59,12 +59,12 @@ class BigDecimalType extends Type
return (string) $value; return (string) $value;
} }
public function getName() public function getName(): string
{ {
return self::BIG_DECIMAL; return self::BIG_DECIMAL;
} }
public function requiresSQLCommentHint(AbstractPlatform $platform) public function requiresSQLCommentHint(AbstractPlatform $platform): bool
{ {
return true; return true;
} }

View file

@ -33,7 +33,7 @@ class LabelResponse extends Response
parent::__construct($content, $status, $headers); parent::__construct($content, $status, $headers);
} }
public function setContent($content) public function setContent($content): self
{ {
parent::setContent($content); parent::setContent($content);
@ -43,7 +43,7 @@ class LabelResponse extends Response
return $this; return $this;
} }
public function prepare(Request $request) public function prepare(Request $request): self
{ {
parent::prepare($request); parent::prepare($request);
@ -87,7 +87,7 @@ class LabelResponse extends Response
* *
* @return $this * @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, '%'))) { if ('' === $filenameFallback && (!preg_match('/^[\x20-\x7e]*$/', $filename) || false !== strpos($filename, '%'))) {
$encoding = mb_detect_encoding($filename, null, true) ?: '8bit'; $encoding = mb_detect_encoding($filename, null, true) ?: '8bit';

View file

@ -94,7 +94,7 @@ final class TreeViewNodeState implements JsonSerializable
return $this; return $this;
} }
public function jsonSerialize() public function jsonSerialize(): array
{ {
$ret = []; $ret = [];
if (null !== $this->selected) { if (null !== $this->selected) {

View file

@ -56,7 +56,7 @@ class UTCDateTimeType extends DateTimeType
{ {
private static $utc_timezone; private static $utc_timezone;
public function convertToDatabaseValue($value, AbstractPlatform $platform) public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string
{ {
if (!self::$utc_timezone) { if (!self::$utc_timezone) {
self::$utc_timezone = new DateTimeZone('UTC'); self::$utc_timezone = new DateTimeZone('UTC');
@ -69,7 +69,7 @@ class UTCDateTimeType extends DateTimeType
return parent::convertToDatabaseValue($value, $platform); return parent::convertToDatabaseValue($value, $platform);
} }
public function convertToPHPValue($value, AbstractPlatform $platform) public function convertToPHPValue($value, AbstractPlatform $platform): ?DateTime
{ {
if (!self::$utc_timezone) { if (!self::$utc_timezone) {
self::$utc_timezone = new DateTimeZone('UTC'); self::$utc_timezone = new DateTimeZone('UTC');

View file

@ -52,7 +52,7 @@ use App\Entity\UserSystem\User;
class LogEntryRepository extends DBElementRepository 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 //Emulate a target element criteria by splitting it manually in the needed criterias
if (isset($criteria['target']) && $criteria['target'] instanceof AbstractDBElement) { if (isset($criteria['target']) && $criteria['target'] instanceof AbstractDBElement) {
@ -76,7 +76,7 @@ class LogEntryRepository extends DBElementRepository
* *
* @return AbstractLogEntry[] * @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); return $this->findBy(['element' => $element], ['timestamp' => $order], $limit, $offset);
} }
@ -179,7 +179,7 @@ class LogEntryRepository extends DBElementRepository
* @param null $limit * @param null $limit
* @param null $offset * @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); return $this->findBy([], ['timestamp' => $order], $limit, $offset);
} }
@ -226,7 +226,7 @@ class LogEntryRepository extends DBElementRepository
return $this->getLastUser($element, ElementCreatedLogEntry::class); 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 = $this->createQueryBuilder('log');
$qb->select('log') $qb->select('log')

View file

@ -54,7 +54,7 @@ class AttachmentVoter extends ExtendedVoter
* *
* @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; return $this->resolver->inherit($user, 'parts_attachments', $attribute) ?? false;
} }
@ -67,7 +67,7 @@ class AttachmentVoter extends ExtendedVoter
* *
* @return bool True if the attribute and subject are supported, false otherwise * @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)) { if (is_a($subject, Attachment::class, true)) {
return in_array($attribute, $this->resolver->listOperationsForPermission('parts_attachments'), false); return in_array($attribute, $this->resolver->listOperationsForPermission('parts_attachments'), false);

View file

@ -94,5 +94,5 @@ abstract class ExtendedVoter extends Voter
* *
* @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;
} }

View file

@ -53,7 +53,7 @@ class GroupVoter extends ExtendedVoter
* *
* @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; return $this->resolver->inherit($user, 'groups', $attribute) ?? false;
} }
@ -66,7 +66,7 @@ class GroupVoter extends ExtendedVoter
* *
* @return bool True if the attribute and subject are supported, false otherwise * @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)) { if (is_a($subject, Group::class, true)) {
return $this->resolver->isValidOperation('groups', $attribute); return $this->resolver->isValidOperation('groups', $attribute);

View file

@ -37,12 +37,12 @@ class LabelProfileVoter extends ExtendedVoter
'revert_element' => 'revert_element', '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; 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 ($subject instanceof LabelProfile) {
if (!isset(self::MAPPING[$attribute])) { if (!isset(self::MAPPING[$attribute])) {

View file

@ -49,7 +49,7 @@ class LogEntryVoter extends ExtendedVoter
{ {
public const ALLOWED_OPS = ['read', 'delete']; 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) { if ('delete' === $attribute) {
return $this->resolver->inherit($user, 'system', 'delete_logs') ?? false; return $this->resolver->inherit($user, 'system', 'delete_logs') ?? false;
@ -70,7 +70,7 @@ class LogEntryVoter extends ExtendedVoter
return false; return false;
} }
protected function supports($attribute, $subject) protected function supports($attribute, $subject): bool
{ {
if ($subject instanceof AbstractLogEntry) { if ($subject instanceof AbstractLogEntry) {
return in_array($subject, static::ALLOWED_OPS, true); return in_array($subject, static::ALLOWED_OPS, true);

View file

@ -33,7 +33,7 @@ class OrderdetailVoter extends ExtendedVoter
*/ */
protected const PART_PERMS = ['show_history', 'revert_element']; 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)) { if (in_array($attribute, self::PART_PERMS, true)) {
return $this->resolver->inherit($user, 'parts', $attribute) ?? false; 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; 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)) { if (is_a($subject, Orderdetail::class, true)) {
return in_array($attribute, array_merge( return in_array($attribute, array_merge(

View file

@ -33,7 +33,7 @@ class PartLotVoter extends ExtendedVoter
*/ */
protected const PART_PERMS = ['show_history', 'revert_element']; 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)) { if (in_array($attribute, self::PART_PERMS, true)) {
return $this->resolver->inherit($user, 'parts', $attribute) ?? false; 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; 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)) { if (is_a($subject, PartLot::class, true)) {
return in_array($attribute, array_merge( return in_array($attribute, array_merge(

View file

@ -54,7 +54,7 @@ class PartVoter extends ExtendedVoter
{ {
public const READ = 'read'; public const READ = 'read';
protected function supports($attribute, $subject) protected function supports($attribute, $subject): bool
{ {
if (is_a($subject, Part::class, true)) { if (is_a($subject, Part::class, true)) {
//Check if a sub permission should be checked -> $attribute has format name.edit //Check if a sub permission should be checked -> $attribute has format name.edit
@ -71,7 +71,7 @@ class PartVoter extends ExtendedVoter
return false; return false;
} }
protected function voteOnUser($attribute, $subject, User $user): bool protected function voteOnUser(string $attribute, $subject, User $user): bool
{ {
//Check for sub permissions //Check for sub permissions
if (false !== strpos($attribute, '.')) { if (false !== strpos($attribute, '.')) {

View file

@ -57,7 +57,7 @@ class PermissionVoter extends ExtendedVoter
* *
* @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, '@'); $attribute = ltrim($attribute, '@');
[$perm, $op] = explode('.', $attribute); [$perm, $op] = explode('.', $attribute);
@ -73,7 +73,7 @@ class PermissionVoter extends ExtendedVoter
* *
* @return bool True if the attribute and subject are supported, false otherwise * @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 //Check if the attribute has the form @permission.operation
if (preg_match('#^@\\w+\\.\\w+$#', $attribute)) { if (preg_match('#^@\\w+\\.\\w+$#', $attribute)) {

View file

@ -33,7 +33,7 @@ class PricedetailVoter extends ExtendedVoter
*/ */
protected const PART_PERMS = ['show_history', 'revert_element']; 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)) { if (in_array($attribute, self::PART_PERMS, true)) {
return $this->resolver->inherit($user, 'parts', $attribute) ?? false; 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; 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)) { if (is_a($subject, Pricedetail::class, true)) {
return in_array($attribute, array_merge( return in_array($attribute, array_merge(

View file

@ -77,7 +77,7 @@ class StructureVoter extends ExtendedVoter
* *
* @return bool True if the attribute and subject are supported, false otherwise * @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)) { if (is_object($subject) || is_string($subject)) {
$permission_name = $this->instanceToPermissionName($subject); $permission_name = $this->instanceToPermissionName($subject);
@ -123,7 +123,7 @@ class StructureVoter extends ExtendedVoter
* *
* @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); $permission_name = $this->instanceToPermissionName($subject);
//Just resolve the permission //Just resolve the permission

View file

@ -55,7 +55,7 @@ class UserVoter extends ExtendedVoter
* *
* @return bool True if the attribute and subject are supported, false otherwise * @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)) { if (is_a($subject, User::class, true)) {
return in_array($attribute, array_merge( return in_array($attribute, array_merge(
@ -74,7 +74,7 @@ class UserVoter extends ExtendedVoter
* *
* @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 //Check if the checked user is the user itself
if (($subject instanceof User) && $subject->getID() === $user->getID() && if (($subject instanceof User) && $subject->getID() === $user->getID() &&

View file

@ -167,7 +167,7 @@ class AttachmentManager
* *
* @return string|null A string like 1.3M * @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); $bytes = $this->getFileSize($attachment);

View file

@ -48,7 +48,7 @@ use Symfony\Component\DependencyInjection\Exception\EnvNotFoundException;
final class CustomEnvVarProcessor implements EnvVarProcessorInterface final class CustomEnvVarProcessor implements EnvVarProcessorInterface
{ {
public function getEnv($prefix, $name, Closure $getEnv) public function getEnv($prefix, $name, Closure $getEnv): bool
{ {
if ('validMailDSN' === $prefix) { if ('validMailDSN' === $prefix) {
try { try {

View file

@ -230,7 +230,7 @@ class EntityImporter
* @param iterable $entities the list of entities that should be fixed * @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) { foreach ($entities as $entity) {
/** @var AbstractStructuralDBElement $entity */ /** @var AbstractStructuralDBElement $entity */

View file

@ -65,7 +65,7 @@ class MoneyFormatter
* @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 * @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; $iso_code = $this->base_currency;
if (null !== $currency && !empty($currency->getIsoCode())) { if (null !== $currency && !empty($currency->getIsoCode())) {

View file

@ -65,7 +65,7 @@ class StructuralElementRecursionHelper
* @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. * 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 //Cancel if we reached our maximal allowed level. Must be zero because -1 is infinity levels
if (0 === $max_depth) { if (0 === $max_depth) {

View file

@ -105,7 +105,7 @@ final class PermissionExtractor implements ExtractorInterface
* *
* @param string $prefix The prefix * @param string $prefix The prefix
*/ */
public function setPrefix($prefix) public function setPrefix(string $prefix): string
{ {
return ''; return '';
} }

View file

@ -93,7 +93,7 @@ class AppExtension extends AbstractExtension
$this->translator = $translator; $this->translator = $translator;
} }
public function getFilters() public function getFilters(): array
{ {
return [ return [
new TwigFilter('entityURL', [$this, 'generateEntityURL']), new TwigFilter('entityURL', [$this, 'generateEntityURL']),
@ -108,7 +108,7 @@ class AppExtension extends AbstractExtension
]; ];
} }
public function getTests() public function getTests(): array
{ {
return [ return [
new TwigTest('instanceof', static function ($var, $instance) { new TwigTest('instanceof', static function ($var, $instance) {
@ -117,7 +117,7 @@ class AppExtension extends AbstractExtension
]; ];
} }
public function getFunctions() public function getFunctions(): array
{ {
return [ return [
new TwigFunction('generateTreeData', [$this, 'treeData']), new TwigFunction('generateTreeData', [$this, 'treeData']),

View file

@ -26,7 +26,7 @@ use Twig\TwigFilter;
class BarcodeExtension extends AbstractExtension class BarcodeExtension extends AbstractExtension
{ {
public function getFilters() public function getFilters(): array
{ {
return [ return [
new TwigFilter('barcodeSVG', static function (string $content, string $type = 'QRCODE') { new TwigFilter('barcodeSVG', static function (string $content, string $type = 'QRCODE') {

View file

@ -38,7 +38,7 @@ class LastUserExtension extends AbstractExtension
$this->repo = $em->getRepository(AbstractLogEntry::class); $this->repo = $em->getRepository(AbstractLogEntry::class);
} }
public function getFunctions() public function getFunctions(): array
{ {
return [ return [
new TwigFunction('getLastEditingUser', [$this->repo, 'getLastEditingUser']), new TwigFunction('getLastEditingUser', [$this->repo, 'getLastEditingUser']),

View file

@ -35,7 +35,7 @@ class BigDecimalGreaterThanValidator extends AbstractComparisonValidator
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function compareValues($value1, $value2) protected function compareValues($value1, $value2): bool
{ {
if ($value1 instanceof BigDecimal) { if ($value1 instanceof BigDecimal) {
$value1 = (string) $value1; $value1 = (string) $value1;
@ -51,7 +51,7 @@ class BigDecimalGreaterThanValidator extends AbstractComparisonValidator
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getErrorCode() protected function getErrorCode(): ?string
{ {
return GreaterThan::TOO_LOW_ERROR; return GreaterThan::TOO_LOW_ERROR;
} }

View file

@ -35,7 +35,7 @@ class BigDecimalGreaterThenOrEqualValidator extends AbstractComparisonValidator
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function compareValues($value1, $value2) protected function compareValues($value1, $value2): bool
{ {
if ($value1 instanceof BigDecimal) { if ($value1 instanceof BigDecimal) {
$value1 = (string) $value1; $value1 = (string) $value1;
@ -51,7 +51,7 @@ class BigDecimalGreaterThenOrEqualValidator extends AbstractComparisonValidator
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getErrorCode() protected function getErrorCode(): ?string
{ {
return GreaterThanOrEqual::TOO_LOW_ERROR; return GreaterThanOrEqual::TOO_LOW_ERROR;
} }

View file

@ -52,7 +52,7 @@ use Symfony\Component\Validator\Constraint;
*/ */
class ValidPartLot extends Constraint class ValidPartLot extends Constraint
{ {
public function getTargets() public function getTargets(): string
{ {
return self::CLASS_CONSTRAINT; return self::CLASS_CONSTRAINT;
} }

View file

@ -49,61 +49,63 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class AttachmentPathResolverTest extends WebTestCase class AttachmentPathResolverTest extends WebTestCase
{ {
public static $media_path; protected $media_path;
public static $footprint_path; protected $footprint_path;
protected static $projectDir_orig; protected $projectDir_orig;
protected static $projectDir; protected $projectDir;
/** /**
* @var AmountFormatter * @var AmountFormatter
*/ */
protected static $service; protected $service;
public function __construct($name = null, array $data = [], $dataName = '') public function setUp(): void
{ {
parent::__construct($name, $data, $dataName); parent::setUp();
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();
//Get an service instance. //Get an service instance.
self::bootKernel(); 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 public function testParameterToAbsolutePath(): void
{ {
//If null is passed, null must be returned //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) //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 //Relative pathes should be resolved
$expected = str_replace('\\', '/', self::$projectDir_orig.DIRECTORY_SEPARATOR.'src'); $expected = str_replace('\\', '/', $this->projectDir_orig.DIRECTORY_SEPARATOR.'src');
$this->assertSame($expected, self::$service->parameterToAbsolutePath('src')); $this->assertSame($expected, $this->service->parameterToAbsolutePath('src'));
$this->assertSame($expected, self::$service->parameterToAbsolutePath('./src')); $this->assertSame($expected, $this->service->parameterToAbsolutePath('./src'));
//Invalid pathes should return null //Invalid pathes should return null
$this->assertNull(self::$service->parameterToAbsolutePath('/this/path/does/not/exist')); $this->assertNull($this->service->parameterToAbsolutePath('/this/path/does/not/exist'));
$this->assertNull(self::$service->parameterToAbsolutePath('/./this/one/too')); $this->assertNull($this->service->parameterToAbsolutePath('/./this/one/too'));
} }
public function placeholderDataProvider(): array 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 [ return [
['%FOOTPRINTS%/test/test.jpg', self::$footprint_path.'/test/test.jpg'], ['%FOOTPRINTS%/test/test.jpg', $this->footprint_path.'/test/test.jpg'],
['%FOOTPRINTS%/test/', self::$footprint_path.'/test/'], ['%FOOTPRINTS%/test/', $this->footprint_path.'/test/'],
['%MEDIA%/test', self::$media_path.'/test'], ['%MEDIA%/test', $this->media_path.'/test'],
['%MEDIA%', self::$media_path], ['%MEDIA%', $this->media_path],
['%FOOTPRINTS%', self::$footprint_path], ['%FOOTPRINTS%', $this->footprint_path],
//Footprints 3D are disabled //Footprints 3D are disabled
['%FOOTPRINTS_3D%', null], ['%FOOTPRINTS_3D%', null],
//Check that invalid pathes return null //Check that invalid pathes return null
@ -120,18 +122,25 @@ class AttachmentPathResolverTest extends WebTestCase
public function realPathDataProvider(): array 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 [ return [
[self::$media_path.'/test/img.jpg', '%MEDIA%/test/img.jpg'], [$this->media_path.'/test/img.jpg', '%MEDIA%/test/img.jpg'],
[self::$media_path.'/test/img.jpg', '%BASE%/data/media/test/img.jpg', true], [$this->media_path.'/test/img.jpg', '%BASE%/data/media/test/img.jpg', true],
[self::$footprint_path.'/foo.jpg', '%FOOTPRINTS%/foo.jpg'], [$this->footprint_path.'/foo.jpg', '%FOOTPRINTS%/foo.jpg'],
[self::$footprint_path.'/foo.jpg', '%FOOTPRINTS%/foo.jpg', true], [$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 //Every kind of absolute path, that is not based with our placeholder dirs must be invald
['/etc/passwd', null], ['/etc/passwd', null],
['C:\\not\\existing.txt', null], ['C:\\not\\existing.txt', null],
//More then one placeholder is not allowed //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 //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 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 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));
} }
} }