Skip to content

Commit

Permalink
Use PHP 7 new features.
Browse files Browse the repository at this point in the history
  • Loading branch information
kagg-design committed Jul 19, 2023
1 parent c7a936c commit 9b4ef71
Show file tree
Hide file tree
Showing 55 changed files with 167 additions and 165 deletions.
6 changes: 3 additions & 3 deletions src/php/ACFE/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function add_hcaptcha( $field ) {
* @noinspection PhpUnusedParameterInspection
* @noinspection PhpUndefinedFunctionInspection
*/
public function remove_recaptcha_verify( $valid, $value, $field, $input ) {
public function remove_recaptcha_verify( $valid, $value, $field, $input ): bool {
$recaptcha = acf_get_field_type( 'acfe_recaptcha' );

remove_filter( self::VALIDATION_HOOK, [ $recaptcha, 'validate_value' ] );
Expand All @@ -141,7 +141,7 @@ public function remove_recaptcha_verify( $valid, $value, $field, $input ) {
* @return bool
* @noinspection PhpUnusedParameterInspection
*/
public function verify( $valid, $value, $field, $input ) {
public function verify( $valid, $value, $field, $input ): bool {
if ( ! $field['required'] ) {
return $valid;
}
Expand Down Expand Up @@ -185,7 +185,7 @@ public function enqueue_scripts() {
*
* @return bool
*/
private function is_recaptcha( $field ) {
private function is_recaptcha( $field ): bool {
return isset( $field['type'] ) && 'acfe_recaptcha' === $field['type'];
}
}
2 changes: 1 addition & 1 deletion src/php/Abstracts/LoginBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function login_failed( $username, $error = null ) {
*
* @return bool
*/
protected function is_login_limit_exceeded() {
protected function is_login_limit_exceeded(): bool {
$now = time();
$login_limit = (int) hcaptcha()->settings()->get( 'login_limit' );
$login_interval = (int) hcaptcha()->settings()->get( 'login_interval' );
Expand Down
2 changes: 1 addition & 1 deletion src/php/Asgaros/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function add_captcha( $output, $tag, $attr, $m ) {
*
* @return bool
*/
public function verify( $verified ) {
public function verify( $verified ): bool {
global $asgarosforum;

$error_message = hcaptcha_get_verify_message(
Expand Down
18 changes: 9 additions & 9 deletions src/php/AutoVerify/AutoVerify.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private function init_hooks() {
*
* @return string
*/
public function content_filter( $content ) {
public function content_filter( $content ): string {
if ( ! $this->is_frontend() ) {
return $content;
}
Expand Down Expand Up @@ -117,7 +117,7 @@ public function verify_form() {
*
* @return bool
*/
private function is_frontend() {
private function is_frontend(): bool {
return ! ( $this->is_cli() || is_admin() || wp_doing_ajax() || $this->is_rest() );
}

Expand All @@ -134,7 +134,7 @@ private function is_frontend() {
* @return bool
* @author matzeeable
*/
private function is_rest() {
private function is_rest(): bool {
if ( ! isset( $_SERVER['REQUEST_URI'] ) ) {
return false;
}
Expand Down Expand Up @@ -173,7 +173,7 @@ private function is_rest() {
*
* @return bool
*/
private function is_cli() {
private function is_cli(): bool {
return defined( 'WP_CLI' ) && constant( 'WP_CLI' );
}

Expand Down Expand Up @@ -210,7 +210,7 @@ private function register_forms( $forms ) {
*
* @return string
*/
private function get_form_action( $form ) {
private function get_form_action( $form ): string {
$form_action = '';

if ( preg_match( '#<form [\S\s]*?action="(.*?)"[\S\s]*?>#', $form, $m ) ) {
Expand All @@ -235,7 +235,7 @@ private function get_form_action( $form ) {
*
* @return array
*/
private function get_visible_input_names( $form ) {
private function get_visible_input_names( $form ): array {
$names = [];

if ( ! preg_match_all( '#<input[\S\s]+?>#', $form, $matches ) ) {
Expand Down Expand Up @@ -266,7 +266,7 @@ private function get_visible_input_names( $form ) {
*
* @return bool
*/
private function is_input_visible( $input ) {
private function is_input_visible( $input ): bool {
return ! preg_match( '#type\s*?=\s*?["\']hidden["\']#', $input );
}
Expand Down Expand Up @@ -307,7 +307,7 @@ private function get_form_auto( $form ) {
*
* @return bool
*/
private function is_form_auto( $form ) {
private function is_form_auto( $form ): bool {
return 'true' === $this->get_form_auto( $form );
}

Expand Down Expand Up @@ -359,7 +359,7 @@ private function update_transient( $forms_data ) {
*
* @return bool
*/
private function is_form_registered( $request_uri ) {
private function is_form_registered( $request_uri ): bool {
$registered_forms = get_transient( self::TRANSIENT );

if ( empty( $registered_forms ) ) {
Expand Down
2 changes: 1 addition & 1 deletion src/php/Avada/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function form_after_open( $args, $params ) {
* @return string
* @noinspection PhpUnusedParameterInspection
*/
public function add_hcaptcha( $html, $args ) {
public function add_hcaptcha( $html, $args ): string {
if ( false === strpos( $html, '<button type="submit"' ) ) {
return $html;
}
Expand Down
2 changes: 1 addition & 1 deletion src/php/BBPress/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function add_captcha() {
*
* @return bool
*/
public function verify() {
public function verify(): bool {
$error_message = hcaptcha_get_verify_message( static::NAME, static::ACTION );

if ( null !== $error_message ) {
Expand Down
2 changes: 1 addition & 1 deletion src/php/BeaverBuilder/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected function init_hooks() {
* @return string
* @noinspection PhpUnusedParameterInspection
*/
protected function add_hcap_form( $out, $module ) {
protected function add_hcap_form( $out, $module ): string {
$form_id = false !== strpos( static::ACTION, 'login' ) ? 'login' : 'contact';
$args = [
'action' => static::ACTION,
Expand Down
2 changes: 1 addition & 1 deletion src/php/BeaverBuilder/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function init_hooks() {
* @return string
* @noinspection PhpUnusedParameterInspection
*/
public function add_hcaptcha( $out, $module ) {
public function add_hcaptcha( $out, $module ): string {

// Process contact form only.
if ( false === strpos( $out, '<form class="fl-contact-form"' ) ) {
Expand Down
2 changes: 1 addition & 1 deletion src/php/BeaverBuilder/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected function init_hooks() {
*
* @return string
*/
public function add_hcaptcha( $out, $module ) {
public function add_hcaptcha( $out, $module ): string {
if ( ! $this->is_login_limit_exceeded() ) {
return $out;
}
Expand Down
2 changes: 1 addition & 1 deletion src/php/BuddyPress/CreateGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function add_captcha() {
* @noinspection PhpUnusedParameterInspection
* @noinspection PhpUndefinedFunctionInspection
*/
public function verify( $bp_group ) {
public function verify( $bp_group ): bool {
if ( ! bp_is_group_creation_step( 'group-details' ) ) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/php/BuddyPress/Register.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function add_captcha() {
* @return bool
* @noinspection PhpUndefinedFieldInspection
*/
public function verify() {
public function verify(): bool {
global $bp;

$error_message = hcaptcha_get_verify_message(
Expand Down
10 changes: 5 additions & 5 deletions src/php/CF7/CF7.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function init_hooks() {
* @return string
* @noinspection PhpUnusedParameterInspection
*/
public function wpcf7_shortcode( $output, $tag, $attr, $m ) {
public function wpcf7_shortcode( $output, $tag, $attr, $m ): string {
if ( 'contact-form-7' !== $tag ) {
return $output;
}
Expand Down Expand Up @@ -89,7 +89,7 @@ public function wpcf7_shortcode( $output, $tag, $attr, $m ) {
* @return string
* @noinspection PhpUnusedParameterInspection
*/
public function cf7_hcaptcha_shortcode( $attr = [] ) {
public function cf7_hcaptcha_shortcode( $attr = [] ): string {
$settings = hcaptcha()->settings();
$hcaptcha_site_key = $settings->get_site_key();
$hcaptcha_theme = $settings->get( 'theme' );
Expand Down Expand Up @@ -183,7 +183,7 @@ class="<?php echo esc_attr( HCaptcha::HCAPTCHA_WIDGET_ID ); ?>"
* @return WPCF7_Validation
* @noinspection PhpUnusedParameterInspection
*/
public function verify_hcaptcha( $result, $tag ) {
public function verify_hcaptcha( $result, $tag ): WPCF7_Validation {
$submission = WPCF7_Submission::get_instance();

if ( null === $submission ) {
Expand All @@ -209,7 +209,7 @@ public function verify_hcaptcha( $result, $tag ) {
*
* @return WPCF7_Validation
*/
private function get_invalidated_result( $result, $captcha_result = '' ) {
private function get_invalidated_result( $result, $captcha_result = '' ): WPCF7_Validation {
if ( '' === $captcha_result ) {
$captcha_result = hcap_get_error_messages()['empty'];
}
Expand Down Expand Up @@ -253,7 +253,7 @@ public function enqueue_scripts() {
*
* @return string
*/
private function add_form_id_to_cf7_hcap_shortcode( $output, $form_id ) {
private function add_form_id_to_cf7_hcap_shortcode( $output, $form_id ): string {
$cf7_hcap_sc_regex = get_shortcode_regex( [ self::SHORTCODE ] );

if ( ! preg_match( "/$cf7_hcap_sc_regex/", $output, $matches ) ) {
Expand Down
2 changes: 1 addition & 1 deletion src/php/ClassifiedListing/Register.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function add_captcha() {
* @return WP_Error
* @noinspection PhpUnusedParameterInspection
*/
public function verify( $validation_error, $email, $username, $password, $post ) {
public function verify( $validation_error, $email, $username, $password, $post ): WP_Error {
// phpcs:disable WordPress.Security.NonceVerification.Missing
$rtcl_register = isset( $_POST['rtcl-register'] ) ?
sanitize_text_field( wp_unslash( $_POST['rtcl-register'] ) ) :
Expand Down
2 changes: 1 addition & 1 deletion src/php/ColorlibCustomizer/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ public function login_head() {
*
* @return string
*/
abstract protected function get_style( $hcaptcha_size );
abstract protected function get_style( $hcaptcha_size ): string;
}
2 changes: 1 addition & 1 deletion src/php/ColorlibCustomizer/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Login extends Base {
*
* @return string
*/
protected function get_style( $hcaptcha_size ) {
protected function get_style( $hcaptcha_size ): string {
ob_start();

switch ( $hcaptcha_size ) {
Expand Down
2 changes: 1 addition & 1 deletion src/php/ColorlibCustomizer/LostPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class LostPassword extends Base {
*
* @return string
*/
protected function get_style( $hcaptcha_size ) {
protected function get_style( $hcaptcha_size ): string {
ob_start();

switch ( $hcaptcha_size ) {
Expand Down
2 changes: 1 addition & 1 deletion src/php/ColorlibCustomizer/Register.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Register extends Base {
*
* @return string
*/
protected function get_style( $hcaptcha_size ) {
protected function get_style( $hcaptcha_size ): string {
ob_start();

switch ( $hcaptcha_size ) {
Expand Down
2 changes: 1 addition & 1 deletion src/php/DelayedScript/DelayedScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class DelayedScript {
*
* @return string
*/
public static function create( $js, $delay = 3000 ) {
public static function create( $js, $delay = 3000 ): string {
ob_start();
?>
<!--suppress JSUnusedAssignment -->
Expand Down
2 changes: 1 addition & 1 deletion src/php/Divi/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ static function ( $item ) {
*
* @noinspection PhpUnusedParameterInspection
*/
public function shortcode_attributes( $props, $attrs, $slug, $_address, $content ) {
public function shortcode_attributes( $props, $attrs, $slug, $_address, $content ): array {
if ( self::TAG !== $slug ) {
return $props;
}
Expand Down
2 changes: 1 addition & 1 deletion src/php/Divi/EmailOptin.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected function init_hooks() {
* @return string
* @noinspection PhpUnusedParameterInspection
*/
public function add_captcha( $html, $single_name_field ) {
public function add_captcha( $html, $single_name_field ): string {
$args = [
'action' => self::ACTION,
'name' => self::NONCE,
Expand Down
2 changes: 1 addition & 1 deletion src/php/DownloadManager/DownloadManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function init_hooks() {
* @noinspection PhpUnusedParameterInspection
* @noinspection HtmlUnknownAttribute
*/
public function add_hcaptcha( $template, $vars ) {
public function add_hcaptcha( $template, $vars ): string {
$form_id = 0;

if ( preg_match( '/wpdmdl=(\d+)/', $template, $m ) ) {
Expand Down
2 changes: 1 addition & 1 deletion src/php/ElementorPro/HCaptchaHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function register_action( $module ) {
*
* @return string
*/
protected static function get_hcaptcha_name() {
protected static function get_hcaptcha_name(): string {
return self::FIELD_ID;
}

Expand Down
6 changes: 3 additions & 3 deletions src/php/FluentForm/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function add_captcha( $submit_button, $form ) {
* @return array
* @noinspection PhpUnusedParameterInspection
*/
public function verify( $errors, $data, $form, $fields ) {
public function verify( $errors, $data, $form, $fields ): array {
// Do not verify if form has its own hcaptcha.
if ( $this->has_own_hcaptcha( $form ) ) {
return $errors;
Expand Down Expand Up @@ -171,7 +171,7 @@ public function enqueue_scripts() {
*
* @return stdClass
*/
public function fluentform_rendering_form_filter( $form ) {
public function fluentform_rendering_form_filter( $form ): stdClass {
static $has_own_captcha = false;

if ( $this->has_own_hcaptcha( $form ) ) {
Expand All @@ -192,7 +192,7 @@ public function fluentform_rendering_form_filter( $form ) {
*
* @return bool
*/
protected function has_own_hcaptcha( $form ) {
protected function has_own_hcaptcha( $form ): bool {
$auto_include = apply_filters( 'ff_has_auto_hcaptcha', false );

if ( $auto_include ) {
Expand Down
6 changes: 3 additions & 3 deletions src/php/FormidableForms/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function get_transient( $value, $transient ) {
*
* @return string
*/
public function add_captcha( $html, $field, $atts ) {
public function add_captcha( $html, $field, $atts ): string {
if ( 'captcha' !== $field['type'] ) {
return $html;
}
Expand Down Expand Up @@ -132,7 +132,7 @@ public function add_captcha( $html, $field, $atts ) {
* @return bool
* @noinspection PhpUnusedParameterInspection
*/
public function prevent_native_validation( $is_field_hidden, $field, $post ) {
public function prevent_native_validation( $is_field_hidden, $field, $post ): bool {
if ( 'captcha' !== $field->type ) {
return $is_field_hidden;
}
Expand All @@ -159,7 +159,7 @@ public function prevent_native_validation( $is_field_hidden, $field, $post ) {
* @return array
* @noinspection PhpUnusedParameterInspection
*/
public function verify( $errors, $values, $validate_args ) {
public function verify( $errors, $values, $validate_args ): array {
$error_message = hcaptcha_verify_post(
self::NONCE,
self::ACTION
Expand Down
Loading

0 comments on commit 9b4ef71

Please sign in to comment.