Skip to content

Use strict string comparison more often#2737

Merged
Crabcyborg merged 1 commit into
masterfrom
use_strict_string_comparison_more_often
Jan 8, 2026
Merged

Use strict string comparison more often#2737
Crabcyborg merged 1 commit into
masterfrom
use_strict_string_comparison_more_often

Conversation

@Crabcyborg
Copy link
Copy Markdown
Contributor

No description provided.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 8, 2026

Walkthrough

Systematic replacement of loose equality and inequality comparisons with strict identity comparisons across multiple controller, helper, model, and view files. All occurrences of == are changed to === and != to !== for type-safe string comparisons without altering control flow.

Changes

Cohort / File(s) Summary
Controllers
classes/controllers/FrmHooksController.php, classes/controllers/FrmSettingsController.php, classes/controllers/FrmStylesController.php
Replaced loose comparisons with strict comparisons in conditional checks for trigger hooks, addon plugin names, and style names.
Helpers
classes/helpers/FrmAppHelper.php, classes/helpers/FrmFormsHelper.php, classes/helpers/FrmFormsListHelper.php, classes/helpers/FrmListHelper.php, classes/helpers/FrmXMLHelper.php
Converted loose equality/inequality operators to strict operators across permission checks, form status handling, pagination logic, and XML data population.
Models
classes/models/FrmAddon.php, classes/models/FrmCreateFile.php, classes/models/FrmDb.php, classes/models/FrmField.php, classes/models/FrmFieldFormHtml.php, classes/models/FrmForm.php, classes/models/FrmFormAction.php, classes/models/FrmTableHTMLGenerator.php
Applied strict comparisons in addon filtering, FTP credential handling, caching type checks, field type validation, form status checks, and table direction detection.
Views
classes/views/frm-fields/back-end/ajax-field-placeholder.php
Updated field type comparison in data attribute generation to use strict equality.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Description check ❓ Inconclusive No pull request description was provided by the author, making it impossible to verify if it relates to the changeset. Add a description explaining the rationale for converting to strict string comparisons and any benefits or testing performed.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Use strict string comparison more often' accurately describes the main change across all modified files, which systematically replace loose equality/inequality operators with strict ones.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 829bb3f and e9813e3.

📒 Files selected for processing (17)
  • classes/controllers/FrmHooksController.php
  • classes/controllers/FrmSettingsController.php
  • classes/controllers/FrmStylesController.php
  • classes/helpers/FrmAppHelper.php
  • classes/helpers/FrmFormsHelper.php
  • classes/helpers/FrmFormsListHelper.php
  • classes/helpers/FrmListHelper.php
  • classes/helpers/FrmXMLHelper.php
  • classes/models/FrmAddon.php
  • classes/models/FrmCreateFile.php
  • classes/models/FrmDb.php
  • classes/models/FrmField.php
  • classes/models/FrmFieldFormHtml.php
  • classes/models/FrmForm.php
  • classes/models/FrmFormAction.php
  • classes/models/FrmTableHTMLGenerator.php
  • classes/views/frm-fields/back-end/ajax-field-placeholder.php
🧰 Additional context used
🧬 Code graph analysis (5)
classes/helpers/FrmXMLHelper.php (1)
classes/controllers/FrmFormActionsController.php (1)
  • FrmFormActionsController (6-815)
classes/models/FrmFormAction.php (1)
classes/models/FrmOnSubmitAction.php (1)
  • update (78-86)
classes/models/FrmFieldFormHtml.php (1)
classes/models/fields/FrmFieldType.php (1)
  • get_field_column (168-178)
classes/models/FrmAddon.php (2)
classes/helpers/FrmAppHelper.php (2)
  • FrmAppHelper (6-5044)
  • pro_is_installed (391-393)
classes/models/FrmSolution.php (1)
  • plugin_name (140-142)
classes/views/frm-fields/back-end/ajax-field-placeholder.php (1)
classes/models/FrmField.php (2)
  • FrmField (6-1627)
  • get_option (1481-1483)
⏰ 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). (6)
  • GitHub Check: PHP 8 tests in WP 6.9
  • GitHub Check: PHP 7.4 tests in WP 6.9
  • GitHub Check: PHP 7.4 tests in WP 6.9
  • GitHub Check: Cypress
  • GitHub Check: Cypress
  • GitHub Check: PHP 8 tests in WP 6.9
🔇 Additional comments (25)
classes/helpers/FrmFormsHelper.php (1)

1239-1239: LGTM! Strict comparison improves type safety.

The change from loose equality to strict identity comparison for the form status check is appropriate and aligns with PHP best practices. Since $form->status is always a string value from the database, this change maintains the same behavior while being more explicit about type expectations.

classes/views/frm-fields/back-end/ajax-field-placeholder.php (1)

6-6: LGTM! Strict type checking for field type comparison.

The change to strict equality when checking for the 'divider' field type is appropriate. Field types are always strings, so this change improves type safety without any functional impact on the data-formid attribute logic.

classes/models/FrmCreateFile.php (1)

275-277: LGTM! Strict comparisons for FTP connection type checks.

The changes to strict equality for checking SSH and FTPEXT connection types are appropriate improvements. Both FS_METHOD (when defined) and $type are string values, so the strict comparisons maintain the same behavior while being more explicit about type expectations.

classes/models/FrmTableHTMLGenerator.php (1)

383-383: LGTM! Strict comparison for RTL direction check.

The change to strict equality for checking the RTL direction is appropriate. The $this->direction property is always a string value ('ltr' or 'rtl'), so this change improves type safety without affecting the cell ordering logic.

classes/models/FrmFieldFormHtml.php (1)

377-377: LGTM! Strict inequality for confirmation field check.

The change to strict inequality when checking if conf_field is not 'stop' is appropriate. This ensures that only the exact string value 'stop' will prevent the filtering loop, making the intent more explicit and improving type safety. The behavior remains consistent with the comment's indication that this check prevents infinite loops on confirmation fields.

classes/models/FrmDb.php (1)

750-750: LGTM: Strict comparison improves type safety.

The change from loose to strict equality comparison is appropriate here. The $type parameter is consistently used as a string throughout this method, so enforcing strict type checking prevents potential type coercion issues.

classes/controllers/FrmStylesController.php (1)

1307-1311: LGTM: Strict string comparisons enhance reliability.

Both changes from loose to strict equality operators are appropriate. The $name variable represents array keys from $default_styles, which are strings. Using strict comparisons (===) ensures exact matches without type coercion, improving code reliability.

classes/helpers/FrmListHelper.php (2)

245-245: LGTM: Appropriate strict comparison for pagination argument.

The change to strict equality is correct. The $key parameter represents pagination argument names (strings), so strict type checking is appropriate and prevents unintended matches.


653-653: LGTM: Strict comparison for position checking.

The strict equality operator is appropriate here. The $which parameter is a string indicating table navigation position ('top' or 'bottom'), making strict type checking the correct choice.

classes/controllers/FrmHooksController.php (1)

21-21: LGTM: Strict comparison for hook name verification.

The change to strict equality is appropriate. The $trigger_hooks variable contains a hook name (string), and using strict comparison ensures exact matches without type coercion, which is the correct approach for string-based conditional logic.

classes/models/FrmForm.php (2)

613-613: LGTM: Strict comparison for status validation.

The change to strict equality is correct. The $status parameter is a string representing form status, so strict type checking prevents unintended matches and improves code reliability.


999-1011: LGTM: Consistent strict comparisons for status checking.

Both changes to strict operators are appropriate. The $row->status values come from database queries and are strings ('published', 'draft', 'trash'). Using strict comparisons (!== and ===) ensures exact string matches without type coercion, which is the correct approach for status validation logic.

classes/helpers/FrmFormsListHelper.php (2)

451-453: LGTM! Strict comparison improves type safety.

The change from != to !== is appropriate here. The $mode variable is always a string (from get_param with default 'list'), so strict comparison with the string literal 'excerpt' is correct and prevents potential type coercion issues.


478-480: LGTM! Strict comparison is appropriate.

Both $item->status (database field) and $this->status (from get_param) are strings, making the strict inequality check appropriate and type-safe.

classes/models/FrmFormAction.php (3)

792-794: LGTM! Strict comparison is safe.

The change to strict inequality is appropriate. While $form_id can be int or string, the first condition ($form_id &&) already handles falsy values, and the strict comparison with the string literal 'all' correctly prevents type coercion.


846-848: LGTM! Strict comparison improves type safety.

The $type parameter is a string, making the strict inequality comparison with 'all' appropriate and type-safe.


943-950: LGTM! Strict comparison is appropriate.

The strict equality check for 'update' === $update is correct. The $update parameter is a string, making this type-safe.

classes/models/FrmAddon.php (3)

191-193: LGTM! Strict comparison is appropriate.

The change to strict inequality correctly enforces both type and value matching for the action check.


198-200: LGTM! Strict comparisons improve type safety.

Both slug comparisons now use strict inequality, which is appropriate since slugs are always strings.


256-277: LGTM! Strict comparison prevents potential issues.

The plugin name comparison now uses strict inequality, which is appropriate since $this->plugin_name is a string property. This prevents any potential type coercion bugs.

classes/helpers/FrmXMLHelper.php (1)

2226-2231: LGTM! Strict comparison is appropriate.

The change from loose to strict equality when checking for 'custom' is correct. This ensures both type and value matching, improving type safety.

classes/controllers/FrmSettingsController.php (2)

148-151: LGTM! Strict comparison improves type safety.

The plugin name comparison now uses strict inequality, which is appropriate for string comparisons and prevents potential type coercion issues.


450-452: LGTM! Strict comparison is safe.

The strict inequality check is appropriate. The $stop_load parameter can be false or the string 'stop_load', and the strict comparison correctly handles both cases without relying on type coercion.

classes/models/FrmField.php (1)

1028-1028: LGTM! Strict string comparisons improve type safety.

The conversions from loose (!=, ==) to strict (!==, ===) comparisons are appropriate for these string checks:

  • Line 1028: $inc_embed string comparison
  • Line 1042: $field->type string comparison
  • Line 1337: Field type string comparisons

These changes prevent unintended type coercion and align with PHP best practices.

Also applies to: 1042-1042, 1337-1337

classes/helpers/FrmAppHelper.php (1)

2385-2385: LGTM! Strict string comparisons improve type safety.

The conversions from loose (==, !=) to strict (===, !==) comparisons are appropriate for these string checks:

  • Line 2385: $show_message compared to 'hide'
  • Lines 2535, 2543: $class compared to 'open'

These changes prevent unintended type coercion and align with the PR's objective of systematic strict comparison adoption across the codebase.

Also applies to: 2535-2535, 2543-2543


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.

@Crabcyborg Crabcyborg merged commit 0c29779 into master Jan 8, 2026
36 checks passed
@Crabcyborg Crabcyborg deleted the use_strict_string_comparison_more_often branch January 8, 2026 14:10
stephywells pushed a commit that referenced this pull request Apr 4, 2026
…_more_often

Use strict string comparison more often
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