From 2c2065f151e740feaeb32582aa3d8827d17f4e9f Mon Sep 17 00:00:00 2001 From: kagg-design Date: Wed, 19 Jul 2023 23:32:01 +0300 Subject: [PATCH] Use PHP 7 new features. --- src/php/ACFE/Form.php | 12 ++++----- src/php/Abstracts/LoginBase.php | 4 +-- src/php/Abstracts/LostPasswordBase.php | 2 +- src/php/Asgaros/Base.php | 4 +-- src/php/AutoVerify/AutoVerify.php | 20 +++++++------- src/php/Avada/Form.php | 6 ++--- src/php/BackInStockNotifier/Form.php | 6 ++--- src/php/BeaverBuilder/Base.php | 2 +- src/php/BeaverBuilder/Contact.php | 4 +-- src/php/BeaverBuilder/Login.php | 4 +-- src/php/Brizy/Base.php | 2 +- src/php/CF7/CF7.php | 10 +++---- src/php/ClassifiedListing/Contact.php | 6 ++--- src/php/ClassifiedListing/Login.php | 2 +- src/php/ClassifiedListing/Register.php | 2 +- src/php/ColorlibCustomizer/Base.php | 2 +- src/php/ColorlibCustomizer/Login.php | 2 +- src/php/ColorlibCustomizer/LostPassword.php | 2 +- src/php/ColorlibCustomizer/Register.php | 2 +- src/php/DelayedScript/DelayedScript.php | 6 +++-- src/php/Divi/Comment.php | 2 +- src/php/Divi/EmailOptin.php | 2 +- src/php/Divi/Fix.php | 2 +- src/php/Divi/Login.php | 4 +-- src/php/DownloadManager/DownloadManager.php | 3 ++- src/php/ElementorPro/HCaptchaHandler.php | 27 ++++++++++--------- src/php/FluentForm/Form.php | 8 +++--- src/php/FormidableForms/Form.php | 8 +++--- src/php/Forminator/Form.php | 6 ++--- src/php/GiveWP/Base.php | 2 +- src/php/GravityForms/Form.php | 5 ++-- src/php/Helpers/HCaptcha.php | 6 ++--- src/php/Jetpack/JetpackBase.php | 6 ++--- src/php/Jetpack/JetpackForm.php | 6 ++--- src/php/Kadence/Form.php | 6 ++--- src/php/Mailchimp/Form.php | 6 ++--- src/php/Main.php | 10 +++---- src/php/MemberPress/Login.php | 2 +- src/php/MemberPress/Register.php | 2 +- src/php/Migrations/Migrations.php | 4 +-- src/php/NF/Fields.php | 4 ++- src/php/NF/NF.php | 8 +++--- src/php/PaidMembershipsPro/Login.php | 4 +-- src/php/Quform/Quform.php | 5 ++-- src/php/Sendinblue/Sendinblue.php | 5 ++-- src/php/Settings/Abstracts/SettingsBase.php | 24 +++++++++-------- .../Settings/Abstracts/SettingsInterface.php | 2 +- src/php/Settings/General.php | 4 +-- src/php/Settings/Integrations.php | 8 +++--- src/php/Settings/PluginSettingsBase.php | 6 ++--- src/php/Settings/Settings.php | 12 ++++----- src/php/Settings/SystemInfo.php | 12 ++++----- src/php/Subscriber/Form.php | 4 +-- src/php/UM/Base.php | 11 +++++--- src/php/UM/Login.php | 6 ++--- src/php/UM/LostPassword.php | 2 +- src/php/WC/Checkout.php | 2 ++ src/php/WC/Login.php | 2 +- src/php/WC/OrderTracking.php | 2 +- src/php/WC/Register.php | 2 +- src/php/WP/Comment.php | 8 +++--- src/php/WP/Login.php | 2 +- src/php/WP/PasswordProtected.php | 3 ++- src/php/WP/Register.php | 2 +- src/php/WPDiscuz/Comment.php | 4 +-- src/php/WPForms/Form.php | 5 ++-- src/php/includes/functions.php | 4 +-- src/php/includes/request.php | 11 ++++---- 68 files changed, 201 insertions(+), 180 deletions(-) diff --git a/src/php/ACFE/Form.php b/src/php/ACFE/Form.php index 6883b50b..a13d9c63 100644 --- a/src/php/ACFE/Form.php +++ b/src/php/ACFE/Form.php @@ -59,7 +59,7 @@ public function init_hooks() { * * @return void */ - public function before_fields( $args ) { + public function before_fields( array $args ) { $this->form_id = $args['ID']; } @@ -71,7 +71,7 @@ public function before_fields( $args ) { * @return void * @noinspection PhpUndefinedFunctionInspection */ - public function remove_recaptcha_render( $field ) { + public function remove_recaptcha_render( array $field ) { if ( ! $this->is_recaptcha( $field ) ) { return; } @@ -88,7 +88,7 @@ public function remove_recaptcha_render( $field ) { * * @return void */ - public function add_hcaptcha( $field ) { + public function add_hcaptcha( array $field ) { if ( ! $this->is_recaptcha( $field ) ) { return; } @@ -122,7 +122,7 @@ public function add_hcaptcha( $field ) { * @noinspection PhpUnusedParameterInspection * @noinspection PhpUndefinedFunctionInspection */ - public function remove_recaptcha_verify( $valid, $value, $field, $input ): bool { + public function remove_recaptcha_verify( bool $valid, string $value, array $field, string $input ): bool { $recaptcha = acf_get_field_type( 'acfe_recaptcha' ); remove_filter( self::VALIDATION_HOOK, [ $recaptcha, 'validate_value' ] ); @@ -141,7 +141,7 @@ public function remove_recaptcha_verify( $valid, $value, $field, $input ): bool * @return bool * @noinspection PhpUnusedParameterInspection */ - public function verify( $valid, $value, $field, $input ): bool { + public function verify( bool $valid, string $value, array $field, string $input ): bool { if ( ! $field['required'] ) { return $valid; } @@ -185,7 +185,7 @@ public function enqueue_scripts() { * * @return bool */ - private function is_recaptcha( $field ): bool { + private function is_recaptcha( array $field ): bool { return isset( $field['type'] ) && 'acfe_recaptcha' === $field['type']; } } diff --git a/src/php/Abstracts/LoginBase.php b/src/php/Abstracts/LoginBase.php index f6bbab8f..d6dabe4e 100644 --- a/src/php/Abstracts/LoginBase.php +++ b/src/php/Abstracts/LoginBase.php @@ -70,7 +70,7 @@ protected function init_hooks() { * @return void * @noinspection PhpUnusedParameterInspection */ - public function login( $user_login, $user ) { + public function login( string $user_login, WP_User $user ) { unset( $this->login_data[ $this->ip ] ); update_option( self::LOGIN_DATA, $this->login_data ); @@ -85,7 +85,7 @@ public function login( $user_login, $user ) { * @return void * @noinspection PhpUnusedParameterInspection */ - public function login_failed( $username, $error = null ) { + public function login_failed( string $username, WP_Error $error = null ) { $this->login_data[ $this->ip ][] = time(); update_option( self::LOGIN_DATA, $this->login_data ); diff --git a/src/php/Abstracts/LostPasswordBase.php b/src/php/Abstracts/LostPasswordBase.php index 40e4032b..82daf40a 100644 --- a/src/php/Abstracts/LostPasswordBase.php +++ b/src/php/Abstracts/LostPasswordBase.php @@ -53,7 +53,7 @@ public function add_captcha() { * * @return void */ - public function verify( $error ) { + public function verify( WP_Error $error ) { // phpcs:disable WordPress.Security.NonceVerification.Missing $post_value = isset( $_POST[ static::POST_KEY ] ) ? sanitize_text_field( wp_unslash( $_POST[ static::POST_KEY ] ) ) : diff --git a/src/php/Asgaros/Base.php b/src/php/Asgaros/Base.php index 5f6733ad..0e9fb874 100644 --- a/src/php/Asgaros/Base.php +++ b/src/php/Asgaros/Base.php @@ -42,7 +42,7 @@ private function init_hooks() { * @noinspection PhpUnusedParameterInspection * @noinspection RegExpUnnecessaryNonCapturingGroup */ - public function add_captcha( $output, $tag, $attr, $m ) { + public function add_captcha( string $output, string $tag, $attr, array $m ) { if ( 'forum' !== $tag ) { return $output; } @@ -77,7 +77,7 @@ public function add_captcha( $output, $tag, $attr, $m ) { * * @return bool */ - public function verify( $verified ): bool { + public function verify( bool $verified ): bool { global $asgarosforum; $error_message = hcaptcha_get_verify_message( diff --git a/src/php/AutoVerify/AutoVerify.php b/src/php/AutoVerify/AutoVerify.php index 6bab99e2..db9af50c 100644 --- a/src/php/AutoVerify/AutoVerify.php +++ b/src/php/AutoVerify/AutoVerify.php @@ -41,7 +41,7 @@ private function init_hooks() { * * @return string */ - public function content_filter( $content ): string { + public function content_filter( string $content ): string { if ( ! $this->is_frontend() ) { return $content; } @@ -182,7 +182,7 @@ private function is_cli(): bool { * * @param array $forms Forms found in the content. */ - private function register_forms( $forms ) { + private function register_forms( array $forms ) { $forms_data = []; foreach ( $forms as $form ) { @@ -210,7 +210,7 @@ private function register_forms( $forms ) { * * @return string */ - private function get_form_action( $form ): string { + private function get_form_action( string $form ): string { $form_action = ''; if ( preg_match( '#
#', $form, $m ) ) { @@ -235,7 +235,7 @@ private function get_form_action( $form ): string { * * @return array */ - private function get_visible_input_names( $form ): array { + private function get_visible_input_names( string $form ): array { $names = []; if ( ! preg_match_all( '##', $form, $matches ) ) { @@ -266,7 +266,7 @@ private function get_visible_input_names( $form ): array { * * @return bool */ - private function is_input_visible( $input ): bool { + private function is_input_visible( string $input ): bool { return ! preg_match( '#type\s*?=\s*?["\']hidden["\']#', $input ); } @@ -277,7 +277,7 @@ private function is_input_visible( $input ): bool { * * @return string|null */ - private function get_input_name( $input ) { + private function get_input_name( string $input ) { if ( preg_match( '#name\s*?=\s*?["\'](.+?)["\']#', $input, $matches ) ) { return $matches[1]; } @@ -292,7 +292,7 @@ private function get_input_name( $input ) { * * @return string|null */ - private function get_form_auto( $form ) { + private function get_form_auto( string $form ) { if ( preg_match( '#class="h-captcha"[\S\s]+?data-auto="(.*)"[\S\s]*?>#', $form, $matches ) ) { return $matches[1]; } @@ -307,7 +307,7 @@ private function get_form_auto( $form ) { * * @return bool */ - private function is_form_auto( $form ): bool { + private function is_form_auto( string $form ): bool { return 'true' === $this->get_form_auto( $form ); } @@ -316,7 +316,7 @@ private function is_form_auto( $form ): bool { * * @param array $forms_data Forms data to update in transient. */ - private function update_transient( $forms_data ) { + private function update_transient( array $forms_data ) { $transient = get_transient( self::TRANSIENT ); $registered_forms = $transient ?: []; @@ -359,7 +359,7 @@ private function update_transient( $forms_data ) { * * @return bool */ - private function is_form_registered( $request_uri ): bool { + private function is_form_registered( string $request_uri ): bool { $registered_forms = get_transient( self::TRANSIENT ); if ( empty( $registered_forms ) ) { diff --git a/src/php/Avada/Form.php b/src/php/Avada/Form.php index 25a0ae87..f711c9a6 100644 --- a/src/php/Avada/Form.php +++ b/src/php/Avada/Form.php @@ -48,7 +48,7 @@ public function init_hooks() { * @return void * @noinspection PhpUnusedParameterInspection */ - public function form_after_open( $args, $params ) { + public function form_after_open( array $args, array $params ) { $this->form_id = isset( $params['id'] ) ? (int) $params['id'] : 0; } @@ -61,7 +61,7 @@ public function form_after_open( $args, $params ) { * @return string * @noinspection PhpUnusedParameterInspection */ - public function add_hcaptcha( $html, $args ): string { + public function add_hcaptcha( string $html, array $args ): string { if ( false === strpos( $html, '