Skip to content

Further improve whitespace consistency after end curly braces#2770

Merged
Crabcyborg merged 1 commit into
masterfrom
further_improve_whitespace_consistency
Jan 10, 2026
Merged

Further improve whitespace consistency after end curly braces#2770
Crabcyborg merged 1 commit into
masterfrom
further_improve_whitespace_consistency

Conversation

@Crabcyborg
Copy link
Copy Markdown
Contributor

No description provided.

@Crabcyborg Crabcyborg added this to the 6.27 milestone Jan 10, 2026
@Crabcyborg Crabcyborg merged commit d702eae into master Jan 10, 2026
36 of 38 checks passed
@Crabcyborg Crabcyborg deleted the further_improve_whitespace_consistency branch January 10, 2026 03:01
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 10, 2026

Walkthrough

This PR consists primarily of formatting and whitespace adjustments across multiple files, with several localized logic enhancements including stylesheet URL storage, JSON encoding in XML migration methods, field metadata population in duplicate detection, and expanded array-access handling in PHP code sniffer rules.

Changes

Cohort / File(s) Summary
Formatting & Whitespace
classes/controllers/FrmEmailStylesController.php, classes/controllers/FrmEntriesController.php, classes/controllers/FrmFormTemplatesController.php, classes/controllers/FrmFormsController.php, classes/helpers/FrmFieldsHelper.php, classes/helpers/FrmStylesCardHelper.php, classes/models/FrmApplicationTemplate.php, classes/models/FrmEntryMeta.php, classes/models/FrmField.php, classes/models/FrmInbox.php, classes/models/fields/FrmFieldCaptcha.php, stripe/models/FrmStrpLiteAuth.php, tests/phpunit/emails/test_FrmEmail.php
Blank lines added for improved code readability and spacing consistency; no functional or control-flow changes
Stylesheet & Style Processing
classes/controllers/FrmStylesController.php
Adds assignment of stylesheet URL to $stylesheet_urls['formidable'] array; introduces conditional mapping for 'alt_bg_color' to use 'bg_color_active' post_content key instead
XML & Email Migration
classes/helpers/FrmXMLHelper.php
Introduces JSON encoding of post_content in migrate_post_settings_to_action and migrate_email_settings_to_action; modifies format_email_to_data to join email_to entries into comma-separated string
Entry & Field Data Processing
classes/models/FrmEntry.php, classes/models/FrmForm.php
Expands field_metas population in is_duplicate to include all field meta values; ensures all fields are recorded to field_array in update_fields regardless of submission status
PHP Code Quality Sniff
phpcs-sniffs/Formidable/Sniffs/WhiteSpace/BlankLineAfterClosingBraceSniff.php
Extends blank-line validation logic to handle array-access patterns (e.g., $arr[...]=...) by detecting and processing square brackets before assignment tokens

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning No description was provided by the author, making it impossible to evaluate whether it is related to the changeset. Add a meaningful pull request description explaining the purpose of the whitespace improvements and how they enhance code consistency.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Further improve whitespace consistency after end curly braces' accurately describes the primary objective of the PR, which involves adding blank lines after closing braces throughout the codebase for consistent formatting.
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

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

Caution

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

⚠️ Outside diff range comments (3)
classes/controllers/FrmStylesController.php (1)

1305-1318: Avoid potential undefined-index notices when mapping alt_bg_colorbg_color_active.

If a style doesn’t have bg_color_active (older defaults, partial post_content, etc.), $style->post_content[ $setting ] will throw notices. Safer to fall back to the existing $val (or $style->post_content[ $name ]) when missing.

Proposed tweak
 			if ( 'border_width' === $name ) {
 				$setting = 'field_border_width';
 			} elseif ( 'alt_bg_color' === $name ) {
 				$setting = 'bg_color_active';
 			}
 
-			$default_styles[ $name ] = $style->post_content[ $setting ];
+			$default_styles[ $name ] = $style->post_content[ $setting ] ?? $style->post_content[ $name ] ?? $val;
 			unset( $name, $val );
phpcs-sniffs/Formidable/Sniffs/WhiteSpace/BlankLineAfterClosingBraceSniff.php (1)

60-98: Handle chained array access (e.g., $a[0][1] = ...) before assignment.

Current logic skips only one [...] segment; a second bracket will cause a false negative.

Proposed fix (loop through consecutive bracketed segments)
-			$checkToken = $nextToken;
-
-			// If followed by array access, skip to after the closing bracket.
-			if ( $tokens[ $nextToken ]['code'] === T_OPEN_SQUARE_BRACKET ) {
-				// Find the matching closing bracket.
-				if ( isset( $tokens[ $nextToken ]['bracket_closer'] ) ) {
-					$closeBracket = $tokens[ $nextToken ]['bracket_closer'];
-					$checkToken   = $phpcsFile->findNext( T_WHITESPACE, $closeBracket + 1, null, true );
-
-					if ( false === $checkToken ) {
-						return;
-					}
-				} else {
-					return;
-				}
-			}
+			$checkToken = $nextToken;
+
+			// If followed by array access, skip to after the closing bracket(s).
+			while ( isset( $tokens[ $checkToken ] ) && $tokens[ $checkToken ]['code'] === T_OPEN_SQUARE_BRACKET ) {
+				if ( ! isset( $tokens[ $checkToken ]['bracket_closer'] ) ) {
+					return;
+				}
+				$closeBracket = $tokens[ $checkToken ]['bracket_closer'];
+				$checkToken   = $phpcsFile->findNext( T_WHITESPACE, $closeBracket + 1, null, true );
+				if ( false === $checkToken ) {
+					return;
+				}
+			}
classes/helpers/FrmXMLHelper.php (1)

1953-2025: Use FrmAppHelper::prepare_and_encode() for consistency and add null guard for switch_action_field_ids() return value.

When $switch is true and switch_action_field_ids() returns null (when $frm_duplicate_ids is empty), json_encode(null) becomes the literal string "null" in the database. Additionally, this code should use FrmAppHelper::prepare_and_encode() instead of raw json_encode() to match the codebase standard applied everywhere else (FrmOnSubmitHelper, migrate_email_settings_to_action, FrmDb::save_settings, tests). The prepare_and_encode method handles critical slash escaping for escape sequences like \r, \n, \u, \t.

Recommended fix
-		$new_action['post_content'] = json_encode( $new_action['post_content'] );
+		if ( null === $new_action['post_content'] ) {
+			$new_action['post_content'] = array();
+		}
+		$new_action['post_content'] = FrmAppHelper::prepare_and_encode( $new_action['post_content'] );
🧹 Nitpick comments (1)
classes/helpers/FrmXMLHelper.php (1)

2256-2282: Joining email_to into a string is fine, but consider trimming/filtering empties.

preg_split can yield empty items; imploding them can produce ", , " sequences.

Optional hardening
-		$atts['email_to'] = implode( ', ', $atts['email_to'] );
+		$atts['email_to'] = implode(
+			', ',
+			array_values(
+				array_filter(
+					array_map( 'trim', $atts['email_to'] ),
+					'strlen'
+				)
+			)
+		);
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4f30f58 and 07b1e4c.

📒 Files selected for processing (18)
  • classes/controllers/FrmEmailStylesController.php
  • classes/controllers/FrmEntriesController.php
  • classes/controllers/FrmFormTemplatesController.php
  • classes/controllers/FrmFormsController.php
  • classes/controllers/FrmStylesController.php
  • classes/helpers/FrmFieldsHelper.php
  • classes/helpers/FrmStylesCardHelper.php
  • classes/helpers/FrmXMLHelper.php
  • classes/models/FrmApplicationTemplate.php
  • classes/models/FrmEntry.php
  • classes/models/FrmEntryMeta.php
  • classes/models/FrmField.php
  • classes/models/FrmForm.php
  • classes/models/FrmInbox.php
  • classes/models/fields/FrmFieldCaptcha.php
  • phpcs-sniffs/Formidable/Sniffs/WhiteSpace/BlankLineAfterClosingBraceSniff.php
  • stripe/models/FrmStrpLiteAuth.php
  • tests/phpunit/emails/test_FrmEmail.php
⏰ 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). (9)
  • GitHub Check: PHP 8 tests in WP 6.9
  • GitHub Check: PHP 7.4 tests in WP 6.9
  • GitHub Check: Cypress
  • GitHub Check: PHP 8 tests in WP 6.9
  • GitHub Check: PHP 7.4 tests in WP 6.9
  • GitHub Check: Cypress
  • GitHub Check: PHP 8 tests in WP 6.9
  • GitHub Check: PHP 7.4 tests in WP 6.9
  • GitHub Check: Cypress
🔇 Additional comments (20)
classes/models/FrmInbox.php (1)

462-462: LGTM! Formatting improvement enhances readability.

The blank line added after the parse_str block provides clear visual separation between parsing the query string and modifying it, making the code flow more evident.

tests/phpunit/emails/test_FrmEmail.php (1)

373-373: LGTM! Consistent formatting improvement in test code.

The blank line clearly separates the sitename normalization logic from its usage, improving test readability.

classes/controllers/FrmFormTemplatesController.php (1)

569-569: LGTM! Improves visual structure of category organization.

The blank line provides clear separation between the conditional category addition and the final 'all-items' category definition, making the special categories section more scannable.

classes/helpers/FrmStylesCardHelper.php (1)

276-276: LGTM! Enhances logical grouping in style parameter generation.

The blank line effectively separates the background color determination logic from the subsequent style rules application, improving code structure and readability.

stripe/models/FrmStrpLiteAuth.php (1)

376-376: LGTM! Clarifies control flow in intent processing.

The blank line provides clear visual separation after the setup intent check and before payment intent processing, making the logic flow easier to follow.

classes/controllers/FrmEntriesController.php (1)

255-263: Whitespace-only change looks good. This improves readability and matches the PR objective.

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

321-330: Whitespace-only change looks good. No logic impact.

classes/controllers/FrmFormsController.php (2)

1224-1236: Whitespace-only change looks good.


1609-1616: Whitespace-only change looks good.

classes/helpers/FrmFieldsHelper.php (1)

1812-1824: Whitespace-only change looks good.

classes/controllers/FrmEmailStylesController.php (1)

303-312: Whitespace-only change looks good.

classes/models/FrmEntry.php (1)

106-121: Functional change in a “whitespace” PR: please double-check duplicate-detection equivalence. The new $field_metas[ $meta->field_id ] = $meta->meta_value mapping is sensible, but it relies on FrmEntryMeta::get_entry_meta_info() returning values in the same (serialized vs non-serialized) form you later compare against array_map( 'maybe_serialize', ...).

classes/models/FrmField.php (1)

694-703: Whitespace-only change in serialization block looks good.

classes/models/FrmApplicationTemplate.php (1)

192-205: Formatting-only spacing improvements are fine; no behavior change spotted.

Also applies to: 210-226

classes/models/FrmEntryMeta.php (2)

361-370: No-op spacing change in meta_field_query is fine.


552-560: No-op spacing change in get_ids_query is fine.

classes/controllers/FrmStylesController.php (1)

240-250: Explicitly keying the stylesheet URL by the formidable handle is the right direction.

classes/models/FrmForm.php (1)

356-367: Unconditionally populating $field_array improves reliability and avoids extra lookups.

classes/helpers/FrmXMLHelper.php (2)

776-799: Whitespace-only adjustment in placeholder migration block is fine.


2082-2137: This concern is unfounded. FrmDb::save_json_post does not encode post_content—it passes the settings array directly to wp_insert_post, which saves the string value as-is.

The prepare_and_encode function correctly returns a JSON-encoded string, which is the expected format for post_content when saving via save_json_post. There is no double encoding, and the contract is being followed correctly throughout the codebase.

Likely an incorrect or invalid review comment.

stephywells pushed a commit that referenced this pull request Apr 4, 2026
…onsistency

Further improve whitespace consistency after end curly braces
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