Skip to content

Fix some phpcs warnings#2676

Merged
Crabcyborg merged 1 commit into
masterfrom
fix_some_phpcs_warnings
Dec 22, 2025
Merged

Fix some phpcs warnings#2676
Crabcyborg merged 1 commit into
masterfrom
fix_some_phpcs_warnings

Conversation

@Crabcyborg
Copy link
Copy Markdown
Contributor

@Crabcyborg Crabcyborg commented Dec 22, 2025

  • Treats a PHPCS warnings as an error to make sure there are no spaces between the variable name and = for single line variable declarations.
  • Removes some declarations for unused variables.
  • Check $delete_meta variable before deleting meta (Like in https://github.com/Strategy11/formidable-stripe/pull/265/files).
  • Fixes an isset check, where it wasn't setting the right variable. $events is never used, but the variable behind the isset check is then assumed to be set moving forward.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 22, 2025

Walkthrough

This PR performs comprehensive code cleanup across multiple files, removing unused variable assignments, unused global declarations, simplifying loop constructs, and normalizing whitespace alignment. Most changes are cosmetic refactors with minimal functional impact; however, a test file and one authentication method contain logic modifications that warrant review.

Changes

Cohort / File(s) Summary
Controllers — Whitespace & Unused Variables
classes/controllers/FrmAddonsController.php, FrmFormTemplatesController.php, FrmStylesController.php, FrmXMLController.php, stripe/controllers/FrmStrpLiteActionsController.php, FrmTransLiteActionsController.php, square/controllers/FrmSquareLiteActionsController.php
Whitespace alignment normalized and unused variable assignments removed (e.g., $data = $form in maybe_show_cred_form); no behavioral changes.
Helpers — Global Scope Cleanup
classes/helpers/FrmAppHelper.php, FrmCSVExportHelper.php, FrmDashboardHelper.php, FrmEntriesHelper.php, FrmFormsListHelper.php, FrmHtmlHelper.php, stripe/helpers/FrmStrpLiteConnectHelper.php, FrmTransLiteListHelper.php
Removed unused global $wpdb and $frm_vars declarations; removed unused loop index variables; whitespace alignment normalized.
Models — Property Declaration Formatting
classes/models/FrmCreateFile.php, FrmField.php, FrmForm.php, FrmFormAction.php, FrmFormMigrator.php, fields/FrmFieldName.php, fields/FrmFieldType.php, stripe/models/FrmStrpLiteAuth.php
Public and protected property declarations whitespace normalized; unused global $wpdb removed from FrmForm::get_count(); conditional meta deletion logic refactored in FrmStrpLiteAuth::get_referer_url.
Views — Unused Variable Assignment Removal
classes/views/frm-entries/form.php, frm-fields/back-end/settings.php, frm-form-actions/_action_inside.php, _email_settings.php, frm-settings/email/email-styles.php, summary-emails/base.php, xml/posts_xml.php
Removed unused FrmAppHelper::get_settings() assignments and unused variable assignments; refactored event initialization in _action_inside.php to directly assign to $action_control->action_options['event'].
Tests — Variable Assignment Cleanup
tests/phpunit/fields/test_FrmFieldValidate.php, forms/test_FrmForm.php, misc/test_FrmAppHelper.php, test_FrmDirectFileAccess.php, stripe/FrmStrpLiteUnitTest.php, styles/test_FrmStylesHelper.php
Removed unused variable assignments and unused global declarations; simplified loop constructs; changed error field collection logic in test_empty_required_fields.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Areas requiring extra attention:

  • tests/phpunit/fields/test_FrmFieldValidate.php — The error field collection logic appears to be inverted: now iterates over non-error fields instead of error fields, potentially producing misleading assertions. Verify intent and correctness of the test logic.
  • stripe/models/FrmStrpLiteAuth.php::get_referer_url() — Meta deletion now conditional on $delete_meta parameter; verify this behavioral change aligns with intended usage and doesn't break callers expecting unconditional deletion.
  • classes/views/frm-form-actions/_action_inside.php — Logic refactored to assign directly to $action_control->action_options['event'] instead of creating intermediate $events variable; verify the action_options structure and downstream consumers are compatible.

Possibly related PRs

Suggested labels

run analysis, run tests

Suggested reviewers

  • lauramekaj1

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description check ✅ Passed The pull request has no author-provided description, but the title and objectives indicate it addresses phpcs warnings. The changeset confirms this with widespread whitespace and code cleanup.
Title check ✅ Passed The title accurately describes the main objective of the pull request, which is to fix phpcs (PHP CodeSniffer) warnings and treat another warning as an error.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix_some_phpcs_warnings

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: 0

🧹 Nitpick comments (2)
tests/phpunit/forms/test_FrmForm.php (1)

64-66: Valid cleanup of unused variable assignment.

Removing the unused return value assignment aligns with the PR's phpcs cleanup objective. The test still validates deletion through the FrmForm::getOne() check on line 65.

Consider explicitly asserting the return value for more precise test reporting:

$result = FrmForm::destroy( $form->id );
$this->assertNotFalse( $result, 'Failed to destroy form ' . $form->form_key );

This would provide clearer feedback if destroy() fails versus if the subsequent check fails.

classes/views/frm-form-actions/_action_inside.php (1)

29-41: Initialize action_options['event'] to a sane default

Setting $action_control->action_options['event'] to 'create' when it’s missing ensures:

  • The event list always contains at least one valid value.
  • Subsequent normalization (explode + count) and rendering (hidden input vs multiselect) behave predictably instead of producing empty/invalid options.

This is a safe, backward‑compatible default and removes the risk of rendering an empty event option when event wasn’t set.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 02d8f76 and 7f22f38.

📒 Files selected for processing (36)
  • classes/controllers/FrmAddonsController.php
  • classes/controllers/FrmFormTemplatesController.php
  • classes/controllers/FrmStylesController.php
  • classes/controllers/FrmXMLController.php
  • classes/helpers/FrmAppHelper.php
  • classes/helpers/FrmCSVExportHelper.php
  • classes/helpers/FrmDashboardHelper.php
  • classes/helpers/FrmEntriesHelper.php
  • classes/helpers/FrmFormsListHelper.php
  • classes/helpers/FrmHtmlHelper.php
  • classes/models/FrmCreateFile.php
  • classes/models/FrmField.php
  • classes/models/FrmForm.php
  • classes/models/FrmFormAction.php
  • classes/models/FrmFormMigrator.php
  • classes/models/fields/FrmFieldName.php
  • classes/models/fields/FrmFieldType.php
  • classes/views/frm-entries/form.php
  • classes/views/frm-fields/back-end/settings.php
  • classes/views/frm-form-actions/_action_inside.php
  • classes/views/frm-form-actions/_email_settings.php
  • classes/views/frm-settings/email/email-styles.php
  • classes/views/summary-emails/base.php
  • classes/views/xml/posts_xml.php
  • square/controllers/FrmSquareLiteActionsController.php
  • stripe/controllers/FrmStrpLiteActionsController.php
  • stripe/controllers/FrmTransLiteActionsController.php
  • stripe/helpers/FrmStrpLiteConnectHelper.php
  • stripe/helpers/FrmTransLiteListHelper.php
  • stripe/models/FrmStrpLiteAuth.php
  • tests/phpunit/fields/test_FrmFieldValidate.php
  • tests/phpunit/forms/test_FrmForm.php
  • tests/phpunit/misc/test_FrmAppHelper.php
  • tests/phpunit/misc/test_FrmDirectFileAccess.php
  • tests/phpunit/stripe/FrmStrpLiteUnitTest.php
  • tests/phpunit/styles/test_FrmStylesHelper.php
💤 Files with no reviewable changes (10)
  • classes/views/frm-settings/email/email-styles.php
  • classes/models/FrmForm.php
  • tests/phpunit/styles/test_FrmStylesHelper.php
  • stripe/helpers/FrmTransLiteListHelper.php
  • classes/views/frm-entries/form.php
  • tests/phpunit/misc/test_FrmAppHelper.php
  • classes/views/xml/posts_xml.php
  • classes/views/frm-form-actions/_email_settings.php
  • classes/views/summary-emails/base.php
  • tests/phpunit/fields/test_FrmFieldValidate.php
🧰 Additional context used
🧬 Code graph analysis (7)
classes/controllers/FrmXMLController.php (1)
classes/models/FrmDb.php (2)
  • FrmDb (6-867)
  • get_results (328-330)
classes/controllers/FrmAddonsController.php (1)
classes/helpers/FrmAppHelper.php (2)
  • FrmAppHelper (6-5049)
  • make_affiliate_url (101-110)
tests/phpunit/forms/test_FrmForm.php (1)
classes/models/FrmForm.php (2)
  • FrmForm (6-1412)
  • destroy (707-747)
stripe/models/FrmStrpLiteAuth.php (1)
stripe/helpers/FrmStrpLiteLinkRedirectHelper.php (1)
  • delete_temporary_referer_meta (180-183)
stripe/helpers/FrmStrpLiteConnectHelper.php (1)
square/helpers/FrmSquareLiteConnectHelper.php (1)
  • post_with_authenticated_body (527-548)
classes/views/frm-form-actions/_action_inside.php (1)
classes/controllers/FrmFormActionsController.php (1)
  • action_control (444-450)
classes/helpers/FrmFormsListHelper.php (3)
square/js/settings.js (1)
  • mode (7-7)
classes/helpers/FrmAppHelper.php (1)
  • get_param (736-773)
classes/helpers/FrmListHelper.php (1)
  • get_param (195-204)
⏰ 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 7.4 tests in WP trunk
  • GitHub Check: PHP 8 tests in WP trunk
  • GitHub Check: Cypress
  • GitHub Check: PHP 7.4 tests in WP trunk
  • GitHub Check: PHP 8 tests in WP trunk
  • GitHub Check: Cypress
🔇 Additional comments (27)
classes/models/fields/FrmFieldType.php (1)

843-857: ✓ Whitespace cleanup in get_new_field_defaults looks good.

The indentation adjustment on line 844 aligns with the PR's phpcs cleanup objective. The method logic remains unchanged—it correctly builds and merges field default arrays without behavioral impact.

square/controllers/FrmSquareLiteActionsController.php (1)

548-556: Formatting change looks good.

The $square_vars array assignment has been reformatted without any functional impact. The array structure remains clear and maintainable.

To confirm this PR fully resolves the phpcs warnings mentioned in the title, please verify that running phpcs against this file now produces no violations. If you have access to the specific warning messages that were reported before this change, confirming they're resolved would be helpful.

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

284-284: LGTM! Clean removal of unused loop variable.

The $name key variable was never referenced inside the loop body, which only accesses $sub_field. This refactor correctly addresses the phpcs warning while preserving behavior.

classes/controllers/FrmXMLController.php (1)

601-601: LGTM!

Formatting adjustment only—no functional changes.

stripe/controllers/FrmTransLiteActionsController.php (1)

566-566: LGTM!

Whitespace normalization with no impact on behavior.

tests/phpunit/misc/test_FrmDirectFileAccess.php (1)

23-23: LGTM!

Good cleanup—removes an unused loop index variable.

classes/helpers/FrmEntriesHelper.php (1)

429-429: LGTM!

Whitespace alignment—no functional change.

classes/controllers/FrmFormTemplatesController.php (1)

569-572: LGTM!

Array formatting normalized; no behavioral impact.

stripe/helpers/FrmStrpLiteConnectHelper.php (1)

891-891: LGTM!

Whitespace adjustment—no logic changes.

classes/models/FrmFormAction.php (1)

663-663: LGTM!

Whitespace cleanup—no functional changes.

stripe/models/FrmStrpLiteAuth.php (1)

820-823: Clarify the lifecycle of temporary referer meta in message flows.

The temporary referer meta is intentionally retained when $delete_meta=false (line 782). This meta persists for entries using the message confirmation method, whereas entries using redirect flows delete it immediately. This is acceptable because the meta is cleaned up when the entry itself is deleted (FrmEntry.php line 381 deletes all metas for an entry). However, the design intent should be documented—clarify whether temporary referer meta should persist for the entry lifetime, or whether it should be explicitly deleted after the message is displayed.

classes/controllers/FrmAddonsController.php (1)

888-901: Affiliate URL preparation remains correct

The change here is purely formatting; FrmAppHelper::make_affiliate_url( $link ); is still called in the same place in the pipeline before UTM tagging, so behavior is unchanged and correct.

classes/helpers/FrmHtmlHelper.php (1)

76-111: Unit input attribute merge unchanged

Only whitespace around $input_number_attrs = array_merge(...) changed; attribute computation (type, value, class) is intact, so the rendered input remains identical.

classes/helpers/FrmAppHelper.php (1)

437-445: Admin-page detection logic untouched

The only change here is spacing on the $page assignment; the logic for detecting Formidable admin pages is identical and remains correct.

classes/helpers/FrmCSVExportHelper.php (1)

505-523: Entry batching query unchanged

The $where array for FrmEntry::getAll() is identical aside from whitespace, preserving the intended parent/child query optimization for Pro vs Lite.

classes/models/FrmFormMigrator.php (1)

41-52: Migrator state defaults preserved

Only spacing on $fields_map and $current_section initializations changed; both still default to empty arrays, so migration logic is unaffected.

classes/models/FrmField.php (1)

8-17: Static cache flag unchanged

public static $use_cache still defaults to true; only whitespace changed, leaving all caching behavior intact.

classes/views/frm-fields/back-end/settings.php (1)

222-222: LGTM! Whitespace normalization.

This formatting change improves code consistency without affecting functionality.

classes/helpers/FrmDashboardHelper.php (1)

192-192: LGTM! Removed unused loop index.

The loop index $i was never referenced in the loop body, so removing it simplifies the code without affecting functionality.

classes/models/FrmCreateFile.php (1)

36-41: LGTM! Whitespace normalization.

These formatting changes improve code consistency in property declarations without affecting functionality.

classes/controllers/FrmStylesController.php (2)

295-295: LGTM! Removed unused variable fetch.

The settings were fetched but never used in this function. Removing the unused variable improves code clarity.


347-347: LGTM! Whitespace normalization.

These formatting changes improve code consistency in array initialization without affecting functionality.

Also applies to: 365-365

classes/helpers/FrmFormsListHelper.php (3)

30-30: LGTM! Removed unused global declaration.

The $wpdb global was declared but never used in the prepare_items() method. Removing it reduces unnecessary global scope pollution.


56-56: LGTM! Whitespace normalization.

This formatting change improves code consistency without affecting functionality.


240-240: LGTM! Removed unused global declaration.

The $frm_vars global was declared but never used in the single_row() method. Removing it reduces unnecessary global scope pollution.

tests/phpunit/stripe/FrmStrpLiteUnitTest.php (1)

452-452: LGTM! Whitespace normalization.

This formatting change improves code consistency without affecting test functionality.

stripe/controllers/FrmStrpLiteActionsController.php (1)

320-320: LGTM! Whitespace normalization.

This formatting change improves code consistency without affecting functionality.

@Crabcyborg Crabcyborg changed the title Fix some phpcs warnings Fix some phpcs warnings and treat another warning as error Dec 22, 2025
@Crabcyborg Crabcyborg merged commit 450e33c into master Dec 22, 2025
36 checks passed
@Crabcyborg Crabcyborg deleted the fix_some_phpcs_warnings branch December 22, 2025 14:24
@Crabcyborg Crabcyborg changed the title Fix some phpcs warnings and treat another warning as error Fix some phpcs warnings Dec 22, 2025
@coderabbitai coderabbitai Bot mentioned this pull request Jan 21, 2026
@coderabbitai coderabbitai Bot mentioned this pull request Mar 11, 2026
stephywells pushed a commit that referenced this pull request Apr 4, 2026
Fix some phpcs warnings and treat another warning as error
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