Skip to content

Conversation

@Crabcyborg
Copy link
Contributor

@Crabcyborg Crabcyborg commented Jan 27, 2026

…ling update_option

Summary by CodeRabbit

  • New Features

    • Added a new code analysis tool to enforce consistent option handling standards across the codebase.
  • Chores

    • Updated internal option storage mechanisms to use standardized parameter formats for improved consistency.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 27, 2026

📝 Walkthrough

Walkthrough

The PR standardizes the autoload parameter in update_option() calls across the codebase by replacing string values ('yes'/'no') with their boolean equivalents (true/false), and adds a PHP_CodeSniffer sniff to enforce this pattern in future code.

Changes

Cohort / File(s) Summary
Controller Updates
classes/controllers/FrmAddonsController.php, FrmAppController.php, FrmDashboardController.php, FrmOnboardingWizardController.php, FrmOverlayController.php, FrmSettingsController.php
Changed update_option() autoload parameter from string 'no' to boolean false across six controller methods.
Helper Updates
classes/helpers/FrmAppHelper.php, FrmFormMigratorsHelper.php
Changed update_option() autoload parameter from string 'no' to boolean false in two helper methods.
Model Updates
classes/models/FrmFormState.php, FrmFormTemplateApi.php, FrmInbox.php, FrmPluginSearch.php, FrmUsage.php, FrmStyle.php
Changed update_option() autoload parameter from string 'no' to boolean false across six model methods.
Settings Model
classes/models/FrmSettings.php
Changed update_option() autoload parameter from string 'yes' to boolean true in translate_settings method.
CodeSniffer Sniff
phpcs-sniffs/Formidable/Sniffs/CodeAnalysis/UpdateOptionAutoloadBooleanSniff.php
New sniff implementation (176 lines) that detects update_option() calls with string autoload parameters ('yes'/'no') and converts them to boolean equivalents (true/false) with automatic fixes. Includes argument parsing, token replacement, and normalization helpers.
Sniff Configuration
phpcs-sniffs/Formidable/ruleset.xml
Added new rule reference Formidable.CodeAnalysis.UpdateOptionAutoloadBoolean to the Formidable ruleset.
Square Integration
square/helpers/FrmSquareLiteConnectHelper.php
Changed seven update_option() calls from string 'no' to boolean false across multiple credential and state updates.
Stripe Integration
stripe/helpers/FrmStrpLiteConnectHelper.php
Changed six update_option() calls from string 'no' to boolean false across initialization and OAuth methods.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 A rabbit hops through code so neat,
Converting strings to booleans sweet,
No more confusing 'yes' and 'no,'
True and false now steal the show!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: introducing a new sniff to enforce boolean autoload parameters in update_option calls, replacing deprecated string values.
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.

@Crabcyborg Crabcyborg merged commit e5dc093 into master Jan 27, 2026
37 of 38 checks passed
@Crabcyborg Crabcyborg deleted the new_sniff_to_enforce_bool_for_wp_update_option_autoload_function branch January 27, 2026 19:12
Copy link
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: 2

🤖 Fix all issues with AI agents
In
`@phpcs-sniffs/Formidable/Sniffs/CodeAnalysis/UpdateOptionAutoloadBooleanSniff.php`:
- Around line 142-146: The level tracking in UpdateOptionAutoloadBooleanSniff is
incrementing for T_OPEN_SHORT_ARRAY but not decrementing for its counterpart;
update the conditional that decrements $level (currently checking
T_CLOSE_PARENTHESIS and T_CLOSE_SQUARE_BRACKET) to also check for
T_CLOSE_SHORT_ARRAY so short-array brackets "[]" properly balance with the
T_OPEN_SHORT_ARRAY token during argument parsing.
- Around line 150-152: The condition using "false === $argStart" in
UpdateOptionAutoloadBooleanSniff is wrong because $argStart is initialized to
null, so update the check to "null === $argStart" (or "! isset($argStart)" /
"$argStart === null") so the condition can ever be true, or simply remove the
entire "false === $argStart" branch if the later null-check already covers this
case; target the comparison using the $argStart variable and the existing "false
=== $argStart" expression for the change.

Comment on lines +142 to +146
if ( $code === T_OPEN_PARENTHESIS || $code === T_OPEN_SHORT_ARRAY || $code === T_OPEN_SQUARE_BRACKET ) {
$level++;
} elseif ( $code === T_CLOSE_PARENTHESIS || $code === T_CLOSE_SQUARE_BRACKET ) {
$level--;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Missing T_CLOSE_SHORT_ARRAY in level decrement.

The level tracking correctly increments for T_OPEN_SHORT_ARRAY but the decrement only handles T_CLOSE_PARENTHESIS and T_CLOSE_SQUARE_BRACKET. This could cause incorrect argument parsing for code containing short array syntax [...].

🐛 Proposed fix
 			if ( $code === T_OPEN_PARENTHESIS || $code === T_OPEN_SHORT_ARRAY || $code === T_OPEN_SQUARE_BRACKET ) {
 				$level++;
-			} elseif ( $code === T_CLOSE_PARENTHESIS || $code === T_CLOSE_SQUARE_BRACKET ) {
+			} elseif ( $code === T_CLOSE_PARENTHESIS || $code === T_CLOSE_SQUARE_BRACKET || $code === T_CLOSE_SHORT_ARRAY ) {
 				$level--;
 			}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if ( $code === T_OPEN_PARENTHESIS || $code === T_OPEN_SHORT_ARRAY || $code === T_OPEN_SQUARE_BRACKET ) {
$level++;
} elseif ( $code === T_CLOSE_PARENTHESIS || $code === T_CLOSE_SQUARE_BRACKET ) {
$level--;
}
if ( $code === T_OPEN_PARENTHESIS || $code === T_OPEN_SHORT_ARRAY || $code === T_OPEN_SQUARE_BRACKET ) {
$level++;
} elseif ( $code === T_CLOSE_PARENTHESIS || $code === T_CLOSE_SQUARE_BRACKET || $code === T_CLOSE_SHORT_ARRAY ) {
$level--;
}
🤖 Prompt for AI Agents
In
`@phpcs-sniffs/Formidable/Sniffs/CodeAnalysis/UpdateOptionAutoloadBooleanSniff.php`
around lines 142 - 146, The level tracking in UpdateOptionAutoloadBooleanSniff
is incrementing for T_OPEN_SHORT_ARRAY but not decrementing for its counterpart;
update the conditional that decrements $level (currently checking
T_CLOSE_PARENTHESIS and T_CLOSE_SQUARE_BRACKET) to also check for
T_CLOSE_SHORT_ARRAY so short-array brackets "[]" properly balance with the
T_OPEN_SHORT_ARRAY token during argument parsing.

Comment on lines +150 to +152
if ( false === $argStart ) {
continue;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Type mismatch in comparison - $argStart initialized as null but compared to false.

$argStart is initialized as null on line 135, but the condition on line 150 checks false === $argStart. In PHP, false === null evaluates to false, so this condition will never be true. This appears to be dead code or a bug.

🐛 Proposed fix
-			if ( false === $argStart ) {
+			if ( null === $argStart && $tokens[ $i ]['code'] === T_WHITESPACE ) {
 				continue;
 			}

Or simply remove this block if the intent is already handled by line 169's condition.

🤖 Prompt for AI Agents
In
`@phpcs-sniffs/Formidable/Sniffs/CodeAnalysis/UpdateOptionAutoloadBooleanSniff.php`
around lines 150 - 152, The condition using "false === $argStart" in
UpdateOptionAutoloadBooleanSniff is wrong because $argStart is initialized to
null, so update the check to "null === $argStart" (or "! isset($argStart)" /
"$argStart === null") so the condition can ever be true, or simply remove the
entire "false === $argStart" branch if the later null-check already covers this
case; target the comparison using the $argStart variable and the existing "false
=== $argStart" expression for the change.

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.

2 participants