From 8daba62281a6627d9f2b9fa0a17854aa30b3e457 Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Thu, 8 Jan 2026 16:34:44 -0400 Subject: [PATCH 01/12] Add phpcs ignore comments where strict comparison is not happening --- classes/controllers/FrmStylesController.php | 2 + classes/helpers/FrmAppHelper.php | 18 +++++--- classes/helpers/FrmEntriesListHelper.php | 3 +- classes/helpers/FrmFieldsHelper.php | 16 ++++--- classes/helpers/FrmFormsListHelper.php | 4 +- classes/helpers/FrmListHelper.php | 13 ++++-- classes/helpers/FrmStylesHelper.php | 2 +- classes/helpers/FrmXMLHelper.php | 15 ++++--- classes/models/FrmDb.php | 4 +- classes/models/FrmEntry.php | 4 +- classes/models/FrmEntryValidate.php | 5 ++- classes/models/FrmField.php | 13 +++--- classes/models/FrmFieldFormHtml.php | 3 +- classes/models/FrmFieldValueSelector.php | 1 + classes/models/FrmForm.php | 7 ++- classes/models/FrmMigrate.php | 2 + classes/models/fields/FrmFieldUrl.php | 2 +- classes/models/fields/FrmFieldUserID.php | 1 + .../views/frm-entries/_sidebar-shared-pub.php | 1 + classes/views/frm-entries/errors.php | 1 + classes/views/frm-entries/sidebar-shared.php | 1 + .../frm-fields/front-end/dropdown-field.php | 1 + classes/views/shared/mb_adv_info.php | 1 + classes/views/shared/toggle.php | 1 + .../components/templates/text-toggle.php | 2 +- css/_single_theme.css.php | 2 +- phpcs.xml | 45 ------------------- .../FrmSquareLiteActionsController.php | 2 + .../FrmStrpLiteActionsController.php | 3 ++ .../FrmStrpLiteEventsController.php | 3 +- .../FrmTransLiteActionsController.php | 1 + .../controllers/FrmTransLiteAppController.php | 2 +- stripe/helpers/FrmTransLiteAppHelper.php | 2 +- stripe/models/FrmStrpLiteAuth.php | 6 ++- stripe/models/FrmTransLiteDb.php | 1 + tests/phpunit/base/FrmUnitTest.php | 1 + 36 files changed, 105 insertions(+), 86 deletions(-) diff --git a/classes/controllers/FrmStylesController.php b/classes/controllers/FrmStylesController.php index 87aced6cf5..fbe1cd96ab 100644 --- a/classes/controllers/FrmStylesController.php +++ b/classes/controllers/FrmStylesController.php @@ -1226,6 +1226,7 @@ public static function get_style_opts() { public static function get_form_style( $form = 'default' ) { $style = FrmFormsHelper::get_form_style( $form ); + // phpcs:ignore Universal.Operators.StrictComparisons if ( empty( $style ) || 1 == $style ) { $style = 'default'; } @@ -1241,6 +1242,7 @@ public static function get_form_style( $form = 'default' ) { * @return string */ public static function get_form_style_class( $class, $style ) { + // phpcs:ignore Universal.Operators.StrictComparisons if ( 1 == $style ) { $style = 'default'; } diff --git a/classes/helpers/FrmAppHelper.php b/classes/helpers/FrmAppHelper.php index 81a1514b40..a1d36aca12 100644 --- a/classes/helpers/FrmAppHelper.php +++ b/classes/helpers/FrmAppHelper.php @@ -1339,6 +1339,7 @@ public static function remove_get_action() { * @return array|string */ public static function get_query_var( $value, $param ) { + // phpcs:ignore Universal.Operators.StrictComparisons if ( $value != '' ) { return $value; } @@ -1828,7 +1829,7 @@ public static function save_combined_js() { * @return bool */ public static function is_true( $value ) { - return true === $value || 1 == $value || 'true' === $value || 'yes' === $value; + return true === $value || 1 === (int) $value || 'true' === $value || 'yes' === $value; // phpcs:ignore Universal.Operators.StrictComparisons } /** @@ -2279,7 +2280,8 @@ public static function current_user_can( $role ) { return is_user_logged_in(); } - if ( $role == 1 ) { + // phpcs:ignore Universal.Operators.StrictComparisons + if ( (int)$role == 1 ) { $role = 'administrator'; } @@ -2319,7 +2321,8 @@ public static function user_has_permission( $needed_role ) { return true; } - if ( $role == $needed_role ) { + // phpcs:ignore Universal.Operators.StrictComparisons + if ( $role == $needed_role ) { break; } } @@ -2447,7 +2450,7 @@ public static function check_selected( $values, $current ) { $current = is_null( $current ) ? '' : htmlspecialchars_decode( trim( $current ) ); - // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict + // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict, Universal.Operators.StrictComparisons return ( is_array( $values ) && in_array( $current, $values ) ) || ( ! is_array( $values ) && $values == $current ); } @@ -3023,6 +3026,7 @@ private static function fill_form_defaults( $post_values, array &$values ) { $form_defaults = FrmFormsHelper::get_default_opts(); foreach ( $form_defaults as $opt => $default ) { + // phpcs:ignore Universal.Operators.StrictComparisons if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { $values[ $opt ] = $post_values && isset( $post_values['options'][ $opt ] ) ? $post_values['options'][ $opt ] : $default; } @@ -3428,6 +3432,7 @@ public static function get_last_record_num( $r_count, $current_p, $p_size ) { * @return int */ public static function get_first_record_num( $r_count, $current_p, $p_size ) { + // phpcs:ignore Universal.Operators.StrictComparisons if ( $current_p == 1 ) { return 1; } @@ -3502,6 +3507,7 @@ public static function json_to_array( $json_vars ) { * @return void */ public static function add_value_to_array( $name, $l1, $val, &$vars ) { + // phpcs:ignore Universal.Operators.StrictComparisons if ( $name == '' ) { $vars[] = $val; } elseif ( ! isset( $vars[ $l1 ] ) ) { @@ -3556,6 +3562,7 @@ public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = * @return void */ public static function select_current_page( $page, $current_page, $action = array() ) { + // phpcs:ignore Universal.Operators.StrictComparisons if ( $current_page != $page ) { return; } @@ -3792,11 +3799,12 @@ public static function maybe_json_encode( $value ) { public static function maybe_highlight_menu( $post_type ) { global $post; + // phpcs:ignore Universal.Operators.StrictComparisons if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) { return; } - if ( is_object( $post ) && $post->post_type != $post_type ) { + if ( is_object( $post ) && $post->post_type !== $post_type ) { return; } diff --git a/classes/helpers/FrmEntriesListHelper.php b/classes/helpers/FrmEntriesListHelper.php index ee247fa203..e0b18ff041 100644 --- a/classes/helpers/FrmEntriesListHelper.php +++ b/classes/helpers/FrmEntriesListHelper.php @@ -177,7 +177,7 @@ protected function get_search_query( &$join_form_in_query ) { ) ); - if ( $s != '' && FrmAppHelper::pro_is_installed() ) { + if ( $s !== '' && FrmAppHelper::pro_is_installed() ) { $fid = self::get_param( array( 'param' => 'fid' ) ); $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid ); } @@ -379,6 +379,7 @@ public function single_row( $item, $style = '' ) { $val = in_array( $column_name, $hidden, true ) ? '' : $this->column_value( $item ); $r .= ""; + // phpcs:ignore Universal.Operators.StrictComparisons if ( $column_name == $action_col ) { $edit_link = admin_url( 'admin.php?page=formidable-entries&frm_action=edit&id=' . $item->id ); $r .= '' . $val . ' '; diff --git a/classes/helpers/FrmFieldsHelper.php b/classes/helpers/FrmFieldsHelper.php index ac9860ca24..74ecdbe3dc 100644 --- a/classes/helpers/FrmFieldsHelper.php +++ b/classes/helpers/FrmFieldsHelper.php @@ -280,6 +280,7 @@ private static function context_is_safe_to_load_field_options_from_request_data( * @return void */ private static function fill_cleared_strings( $field, array &$field_array ) { + // phpcs:ignore Universal.Operators.StrictComparisons if ( '' == $field_array['blank'] && '1' === $field_array['required'] ) { $field_array['blank'] = self::default_blank_msg(); } @@ -293,6 +294,7 @@ private static function fill_cleared_strings( $field, array &$field_array ) { } } + // phpcs:ignore Universal.Operators.StrictComparisons if ( '' == $field_array['custom_html'] ) { $field_array['custom_html'] = self::get_default_html( $field->type ); } @@ -620,7 +622,7 @@ public static function run_wpautop( $atts, &$value ) { * @return string */ public static function &label_position( $position, $field, $form ) { - if ( $position && $position != '' ) { + if ( $position ) { if ( $position === 'inside' && ! self::is_placeholder_field_type( $field['type'] ) ) { $position = 'top'; } @@ -698,7 +700,7 @@ public static function show_single_option( $field ) { $field_name = $base_name . ( $default_type === 'checkbox' ? '[' . $opt_key . ']' : '' ); - // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict + // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict, Universal.Operators.StrictComparisons $checked = ( isset( $field['default_value'] ) && ( ( ! is_array( $field['default_value'] ) && $field['default_value'] == $field_val ) || ( is_array( $field['default_value'] ) && in_array( $field_val, $field['default_value'] ) ) ) ); // If this is an "Other" option, get the HTML for it. @@ -887,10 +889,11 @@ public static function value_meets_condition( $observed_value, $cond, $hide_opt $m = false; + // phpcs:ignore Universal.Operators.StrictComparisons if ( $cond === '==' ) { - $m = $observed_value == $hide_opt; + $m = $observed_value == $hide_opt; // phpcs:ignore Universal.Operators.StrictComparisons } elseif ( $cond === '!=' ) { - $m = $observed_value != $hide_opt; + $m = $observed_value != $hide_opt; // phpcs:ignore Universal.Operators.StrictComparisons } elseif ( $cond === '>' ) { $m = $observed_value > $hide_opt; } elseif ( $cond === '>=' ) { @@ -1268,6 +1271,7 @@ private static function get_field_shortcode_value( $atts ) { $string_value = FrmAppHelper::safe_implode( $sep, $replace_with ); } + // phpcs:ignore Universal.Operators.StrictComparisons if ( ! $string_value && $string_value != '0' ) { $replace_with = ''; } else { @@ -1344,6 +1348,7 @@ public static function process_get_shortcode( $atts, $return_array = false ) { $new_value = FrmAppHelper::get_param( $atts['param'], '', 'get', 'sanitize_text_field' ); $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] ); + // phpcs:ignore Universal.Operators.StrictComparisons if ( $new_value == '' ) { if ( ! isset( $atts['prev_val'] ) ) { $atts['prev_val'] = ''; @@ -1577,6 +1582,7 @@ public static function get_other_val( $args ) { if ( $field['type'] === 'checkbox' && is_array( $field['value'] ) ) { // Check if there is an "other" val in saved value and make sure the // "other" val is not equal to the Other checkbox option + // phpcs:ignore Universal.Operators.StrictComparisons if ( isset( $field['value'][ $opt_key ] ) && $field['options'][ $opt_key ] != $field['value'][ $opt_key ] ) { $other_val = $field['value'][ $opt_key ]; } @@ -1596,7 +1602,7 @@ public static function get_other_val( $args ) { if ( isset( $field['value'][ $o_key ] ) ) { unset( $field['value'][ $o_key ], $o_key ); } - } elseif ( $temp_val == $field['value'] ) { + } elseif ( $temp_val == $field['value'] ) { // phpcs:ignore Universal.Operators.StrictComparisons // For radio and regular dropdowns return ''; } else { diff --git a/classes/helpers/FrmFormsListHelper.php b/classes/helpers/FrmFormsListHelper.php index 18ef146a80..04c3e7e413 100644 --- a/classes/helpers/FrmFormsListHelper.php +++ b/classes/helpers/FrmFormsListHelper.php @@ -88,7 +88,7 @@ public function prepare_items() { ) ); - if ( $s != '' ) { + if ( $s !== '' ) { preg_match_all( '/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches ); $search_terms = array_map( 'trim', $matches[0] ); @@ -202,7 +202,7 @@ public function get_views() { foreach ( $statuses as $status => $name ) { - $class = $status == $form_type ? ' class="current"' : ''; + $class = $status == $form_type ? ' class="current"' : ''; // phpcs:ignore Universal.Operators.StrictComparisons if ( $counts->{$status} || 'draft' !== $status ) { /* translators: %1$s: Status, %2$s: Number of items */ diff --git a/classes/helpers/FrmListHelper.php b/classes/helpers/FrmListHelper.php index 4312a96a62..e9eabec94e 100644 --- a/classes/helpers/FrmListHelper.php +++ b/classes/helpers/FrmListHelper.php @@ -480,6 +480,7 @@ private function get_bulk_action( $action_name ) { ) ); + // phpcs:ignore Universal.Operators.StrictComparisons if ( $action_param && - 1 != $action_param ) { $action = $action_param; } @@ -534,6 +535,7 @@ protected function view_switcher( $current_mode ) { foreach ( $this->modes as $mode => $title ) { $classes = array( 'view-' . $mode ); + // phpcs:ignore Universal.Operators.StrictComparisons if ( $current_mode == $mode ) { $classes[] = 'current'; } @@ -717,17 +719,19 @@ private function disabled_pages( $total_pages ) { 'next' => false, ); + // phpcs:ignore Universal.Operators.StrictComparisons if ( $current == 1 ) { $disable['first'] = true; $disable['prev'] = true; - } elseif ( $current == 2 ) { + } elseif ( $current == 2 ) { // phpcs:ignore Universal.Operators.StrictComparisons $disable['first'] = true; } + // phpcs:ignore Universal.Operators.StrictComparisons if ( $current == $total_pages ) { $disable['last'] = true; $disable['next'] = true; - } elseif ( $current == $total_pages - 1 ) { + } elseif ( $current == $total_pages - 1 ) { // phpcs:ignore Universal.Operators.StrictComparisons $disable['last'] = true; } @@ -994,7 +998,8 @@ public function print_column_headers( $with_id = true ) { if ( isset( $sortable[ $column_key ] ) ) { list( $orderby, $desc_first ) = $sortable[ $column_key ]; - if ( $current_orderby == $orderby ) { + // phpcs:ignore Universal.Operators.StrictComparisons + if ( $current_orderby == $orderby ) { // The sorted column. The `aria-sort` attribute must be set only on the sorted column. if ( 'asc' === $current_order ) { $order = 'desc'; @@ -1271,7 +1276,7 @@ protected function single_row_columns( $item ) { * @return string The row actions output. In this case, an empty string. */ protected function handle_row_actions( $item, $column_name, $primary ) { - return $column_name == $primary ? '' : ''; + return $column_name == $primary ? '' : ''; // phpcs:ignore Universal.Operators.StrictComparisons } /** diff --git a/classes/helpers/FrmStylesHelper.php b/classes/helpers/FrmStylesHelper.php index bf12a470dd..4a0f5f3985 100644 --- a/classes/helpers/FrmStylesHelper.php +++ b/classes/helpers/FrmStylesHelper.php @@ -202,7 +202,7 @@ public static function bs_icon_select( $style, $frm_style, $type = 'arrow' ) {