From 4094ea47712efbe58624ff74daeb1f77c9b0edcf Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Tue, 12 Apr 2016 11:36:01 +0200 Subject: Convert array + phpDoc Thanks for https://github.com/thomasbachem/php-short-array-syntax-converter --- .../CoreBundle/Form/Type/ChangePasswordType.php | 26 +++++------ src/Wallabag/CoreBundle/Form/Type/ClientType.php | 10 ++--- src/Wallabag/CoreBundle/Form/Type/ConfigType.php | 32 +++++++------- .../CoreBundle/Form/Type/EditEntryType.php | 20 ++++----- .../CoreBundle/Form/Type/EntryFilterType.php | 50 +++++++++++----------- src/Wallabag/CoreBundle/Form/Type/NewEntryType.php | 8 ++-- src/Wallabag/CoreBundle/Form/Type/NewTagType.php | 6 +-- src/Wallabag/CoreBundle/Form/Type/NewUserType.php | 32 +++++++------- src/Wallabag/CoreBundle/Form/Type/RssType.php | 12 +++--- .../CoreBundle/Form/Type/TaggingRuleType.php | 16 +++---- .../CoreBundle/Form/Type/UserInformationType.php | 20 ++++----- 11 files changed, 116 insertions(+), 116 deletions(-) (limited to 'src/Wallabag/CoreBundle/Form/Type') diff --git a/src/Wallabag/CoreBundle/Form/Type/ChangePasswordType.php b/src/Wallabag/CoreBundle/Form/Type/ChangePasswordType.php index 841af51e..81c4a616 100644 --- a/src/Wallabag/CoreBundle/Form/Type/ChangePasswordType.php +++ b/src/Wallabag/CoreBundle/Form/Type/ChangePasswordType.php @@ -15,28 +15,28 @@ class ChangePasswordType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $builder - ->add('old_password', PasswordType::class, array( - 'constraints' => new UserPassword(array('message' => 'validator.password_wrong_value')), + ->add('old_password', PasswordType::class, [ + 'constraints' => new UserPassword(['message' => 'validator.password_wrong_value']), 'label' => 'config.form_password.old_password_label', - )) - ->add('new_password', RepeatedType::class, array( + ]) + ->add('new_password', RepeatedType::class, [ 'type' => PasswordType::class, 'invalid_message' => 'validator.password_must_match', 'required' => true, - 'first_options' => array('label' => 'config.form_password.new_password_label'), - 'second_options' => array('label' => 'config.form_password.repeat_new_password_label'), - 'constraints' => array( - new Constraints\Length(array( + 'first_options' => ['label' => 'config.form_password.new_password_label'], + 'second_options' => ['label' => 'config.form_password.repeat_new_password_label'], + 'constraints' => [ + new Constraints\Length([ 'min' => 8, 'minMessage' => 'validator.password_too_short', - )), + ]), new Constraints\NotBlank(), - ), + ], 'label' => 'config.form_password.new_password_label', - )) - ->add('save', SubmitType::class, array( + ]) + ->add('save', SubmitType::class, [ 'label' => 'config.form.save', - )) + ]) ; } diff --git a/src/Wallabag/CoreBundle/Form/Type/ClientType.php b/src/Wallabag/CoreBundle/Form/Type/ClientType.php index 9f620414..8b351e60 100644 --- a/src/Wallabag/CoreBundle/Form/Type/ClientType.php +++ b/src/Wallabag/CoreBundle/Form/Type/ClientType.php @@ -14,8 +14,8 @@ class ClientType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $builder - ->add('redirect_uris', UrlType::class, array('required' => true, 'label' => 'developer.client.form.redirect_uris_label')) - ->add('save', SubmitType::class, array('label' => 'developer.client.form.save_label')) + ->add('redirect_uris', UrlType::class, ['required' => true, 'label' => 'developer.client.form.redirect_uris_label']) + ->add('save', SubmitType::class, ['label' => 'developer.client.form.save_label']) ; $builder->get('redirect_uris') @@ -24,7 +24,7 @@ class ClientType extends AbstractType return $originalUri; }, function ($submittedUri) { - return array($submittedUri); + return [$submittedUri]; } )) ; @@ -32,9 +32,9 @@ class ClientType extends AbstractType public function configureOptions(OptionsResolver $resolver) { - $resolver->setDefaults(array( + $resolver->setDefaults([ 'data_class' => 'Wallabag\ApiBundle\Entity\Client', - )); + ]); } public function getBlockPrefix() diff --git a/src/Wallabag/CoreBundle/Form/Type/ConfigType.php b/src/Wallabag/CoreBundle/Form/Type/ConfigType.php index b30b4706..4cf22200 100644 --- a/src/Wallabag/CoreBundle/Form/Type/ConfigType.php +++ b/src/Wallabag/CoreBundle/Form/Type/ConfigType.php @@ -10,8 +10,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class ConfigType extends AbstractType { - private $themes = array(); - private $languages = array(); + private $themes = []; + private $languages = []; /** * @param array $themes Themes come from the LiipThemeBundle (liip_theme.themes) @@ -30,39 +30,39 @@ class ConfigType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $builder - ->add('theme', ChoiceType::class, array( + ->add('theme', ChoiceType::class, [ 'choices' => array_flip($this->themes), 'choices_as_values' => true, 'label' => 'config.form_settings.theme_label', - )) - ->add('items_per_page', null, array( + ]) + ->add('items_per_page', null, [ 'label' => 'config.form_settings.items_per_page_label', - )) - ->add('reading_speed', ChoiceType::class, array( + ]) + ->add('reading_speed', ChoiceType::class, [ 'label' => 'config.form_settings.reading_speed.label', - 'choices' => array( + 'choices' => [ 'config.form_settings.reading_speed.100_word' => '0.5', 'config.form_settings.reading_speed.200_word' => '1', 'config.form_settings.reading_speed.300_word' => '1.5', 'config.form_settings.reading_speed.400_word' => '2', - ), - )) - ->add('language', ChoiceType::class, array( + ], + ]) + ->add('language', ChoiceType::class, [ 'choices' => array_flip($this->languages), 'choices_as_values' => true, 'label' => 'config.form_settings.language_label', - )) - ->add('save', SubmitType::class, array( + ]) + ->add('save', SubmitType::class, [ 'label' => 'config.form.save', - )) + ]) ; } public function configureOptions(OptionsResolver $resolver) { - $resolver->setDefaults(array( + $resolver->setDefaults([ 'data_class' => 'Wallabag\CoreBundle\Entity\Config', - )); + ]); } public function getBlockPrefix() diff --git a/src/Wallabag/CoreBundle/Form/Type/EditEntryType.php b/src/Wallabag/CoreBundle/Form/Type/EditEntryType.php index 23d7b239..40e5b5b9 100644 --- a/src/Wallabag/CoreBundle/Form/Type/EditEntryType.php +++ b/src/Wallabag/CoreBundle/Form/Type/EditEntryType.php @@ -14,30 +14,30 @@ class EditEntryType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $builder - ->add('title', TextType::class, array( + ->add('title', TextType::class, [ 'required' => true, 'label' => 'entry.edit.title_label', - )) - ->add('is_public', CheckboxType::class, array( + ]) + ->add('is_public', CheckboxType::class, [ 'required' => false, 'label' => 'entry.edit.is_public_label', - )) - ->add('url', TextType::class, array( + ]) + ->add('url', TextType::class, [ 'disabled' => true, 'required' => false, 'label' => 'entry.edit.url_label', - )) - ->add('save', SubmitType::class, array( + ]) + ->add('save', SubmitType::class, [ 'label' => 'entry.edit.save_label', - )) + ]) ; } public function configureOptions(OptionsResolver $resolver) { - $resolver->setDefaults(array( + $resolver->setDefaults([ 'data_class' => 'Wallabag\CoreBundle\Entity\Entry', - )); + ]); } public function getBlockPrefix() diff --git a/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php b/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php index ec36503b..dcdb3ab7 100644 --- a/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php +++ b/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php @@ -34,28 +34,28 @@ class EntryFilterType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $builder - ->add('readingTime', NumberRangeFilterType::class, array( + ->add('readingTime', NumberRangeFilterType::class, [ 'label' => 'entry.filters.reading_time.label', - )) - ->add('createdAt', DateRangeFilterType::class, array( - 'left_date_options' => array( - 'attr' => array( + ]) + ->add('createdAt', DateRangeFilterType::class, [ + 'left_date_options' => [ + 'attr' => [ 'placeholder' => 'dd/mm/yyyy', - ), + ], 'format' => 'dd/MM/yyyy', 'widget' => 'single_text', - ), - 'right_date_options' => array( - 'attr' => array( + ], + 'right_date_options' => [ + 'attr' => [ 'placeholder' => 'dd/mm/yyyy', - ), + ], 'format' => 'dd/MM/yyyy', 'widget' => 'single_text', - ), + ], 'label' => 'entry.filters.created_at.label', - ) + ] ) - ->add('domainName', TextFilterType::class, array( + ->add('domainName', TextFilterType::class, [ 'apply_filter' => function (QueryInterface $filterQuery, $field, $values) { $value = $values['value']; if (strlen($value) <= 2 || empty($value)) { @@ -66,14 +66,14 @@ class EntryFilterType extends AbstractType return $filterQuery->createCondition($expression); }, 'label' => 'entry.filters.domain_label', - )) - ->add('isArchived', CheckboxFilterType::class, array( + ]) + ->add('isArchived', CheckboxFilterType::class, [ 'label' => 'entry.filters.archived_label', - )) - ->add('isStarred', CheckboxFilterType::class, array( + ]) + ->add('isStarred', CheckboxFilterType::class, [ 'label' => 'entry.filters.starred_label', - )) - ->add('previewPicture', CheckboxFilterType::class, array( + ]) + ->add('previewPicture', CheckboxFilterType::class, [ 'apply_filter' => function (QueryInterface $filterQuery, $field, $values) { if (false === $values['value']) { return; @@ -84,12 +84,12 @@ class EntryFilterType extends AbstractType return $filterQuery->createCondition($expression); }, 'label' => 'entry.filters.preview_picture_label', - )) - ->add('language', ChoiceFilterType::class, array( + ]) + ->add('language', ChoiceFilterType::class, [ 'choices' => array_flip($this->repository->findDistinctLanguageByUser($this->user->getId())), 'choices_as_values' => true, 'label' => 'entry.filters.language_label', - )) + ]) ; } @@ -100,9 +100,9 @@ class EntryFilterType extends AbstractType public function configureOptions(OptionsResolver $resolver) { - $resolver->setDefaults(array( + $resolver->setDefaults([ 'csrf_protection' => false, - 'validation_groups' => array('filtering'), - )); + 'validation_groups' => ['filtering'], + ]); } } diff --git a/src/Wallabag/CoreBundle/Form/Type/NewEntryType.php b/src/Wallabag/CoreBundle/Form/Type/NewEntryType.php index 69fab6fb..7d74fee3 100644 --- a/src/Wallabag/CoreBundle/Form/Type/NewEntryType.php +++ b/src/Wallabag/CoreBundle/Form/Type/NewEntryType.php @@ -12,18 +12,18 @@ class NewEntryType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $builder - ->add('url', UrlType::class, array( + ->add('url', UrlType::class, [ 'required' => true, 'label' => 'entry.new.form_new.url_label', - )) + ]) ; } public function configureOptions(OptionsResolver $resolver) { - $resolver->setDefaults(array( + $resolver->setDefaults([ 'data_class' => 'Wallabag\CoreBundle\Entity\Entry', - )); + ]); } public function getBlockPrefix() diff --git a/src/Wallabag/CoreBundle/Form/Type/NewTagType.php b/src/Wallabag/CoreBundle/Form/Type/NewTagType.php index c7568de7..3db4105f 100644 --- a/src/Wallabag/CoreBundle/Form/Type/NewTagType.php +++ b/src/Wallabag/CoreBundle/Form/Type/NewTagType.php @@ -12,15 +12,15 @@ class NewTagType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $builder - ->add('label', TextType::class, array('required' => true)) + ->add('label', TextType::class, ['required' => true]) ; } public function configureOptions(OptionsResolver $resolver) { - $resolver->setDefaults(array( + $resolver->setDefaults([ 'data_class' => 'Wallabag\CoreBundle\Entity\Tag', - )); + ]); } public function getBlockPrefix() diff --git a/src/Wallabag/CoreBundle/Form/Type/NewUserType.php b/src/Wallabag/CoreBundle/Form/Type/NewUserType.php index 60fcc20c..6a6f63d1 100644 --- a/src/Wallabag/CoreBundle/Form/Type/NewUserType.php +++ b/src/Wallabag/CoreBundle/Form/Type/NewUserType.php @@ -17,38 +17,38 @@ class NewUserType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $builder - ->add('username', TextType::class, array( + ->add('username', TextType::class, [ 'required' => true, 'label' => 'config.form_new_user.username_label', - )) - ->add('plainPassword', RepeatedType::class, array( + ]) + ->add('plainPassword', RepeatedType::class, [ 'type' => PasswordType::class, 'invalid_message' => 'validator.password_must_match', - 'first_options' => array('label' => 'config.form_new_user.password_label'), - 'second_options' => array('label' => 'config.form_new_user.repeat_new_password_label'), - 'constraints' => array( - new Constraints\Length(array( + 'first_options' => ['label' => 'config.form_new_user.password_label'], + 'second_options' => ['label' => 'config.form_new_user.repeat_new_password_label'], + 'constraints' => [ + new Constraints\Length([ 'min' => 8, 'minMessage' => 'validator.password_too_short', - )), + ]), new Constraints\NotBlank(), - ), + ], 'label' => 'config.form_new_user.plain_password_label', - )) - ->add('email', EmailType::class, array( + ]) + ->add('email', EmailType::class, [ 'label' => 'config.form_new_user.email_label', - )) - ->add('save', SubmitType::class, array( + ]) + ->add('save', SubmitType::class, [ 'label' => 'config.form.save', - )) + ]) ; } public function configureOptions(OptionsResolver $resolver) { - $resolver->setDefaults(array( + $resolver->setDefaults([ 'data_class' => 'Wallabag\UserBundle\Entity\User', - )); + ]); } public function getBlockPrefix() diff --git a/src/Wallabag/CoreBundle/Form/Type/RssType.php b/src/Wallabag/CoreBundle/Form/Type/RssType.php index a9f68e54..94324fed 100644 --- a/src/Wallabag/CoreBundle/Form/Type/RssType.php +++ b/src/Wallabag/CoreBundle/Form/Type/RssType.php @@ -12,20 +12,20 @@ class RssType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $builder - ->add('rss_limit', null, array( + ->add('rss_limit', null, [ 'label' => 'config.form_rss.rss_limit', - )) - ->add('save', SubmitType::class, array( + ]) + ->add('save', SubmitType::class, [ 'label' => 'config.form.save', - )) + ]) ; } public function configureOptions(OptionsResolver $resolver) { - $resolver->setDefaults(array( + $resolver->setDefaults([ 'data_class' => 'Wallabag\CoreBundle\Entity\Config', - )); + ]); } public function getBlockPrefix() diff --git a/src/Wallabag/CoreBundle/Form/Type/TaggingRuleType.php b/src/Wallabag/CoreBundle/Form/Type/TaggingRuleType.php index cfee21f1..732606c9 100644 --- a/src/Wallabag/CoreBundle/Form/Type/TaggingRuleType.php +++ b/src/Wallabag/CoreBundle/Form/Type/TaggingRuleType.php @@ -14,19 +14,19 @@ class TaggingRuleType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $builder - ->add('rule', TextType::class, array( + ->add('rule', TextType::class, [ 'required' => true, 'label' => 'config.form_rules.rule_label', - )) - ->add('save', SubmitType::class, array( + ]) + ->add('save', SubmitType::class, [ 'label' => 'config.form.save', - )) + ]) ; $tagsField = $builder - ->create('tags', TextType::class, array( + ->create('tags', TextType::class, [ 'label' => 'config.form_rules.tags_label', - )) + ]) ->addModelTransformer(new StringToListTransformer(',')); $builder->add($tagsField); @@ -34,9 +34,9 @@ class TaggingRuleType extends AbstractType public function configureOptions(OptionsResolver $resolver) { - $resolver->setDefaults(array( + $resolver->setDefaults([ 'data_class' => 'Wallabag\CoreBundle\Entity\TaggingRule', - )); + ]); } public function getBlockPrefix() diff --git a/src/Wallabag/CoreBundle/Form/Type/UserInformationType.php b/src/Wallabag/CoreBundle/Form/Type/UserInformationType.php index 799ea39e..07c99949 100644 --- a/src/Wallabag/CoreBundle/Form/Type/UserInformationType.php +++ b/src/Wallabag/CoreBundle/Form/Type/UserInformationType.php @@ -15,19 +15,19 @@ class UserInformationType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $builder - ->add('name', TextType::class, array( + ->add('name', TextType::class, [ 'label' => 'config.form_user.name_label', - )) - ->add('email', EmailType::class, array( + ]) + ->add('email', EmailType::class, [ 'label' => 'config.form_user.email_label', - )) - ->add('twoFactorAuthentication', CheckboxType::class, array( + ]) + ->add('twoFactorAuthentication', CheckboxType::class, [ 'required' => false, 'label' => 'config.form_user.twoFactorAuthentication_label', - )) - ->add('save', SubmitType::class, array( + ]) + ->add('save', SubmitType::class, [ 'label' => 'config.form.save', - )) + ]) ->remove('username') ->remove('plainPassword') ; @@ -40,9 +40,9 @@ class UserInformationType extends AbstractType public function configureOptions(OptionsResolver $resolver) { - $resolver->setDefaults(array( + $resolver->setDefaults([ 'data_class' => 'Wallabag\UserBundle\Entity\User', - )); + ]); } public function getBlockPrefix() -- cgit v1.2.3