Fixed some deprecations

This commit is contained in:
Jan Böhmer 2023-06-11 17:38:08 +02:00
parent df8f54f5a4
commit 219b57a362
35 changed files with 42 additions and 54 deletions

View file

@ -30,9 +30,6 @@ framework:
php_errors:
log: true
form:
legacy_error_messages: false # Enable to use the new Form component validation messages
when@test:
framework:
test: true

View file

@ -1,5 +1,4 @@
security:
enable_authenticator_manager: true
# https://symfony.com/doc/current/security.html#registering-the-user-hashing-passwords
password_hashers:
Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto'

View file

@ -45,7 +45,7 @@ class ImportPartKeeprCommand extends Command
parent::__construct(self::$defaultName);
}
protected function configure()
protected function configure(): void
{
$this->setHelp('This command allows you to import a PartKeepr database exported by mysqldump as XML file into Part-DB');

View file

@ -21,6 +21,7 @@
namespace App\Doctrine;
use App\Exceptions\InvalidRegexException;
use Doctrine\Bundle\DoctrineBundle\Attribute\AsDoctrineListener;
use Doctrine\Bundle\DoctrineBundle\EventSubscriber\EventSubscriberInterface;
use Doctrine\DBAL\Event\ConnectionEventArgs;
use Doctrine\DBAL\Events;
@ -31,7 +32,8 @@ use Doctrine\DBAL\Platforms\SqlitePlatform;
* As a PHP callback is called for every entry to compare it is most likely much slower than using regex on MySQL.
* But as regex is not often used, this should be fine for most use cases, also it is almost impossible to implement a better solution.
*/
class SQLiteRegexExtension implements EventSubscriberInterface
#[AsDoctrineListener(Events::postConnect)]
class SQLiteRegexExtension
{
public function postConnect(ConnectionEventArgs $eventArgs): void
{
@ -53,11 +55,4 @@ class SQLiteRegexExtension implements EventSubscriberInterface
}
}
}
public function getSubscribedEvents(): array
{
return[
Events::postConnect
];
}
}

View file

@ -121,7 +121,6 @@ abstract class AbstractParameter extends AbstractNamedDBElement
* @var string the group this parameter belongs to
*/
#[Groups(['full'])]
#[Groups(['full'])]
#[ORM\Column(type: Types::STRING, name: 'param_group')]
protected string $group = '';

View file

@ -170,7 +170,7 @@ class AttachmentFormType extends AbstractType
]);
}
public function finishView(FormView $view, FormInterface $form, array $options)
public function finishView(FormView $view, FormInterface $form, array $options): void
{
$view->vars['max_upload_size'] = $this->submitHandler->getMaximumAllowedUploadSize();
}

View file

@ -98,7 +98,7 @@ class CollectionTypeExtension extends AbstractTypeExtension
$resolver->setAllowedTypes('reindex_path', 'string');
}
public function finishView(FormView $view, FormInterface $form, array $options)
public function finishView(FormView $view, FormInterface $form, array $options): void
{
parent::finishView($view, $form, $options);
//Add prototype name to view, so that we can pass it to the stimulus controller

View file

@ -58,7 +58,7 @@ class AttachmentFilterType extends AbstractType
]);
}
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add('dbId', NumberConstraintType::class, [
'label' => 'part.filter.dbId',

View file

@ -46,7 +46,7 @@ class BooleanConstraintType extends AbstractType
]);
}
public function finishView(FormView $view, FormInterface $form, array $options)
public function finishView(FormView $view, FormInterface $form, array $options): void
{
//Remove the label from the compound form, as the checkbox already has a label
$view->vars['label'] = false;

View file

@ -84,7 +84,7 @@ class DateTimeConstraintType extends AbstractType
]);
}
public function buildView(FormView $view, FormInterface $form, array $options)
public function buildView(FormView $view, FormInterface $form, array $options): void
{
parent::buildView($view, $form, $options);

View file

@ -31,7 +31,7 @@ class InstanceOfConstraintType extends AbstractType
{
}
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefault('data_class', InstanceOfConstraint::class);
}

View file

@ -91,10 +91,8 @@ class NumberConstraintType extends AbstractType
]);
}
public function buildView(FormView $view, FormInterface $form, array $options)
public function buildView(FormView $view, FormInterface $form, array $options): void
{
parent::buildView($view, $form, $options);
$view->vars['text_suffix'] = $options['text_suffix'];
}
}

View file

@ -65,7 +65,7 @@ class StructuralEntityConstraintType extends AbstractType
]);
}
public function buildView(FormView $view, FormInterface $form, array $options)
public function buildView(FormView $view, FormInterface $form, array $options): void
{
parent::buildView($view, $form, $options);
$view->vars['text_suffix'] = $options['text_suffix'];

View file

@ -70,7 +70,7 @@ class TextConstraintType extends AbstractType
]);
}
public function buildView(FormView $view, FormInterface $form, array $options)
public function buildView(FormView $view, FormInterface $form, array $options): void
{
parent::buildView($view, $form, $options);

View file

@ -60,7 +60,7 @@ class UserEntityConstraintType extends AbstractType
]);
}
public function buildView(FormView $view, FormInterface $form, array $options)
public function buildView(FormView $view, FormInterface $form, array $options): void
{
parent::buildView($view, $form, $options);
$view->vars['text_suffix'] = $options['text_suffix'];

View file

@ -101,7 +101,7 @@ class LogFilterType extends AbstractType
]);
}
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add('dbId', NumberConstraintType::class, [
'label' => 'part.filter.dbId',

View file

@ -59,7 +59,7 @@ class PartFilterType extends AbstractType
]);
}
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
/*
* Common tab

View file

@ -148,7 +148,7 @@ class ParameterType extends AbstractType
]);
}
public function finishView(FormView $view, FormInterface $form, array $options)
public function finishView(FormView $view, FormInterface $form, array $options): void
{
//By default use part parameters for autocomplete
$view->vars['type'] = 'part';

View file

@ -13,7 +13,7 @@ class ProjectBOMEntryCollectionType extends AbstractType
return CollectionType::class;
}
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'entry_type' => ProjectBOMEntryType::class,

View file

@ -18,7 +18,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class ProjectBOMEntryType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{

View file

@ -43,7 +43,7 @@ class ProjectBuildType extends AbstractType implements DataMapperInterface
{
}
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'compound' => true,
@ -51,7 +51,7 @@ class ProjectBuildType extends AbstractType implements DataMapperInterface
]);
}
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->setDataMapper($this);
@ -104,7 +104,7 @@ class ProjectBuildType extends AbstractType implements DataMapperInterface
});
}
public function mapDataToForms($data, \Traversable $forms)
public function mapDataToForms($data, \Traversable $forms): void
{
if (!$data instanceof ProjectBuildRequest) {
throw new \RuntimeException('Data must be an instance of ' . ProjectBuildRequest::class);
@ -129,7 +129,7 @@ class ProjectBuildType extends AbstractType implements DataMapperInterface
}
public function mapFormsToData(\Traversable $forms, &$data)
public function mapFormsToData(\Traversable $forms, &$data): void
{
if (!$data instanceof ProjectBuildRequest) {
throw new \RuntimeException('Data must be an instance of ' . ProjectBuildRequest::class);

View file

@ -28,7 +28,7 @@ use Symfony\Component\Form\FormBuilderInterface;
class BigDecimalMoneyType extends AbstractType implements DataTransformerInterface
{
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->addModelTransformer($this);
}

View file

@ -28,7 +28,7 @@ use Symfony\Component\Form\FormBuilderInterface;
class BigDecimalNumberType extends AbstractType implements DataTransformerInterface
{
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->addModelTransformer($this);
}

View file

@ -37,7 +37,7 @@ class PartLotSelectType extends AbstractType
return EntityType::class;
}
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setRequired('part');
$resolver->setAllowedTypes('part', Part::class);

View file

@ -26,7 +26,7 @@ class PartSelectType extends AbstractType implements DataMapperInterface
{
}
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
//At initialization, we have to fill the form element with our selected data, so the user can see it
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (PreSetDataEvent $event) {
@ -66,7 +66,7 @@ class PartSelectType extends AbstractType implements DataMapperInterface
$builder->setDataMapper($this);
}
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'class' => Part::class,
@ -110,13 +110,13 @@ class PartSelectType extends AbstractType implements DataMapperInterface
]);
}
public function mapDataToForms($data, \Traversable $forms)
public function mapDataToForms($data, \Traversable $forms): void
{
$form = current(iterator_to_array($forms, false));
$form->setData($data);
}
public function mapFormsToData(\Traversable $forms, &$data)
public function mapFormsToData(\Traversable $forms, &$data): void
{
$form = current(iterator_to_array($forms, false));
$data = $form->getData();

View file

@ -28,7 +28,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class RichTextEditorType extends AbstractType
{
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
parent::configureOptions($resolver); // TODO: Change the autogenerated stub
@ -39,7 +39,7 @@ class RichTextEditorType extends AbstractType
}
public function finishView(FormView $view, FormInterface $form, array $options)
public function finishView(FormView $view, FormInterface $form, array $options): void
{
$view->vars['attr'] = array_merge($view->vars['attr'], $this->optionsToAttrArray($options));

View file

@ -35,7 +35,7 @@ class ThemeChoiceType extends AbstractType
return ChoiceType::class;
}
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'choices' => $this->available_themes,

View file

@ -28,7 +28,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class UserSelectType extends AbstractType
{
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'class' => User::class,

View file

@ -30,7 +30,7 @@ use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
class BigNumberNormalizer implements NormalizerInterface, CacheableSupportsMethodInterface
{
public function supportsNormalization($data, string $format = null): bool
public function supportsNormalization($data, string $format = null, array $context = []): bool
{
return $data instanceof BigNumber;
}

View file

@ -51,7 +51,7 @@ class PartNormalizer implements NormalizerInterface, DenormalizerInterface, Cach
{
}
public function supportsNormalization($data, string $format = null): bool
public function supportsNormalization($data, string $format = null, array $context = []): bool
{
return $data instanceof Part;
}
@ -74,7 +74,7 @@ class PartNormalizer implements NormalizerInterface, DenormalizerInterface, Cach
return $data;
}
public function supportsDenormalization($data, string $type, string $format = null): bool
public function supportsDenormalization($data, string $type, string $format = null, array $context = []): bool
{
return is_array($data) && is_a($type, Part::class, true);
}

View file

@ -35,7 +35,7 @@ class StructuralElementFromNameDenormalizer implements DenormalizerInterface, Ca
{
}
public function supportsDenormalization($data, string $type, string $format = null): bool
public function supportsDenormalization($data, string $type, string $format = null, array $context = []): bool
{
return is_string($data) && is_subclass_of($type, AbstractStructuralDBElement::class);
}

View file

@ -34,7 +34,7 @@ class StructuralElementNormalizer implements NormalizerInterface, CacheableSuppo
{
}
public function supportsNormalization($data, string $format = null): bool
public function supportsNormalization($data, string $format = null, array $context = []): bool
{
return $data instanceof AbstractStructuralDBElement;
}

View file

@ -33,7 +33,7 @@ final class LogExtension extends AbstractExtension
{
}
public function getFunctions()
public function getFunctions(): array
{
return [
new TwigFunction('format_log_data', fn($data, AbstractLogEntry $logEntry, string $fieldName): string => $this->logDataFormatter->formatData($data, $logEntry, $fieldName), ['is_safe' => ['html']]),

View file

@ -36,7 +36,7 @@ class ValidProjectBuildRequestValidator extends ConstraintValidator
->setParameter('{{ lot }}', $partLot->getName());
}
public function validate($value, Constraint $constraint)
public function validate($value, Constraint $constraint): void
{
if (!$constraint instanceof ValidProjectBuildRequest) {
throw new UnexpectedTypeException($constraint, ValidProjectBuildRequest::class);

View file

@ -74,7 +74,7 @@ class CompoundFilterTraitTest extends TestCase
'filter3' => $f3
], $result);
}
public function testApplyAllChildFilters(): void
{
$f1 = $this->createMock(FilterInterface::class);