Skip to content

Add phpcs ignore comments where strict comparison is not happening#2745

Merged
Crabcyborg merged 12 commits into
masterfrom
add_phpcs_ignore_comments_where_strict_comparison_is_not_happening
Jan 8, 2026
Merged

Add phpcs ignore comments where strict comparison is not happening#2745
Crabcyborg merged 12 commits into
masterfrom
add_phpcs_ignore_comments_where_strict_comparison_is_not_happening

Conversation

@Crabcyborg
Copy link
Copy Markdown
Contributor

This update also fixes some more cases where strict comparison is not being used.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 8, 2026

Warning

Rate limit exceeded

@Crabcyborg has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 27 minutes and 51 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 696bfc8 and 40c3b37.

📒 Files selected for processing (19)
  • classes/controllers/FrmEntriesController.php
  • classes/controllers/FrmFieldsController.php
  • classes/controllers/FrmFormActionsController.php
  • classes/controllers/FrmFormsController.php
  • classes/helpers/FrmAppHelper.php
  • classes/helpers/FrmEntriesHelper.php
  • classes/helpers/FrmFieldsHelper.php
  • classes/helpers/FrmFormsHelper.php
  • classes/helpers/FrmListHelper.php
  • classes/helpers/FrmXMLHelper.php
  • classes/models/FrmEntryMeta.php
  • classes/models/FrmField.php
  • classes/models/FrmFieldFormHtml.php
  • classes/models/FrmFormAction.php
  • classes/models/FrmStyle.php
  • phpstan.neon
  • stripe/controllers/FrmTransLiteAppController.php
  • stripe/models/FrmStrpLiteAuth.php
  • tests/phpunit/entries/test_FrmShowEntryShortcode.php

Walkthrough

This PR systematically adds PHPCS ignore directives for strict comparison warnings throughout the codebase and replaces loose comparisons with strict type-checked equivalents across helpers, models, controllers, and view files. A single public API change increases method visibility. Most modifications are non-functional linting annotations; some comparisons gain explicit integer type casting for stricter evaluation.

Changes

Cohort / File(s) Summary
Linting Suppressions Only
classes/controllers/FrmStylesController.php, classes/helpers/FrmListHelper.php, classes/helpers/FrmStylesHelper.php, classes/models/FrmFieldFormHtml.php, classes/models/FrmFieldValueSelector.php, classes/models/FrmMigrate.php, classes/models/fields/FrmFieldUrl.php, classes/views/frm-entries/errors.php, classes/views/frm-fields/front-end/dropdown-field.php, css/_single_theme.css.php, stripe/controllers/FrmTransLiteActionsController.php, stripe/models/FrmTransLiteDb.php, tests/phpunit/base/FrmUnitTest.php
Adds phpcs:ignore directives for Universal.Operators.StrictComparisons warnings; no functional changes to control flow or logic.
Strict Type-Safe Comparisons
classes/helpers/FrmAppHelper.php, classes/helpers/FrmEntriesListHelper.php, classes/helpers/FrmFieldsHelper.php, classes/helpers/FrmFormsListHelper.php, classes/helpers/FrmXMLHelper.php
Replaces loose comparisons (==, !=) with strict equivalents (===, !==); adds integer type casts in critical comparisons (e.g., role ID checks, string emptiness validation). Behavior largely preserved with narrower type acceptance.
Model/Persistence Layer Strict Comparisons
classes/models/FrmDb.php, classes/models/FrmEntry.php, classes/models/FrmField.php, classes/models/FrmForm.php
Tightens type checks in database query construction and entity matching; casts IDs to integers before strict comparison; changes group/table matching in FrmDb::get_group_and_table_name from loose to strict equality.
Validation & Entry Handling
classes/models/FrmEntryValidate.php, classes/models/fields/FrmFieldUserID.php
Introduces strict count comparisons and strict empty-string checks; changes FrmEntryValidate::get_spam_check_user_info visibility from private to public—a public API modification.
Entry List & Display Helpers
classes/helpers/FrmEntriesListHelper.php, classes/views/frm-entries/_sidebar-shared-pub.php, classes/views/frm-entries/sidebar-shared.php
Applies strict inequality for string emptiness checks and adds linting suppressions around entry update timestamp comparisons.
Field & Form Rendering
classes/views/shared/mb_adv_info.php, classes/views/shared/toggle.php, classes/views/styles/components/templates/text-toggle.php
Adds linting directives; introduces conditional rendering logic in toggle.php to check on_label not equal to 1 before rendering label span.
Payment/Stripe Integration
stripe/controllers/FrmStrpLiteActionsController.php, stripe/controllers/FrmStrpLiteEventsController.php, stripe/helpers/FrmTransLiteAppHelper.php, stripe/models/FrmStrpLiteAuth.php, stripe/models/FrmTransLiteAppController.php
Tightens payment ID comparisons to strict integer equality; casts interval_count to int before comparison; makes form ID matching in FrmStrpLiteAuth::add_hidden_token_field strict; adds phpcs suppress comments around amount and transaction validations.
Square Integration
square/controllers/FrmSquareLiteActionsController.php
Adds linting suppressions around amount validation and script loading checks without functional changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • truongwp
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding phpcs ignore comments to suppress strict comparison warnings for loose comparisons in the codebase.
Description check ✅ Passed The description is directly related to the changeset, explaining that the update fixes cases where strict comparison is not being used, which aligns with the comprehensive changes throughout multiple files.
Docstring Coverage ✅ Passed Docstring coverage is 93.75% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
classes/views/frm-fields/front-end/dropdown-field.php (1)

62-66: Use strict comparison for option value checks.

The condition $opt == '' should use strict comparison (=== '') to avoid treating valid option values like '0' as empty. This ensures only actual empty strings are skipped.

♻️ Proposed fix
-		// phpcs:ignore Universal.Operators.StrictComparisons
-		if ( $placeholder && $opt == '' && ! $skipped ) {
+		if ( $placeholder && $opt === '' && ! $skipped ) {
 			$skipped = true;
 			continue;
 		}
🤖 Fix all issues with AI agents
In @classes/helpers/FrmAppHelper.php:
- Around line 1831-1833: Remove the unnecessary phpcs:ignore comment on the
is_true function: in the is_true( $value ) method remove the trailing "//
phpcs:ignore Universal.Operators.StrictComparisons" since the code uses strict
comparisons and an explicit (int) cast, so the suppression is misleading; just
keep the return expression as-is without the phpcs comment and run lint/tests to
confirm no warnings.
- Around line 3797-3807: In maybe_highlight_menu, change the loose comparison of
$_REQUEST['post_type'] to a strict comparison to match the $post->post_type ===
$post_type check: replace the != check with !==, remove the phpcs:ignore
comment, and ensure both checks compare strings strictly (i.e., use !== for
$_REQUEST['post_type'] and keep $post->post_type !== $post_type) so the function
consistently uses strict comparisons.
- Around line 3027-3030: The condition in FrmAppHelper that currently checks if
a value is missing or loose-equals an empty string (if ( ! isset( $values[ $opt
] ) || $values[ $opt ] == '' )) can incorrectly treat 0, '0' or false as empty;
update this to use a strict comparison so only an actual empty string is
replaced: change the expression to ( ! isset( $values[ $opt ] ) || $values[ $opt
] === '' ) in the block that assigns $values[$opt] from
$post_values['options'][$opt] or $default (referencing $values, $opt,
$post_values and $default in FrmAppHelper).

In @classes/helpers/FrmStylesHelper.php:
- Around line 205-208: The list-item class check uses a loose comparison; change
the conditional that builds the li class from comparing
$style->post_content['collapse_icon'] == $key to a strict comparison
($style->post_content['collapse_icon'] === $key) so the active class only
applies when both value and type match the radio input (which is validated
strictly by checked()); update the expression around the li element that
references $style->post_content['collapse_icon'] and $key accordingly.

In @classes/views/shared/mb_adv_info.php:
- Around line 64-67: The conditional in the loop uses mixed equality operators:
replace the loose comparison `$f->field_options['data_type'] == ''` with a
strict comparison `=== ''` so the if statement consistently uses strict equality
for `$f->type` and `$f->field_options['data_type']`, preventing unintended type
coercion when checking `$f->field_options['data_type']`.

In @classes/views/styles/components/templates/text-toggle.php:
- Line 27: Replace the loose equality check in the checked(...) call with a
strict comparison: remove the phpcs:ignore and compare $option['value'] and
$field_value using === after normalizing their types (for example, cast both to
string or to the expected type) so the condition becomes ( $is_default_checked
&& 0 === $index ) || (string) $option['value'] === (string) $field_value; keep
the rest of the checked(...) arguments unchanged and preserve the existing logic
around $is_default_checked and $index.

In @stripe/models/FrmTransLiteDb.php:
- Around line 38-41: The version check uses loose comparison between
$this->db_version and $old_db_version (which may be a string from get_option());
change the if in FrmTransLiteDb to use a strict comparison and explicit
casting—e.g., cast the retrieved $old_db_version (or $this->db_version) to int
and compare with ===—so replace the current loose equality check with a strict,
typed comparison involving (int)$old_db_version (or (int)$this->db_version).
🧹 Nitpick comments (31)
css/_single_theme.css.php (1)

203-203: Consider using strict comparison instead of suppressing the warning.

The phpcs:ignore directive is correctly placed, but the underlying comparison $submit_width == '' could be made stricter using ===. While suppressing the warning is valid, the broader PR appears to fix comparisons in other files rather than just ignoring them. For consistency and robustness, using === is the preferred approach.

Proposed fix: Use strict comparison
-	width:<?php echo esc_html( ( $submit_width == '' ? 'auto' : $submit_width ) . $important ); // phpcs:ignore Universal.Operators.StrictComparisons ?>;
+	width:<?php echo esc_html( ( $submit_width === '' ? 'auto' : $submit_width ) . $important ); ?>;
classes/views/frm-entries/errors.php (1)

11-12: Consider fixing the loose comparison instead of suppressing the linting rule.

While the loose comparison != is safe here (since isset() protects against null values), suppressing PHPCS warnings without fixing the underlying issue is not ideal. This approach doesn't improve code quality—it just hides warnings.

Consider one of these alternatives instead:

  1. Use strict comparison (best practice):

    if ( isset( $message ) && $message !== '' ) {
  2. Use idiomatic PHP (cleaner):

    if ( ! empty( $message ) ) {

The empty() approach is particularly preferable here since it's a single function call and more concisely expresses the intent.

classes/views/shared/toggle.php (1)

81-82: Consider refactoring for type safety instead of suppressing the warning.

While the phpcs:ignore directive silences the warning, the loose comparison can be made more explicit and type-safe. The current logic prevents showing a label when $on_label is 1 (integer) or "1" (string), but this behavior could be clearer.

Consider one of these alternatives:

  1. Cast to int in the comparison (preserves loose equality intent explicitly):
-		<?php // phpcs:ignore Universal.Operators.StrictComparisons ?>
-		<?php if ( $show_labels && $on_label != 1 ) { ?>
+		<?php if ( $show_labels && (int) $on_label !== 1 ) { ?>
  1. Normalize the type earlier (better for maintainability):

At line 20, explicitly handle the type:

$on_label = $args['on_label'] ?? 1;
// Normalize: if it's the default sentinel value, keep as int; otherwise treat as string label
if ( 1 === $on_label || '1' === $on_label ) {
	$on_label = 1;
}

Then use strict comparison at line 82:

-		<?php // phpcs:ignore Universal.Operators.StrictComparisons ?>
-		<?php if ( $show_labels && $on_label != 1 ) { ?>
+		<?php if ( $show_labels && $on_label !== 1 ) { ?>

Note: If the intent is to allow "1" to be displayed as a label, the current loose comparison prevents that. Clarifying the expected behavior would help determine the best approach.

square/controllers/FrmSquareLiteActionsController.php (2)

112-116: Consider using strict comparison and removing redundancy.

The $amount == 000 check is redundant after empty($amount) since empty() already catches 0, '0', null, and other falsy values. Additionally, suppressing the linting warning doesn't address the underlying type-safety concern in payment validation logic.

♻️ Refactor to use strict comparison
-		// phpcs:ignore Universal.Operators.StrictComparisons
-		if ( empty( $amount ) || $amount == 000 ) {
+		if ( empty( $amount ) ) {
 			$response['error'] = __( 'Please specify an amount for the payment', 'formidable' );
 			return $response;
 		}

If you need to explicitly check for zero as distinct from empty/null, consider:

-		// phpcs:ignore Universal.Operators.StrictComparisons
-		if ( empty( $amount ) || $amount == 000 ) {
+		$numeric_amount = (float) $amount;
+		if ( empty( $amount ) || $numeric_amount === 0.0 ) {
 			$response['error'] = __( 'Please specify an amount for the payment', 'formidable' );
 			return $response;
 		}

447-451: Prefer strict comparison with explicit type casting.

The loose comparison between form IDs suppresses the linting warning but doesn't ensure type safety. For consistency with the rest of the codebase (e.g., line 32 uses strict comparison with casting), consider using strict comparison with explicit type casting.

♻️ Use strict comparison
-		// phpcs:ignore Universal.Operators.StrictComparisons
-		if ( $params['form_id'] == $params['posted_form_id'] ) {
+		if ( (int) $params['form_id'] === (int) $params['posted_form_id'] ) {
 			// This form has already been posted, so we aren't on the first page.
 			return;
 		}
classes/models/FrmEntryValidate.php (1)

186-187: Consider using !empty($value) or strict comparison for clarity.

The loose $value != '' comparison will treat 0, '0', false, and null as empty. If this is intentional, the ignore comment is fine. However, if you only want to skip validation for actual empty strings, consider:

-		// phpcs:ignore Universal.Operators.StrictComparisons
-		if ( $value != '' ) {
+		if ( $value !== '' ) {

Alternatively, !empty($value) would be more idiomatic if you truly want to skip all falsy values.

classes/models/fields/FrmFieldUserID.php (1)

75-76: Use strict comparison for consistency and to prevent unintended type coercion.

This file already uses strict comparison at line 141 ('' === $value) with an explicit comment: "Allow for an empty User ID. Return early to prevent it from getting set to 0." The loose comparison at line 76 ('' == $args['value']) contradicts this pattern and could allow the numeric value 0 to bypass validation due to type coercion, since '' == 0 evaluates to true.

♻️ Suggested refactor to match line 141 pattern
-		// phpcs:ignore Universal.Operators.StrictComparisons
-		if ( '' == $args['value'] ) {
+		if ( '' === $args['value'] ) {
 			return array();
 		}
stripe/controllers/FrmTransLiteActionsController.php (1)

503-504: LGTM! Consider strict comparison as an optional improvement.

The phpcs suppression is consistent with the PR's approach. However, since both form_id values are integers, using strict inequality (!==) would be more precise and avoid potential type coercion edge cases.

♻️ Optional refactor to strict comparison
-	// phpcs:ignore Universal.Operators.StrictComparisons
-	if ( empty( $previous_entry ) || $previous_entry->form_id != $field->form_id ) {
+	if ( empty( $previous_entry ) || $previous_entry->form_id !== $field->form_id ) {
		return $values;
	}
classes/views/frm-entries/sidebar-shared.php (1)

92-93: LGTM! Consider strict comparison as an optional improvement.

The phpcs suppression is appropriate for this linting cleanup PR. Since both updated_by and user_id are integer user IDs, using strict inequality (!==) would be more precise.

♻️ Optional refactor to strict comparison
-	<?php // phpcs:ignore Universal.Operators.StrictComparisons ?>
-	<?php if ( $entry->updated_by && $entry->updated_by != $entry->user_id ) { ?>
+	<?php if ( $entry->updated_by && $entry->updated_by !== $entry->user_id ) { ?>
		<div class="misc-pub-section">
tests/phpunit/base/FrmUnitTest.php (1)

352-353: LGTM! Consider strict comparison or empty() as optional improvements.

The phpcs suppression aligns with the PR's goals. Note that $page == '' will match multiple falsy values (empty string, 0, false, null). For clarity and precision, consider using $page === '' to match only empty strings, or empty($page) if the intent is to catch any empty value.

♻️ Optional refactor options

Option 1: Strict comparison if only empty string is intended

-	// phpcs:ignore Universal.Operators.StrictComparisons
-	if ( $page == '' ) {
+	if ( $page === '' ) {
		$page = home_url( '/' );
	}

Option 2: Use empty() if intent is to catch all falsy values

-	// phpcs:ignore Universal.Operators.StrictComparisons
-	if ( $page == '' ) {
+	if ( empty( $page ) ) {
		$page = home_url( '/' );
	}
classes/models/FrmFieldValueSelector.php (1)

287-290: LGTM! Verify intended behavior for option values.

The phpcs suppression is appropriate. Note that $value == '' will skip options with values of empty string, 0, false, or null. If 0 is a valid option value in your field options, this could inadvertently hide it. Consider using $value === '' if only empty strings should be skipped.

♻️ Optional refactor if 0 is a valid option value
-		// phpcs:ignore Universal.Operators.StrictComparisons
-		if ( $value == '' ) {
+		if ( $value === '' ) {
			continue;
		}
stripe/controllers/FrmStrpLiteActionsController.php (3)

124-128: LGTM! Consider strict comparison for payment validation.

The phpcs suppression is acceptable, though note that 000 is simply 0 (octal notation). The loose comparison $amount == 000 will match empty string, 0, '0', and false. For payment validation, being explicit about type would be safer. Consider using (float) $amount <= 0 or $amount === '000' depending on whether $amount is expected to be a string or number at this point.

♻️ Optional refactor for clarity
-	// phpcs:ignore Universal.Operators.StrictComparisons
-	if ( empty( $amount ) || $amount == 000 ) {
+	if ( empty( $amount ) || (float) $amount <= 0 ) {
		$response['error'] = __( 'Please specify an amount for the payment', 'formidable' );
		return $response;
	}

351-354: LGTM! Consider strict comparison for plan ID matching.

The phpcs suppression is consistent with the PR approach. Since both values are Stripe plan ID strings, using strict inequality (!==) would be more precise and avoid type coercion issues.

♻️ Optional refactor to strict comparison
-	// phpcs:ignore Universal.Operators.StrictComparisons
-	if ( $plan_opts['id'] != $settings['plan_id'] ) {
+	if ( $plan_opts['id'] !== $settings['plan_id'] ) {
		$settings['plan_id'] = FrmStrpLiteSubscriptionHelper::maybe_create_plan( $plan_opts );
	}

379-383: LGTM! Consider strict comparison for form ID matching.

The phpcs suppression is appropriate for this PR. Since both values are form IDs, using strict equality (===) would prevent type coercion issues between string '123' and integer 123.

♻️ Optional refactor to strict comparison
-	// phpcs:ignore Universal.Operators.StrictComparisons
-	if ( $params['form_id'] == $params['posted_form_id'] ) {
+	if ( (int) $params['form_id'] === (int) $params['posted_form_id'] ) {
		// This form has already been posted, so we aren't on the first page.
		return;
	}
classes/models/FrmFieldFormHtml.php (2)

229-231: Consider using strict comparison or simplifying the condition.

The condition ( $description && $description != '' ) is redundant—the first check already ensures $description is truthy. If the intent is to check for non-empty strings, use $description !== '' directly, or rely solely on the truthy check. The loose comparison != can cause unexpected behavior with values like '0'.

♻️ Suggested simplification
 		$this->maybe_add_description_id();
 		$description = FrmAppHelper::maybe_kses( $this->field_obj->get_field_column( 'description' ) );
-		FrmShortcodeHelper::remove_inline_conditions( ( $description && $description != '' ), 'description', $description, $this->html ); // phpcs:ignore Universal.Operators.StrictComparisons
+		FrmShortcodeHelper::remove_inline_conditions( $description !== '', 'description', $description, $this->html );

244-247: Use strict comparison for string checks.

The condition $description != '' should use strict comparison (!==) to avoid type coercion issues. With loose comparison, values like 0 or false could produce unexpected results.

♻️ Proposed fix
-		// phpcs:ignore Universal.Operators.StrictComparisons
-		if ( $description != '' ) {
+		if ( $description !== '' ) {
 			$this->add_element_id( 'description', 'desc' );
 		}
classes/controllers/FrmStylesController.php (2)

229-232: Consider using strict comparison with explicit type casting.

While the phpcs:ignore suppresses the warning, the loose comparison 1 == $style will match both integer 1 and string "1". For clearer intent and type safety, consider:

if ( empty( $style ) || (int) $style === 1 ) {

This makes the type coercion explicit and avoids potential issues with other truthy values.


245-248: Consider using strict comparison with explicit type casting.

Similar to line 230, the loose comparison could be replaced with a strict one:

if ( (int) $style === 1 ) {
    $style = 'default';
}

This provides better type safety and clearer intent.

stripe/controllers/FrmStrpLiteEventsController.php (2)

190-193: Simplify the boolean comparison.

Instead of == true, you can directly check the property's truthiness:

if ( $this->invoice->cancel_at_period_end ) {
    $this->subscription_canceled( 'future_cancel' );
}

This is more idiomatic PHP and avoids the need for the phpcs:ignore comment.


428-437: Consider using strict comparison for numeric values.

The loose inequality != could allow unexpected type juggling. Since both $amount and $amount_refunded should be numeric, consider:

$partial = (int) $amount !== (int) $amount_refunded;

This ensures type safety and removes the need for the phpcs:ignore directive.

classes/helpers/FrmFormsListHelper.php (1)

205-205: Consider using strict comparison for string equality.

Since both $status and $form_type are strings (sanitized with sanitize_title), you can use strict comparison:

$class = $status === $form_type ? ' class="current"' : '';

This removes the need for the phpcs:ignore comment and improves type safety.

classes/models/FrmForm.php (1)

1089-1091: Consider using strict comparison with explicit casting for IDs.

Since both $form->id and $values['posted_form_id'] are form IDs, use explicit integer comparison:

if ( (int) $form->id === (int) $values['posted_form_id'] ) {

This aligns with the pattern established elsewhere in the codebase (see line 1192) and removes the need for the phpcs:ignore comment.

stripe/controllers/FrmTransLiteAppController.php (1)

90-90: Good use of strict comparison with explicit casting, but phpcs:ignore may be unnecessary.

The explicit integer casting followed by strict comparison (int) $check_payment->id !== (int) $last_payment->id is the correct pattern for comparing IDs. However, the phpcs:ignore Universal.Operators.StrictComparisons comment appears unnecessary since you're now using strict comparison (!==).

Consider removing the phpcs:ignore comment:

$new_payment   = (int) $check_payment->id !== (int) $last_payment->id;
stripe/models/FrmStrpLiteAuth.php (1)

336-339: Documented intentional loose comparisons for IDs and amounts

The added Universal.Operators.StrictComparisons ignores correctly mark places where loose == / != is intentional (form IDs from POST and Stripe amount/string sentinels), with no behavioral change. If you ever revisit this, a future refactor could normalize amounts to integers before comparison to avoid relying on ==, but that’s not required for this PR.

Also applies to: 373-377, 394-397, 545-547

classes/helpers/FrmFieldsHelper.php (1)

624-647: label_position falsy check slightly broadens the fallback condition

Switching from an explicit non-empty check to if ( $position ) means values like 0 or '0' will now be treated as “no position set” and fall back to the style setting. That’s probably fine since valid positions are textual (top, none, no_label, inside), but if any caller passes '0' as a sentinel, behavior would change subtly.

classes/helpers/FrmXMLHelper.php (1)

1077-1083: Stricter post_id vs post['ID'] comparison is fine; PHPStan warning is cosmetic

The new if ( isset( $post['ID'] ) && (int) $post_id === (int) $post['ID'] ) keeps the previous numeric == semantics while making the check explicit and type-safe. The PHPStan “casting to int something that's already int” warning here is mostly stylistic; if you want to silence it, you can safely drop the cast on $post_id and keep the cast on $post['ID']:

Optional tweak to satisfy PHPStan without behavior change
-			if ( isset( $post['ID'] ) && (int) $post_id === (int) $post['ID'] ) {
+			if ( isset( $post['ID'] ) && $post_id === (int) $post['ID'] ) {
classes/helpers/FrmAppHelper.php (5)

1341-1354: Consider strict comparison to avoid edge case issues.

The loose comparison $value != '' with a phpcs:ignore comment could mask potential bugs. If a query variable is set to 0 or '0', it would incorrectly be treated as empty and trigger the fallback logic. Consider using strict comparison:

-	// phpcs:ignore Universal.Operators.StrictComparisons
-	if ( $value != '' ) {
+	if ( $value !== '' && $value !== null ) {

This would more explicitly handle the intended empty cases while preserving numeric zero as a valid value.


2445-2453: Consider strict comparisons to avoid form value matching bugs.

The loose comparisons with phpcs:ignore comments could cause unexpected behavior:

  1. in_array( $current, $values ) without the third parameter uses loose comparison, which can cause in_array(0, ['string']) to return true.
  2. $values == $current can match different types incorrectly (e.g., '0' == false).

Consider making these strict:

-	// phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict, Universal.Operators.StrictComparisons
-	return ( is_array( $values ) && in_array( $current, $values ) ) || ( ! is_array( $values ) && $values == $current );
+	if ( is_array( $values ) ) {
+		// Convert array values to strings for comparison with form data
+		$values = array_map( 'strval', $values );
+		$current = (string) $current;
+		return in_array( $current, $values, true );
+	}
+	return (string) $values === (string) $current;

This ensures type-safe comparisons while handling form data that comes as strings.


3432-3438: Use strict comparison for pagination logic.

The loose comparison for page number checking is unnecessary since $current_p should always be numeric:

-	// phpcs:ignore Universal.Operators.StrictComparisons
-	if ( $current_p == 1 ) {
+	if ( $current_p === 1 || (int) $current_p === 1 ) {

Or more simply, cast once at function entry:

 public static function get_first_record_num( $r_count, $current_p, $p_size ) {
+	$current_p = (int) $current_p;
-	// phpcs:ignore Universal.Operators.StrictComparisons
-	if ( $current_p == 1 ) {
+	if ( $current_p === 1 ) {

This avoids the phpcs:ignore while ensuring type safety.


3507-3514: Strict comparison needed for array key validation.

The loose comparison $name == '' could incorrectly treat '0' as an empty key, which is a valid array key in PHP:

-	// phpcs:ignore Universal.Operators.StrictComparisons
-	if ( $name == '' ) {
+	if ( $name === '' ) {

Using strict comparison ensures only actual empty strings trigger the array append logic, preserving '0' as a valid named key.


3562-3577: Use strict comparison for page matching.

The loose comparison for page matching is unnecessary and could cause type coercion issues:

-	// phpcs:ignore Universal.Operators.StrictComparisons
-	if ( $current_page != $page ) {
+	if ( $current_page !== $page && (string) $current_page !== (string) $page ) {

Or normalize types earlier:

 public static function select_current_page( $page, $current_page, $action = array() ) {
+	$page         = (string) $page;
+	$current_page = (string) $current_page;
-	// phpcs:ignore Universal.Operators.StrictComparisons
-	if ( $current_page != $page ) {
+	if ( $current_page !== $page ) {

This ensures type-safe comparison while avoiding the phpcs:ignore directive.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b9fffa4 and 696bfc8.

⛔ Files ignored due to path filters (1)
  • phpcs.xml is excluded by !**/*.xml
📒 Files selected for processing (35)
  • classes/controllers/FrmStylesController.php
  • classes/helpers/FrmAppHelper.php
  • classes/helpers/FrmEntriesListHelper.php
  • classes/helpers/FrmFieldsHelper.php
  • classes/helpers/FrmFormsListHelper.php
  • classes/helpers/FrmListHelper.php
  • classes/helpers/FrmStylesHelper.php
  • classes/helpers/FrmXMLHelper.php
  • classes/models/FrmDb.php
  • classes/models/FrmEntry.php
  • classes/models/FrmEntryValidate.php
  • classes/models/FrmField.php
  • classes/models/FrmFieldFormHtml.php
  • classes/models/FrmFieldValueSelector.php
  • classes/models/FrmForm.php
  • classes/models/FrmMigrate.php
  • classes/models/fields/FrmFieldUrl.php
  • classes/models/fields/FrmFieldUserID.php
  • classes/views/frm-entries/_sidebar-shared-pub.php
  • classes/views/frm-entries/errors.php
  • classes/views/frm-entries/sidebar-shared.php
  • classes/views/frm-fields/front-end/dropdown-field.php
  • classes/views/shared/mb_adv_info.php
  • classes/views/shared/toggle.php
  • classes/views/styles/components/templates/text-toggle.php
  • css/_single_theme.css.php
  • square/controllers/FrmSquareLiteActionsController.php
  • stripe/controllers/FrmStrpLiteActionsController.php
  • stripe/controllers/FrmStrpLiteEventsController.php
  • stripe/controllers/FrmTransLiteActionsController.php
  • stripe/controllers/FrmTransLiteAppController.php
  • stripe/helpers/FrmTransLiteAppHelper.php
  • stripe/models/FrmStrpLiteAuth.php
  • stripe/models/FrmTransLiteDb.php
  • tests/phpunit/base/FrmUnitTest.php
🧰 Additional context used
🧬 Code graph analysis (4)
classes/models/FrmFieldFormHtml.php (1)
classes/helpers/FrmShortcodeHelper.php (2)
  • FrmShortcodeHelper (9-156)
  • remove_inline_conditions (146-155)
classes/views/styles/components/templates/text-toggle.php (1)
classes/helpers/FrmAppHelper.php (1)
  • checked (2433-2437)
classes/helpers/FrmEntriesListHelper.php (1)
classes/helpers/FrmAppHelper.php (2)
  • FrmAppHelper (6-5051)
  • pro_is_installed (391-393)
stripe/models/FrmStrpLiteAuth.php (1)
classes/controllers/FrmFormsController.php (2)
  • FrmFormsController (6-3722)
  • just_created_entry (2628-2632)
🪛 GitHub Check: PHPStan
classes/helpers/FrmXMLHelper.php

[failure] 1077-1077:
Casting to int something that's already int.

classes/models/FrmField.php

[failure] 795-795:
Casting to int something that's already int.

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Cypress
  • GitHub Check: PHP 7.4 tests in WP 6.9
  • GitHub Check: PHP 8 tests in WP 6.9
🔇 Additional comments (29)
classes/models/FrmMigrate.php (2)

566-567: LGTM: Properly annotated loose comparison.

The phpcs:ignore comment is correctly placed and uses the appropriate standard name. The loose equality check on default_template is acknowledged by the annotation.

Consider whether future refactors could adopt strict comparison (===) if $form->default_template is guaranteed to be an integer from the database, but the current approach is acceptable as-is.


867-868: LGTM: String comparison annotations are correct.

The phpcs:ignore comment correctly suppresses the strict comparison warning for both the != and == operators applied to HTML strings. Since both operands are strings, loose comparison operators pose minimal type-juggling risk here, though strict operators would align with modern PHP best practices.

classes/models/fields/FrmFieldUrl.php (1)

85-85: Verify that loose comparison is intentional for field validation.

The phpcs:ignore comment suppresses the strict comparison warning on $this->field->required == '1', but this approach masks rather than fixes the underlying issue. For field validation logic, explicit type checking is safer.

Consider whether the comparison should instead be converted to strict comparison with explicit casting (e.g., (int) $this->field->required === 1 or (string) $this->field->required === '1') to ensure type safety, particularly since this affects required field validation.

To verify the safety of this loose comparison, could you clarify:

  1. What is the expected data type of $this->field->required—is it always the string '1' or could it be the integer 1?
  2. Are there other cases in the codebase where $this->field->required is compared that use strict comparison, which would indicate an inconsistent approach?

You may also want to check if other similar required field checks elsewhere in the codebase use strict or loose comparison for consistency.

classes/models/FrmEntryValidate.php (4)

94-95: LGTM!

The phpcs ignore comment appropriately documents the intentional use of loose comparison to handle cases where item_key might be null, false, or an empty string.


160-160: LGTM!

Good fix—count() always returns an integer, so using strict comparison (===) is the correct approach rather than adding an ignore comment.


170-171: LGTM!

The phpcs ignore comment is appropriate here. The required property may be stored as either '1' (string) or 1 (integer) depending on how the field was saved, so loose comparison handles both cases.


751-751: Visibility change is intentional and properly documented.

This method's change from private to public in version 6.21 is already documented via the @since annotation in the docstring. The method is actively used by external code (e.g., FrmSpamCheckWPDisallowedWords::FrmSpamCheckWPDisallowedWords()), confirming that public access is necessary and appropriate.

Likely an incorrect or invalid review comment.

classes/helpers/FrmListHelper.php (1)

483-484: LGTM! phpcs:ignore annotations are appropriate.

The phpcs:ignore annotations suppress strict comparison warnings for intentional loose comparisons (action parameters, mode strings, and pagination numbers). These are non-functional changes that maintain existing behavior while addressing linting concerns.

Also applies to: 538-539, 722-726, 730-734, 1279-1279

classes/views/frm-entries/_sidebar-shared-pub.php (1)

41-42: LGTM! phpcs:ignore annotation is appropriate.

The annotation suppresses a strict comparison warning for datetime comparison. Since updated_at and created_at are datetime strings that can be safely compared with loose equality, this non-functional linting annotation is appropriate.

classes/models/FrmDb.php (2)

390-390: LGTM! Strict comparison is appropriate.

Changing from loose (==) to strict (===) comparison for string comparison between $group and $table is correct. Both variables contain string values from table name parsing, so strict comparison is safer and maintains identical behavior.


437-438: LGTM! phpcs:ignore annotations are appropriate.

The annotations suppress strict comparison warnings for empty string checks. These loose comparisons (== '') intentionally catch multiple falsy values (null, false, empty string, 0), which is the desired behavior for filtering out empty arguments.

Also applies to: 521-522

classes/helpers/FrmEntriesListHelper.php (2)

180-180: LGTM! Strict comparison is appropriate.

Changing from loose (!=) to strict (!==) comparison for the empty string check is correct. The $s variable comes from sanitize_text_field(), which always returns a string, so strict comparison is safer and maintains identical behavior.


382-383: LGTM! phpcs:ignore annotation is appropriate.

The annotation suppresses a strict comparison warning for the column name check. This loose comparison is intentional to allow flexibility when matching action columns.

stripe/helpers/FrmTransLiteAppHelper.php (1)

222-222: The casting to int is safe and reasonable defensive programming.

interval_count is consistently initialized to 1 across the database schema (default), models (default 1), and form fields. The Subscription model sanitizes this value with absint(), which ensures it's always numeric. The HTML form restricts input to type="number" with min="1", preventing null or empty string from being submitted in normal use. No evidence exists in the codebase of interval_count being intentionally set to null or empty string.

classes/helpers/FrmFormsListHelper.php (1)

91-91: Good improvement to strict comparison.

The change from != to !== ensures that the search term is checked with type safety. This prevents potential issues where 0 or other falsy values might be treated as empty strings.

classes/models/FrmForm.php (4)

946-949: Good addition of strict integer comparison.

The explicit cast (int) $limit === 1 makes the type coercion clear and ensures that both integer 1 and string "1" are handled correctly. This is a solid improvement over loose comparison.


1192-1194: Excellent use of strict comparison with explicit casting.

This change demonstrates the correct pattern for comparing IDs: explicit type casting followed by strict comparison. This ensures type safety while handling cases where IDs might be stored as strings or integers.


156-160: Array comparison with loose equality is acceptable here.

Using != for array comparison is a common PHP pattern that checks both structure and values. The phpcs:ignore is appropriate as !== would only check if they're the same array instance, not if they have the same content.


543-547: Array comparison with loose equality is acceptable here.

Similar to line 157, the loose comparison != is appropriate for comparing array contents. The phpcs:ignore correctly suppresses a false positive warning.

classes/models/FrmEntry.php (3)

85-88: Loose item_key vs name comparison is safely documented

Adding the Universal.Operators.StrictComparisons ignore here is appropriate; the existing loose == comparison is intentional and behavior is unchanged.


567-573: Stricter item_id vs entry->id comparison looks safe

Casting both sides to int and using === keeps semantics equivalent to the prior loose compare for numeric IDs while improving type safety in get_meta.


663-668: PHPCS ignore on $limit == '' is consistent with current behavior

Keeping a loose comparison against the empty string (and just suppressing the sniff) maintains existing behavior for falsy/empty limits while documenting the intent.

stripe/models/FrmStrpLiteAuth.php (1)

212-224: Stricter form ID comparison in add_hidden_token_field is correct

Using $posted_form !== (int) $form->id after absint on the POSTed value makes the form ID check type-safe without changing behavior for valid numeric IDs.

classes/helpers/FrmFieldsHelper.php (1)

282-286: PHPCS ignores correctly document intentional loose comparisons

All the added Universal.Operators.StrictComparisons (and related) ignores in these blocks simply annotate existing, intentional uses of loose ==/!= and non-strict in_array (for blank messages, custom HTML, checkbox defaults, conditional logic, shortcode defaults, and legacy update_email flags). Runtime behavior is unchanged and consistent with prior logic.

Also applies to: 297-300, 703-705, 892-897, 1274-1276, 1352-1357, 1583-1587, 1600-1606, 2245-2249

classes/models/FrmField.php (2)

893-946: Stricter type filtering and limit handling in field queries look correct

Using $type !== $result->type in get_all_types_in_form is safe since both come from field type strings, and preserving if ( $limit == 1 ) (plus the ' LIMIT 1' check in getAll) keeps legacy limit semantics intact while satisfying PHPCS via ignores. No behavioral regressions expected.

Also applies to: 1103-1104


610-613: PHPCS ignores here correctly preserve existing loose-comparison semantics

The added Universal.Operators.StrictComparisons ignores in duplicate(), is_required(), and is_option_value_in_object() simply document intentional non-strict comparisons used for historical flags (required stored as '0'/'1') and key mangling. Behavior is unchanged and consistent with prior logic.

Also applies to: 639-641, 1387-1388, 1472-1474

classes/helpers/FrmXMLHelper.php (1)

792-799: PHPCS ignores correctly mark intentional loose comparisons in XML import/export

All added Universal.Operators.StrictComparisons ignores (placeholder migration, field creation result checks, style change detection, post-date matching, custom style export, default HTML trimming, and legacy update_email flags) simply annotate existing loose ==/!= usages that are relied on for backward compatibility. No runtime behavior changes are introduced.

Also applies to: 814-828, 959-973, 1449-1452, 1695-1708, 1868-1874, 2218-2249

classes/helpers/FrmAppHelper.php (2)

2283-2285: Good strict comparison implementation.

The change to (int) $role === 1 properly handles both string and integer inputs while maintaining type safety. This ensures that string '1' is correctly identified as the administrator role.


2323-2325: Good strict comparison for role matching.

The strict comparison $role === $needed_role ensures exact role name matching without type coercion, which is appropriate for permission checks.

Comment thread classes/helpers/FrmAppHelper.php
Comment thread classes/helpers/FrmAppHelper.php
Comment thread classes/helpers/FrmAppHelper.php
Comment thread classes/helpers/FrmStylesHelper.php
Comment thread classes/views/shared/mb_adv_info.php
Comment thread classes/views/styles/components/templates/text-toggle.php
Comment thread stripe/models/FrmTransLiteDb.php
@Crabcyborg Crabcyborg merged commit 77cee6b into master Jan 8, 2026
16 checks passed
@Crabcyborg Crabcyborg deleted the add_phpcs_ignore_comments_where_strict_comparison_is_not_happening branch January 8, 2026 21:17
stephywells pushed a commit that referenced this pull request Apr 4, 2026
…ere_strict_comparison_is_not_happening

Add phpcs ignore comments where strict comparison is not happening
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant