From 8fe6b05055a91a35dcbfd8c45a805fef0eb810a9 Mon Sep 17 00:00:00 2001 From: Zdeno Kuzmany Date: Tue, 13 Apr 2021 21:47:54 +0200 Subject: [PATCH] CS fixer and rector --- Config/config.php | 8 +++----- Controller/JsController.php | 9 +++------ EventListener/FormSubscriber.php | 15 ++++----------- EventListener/FormValidationSubscriber.php | 17 ++++------------- Form/Type/InternationalPhoneInputType.php | 5 ----- .../internationalphoneinput.html.php | 4 ++-- countries.php | 5 ++--- 7 files changed, 18 insertions(+), 45 deletions(-) diff --git a/Config/config.php b/Config/config.php index c52cead..59482d3 100644 --- a/Config/config.php +++ b/Config/config.php @@ -25,10 +25,10 @@ ], 'mautic.form.validation.inttel.subscriber' => [ 'class' => \MauticPlugin\MauticInternationalPhoneInputBundle\EventListener\FormValidationSubscriber::class, - 'arguments' => [ + 'arguments' => [ 'translator', - 'request_stack' - ] + 'request_stack', + ], ], ], 'forms' => [ @@ -38,7 +38,6 @@ ], ], 'models' => [ - ], 'integrations' => [ 'mautic.integration.internationalphoneinput' => [ @@ -74,6 +73,5 @@ ], ], 'parameters' => [ - ], ]; diff --git a/Controller/JsController.php b/Controller/JsController.php index 5265af4..881561e 100644 --- a/Controller/JsController.php +++ b/Controller/JsController.php @@ -31,9 +31,6 @@ class JsController extends CommonController /** * PublicController constructor. - * - * @param IpLookupHelper $ipLookupHelper - * @param AssetsHelper $assetsHelper */ public function __construct(IpLookupHelper $ipLookupHelper, AssetsHelper $assetsHelper) { @@ -50,10 +47,10 @@ public function generateCountryCodeAction($formName) { $ip = $this->ipLookupHelper->getIpAddress(); include_once __DIR__.'/../countries.php'; - $country = ArrayHelper::getValue('country', $ip->getIpDetails() ?? []); - $countryCode = array_search(strtolower($country), array_map('strtolower', $countries)); ## easy version + $country = ArrayHelper::getValue('country', $ip->getIpDetails() ?? []); + $countryCode = array_search(strtolower($country), array_map('strtolower', $countries)); //# easy version $realFormName = ltrim($formName, '_'); - $utilsUrl = $this->assetsHelper->getUrl('plugins/MauticInternationalPhoneInputBundle/Assets/lib/js/utils.js', null, null, true + $utilsUrl = $this->assetsHelper->getUrl('plugins/MauticInternationalPhoneInputBundle/Assets/lib/js/utils.js', null, null, true ); $js = <<getIntegrationObject(InternationalPhoneInputIntegration::INTEGRATION_NAME); if ($integrationObject instanceof AbstractIntegration && $integrationObject->getIntegrationSettings()->getIsPublished()) { - $this->internationalphoneinputIsConfigured = true; + $this->internationalphoneinputIsConfigured = true; } } @@ -56,14 +53,11 @@ public function __construct( public static function getSubscribedEvents() { return [ - FormEvents::FORM_ON_BUILD => ['onFormBuild', 0], + FormEvents::FORM_ON_BUILD => ['onFormBuild', 0], InternationalPhoneInputEvents::ON_FORM_VALIDATE => ['onFormValidate', 0], ]; } - /** - * @param FormBuilderEvent $event - */ public function onFormBuild(FormBuilderEvent $event) { if (!$this->internationalphoneinputIsConfigured) { @@ -71,11 +65,10 @@ public function onFormBuild(FormBuilderEvent $event) } $event->addFormField(self::FIELD_NAME, [ 'label' => 'mautic.plugin.actions.internationalphoneinput', - 'formType' => InternationalPhoneInputType::class, + 'formType' => InternationalPhoneInputType::class, 'template' => 'MauticInternationalPhoneInputBundle:Integration:internationalphoneinput.html.php', 'builderOptions' => [ ], ]); - } } diff --git a/EventListener/FormValidationSubscriber.php b/EventListener/FormValidationSubscriber.php index 39d8b8d..2f04abf 100644 --- a/EventListener/FormValidationSubscriber.php +++ b/EventListener/FormValidationSubscriber.php @@ -23,7 +23,6 @@ class FormValidationSubscriber implements EventSubscriberInterface { - /** * @var TranslatorInterface */ @@ -37,10 +36,9 @@ class FormValidationSubscriber implements EventSubscriberInterface public function __construct(TranslatorInterface $translator, RequestStack $requestStack) { $this->translator = $translator; - $this->request = $requestStack->getCurrentRequest(); + $this->request = $requestStack->getCurrentRequest(); } - /** * {@inheritdoc} */ @@ -54,8 +52,6 @@ public static function getSubscribedEvents() /** * Add a simple email form. - * - * @param Events\FormBuilderEvent $event */ public function onFormBuilder(Events\FormBuilderEvent $event) { @@ -71,15 +67,13 @@ public function onFormBuilder(Events\FormBuilderEvent $event) /** * Custom validation *. - * - *@param Events\ValidationEvent $event */ public function onFormValidate(Events\ValidationEvent $event) { - $field = $event->getField(); - $phoneNumber = $event->getValue(); + $field = $event->getField(); + $phoneNumber = $event->getValue(); $fullPhoneNumber = ArrayHelper::getValue($field->getAlias(), $this->request ? $this->request->request->get('mauticform') : []); - if (!empty($phoneNumber) && $field->getType() === FormSubscriber::FIELD_NAME && !empty($field->getValidation()['international'])) { + if (!empty($phoneNumber) && FormSubscriber::FIELD_NAME === $field->getType() && !empty($field->getValidation()['international'])) { $phoneUtil = PhoneNumberUtil::getInstance(); try { $parsedPhone = $phoneUtil->parse($fullPhoneNumber, PhoneNumberUtil::UNKNOWN_REGION); @@ -92,9 +86,6 @@ public function onFormValidate(Events\ValidationEvent $event) } } - /** - * @param Events\ValidationEvent $event - */ private function setFailedValidation(Events\ValidationEvent $event) { $field = $event->getField(); diff --git a/Form/Type/InternationalPhoneInputType.php b/Form/Type/InternationalPhoneInputType.php index 190a125..cc570ea 100644 --- a/Form/Type/InternationalPhoneInputType.php +++ b/Form/Type/InternationalPhoneInputType.php @@ -13,15 +13,10 @@ class InternationalPhoneInputType extends AbstractType { - /** - * @param FormBuilderInterface $builder - * @param array $options - */ public function buildForm(FormBuilderInterface $builder, array $options) { } - /** * @return string */ diff --git a/Views/Integration/internationalphoneinput.html.php b/Views/Integration/internationalphoneinput.html.php index 9450298..af27710 100644 --- a/Views/Integration/internationalphoneinput.html.php +++ b/Views/Integration/internationalphoneinput.html.php @@ -29,7 +29,7 @@ echo str_replace(' HTML; -} \ No newline at end of file +} diff --git a/countries.php b/countries.php index 9b47b96..67c68f4 100644 --- a/countries.php +++ b/countries.php @@ -8,8 +8,7 @@ * * Do not modify this file directly! */ - -$countries = array ( +$countries = [ 'AC' => 'Ascension Island', 'AD' => 'Andorra', 'AE' => 'United Arab Emirates', @@ -263,4 +262,4 @@ 'ZA' => 'South Africa', 'ZM' => 'Zambia', 'ZW' => 'Zimbabwe', -); +];