Skip to content

Add return type comments and more missing param type comments#2609

Merged
Crabcyborg merged 20 commits into
masterfrom
add_return_type_comments
Nov 27, 2025
Merged

Add return type comments and more missing param type comments#2609
Crabcyborg merged 20 commits into
masterfrom
add_return_type_comments

Conversation

@Crabcyborg
Copy link
Copy Markdown
Contributor

@Crabcyborg Crabcyborg commented Nov 27, 2025

We no longer ignore the '#has no return type specified#' and '#with no type specified#' substrings from PHPStan with this update.

I've kept some exceptions for '#has no return type specified#' where the function really dies and never returns. I don't think never works consistently yet across PHP versions though.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Nov 27, 2025

Walkthrough

This PR introduces widespread PHPDoc documentation improvements across ~100+ files, primarily adding return type and parameter annotations to existing methods without altering their signatures. Key functional additions include new addon license management methods in FrmAddon, enhanced CSV export parameter/header handling, new unread inbox retrieval in FrmInbox, new FrmFormState getter method, and invoice handling improvements in Stripe payment processing. Configuration changes to phpstan.neon shift ignore rules from global to file-scoped patterns.

Changes

Cohort / File(s) Summary
Core PHPDoc Annotations across Controllers
classes/controllers/FrmAddonsController.php, FrmAppController.php, FrmCronController.php, FrmEmailStylesController.php, FrmEmailSummaryController.php, FrmEntriesController.php, FrmFieldsController.php, FrmFormTemplatesController.php, FrmOnboardingWizardController.php, FrmSettingsController.php, FrmUsageController.php, FrmWelcomeTourController.php, FrmXMLController.php, FrmStylesController.php, FrmFormActionsController.php, FrmFormsController.php
Added PHPDoc blocks documenting return types and parameters for numerous public/protected methods without changing signatures or control flow.
Core PHPDoc Annotations across Helpers
classes/helpers/FrmCSVExportHelper.php, FrmEmailSummaryHelper.php, FrmEntriesListHelper.php, FrmFieldGridHelper.php, FrmFormActionsHelper.php, FrmFormMigratorsHelper.php, FrmFormTemplatesHelper.php, FrmOnSubmitHelper.php, FrmShortcodeHelper.php, FrmStylesHelper.php, FrmSubmitHelper.php, FrmTipsHelper.php, FrmAppHelper.php, FrmEntriesHelper.php, FrmFieldsHelper.php, FrmFormsHelper.php, FrmListHelper.php, FrmXMLHelper.php
Added comprehensive PHPDoc blocks to methods specifying parameter and return types. FrmCSVExportHelper also expanded set_class_parameters() with additional filter applications and print_file_headers() with enhanced header output.
Core PHPDoc Annotations across Models
classes/models/FrmAntiSpam.php, FrmCreateFile.php, FrmDb.php, FrmEmail.php, FrmEmailStats.php, FrmEntryShortcodeFormatter.php, FrmFieldOption.php, FrmFieldValue.php, FrmFormApi.php, FrmFormTemplateApi.php, FrmHoneypot.php, FrmInstallPlugin.php, FrmInstallerSkin.php, FrmPersonalData.php, FrmSalesApi.php, FrmSettings.php, FrmSolution.php, FrmSpamCheck.php, FrmSpamCheckDenylist.php, FrmStyle.php, FrmEntry.php, FrmEntryMeta.php, FrmEntryValidate.php, FrmField.php, FrmForm.php, FrmFormAction.php, FrmFormMigrator.php, FrmMigrate.php, fields/FrmFieldCaptcha.php, fields/FrmFieldCheckbox.php, fields/FrmFieldCreditCard.php, fields/FrmFieldHidden.php, fields/FrmFieldRadio.php, fields/FrmFieldUserID.php, FrmEntryFormatter.php, FrmFieldFormHtml.php
Added PHPDoc annotations documenting parameters and return types for numerous public/private/protected methods without altering behavior or signatures.
Functional Additions in Dashboard & Overlay
classes/controllers/FrmDashboardController.php
Added private method inbox_clean_messages_cta($cta) to remove dismiss buttons from CTA HTML using regex; invoked by inbox_prepare_messages.
Functional Additions in Overlay
classes/controllers/FrmOverlayController.php
Added public constructor __construct($config = array()) with config validation, recurring execution enablement, and options data initialization.
Functional Additions in Form State & Inbox
classes/models/FrmFormState.php, FrmInbox.php
Added public instance method get($key, $default) to FrmFormState for state retrieval. Added public method unread() to FrmInbox returning array of unread messages; updated get_messages() docblock.
Extensive Functional Additions in Addon Management
classes/models/FrmAddon.php
Added ~25 new public/private methods for license management: insert_installed_addon(), get_addon(), edd_plugin_updater(), get/set_license(), is_active(), clear_license(), set_active(), clear_expired_download(), activate(), activate_license_for_plugin(), send_mothership_request(), manually_queue_update(), plus supporting private methods for license status, caching, concurrency, and API communication.
Payment Processing Enhancements
square/helpers/FrmSquareLiteConnectHelper.php, stripe/controllers/FrmStrpLiteEventsController.php, stripe/helpers/FrmStrpLiteConnectHelper.php, stripe/helpers/FrmTransLiteAppHelper.php, stripe/helpers/FrmTransLiteListHelper.php, stripe/models/FrmStrpLiteSettings.php, stripe/models/FrmTransLiteDb.php, stripe/models/FrmStrpLiteAuth.php, square/models/FrmSquareLiteSettings.php, stripe/controllers/FrmTransLiteHooksController.php, stripe/controllers/FrmTransLiteListsController.php, stripe/helpers/FrmStrpLiteConnectApiAdapter.php, stripe/helpers/FrmStrpLiteLinkRedirectHelper.php
Added/updated comprehensive PHPDoc blocks for payment processing methods. Modified create_payment() in square helper to build explicit payload (amount, currency, square_token, verification_token, description). Added prepare_from_invoice() in Stripe with invoice-to-payment derivation logic and subscription management. Added ~4 new public methods to FrmTransLiteDb (get_all_by, get_all_for_user, get_all_for_entry, get_count) and updated get_one() docblock. Added input validation for orderby/order in FrmTransLiteListHelper::prepare_items().
Core Field Types Documentation
classes/models/fields/FrmFieldType.php
Added PHPDoc annotations to numerous protected/public methods documenting parameter and return types.
Factory & View Components Documentation
classes/factories/FrmFieldFactory.php, classes/views/styles/components/FrmSliderStyleComponent.php, FrmStyleComponent.php, classes/views/styles/components/FrmStyleComponent.php, classes/widgets/FrmElementorWidget.php, FrmShowForm.php
Added PHPDoc blocks documenting parameters and return types for component constructors and methods.
Deprecated Stubs
deprecated/FrmEDD_SL_Plugin_Updater.php
Added three public stub methods: show_changelog(), get_cached_version_info($cache_key = ''), set_version_info_cache($value = '', $cache_key = '') with deprecation notices and minimal implementations.
PHPStan Configuration
phpstan.neon
Restructured global ignore patterns into file-scoped rules: replaced broad global ignore patterns with specific file-scoped ignores for "#has no return type specified#", "#with no value type specified#", and "#with no type specified#" targeting large sets of controllers, helpers, models, and stubs.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~70 minutes

Areas requiring extra attention:

  • classes/models/FrmAddon.php — Largest functional addition with 25+ new methods implementing license activation, update management, API communication, concurrency control, and caching logic; requires careful review of license flow, error handling, and state management.
  • stripe/models/FrmTransLiteDb.php — Four new public query methods (get_all_by, get_all_for_user, get_all_for_entry, get_count) with validation and database interactions; verify input sanitization and query correctness.
  • stripe/controllers/FrmStrpLiteEventsController.php — New prepare_from_invoice() method with complex payment derivation and subscription state changes; verify invoice-to-payment mapping and subscription cancellation logic.
  • square/helpers/FrmSquareLiteConnectHelper.php — Modified create_payment() payload structure; verify new payload format matches Square API expectations.
  • phpstan.neon — Major restructuring of ignore rules from global to file-scoped patterns; ensure all targeted files are correctly scoped and no unintended rule removals affect type checking.
  • classes/helpers/FrmCSVExportHelper.php — Enhanced parameter and header initialization with multiple filter applications; verify filter order and charset/column separator logic.

Possibly related PRs

  • Move some phpstan exceptions to problematic files only #2236 — Modifies phpstan.neon to shift from broad global ignore patterns to file-scoped rules, directly parallel to this PR's phpstan configuration restructuring.
  • New sales API #2205 — Modifies FrmInbox and FrmAddon classes adding inbox/upgrade/sales flows; overlaps with this PR's new FrmInbox::unread() and extensive FrmAddon license management additions.
  • Square payments #2229 — Touches Square payments integration in FrmSquareLiteConnectHelper and related classes; overlaps with this PR's Square payment processing enhancements.

Suggested reviewers

  • lauramekaj1

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding return type comments and parameter type comments throughout the codebase to comply with stricter PHPStan rules.
Docstring Coverage ✅ Passed Docstring coverage is 99.06% which is sufficient. The required threshold is 80.00%.
Description check ✅ Passed The PR description accurately describes the changeset: adding return type comments and param type comments to address PHPStan compliance by removing previous ignore patterns.
✨ 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 add_return_type_comments

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

Caution

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

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

504-509: Documentation mismatch: docstring describes wrong functionality.

The docblock for get_page_url() states "Get the path to the Onboarding Wizard views" (lines 504-509), but this method actually returns the URL to access the page, not the filesystem path. The description appears to be copied from get_view_path(). This is a pre-existing documentation error unrelated to this PR's changes, but worth correcting.

Suggested fix:

 	/**
-	 * Get the path to the Onboarding Wizard views.
+	 * Get the URL to access the Onboarding Wizard page.
 	 *
 	 * @since 6.9
 	 *
-	 * @return string Path to views.
+	 * @return string URL to access the Onboarding Wizard page.
 	 */
 	public static function get_page_url() {
 		return self::$page_url;
 	}
classes/helpers/FrmTipsHelper.php (1)

398-402: Add empty array guard to prevent runtime exception.

If $tips is an empty array, count($tips) - 1 equals -1, causing random_int(0, -1) to throw a ValueError because the minimum exceeds the maximum. This can crash the application when any tip-generation method returns an empty array.

Apply this diff to add a guard:

 public static function get_random_tip( $tips ) {
+	if ( empty( $tips ) ) {
+		return array();
+	}
 	$random = random_int( 0, count( $tips ) - 1 );
 
 	return $tips[ $random ];
 }
classes/controllers/FrmStylesController.php (1)

837-849: Add null check for get_default_style() return value to prevent potential null dereference.

The FrmStyle::get_default_style() method (line 566 in classes/models/FrmStyle.php) can implicitly return null if the foreach loop doesn't find a style with a truthy menu_order value. Line 846 in get_custom_css() directly accesses $style->post_content['custom_css'] without null protection, which will fail if get_default_style() returns null.

Recommended fix:

$style = $frm_style->get_default_style();
if ( $style && isset( $style->post_content['custom_css'] ) ) {
    $custom_css = $style->post_content['custom_css'];
} else {
    $custom_css = '';  // or appropriate fallback
}
🧹 Nitpick comments (23)
classes/models/fields/FrmFieldCreditCard.php (1)

24-26: @return array annotation matches implementation

The new docblock correctly documents the return type as array for field_settings_for_type(), which always returns the $settings array literal. If you want to go further for static analysis, you could narrow it to something like @return array<string,bool> (or a shaped array), but that’s optional given the current project style.

classes/models/FrmPersonalData.php (1)

160-162: Docblock return type is correct; optional clarification.

get_current_page() does return a string (the LIMIT clause), so @return string is accurate and helpful. If you want to go a bit further, you could add a short description (e.g., “SQL LIMIT string for the current page”) to make its purpose clearer to readers and static analyzers.

classes/models/FrmFieldOption.php (1)

37-43: Constructor docblock looks correct; optional opportunity to tighten $args type

The param/return annotations here are consistent with the properties and constructor behavior, and adding @return void is fine for tooling and readability. If you know the expected structure of $args, you could optionally narrow it (e.g., array<string,mixed>) to give static analysis a bit more signal, but it’s not required for this PR’s goal.

classes/models/FrmInstallPlugin.php (1)

28-28: Consider removing the unused $file variable.

The list() unpacking assigns to both $slug and $file, but $file is never used. You can simplify this by using array destructuring with underscore or extracting only what's needed.

Apply this diff to clean up the unused variable:

-		list( $slug, $file ) = explode( '/', $this->plugin_file );
+		list( $slug ) = explode( '/', $this->plugin_file );

Alternatively, using modern PHP array destructuring:

-		list( $slug, $file ) = explode( '/', $this->plugin_file );
+		[ $slug ] = explode( '/', $this->plugin_file );
classes/models/FrmFormApi.php (1)

263-267: Return type docblock matches implementation; consider narrowing from object if possible

The new @return false|object accurately reflects the two return paths ($updater or false). If the updater has a stable concrete class or interface in this codebase, you might optionally tighten this to false|SomeUpdaterClass (or similar) for better static analysis and IDE support, but the current annotation is correct and safe.

classes/helpers/FrmShortcodeHelper.php (1)

131-138: PHPDoc matches method signature and behavior

The parameter and return types in the new docblock correctly reflect the method’s current signature and side‑effect‑only behavior. If you want to be extra explicit, you could denote $html as by‑reference (e.g., @param string &$html or a short description mentioning it’s modified in place), but that’s optional given the signature already shows &.

classes/models/FrmFormState.php (1)

77-85: Docblock and getter behavior look good; consider adding an @since tag

The get( $key, $default ) implementation is straightforward and correctly mirrors the pattern used by get_from_request, and the docblock accurately reflects the signature and return value. Since this is a new public accessor method, you may want to add an @since tag to the docblock for API clarity and consistency with other documented entry points.

classes/helpers/FrmOnSubmitHelper.php (1)

140-150: Observation: Pre-existing cache bug in get_actions().

Outside the scope of this PR, but line 148 calls wp_cache_set( $cache_key, 'frm_actions' ) with only two arguments. The signature is wp_cache_set( $key, $data, $group ), so the cache group is being passed as the value, and $actions is never cached. This should be wp_cache_set( $cache_key, $actions, 'frm_actions' ). Worth addressing separately if not already known.

classes/models/FrmInstallerSkin.php (1)

49-103: Optional: add @return void to other void methods for consistency

header(), footer(), error(), and feedback() also return nothing; consider adding @return void to their docblocks to fully align this class with the PR’s “add return type comments” objective.

classes/models/FrmCreateFile.php (1)

189-191: Verify return type precision for get_creds().

The return type is documented as array|bool. However, examining the code flow:

  • Line 199: request_filesystem_credentials() returns array|false (not true)
  • Line 201: get_ftp_creds() returns array|false (documented at line 210)

Using array|false would be more precise and consistent with the get_ftp_creds() return type on line 210. Consider updating this for consistency.

classes/helpers/FrmFormMigratorsHelper.php (1)

114-121: Consider refactoring for consistency.

The PHPDoc accurately describes the current behavior, but the function mixes two patterns: returning an empty string on early exit (line 121) versus outputting HTML and implicitly returning null. Since the return value is never used (line 33), consider refactoring for clarity:

Option 1: Make it void (preferred for side-effect functions)

 /**
  * @param array $install
  *
- * @return string|null
+ * @return void
  */
 private static function install_banner( $install ) {
     if ( empty( $install['link'] ) ) {
-        return '';
+        return;
     }

Option 2: Use output buffering to always return a string

 private static function install_banner( $install ) {
     if ( empty( $install['link'] ) ) {
         return '';
     }
     
+    ob_start();
     ?>
     <div class="frm-feature-banner">
         <!-- ... HTML ... -->
     </div>
     <?php
+    return ob_get_clean();
 }
classes/models/FrmStyle.php (1)

561-565: Tighten get_default_style() return PHPDoc to match actual types

The implementation returns the same kind of style objects as get_all()/get_one() (i.e., WP_Post or stdClass) or null when none is found. Using object|null is technically correct but overly generic and inconsistent with neighboring docblocks.

Consider narrowing the type for better static analysis and consistency:

-   /**
-    * @param array|null $styles
-    *
-    * @return object|null
-    */
+   /**
+    * @param array|null $styles
+    *
+    * @return stdClass|WP_Post|null
+    */
classes/models/FrmSolution.php (1)

320-323: get_steps_data() return annotation matches implementation (optionally could be more specific)

@return array aligns with the $steps structure returned here and is accurate. If you ever want stricter static analysis, you could later refine this to a keyed array/shape, but it’s not necessary for this PR.

classes/controllers/FrmOverlayController.php (2)

56-58: Consider enhancing the PHPDoc with config details or cross-reference.

The added PHPDoc accurately documents the parameter type but could be more helpful by either describing the required array structure inline or referencing the detailed documentation at lines 23-31.

Consider one of these approaches:

 /**
- * @param array $config
+ * @param array $config {
+ *     @type string $execution-frequency Time interval for recurring execution (e.g., '1 day', '1 week').
+ *     @type string $config-option-name Handle name for storing overlay options.
+ * }

Or add a cross-reference:

 /**
- * @param array $config
+ * @param array $config See {@see FrmOverlayController::$config} for structure details.
+ * @return void

60-62: Consider adding feedback for invalid configuration.

The constructor silently returns when required config keys are missing, leaving the instance in a non-functional state without notification. While this doesn't cause errors, it could lead to confusion when the overlay doesn't behave as expected.

Consider adding developer feedback:

 public function __construct( $config = array() ) {
 	if ( ! isset( $config['config-option-name'] ) || ! isset( $config['execution-frequency'] ) ) {
+		// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error
+		trigger_error( 'FrmOverlayController requires config-option-name and execution-frequency keys.', E_USER_NOTICE );
 		return;
 	}

Alternatively, validate and throw an exception if the config is required for the instance to function properly.

classes/controllers/FrmEntriesController.php (1)

445-474: (Optional) Consider narrowing the route() return type

route() currently only ever returns null/no meaningful value (calling methods that themselves return void). If there’s no expectation for third‑party overrides to return content, you could narrow its PHPDoc to @return void for clearer static analysis; otherwise mixed is fine.

Also applies to: 112-134

classes/controllers/FrmDashboardController.php (1)

445-456: Consider minor refinements to the regex replacement.

The regex pattern correctly removes dismiss buttons, but consider these optional improvements:

  1. Type safety: The $cta parameter lacks type validation before preg_replace(). Consider adding a type check or type hint.
  2. Whitespace handling: Replacing matches with a single space (line 455) may create extra whitespace. Consider using an empty string '' or adding a trim operation afterward.

Apply this diff to add a type hint and adjust whitespace handling:

 /**
  * Clean messages CTA.
  *
  * @param string $cta
  * @return string
  */
-private static function inbox_clean_messages_cta( $cta ) {
+private static function inbox_clean_messages_cta( string $cta ): string {
 
 	// remove dismiss button
 	$pattern = '/<a[^>]*class="[^"]*frm_inbox_dismiss[^"]*"[^>]*>.*?<\/a>/is';
-	return preg_replace( $pattern, ' ', $cta );
+	return preg_replace( $pattern, '', $cta );
 }
square/helpers/FrmSquareLiteConnectHelper.php (1)

678-682: Consider adding a PHPDoc block for documentation consistency.

While the method logic is straightforward, public methods benefit from documentation, especially regarding return behavior and side effects (disconnects and resets Square API integration).

Apply this diff to add documentation:

+	/**
+	 * Handle disconnect request from AJAX.
+	 *
+	 * @return void
+	 */
 	public static function handle_disconnect() {
 		self::disconnect();
 		self::reset_square_api_integration();
 		wp_send_json_success();
 	}
classes/models/FrmFieldValue.php (1)

112-123: @return mixed annotations match behavior; small message/method-name nit

The new @return mixed docblocks for:

  • get_field_option()
  • get_field_attr()
  • get_saved_value()
  • get_displayed_value()

are consistent with how these methods are currently implemented (they can legitimately surface a variety of types, depending on field config and filters). No functional concerns here.

One minor consistency nit while we’re in this area: in get_displayed_value(), the error message refers to prepare_display_value() but the actual method name is prepare_displayed_value(). Consider tightening this up:

-			return __( 'The display value has not been prepared. Please use the prepare_display_value() method before calling get_displayed_value().', 'formidable' );
+			return __( 'The display value has not been prepared. Please use the prepare_displayed_value() method before calling get_displayed_value().', 'formidable' );

Also applies to: 125-134, 189-210

classes/controllers/FrmAddonsController.php (1)

476-499: Return type of is_license_expired does not match its docblock

The docblock says @return bool, but the method returns either false or $version_info['error'] (an array). Consider either:

  • Normalizing the method to return a strict bool, or
  • Updating the annotation to something like @return bool|array and, ideally, renaming the method to better reflect the non-boolean return.
classes/models/fields/FrmFieldCaptcha.php (1)

402-406: Clarify unused $frm_settings parameter in send_api_check()

The new docblock correctly describes @param FrmSettings $frm_settings and @return array|WP_Error, but the method no longer uses $frm_settings internally (it relies on FrmCaptchaFactory::get_settings_object() instead).

To avoid future confusion, consider noting this in the docblock, e.g.:

-	 * @param FrmSettings $frm_settings
+	 * @param FrmSettings $frm_settings Unused, kept for backwards compatibility.

This keeps the signature stable while signalling that the param isn’t read.

phpstan.neon (2)

34-34: Global ignore for “no value type specified” remains broad

You’ve tightened other “missing type” ignores to specific paths, but '#no value type specified.#' is still a global ignore. If the medium‑term goal is to enforce collection value types project‑wide, consider scoping this pattern to selected files as you did for return types, instead of suppressing it everywhere.

Please double‑check how often this rule currently fires in phpstan and whether further scoping makes sense for your codebase.


137-194: New file‑scoped ignore blocks for return/type messages look fine, but can be tidied

The two new ignoreErrors entries for:

  • '#has no return type specified#'
  • '#with no type specified#'

scoped to a list of concrete file paths are a good step away from blanket suppression.

A couple of minor cleanup points:

  • Some paths are duplicated multiple times (for example classes/models/FrmEntryValidate.php appears more than once in each list).
  • A few entries appear to have trailing spaces (e.g. classes/controllers/FrmEmailStylesController.php ), which may prevent exact path matching depending on how NEON is parsed.

Neither affects correctness dramatically, but deduplicating and trimming would keep the config clearer and avoid surprises if phpstan ever becomes stricter about path matching.

Please run phpstan locally and confirm that:

  • these ignore patterns are actually matching the intended files (no unexpected “unmatched ignored errors”), and
  • you’re not still getting “has no return type specified” / “with no type specified” warnings from files you expected to be covered.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8f08e48 and e18d299.

⛔ Files ignored due to path filters (3)
  • composer.json is excluded by !**/*.json
  • phpcs.xml is excluded by !**/*.xml
  • psalm.xml is excluded by !**/*.xml
📒 Files selected for processing (61)
  • classes/controllers/FrmAddonsController.php (4 hunks)
  • classes/controllers/FrmAppController.php (6 hunks)
  • classes/controllers/FrmCronController.php (1 hunks)
  • classes/controllers/FrmDashboardController.php (1 hunks)
  • classes/controllers/FrmEmailStylesController.php (1 hunks)
  • classes/controllers/FrmEmailSummaryController.php (1 hunks)
  • classes/controllers/FrmEntriesController.php (8 hunks)
  • classes/controllers/FrmFieldsController.php (5 hunks)
  • classes/controllers/FrmFormTemplatesController.php (1 hunks)
  • classes/controllers/FrmOnboardingWizardController.php (1 hunks)
  • classes/controllers/FrmOverlayController.php (1 hunks)
  • classes/controllers/FrmSettingsController.php (10 hunks)
  • classes/controllers/FrmStylesController.php (9 hunks)
  • classes/controllers/FrmUsageController.php (2 hunks)
  • classes/controllers/FrmWelcomeTourController.php (2 hunks)
  • classes/controllers/FrmXMLController.php (2 hunks)
  • classes/factories/FrmFieldFactory.php (1 hunks)
  • classes/helpers/FrmCSVExportHelper.php (13 hunks)
  • classes/helpers/FrmEmailSummaryHelper.php (7 hunks)
  • classes/helpers/FrmEntriesListHelper.php (4 hunks)
  • classes/helpers/FrmFieldGridHelper.php (1 hunks)
  • classes/helpers/FrmFormActionsHelper.php (1 hunks)
  • classes/helpers/FrmFormMigratorsHelper.php (1 hunks)
  • classes/helpers/FrmFormTemplatesHelper.php (1 hunks)
  • classes/helpers/FrmOnSubmitHelper.php (7 hunks)
  • classes/helpers/FrmShortcodeHelper.php (1 hunks)
  • classes/helpers/FrmStylesHelper.php (7 hunks)
  • classes/helpers/FrmSubmitHelper.php (4 hunks)
  • classes/helpers/FrmTipsHelper.php (1 hunks)
  • classes/models/FrmAntiSpam.php (1 hunks)
  • classes/models/FrmCreateFile.php (3 hunks)
  • classes/models/FrmDb.php (5 hunks)
  • classes/models/FrmEmail.php (1 hunks)
  • classes/models/FrmEmailStats.php (2 hunks)
  • classes/models/FrmEntryShortcodeFormatter.php (1 hunks)
  • classes/models/FrmFieldOption.php (1 hunks)
  • classes/models/FrmFieldValue.php (8 hunks)
  • classes/models/FrmFormApi.php (1 hunks)
  • classes/models/FrmFormState.php (1 hunks)
  • classes/models/FrmFormTemplateApi.php (1 hunks)
  • classes/models/FrmHoneypot.php (5 hunks)
  • classes/models/FrmInbox.php (2 hunks)
  • classes/models/FrmInstallPlugin.php (1 hunks)
  • classes/models/FrmInstallerSkin.php (2 hunks)
  • classes/models/FrmPersonalData.php (1 hunks)
  • classes/models/FrmSalesApi.php (1 hunks)
  • classes/models/FrmSettings.php (3 hunks)
  • classes/models/FrmSolution.php (3 hunks)
  • classes/models/FrmSpamCheck.php (1 hunks)
  • classes/models/FrmSpamCheckDenylist.php (7 hunks)
  • classes/models/FrmStyle.php (1 hunks)
  • classes/models/fields/FrmFieldCaptcha.php (2 hunks)
  • classes/models/fields/FrmFieldCheckbox.php (1 hunks)
  • classes/models/fields/FrmFieldCreditCard.php (1 hunks)
  • classes/models/fields/FrmFieldHidden.php (1 hunks)
  • classes/models/fields/FrmFieldRadio.php (1 hunks)
  • classes/models/fields/FrmFieldUserID.php (1 hunks)
  • deprecated/FrmEDD_SL_Plugin_Updater.php (1 hunks)
  • phpstan.neon (2 hunks)
  • square/helpers/FrmSquareLiteConnectHelper.php (7 hunks)
  • stripe/models/FrmStrpLiteAuth.php (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (4)
classes/controllers/FrmSettingsController.php (1)
classes/helpers/FrmStylesHelper.php (1)
  • save_button (27-31)
classes/models/FrmHoneypot.php (1)
classes/models/FrmFormState.php (1)
  • get_from_request (70-75)
classes/controllers/FrmStylesController.php (1)
stubs.php (1)
  • FrmProStylesController (170-193)
square/helpers/FrmSquareLiteConnectHelper.php (1)
stripe/controllers/FrmTransLitePaymentsController.php (1)
  • refund_payment (198-230)
🪛 GitHub Actions: Psalm Code Analysis
classes/controllers/FrmStylesController.php

[error] 846-846: Psalm: PossiblyNullArrayAccess. Cannot access array value on possibly null variable $style->post_content of type mixed|null.

🪛 PHPMD (2.15.0)
classes/models/FrmInstallPlugin.php

28-28: Avoid unused local variables such as '$file'. (undefined)

(UnusedLocalVariable)

deprecated/FrmEDD_SL_Plugin_Updater.php

100-100: Avoid unused parameters such as '$cache_key'. (undefined)

(UnusedFormalParameter)

⏰ 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). (4)
  • GitHub Check: PHP 7.4 tests in WP trunk
  • GitHub Check: PHP 8 tests in WP trunk
  • GitHub Check: PHP 8 tests in WP trunk
  • GitHub Check: PHP 7.4 tests in WP trunk
🔇 Additional comments (93)
classes/helpers/FrmFormActionsHelper.php (1)

15-16: LGTM!

The @return array annotation accurately documents the return type for this method. The change is purely documentation-focused and aligns well with the PR's objective to add return type comments across the codebase.

classes/controllers/FrmWelcomeTourController.php (1)

303-304: PHPDoc return type annotations are accurate and properly documented.

The @return void annotations added to show_completed_links() (lines 303–304) and save_checklist() (lines 521–522) correctly document that both methods perform side effects (output rendering and option updates) without returning values. These additions support static analysis tooling and improve type safety documentation.

Also applies to: 521-522

classes/models/FrmFormTemplateApi.php (1)

69-70: LGTM! The @return void annotation accurately reflects the method's behavior and maintains consistency with other void-returning methods in the class.

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

40-49: Return type annotation is accurate and well-placed.

The @return array PHPDoc correctly documents the method's return type, and the annotation is consistent with existing documentation patterns in the class (e.g., html5_input_type() at line 55).

classes/controllers/FrmEmailSummaryController.php (1)

18-22: Return type docblock accurately reflects method behavior

maybe_send_emails() does not return a value (only early returns without data), so adding @return void is correct and aligns with the PR’s documentation goal.

classes/factories/FrmFieldFactory.php (1)

138-139: PHPDoc return type accurately documents dynamic property access.

The added @return mixed annotation correctly reflects that the method returns a dynamically accessed property which can be of various types depending on the $property parameter. The documentation is properly formatted and aligns with the PR's objective to document return types.

classes/models/FrmSpamCheck.php (1)

22-24: PHPDoc parameter documentation is accurate and well-placed.

The @param array $values annotation correctly documents the constructor parameter and aligns with the property type declaration on line 18. The documentation follows the existing pattern used throughout the file (e.g., return types on other methods).

classes/models/FrmEmailStats.php (1)

128-129: Documentation improvements look good.

The @return void annotations accurately document that these methods modify the $stats array by reference without returning a value. The additions are consistent with the existing PHPDoc style in this file and align with the PR's objective.

Also applies to: 144-145

classes/models/FrmSalesApi.php (1)

488-490: Docblock return type for menu() correctly reflects implementation

FrmSalesApi::menu() does not return a value, so documenting @return void is accurate and helps static analysis without changing behavior.

stripe/models/FrmStrpLiteAuth.php (1)

742-743: Return type annotation properly added.

The get_message_url() docblock now correctly includes the @return string annotation. The method returns the result of add_query_arg(), which produces a URL string, making the annotation accurate.

classes/helpers/FrmFieldGridHelper.php (1)

57-60: LGTM!

The PHPDoc block for the @param bool $nested parameter is accurate and consistent with the documentation style throughout the class. This documentation addition aligns well with the PR objective and improves IDE support and code clarity.

classes/controllers/FrmCronController.php (1)

38-39: LGTM! Documentation enhancement for consistency.

The @return void annotation accurately documents that schedule_events() returns no value, consistent with the existing annotation style in this class (see remove_crons()).

classes/helpers/FrmFormTemplatesHelper.php (1)

25-26: Accurate return type documentation added.

The @return void annotation correctly documents the method's behavior. Since prepare_template_details() modifies its parameter by reference without returning a value, this documentation is precise and will improve static analysis tool support (PHPStan, Psalm, etc.) and IDE type hints.

classes/models/FrmEmail.php (1)

819-820: Return type annotation improves documentation.

The @return string annotation accurately reflects the method's behavior. All code paths return a formatted email string, making this a solid documentation improvement aligned with the PR's goal.

classes/controllers/FrmUsageController.php (1)

97-98: Solid documentation additions.

Both @return void annotations are correct and consistent with the existing PHPDoc pattern across the class. The changes align with the PR objective of adding explicit return type documentation without altering function signatures or behavior.

Also applies to: 127-128

classes/models/FrmInstallPlugin.php (2)

23-25: PHPDoc parameter annotation is accurate and adds clarity.

The @param array $atts documents the constructor's interface and aligns with usage in the method body.


32-34: PHPDoc return type is accurate.

The @return string correctly documents the method's behavior; all code paths return either an empty string or a URL string from the helper methods.

classes/models/FrmAntiSpam.php (1)

75-77: Docblock return type is accurate and consistent with implementation

get_antispam_secret_key() always returns a string in all code paths, so @return string is correct and aligns with the method’s behavior and the PR goal of clearer return annotations.

classes/controllers/FrmFormTemplatesController.php (1)

143-162: Documentation improvement: return type annotation added.

The addition of @return void to the load_admin_hooks() method docblock (lines 146–147) is appropriate and consistent with the documentation pattern used throughout this file. All other methods in the class are already properly annotated with their return types.

classes/controllers/FrmOnboardingWizardController.php (1)

123-124: Minor documentation addition looks good.

The addition of @return void annotation to load_admin_hooks() is consistent with the PR objectives and existing patterns in the file.

classes/controllers/FrmSettingsController.php (1)

17-19: Comprehensive PHPDoc additions are accurate and well-placed.

All return type annotations (@return void) correctly reflect actual function behavior—methods either include view templates or echo output. Parameter documentation on display_form(), route(), and fake_color_picker() matches their signatures precisely, with the union type @param bool|string $stop_load accurately capturing the documented flexibility. These changes will improve static analysis and IDE support without altering any runtime behavior.

Also applies to: 39-44, 297-298, 307-309, 321-323, 332-334, 343-345, 360-362, 420-422, 429-433, 518-520

classes/helpers/FrmEntriesListHelper.php (4)

41-48: PHPDoc additions are accurate and consistent.

The @param array $s_query and @return void annotations correctly document the function behavior. The typing aligns with the function's actual usage and return semantics.


50-66: Void return type correctly documented.

The @return void annotation is accurate and the formatting is consistent with the file's PHPDoc style.


68-78: Void return correctly documented.

The @return void annotation accurately reflects that this method modifies global state but does not return a value.


400-405: Return type correctly documented as mixed.

The @param object $item and @return mixed accurately reflect the function's polymorphic return behavior (strings, HTML markup, and filtered values). This is appropriate for a column value renderer.

classes/controllers/FrmXMLController.php (2)

185-186: LGTM! Accurate return type documentation.

The @return string annotation correctly documents the method's return behavior, which consistently returns a string value (either from the form array or an empty string).


755-759: LGTM! Accurate parameter and return type documentation.

The PHPDoc block correctly documents the $mimes parameter as an array and the return type as an array, which accurately reflects the method's signature and implementation.

classes/helpers/FrmOnSubmitHelper.php (1)

27-28: Return type documentation is accurate across all added annotations.

All nine @return PHPDoc additions correctly reflect the method behaviors:

  • Void-returning methods (output or side-effects only) are properly documented as @return void
  • String-returning methods correctly marked as @return string

The changes complete type coverage for this helper class consistently. No logic, signatures, or runtime behavior is altered.

Also applies to: 86-87, 105-106, 162-164, 169-171, 177-179, 199-200, 235-236, 275-276

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

55-61: Return type annotation matches actual behavior

get_field_value() returns either the stored field value or the current user ID, both of which are effectively int|string, so the new @return int|string PHPDoc accurately reflects the implementation and improves static analysis without changing behavior.

classes/helpers/FrmEmailSummaryHelper.php (1)

85-86: Documentation enhancements are accurate and well-placed.

The seven @return void annotations added to save_options(), send_monthly(), send_yearly(), set_last_sent_date(), show_comparison(), section_heading_with_icon(), and plain_text_echo() are all correct. Each method performs side effects (updating options, sending emails, or outputting content) without returning a meaningful value, making @return void the appropriate return type. The PHPDoc formatting is consistent with existing annotations throughout the file, and these changes align cleanly with the PR objective to add return type comments across the codebase.

Also applies to: 138-139, 151-152, 258-259, 350-351, 422-423, 570-571

classes/models/FrmInstallerSkin.php (2)

21-34: Accurate @return void for set_upgrader

The new @return void matches the implementation (no return value) and improves static analysis without changing behavior. Looks good.


36-47: Accurate @return void for set_result

Same here: the method only mutates state and does not return anything, so @return void is correct and consistent with the intent.

classes/models/FrmEntryShortcodeFormatter.php (1)

152-158: Docblock return type accurately reflects implementation

content() can return a string (empty, plain text, or HTML) or an array via get_array(), so @return string|array is correct and improves static analysis/readability without changing behavior.

classes/models/FrmCreateFile.php (2)

17-19: Constructor parameter documentation added correctly.

The $atts parameter is now documented in PHPDoc format. The documentation accurately reflects that this parameter accepts an array.


207-210: get_ftp_creds() parameter and return type documentation added correctly.

Both the parameter (line 208, existing) and return type (lines 209–210, added) are now properly documented. The return type array|false accurately reflects the implementation: the method returns the credentials array on line 263 or false on line 266.

classes/models/FrmSpamCheckDenylist.php (7)

23-25: LGTM!

The parameter type annotation is accurate and improves static analysis support.


34-36: LGTM!

The return type annotation is accurate and consistent with the method implementation.


48-49: LGTM!

The @return void annotation is accurate—this method modifies the array by reference and has no return value.


200-201: LGTM!

The @return void annotation is accurate for this by-reference parameter method.


399-400: LGTM!

The @return void annotation is accurate for this by-reference parameter method.


495-500: LGTM!

All parameter and return type annotations are accurate and consistent with the method implementation.


560-564: LGTM!

The parameter and return type annotations are accurate for this private utility method.

classes/models/FrmHoneypot.php (1)

32-34: LGTM! PHPDoc annotations are accurate and improve code documentation.

All the added PHPDoc blocks correctly document the return types and parameters based on the actual implementations. These documentation improvements enhance type clarity and maintainability without introducing any behavioral changes.

Also applies to: 133-134, 167-168, 245-249, 259-261, 268-270

classes/helpers/FrmTipsHelper.php (1)

393-397: LGTM! Documentation is accurate.

The PHPDoc correctly documents the parameter and return types for this method.

classes/models/FrmSolution.php (2)

30-33: Constructor param docblock is consistent with the signature

@param array $atts matches __construct( $atts = array() ) and doesn’t introduce any behavioral change. No issues here.


75-80: plugin_links() PHPDoc correctly matches filter usage

Documenting $links as array and the return type as array is consistent with how the method is used in the plugin_action_links_* filter.

classes/helpers/FrmStylesHelper.php (1)

8-10: PHPDoc return type annotations are accurate and well-placed.

All added @return documentation correctly reflects the actual return types of these methods. These changes improve static analysis compliance and IDE support.

Also applies to: 20-26, 33-37, 77-79, 105-107, 272-279, 363-369

classes/controllers/FrmStylesController.php (2)

23-25: PHPDoc return annotations are accurate and improve type safety.

All added @return and @param documentation correctly matches the actual function implementations. The return types are well-chosen (void, string, array, mixed) and align with real behavior.

Also applies to: 32-34, 245-251, 263-268, 1133-1137, 1182-1187, 1204-1210, 1219-1223, 1231-1235, 1258-1263


270-270: Strict equality comparison improves type safety.

Changed loose equality (==) to strict equality (===), eliminating potential type-juggling bugs. The logic is preserved and this aligns with PHP best practices.

classes/controllers/FrmEntriesController.php (4)

8-27: Admin routing/menu docblocks look consistent with behavior

The new @return void annotations for menu() and load_manage_entries_hooks() match the implementations, and the route() docblock is also consistent with current usage as a screen callback. No runtime behavior changes introduced here.

Also applies to: 94-110, 112-134


158-205: Column-related helper docblocks correctly describe parameters and return types

The added PHPDoc for manage_columns(), get_columns_for_form(), maybe_add_ip_col(), and sortable_columns() aligns with how these methods are used (arrays in, arrays out / by‑ref mutation, void where appropriate). This should help static analysis around the entries list table.

Also applies to: 304-314, 317-324, 445-474


707-774: process_entry() docblock matches actual usage

The new docblock for process_entry() correctly reflects $errors as string|array and $ajax as bool, with a void return. This aligns with how $errors is initialized, validated, filtered, and stored.


906-936: entry_sidebar() parameter/return annotations are accurate

Documenting $entry as object|false and the method as returning void matches the implementation and how the included view uses the prepared data.

classes/controllers/FrmEmailStylesController.php (1)

333-334: LGTM: Documentation enhancement.

The @return void annotation accurately documents the method's behavior.

classes/models/FrmInbox.php (2)

52-53: LGTM: Documentation enhancement.

The @return array annotation accurately documents the return type.


330-342: LGTM: Clean implementation of unread message filtering.

The method correctly filters messages to return only those unread by the current user, with proper null-safety checks.

classes/models/FrmDb.php (1)

59-60: LGTM: Comprehensive documentation improvements.

The PHPDoc additions accurately document parameter types and return values across multiple private methods, improving code maintainability with no functional changes.

Also applies to: 177-178, 340-341, 376-382, 553-554

classes/helpers/FrmSubmitHelper.php (1)

149-150: LGTM: Accurate void return documentation.

The @return void annotations correctly document methods that perform side effects without returning values.

Also applies to: 178-179, 213-214, 242-243

deprecated/FrmEDD_SL_Plugin_Updater.php (1)

97-103: Unused parameter is acceptable in deprecated stub.

The static analysis warning about the unused $cache_key parameter can be safely ignored—this is a deprecated stub method maintained for backward compatibility.

classes/helpers/FrmCSVExportHelper.php (2)

244-258: LGTM: Well-designed filter integration.

The addition of frm_csv_line_break and frm_csv_date_format filters enhances extensibility while maintaining backward compatibility. The filter pattern is consistent with the existing frm_csv_sep filter.


260-267: LGTM: Comprehensive PHPDoc coverage.

The extensive documentation additions improve code maintainability by clarifying parameter types and return values across all helper methods, with no functional changes.

Also applies to: 269-294, 313-331, 333-366, 368-463, 484-489, 491-526, 528-546, 548-589, 628-641, 643-686, 740-757, 759-811, 813-845

square/helpers/FrmSquareLiteConnectHelper.php (11)

133-135: LGTM!

The return type annotation false|string accurately reflects the method's behavior.


210-213: LGTM!

The parameter and return type annotations are accurate.


532-534: LGTM!

The return type annotation accurately reflects that this method returns an array.


558-560: LGTM!

The return type annotation matches the property type declared at line 15.


565-569: LGTM!

The return type annotation false|object matches the return type of post_with_authenticated_body().


643-649: LGTM!

The updated return type annotation false|object is accurate.


651-658: LGTM!

The return type annotation false|object is accurate.


660-667: LGTM!

The return type annotation false|object is accurate.


669-676: LGTM!

The return type annotation false|object is accurate.


768-779: LGTM!

The return type annotation false|object accurately reflects the method's behavior.


484-504: I'll verify the concerns raised in this review comment by searching for all callers of the create_payment() method and checking for inconsistencies with similar methods.
<function_calls>

#!/bin/bash

Search for all calls to FrmSquareLiteConnectHelper::create_payment

echo "=== Static calls to FrmSquareLiteConnectHelper::create_payment ==="
rg -nP --type=php 'FrmSquareLiteConnectHelper::create_payment\s*(' -C3

echo ""
echo "=== Instance method calls to create_payment ==="
rg -nP --type=php '->create_payment\s*(' -C3


</function_calls>

classes/models/FrmFieldValue.php (1)

145-187: String return types for field metadata getters look correct

The new @return string annotations on:

  • get_field_label() (name)
  • get_field_id() (id)
  • get_field_key() (field_key)
  • get_field_type() (type)

match the expected shapes of these properties and how they’re used throughout (labels, keys, and type slugs). These docblocks should give tools better signal without changing behavior.

classes/controllers/FrmAddonsController.php (4)

28-33: load_admin_hooks @return void annotation is accurate

Method only wires hooks and does not return a value; the new @return void is correct and helps static analysis.


423-451: get_pro_license return type now correctly documented as string

All code paths return a string (either the normalized license or an empty string), so the @return string addition is correct.


463-474: license_type @return string matches current behavior

This method always returns a string (FrmProAddonsController::license_type() or 'free'), so the new @return string annotation is consistent.


1042-1073: install_addon union return type (array|string) matches implementation

This method returns an error array on failure and the plugin identifier string on success; the new @return array|string docblock correctly describes that behavior and is compatible with callers like download_and_activate and handle_addon_action.

classes/controllers/FrmAppController.php (6)

33-48: menu_icon @return string annotation is correct

The method always returns an SVG data URI string (possibly filtered), so documenting @return string is accurate.


139-183: is_white_page now correctly documented as returning bool

The method derives a boolean and then passes it through apply_filters( 'frm_is_white_page', … ). Treating this as bool matches intended usage in callers like add_admin_class.


821-833: enqueue_global_settings_scripts @return void annotation fits usage

This helper only enqueues assets conditionally based on $page and has no return value; @return void is appropriate.


1080-1090: can_update_db @return bool is consistent with transient usage

get_transient( 'frm_updating_api' ) is only ever set to true in this file and otherwise evaluates to false, so modeling the permission callback as returning bool is accurate for REST.


1198-1211: drop_tables docblock aligns with behavior

The method takes an array of table names and appends four Formidable tables before returning the array; @param array $tables / @return array correctly describe its contract for use in drop-table filters.


1252-1263: set_footer_text return type is now clearly specified

This filter callback always returns a string (either the original footer text or an empty string on Formidable admin pages), so the @return string annotation is accurate and useful for static analysis.

classes/models/FrmSettings.php (2)

111-113: Constructor PHPDoc matches current usage

$args is only ever treated as an array (passed straight into maybe_filter_for_form() which expects an array), so documenting it as @param array $args is consistent with current usage. No functional concerns here.


381-386: validate() PHPDoc is consistent with filter contract

@param array $params, @param array $errors, and @return array match the usage with apply_filters( 'frm_validate_settings', $errors, $params ), which expects and returns an error array. Looks good.

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

31-33: Accurate input_html() return type

Documenting input_html() as returning string is consistent with the multiple_input_html() return value. No issues.

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

278-282: allow_multiple() PHPDoc matches implementation

@param FrmSettings $frm_settings and @return bool align with reading $frm_settings->re_multi. This improves static analysis without behavior change.

classes/controllers/FrmFieldsController.php (5)

156-164: load_single_field() documented as void is appropriate

The method only performs rendering (includes a view and may early‑return) and doesn’t return a value; @return void is accurate.


511-516: input_html() return type is correct despite echo side‑effect

The method always builds $add_html as a string and returns it, regardless of whether it also echoes when $echo === true. Documenting @return string is accurate and helpful for callers that rely on the return value.


778-783: add_validation_messages() PHPDoc matches usage

$field is treated as an array and $add_html is passed by reference as an array of extra attributes. The @param array / @return void annotations line up with the implementation.


1016-1022: check_value() PHPDoc correctly uses mixed

Given $opt can be scalar or array and is normalized before returning, using mixed for both the input and return types is appropriate, and array|object for $field matches how it’s inspected via FrmField::is_option_true().


1035-1039: check_label() PHPDoc is consistent

$opt can be either an array or scalar; the method normalizes array inputs to a scalar and returns that. @param mixed $opt / @return mixed is accurate.

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

36-38: input_html() return type annotation is correct

Documenting input_html() as returning string aligns with the multiple_input_html() call. This is consistent with the checkbox field implementation.

Comment thread classes/models/FrmSettings.php
Comment thread deprecated/FrmEDD_SL_Plugin_Updater.php
Comment thread square/helpers/FrmSquareLiteConnectHelper.php
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: 1

Caution

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

⚠️ Outside diff range comments (1)
stripe/models/FrmTransLiteDb.php (1)

263-273: Incomplete return type annotation.

The return type should include null since wpdb->get_var() returns string|null, not just string. The method can return null when no rows are found.

Apply this diff to correct the return type:

 /**
- * @return string
+ * @return string|null
  */
 public function get_count() {
🧹 Nitpick comments (6)
classes/views/styles/components/FrmSliderStyleComponent.php (1)

25-29: Constructor PHPDoc looks correct; consider documenting $data shape

The param types align with how the constructor and helpers use these values. For stronger static analysis and self‑documentation, you might optionally expand the $data type (e.g., array{units?: string[], type?: string, icon?: string, max_value?: int|float, ...}) or at least mention expected keys in the summary line above the tags.

square/models/FrmSquareLiteSettings.php (1)

61-63: Good documentation addition.

The PHPDoc correctly documents the return type. For greater specificity and consistency with the property declaration at line 11, consider using @return stdClass instead of @return object.

Apply this diff for more specific type documentation:

 	/**
-	 * @return object
+	 * @return stdClass
 	 */
stripe/helpers/FrmStrpLiteConnectApiAdapter.php (1)

160-161: Consider a more specific return type.

The method delegates to FrmStrpLiteConnectHelper::maybe_create_plan(), which returns false|string (line 822-830 in the helper). Consider using @return false|string instead of @return mixed for better type clarity.

stripe/helpers/FrmStrpLiteConnectHelper.php (1)

488-492: Refine the return type annotation.

The @return object|null annotation is incomplete. Since json_decode() is called without the second parameter (line 496), it can return object, array, scalar values, or null depending on the JSON structure. Consider using @return mixed or, if the API consistently returns JSON objects, @return object|array|null for accuracy.

phpstan.neon (2)

34-34: Consider scoping '#no value type specified.#' instead of ignoring it globally

If the medium‑term goal is to tighten PHPStan coverage on generics/value types as well, this global ignore will mask those issues everywhere. You might want to mirror the approach used below for return types and introduce a paths: list here, so new/actively‑touched code can start enforcing value types while legacy areas remain suppressed.


137-198: Deduplicate paths entries in the new return‑type ignore rules

In both new ignoreErrors blocks ('#has no return type specified#' and '#with no type specified#'), some paths (e.g., classes/models/FrmEntryValidate.php) appear multiple times. It’s harmless but adds noise and can confuse future maintainers scanning for “special” files.

Suggest trimming duplicates so each path appears once per block, for example:

-                - classes/models/FrmEntryValidate.php
-                - classes/models/FrmEntryMeta.php
-                - classes/models/FrmEntry.php
-                - classes/models/FrmEntryValidate.php
+                - classes/models/FrmEntryValidate.php
+                - classes/models/FrmEntryMeta.php
+                - classes/models/FrmEntry.php

…and similarly in the second block.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e18d299 and d98defa.

📒 Files selected for processing (17)
  • classes/views/styles/components/FrmSliderStyleComponent.php (1 hunks)
  • classes/views/styles/components/FrmStyleComponent.php (2 hunks)
  • classes/widgets/FrmElementorWidget.php (4 hunks)
  • classes/widgets/FrmShowForm.php (1 hunks)
  • phpstan.neon (2 hunks)
  • square/models/FrmSquareLiteSettings.php (1 hunks)
  • stripe/controllers/FrmStrpLiteEventsController.php (3 hunks)
  • stripe/controllers/FrmTransLiteHooksController.php (1 hunks)
  • stripe/controllers/FrmTransLiteListsController.php (1 hunks)
  • stripe/helpers/FrmStrpLiteConnectApiAdapter.php (1 hunks)
  • stripe/helpers/FrmStrpLiteConnectHelper.php (1 hunks)
  • stripe/helpers/FrmStrpLiteLinkRedirectHelper.php (1 hunks)
  • stripe/helpers/FrmTransLiteAppHelper.php (6 hunks)
  • stripe/helpers/FrmTransLiteListHelper.php (2 hunks)
  • stripe/models/FrmStrpLiteSettings.php (1 hunks)
  • stripe/models/FrmTransLiteAction.php (1 hunks)
  • stripe/models/FrmTransLiteDb.php (4 hunks)
✅ Files skipped from review due to trivial changes (5)
  • classes/views/styles/components/FrmStyleComponent.php
  • stripe/controllers/FrmTransLiteListsController.php
  • classes/widgets/FrmShowForm.php
  • stripe/models/FrmStrpLiteSettings.php
  • classes/widgets/FrmElementorWidget.php
🧰 Additional context used
🪛 PHPMD (2.15.0)
stripe/models/FrmTransLiteDb.php

260-260: Avoid unused local variables such as '$field'. (undefined)

(UnusedLocalVariable)

⏰ 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). (2)
  • GitHub Check: PHP 8 tests in WP trunk
  • GitHub Check: PHP 7.4 tests in WP trunk
🔇 Additional comments (10)
stripe/controllers/FrmTransLiteHooksController.php (1)

70-72: LGTM! Documentation improvement.

The PHPDoc annotation accurately documents the void return type and is consistent with other method annotations in this file.

stripe/models/FrmTransLiteAction.php (1)

26-27: LGTM!

The @return void annotation accurately documents that the form() method produces no return value. This enhances IDE support and code clarity without changing functionality.

stripe/helpers/FrmStrpLiteLinkRedirectHelper.php (1)

115-116: LGTM!

The @return bool annotation accurately reflects the method's return type.

stripe/helpers/FrmTransLiteAppHelper.php (1)

152-153: LGTM!

All return type annotations accurately reflect the methods' behaviors. The documentation improvements enhance code clarity without altering functionality.

Also applies to: 163-164, 268-272, 523-525, 534-535, 558-559

stripe/controllers/FrmStrpLiteEventsController.php (1)

206-208: LGTM!

The return type annotations accurately document the possible return values for these methods. The documentation improvements help clarify method contracts.

Also applies to: 327-331, 349-353

stripe/helpers/FrmTransLiteListHelper.php (2)

261-266: Docblock for get_column_value matches implementation.

The @return string annotation aligns with all code paths returning a string-like value used for HTML output; no further changes needed.


483-487: Accurate return type on get_status_column docblock.

The @param object $item and @return string annotations correctly describe the method’s usage and output.

stripe/models/FrmTransLiteDb.php (3)

160-160: LGTM! Correct return type refinement.

Removing void from the return type annotation is accurate since wpdb->get_row() returns array|object|null and this method has no early return without a value.


199-228: LGTM! Well-structured query method.

The implementation correctly validates the field against a whitelist before using it in the SQL query, and returns an empty array for invalid states. The return type annotation accurately reflects that wpdb->get_results() returns an array.


230-252: LGTM! Proper JOIN implementation.

The SQL join between payments and items tables is correctly structured with a prepared statement for the user ID parameter. The return type annotation accurately reflects the array result from wpdb->get_results().

Comment thread stripe/models/FrmTransLiteDb.php
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: 3

Caution

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

⚠️ Outside diff range comments (3)
classes/models/FrmEntry.php (1)

272-306: Handle the case when the entry does not exist.

If getOne() returns null because the entry with the given $id doesn't exist, attempting to access $values->name and other properties on line 279-283 will cause a fatal error.

Apply this diff to add validation:

 public static function duplicate( $id ) {
 	global $wpdb;
 
 	$values = self::getOne( $id );
+	if ( ! $values ) {
+		return false;
+	}
 
 	$new_values               = array();
classes/helpers/FrmAppHelper.php (1)

3077-3080: Fix invalid date regex quantifier in get_formatted_time

In get_formatted_time, the pattern '/^\d{1-2}\/\d{1-2}\/\d{4}$/' (Line 3077) uses {1-2}, which is not a valid quantifier and can cause a preg_match compilation warning at runtime. It looks like this was meant to be “1 or 2 digits”.

You can safely correct it as:

-		if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) {
+		if ( preg_match( '/^\d{1,2}\/\d{1,2}\/\d{4}$/', $date ) && self::pro_is_installed() ) {

This keeps the intent (detecting mm/dd/yyyy-style input) without risking regex compilation errors.

classes/models/FrmAddon.php (1)

83-96: Handle false result from get_addon to avoid fatal errors

The @return false|FrmAddon annotation is accurate, but current callers like activate_license_for_plugin() and set_license_from_post() assume a non-false return and immediately call methods on the result. If frm_installed_addons ever returns an array without the requested slug (e.g., unexpected slug in the AJAX request), this will trigger a fatal error.

I recommend either:

  • Guarding at the call sites and returning a structured error when $this_plugin is false, or
  • Making get_addon() throw a controlled exception / return a structured error instead of false, and updating callers accordingly.
🧹 Nitpick comments (13)
classes/helpers/FrmListHelper.php (4)

682-686: Consider tightening disabled_pages return type

The current @return array is correct but very generic. If you want stronger tooling support, you could document the fixed keys and boolean values:

-	 * @return array
+	 * @return array{first:bool,last:bool,prev:bool,next:bool}

This would make phpstan/psalm aware of the exact shape.


713-717: Optionally narrow link_label param type

$link is effectively limited to 'first', 'last', 'prev', 'next' by the call sites. You can express that for better static checking:

-	 * @param string $link
+	 * @param 'first'|'last'|'prev'|'next' $link

The existing string annotation is still correct, so this is purely an enhancement.


735-739: add_page_link docblock is correct; could specify expected keys

@param array $atts / @return string matches usage. If you’d like, you can document the expected structure for better IDE support:

-	 * @param array $atts
+	 * @param array{
+	 *     page:string,
+	 *     arrow:string,
+	 *     number:int,
+	 *     disabled:bool
+	 * } $atts

759-763: add_active_link docblock OK; array-shape annotation would be a nice follow-up

Like add_page_link, this expects a structured $atts array and returns an HTML string. Current types are correct; consider an array-shape annotation similar to:

-	 * @param array $atts
+	 * @param array{
+	 *     page:string,
+	 *     arrow:string,
+	 *     number:int
+	 * } $atts

to help static analysis.

classes/controllers/FrmFormsController.php (1)

1237-1243: save_per_page docblock matches behavior, with a minor param-type nuance

The docblock reflects usage well; $save as mixed and return mixed is appropriate, and $option is indeed a string. Since $value comes from a request and is then cast with (int) $value, you might consider documenting it as int|string for maximal accuracy, but it’s not critical.

classes/models/FrmEntry.php (1)

401-410: Clarify the purpose of the $value parameter.

The $value parameter is only used in an isset() check to determine whether to set form_id to $form_id or null, but the actual value is never used. This makes the API confusing.

Consider one of these approaches:

  1. If $value represents whether to set or unset the form linkage, rename it and use a boolean:
-public static function update_form( $id, $value, $form_id ) {
+public static function update_form( $id, $form_id, $set_linkage = true ) {
 	global $wpdb;
-	$form_id = isset( $value ) ? $form_id : null;
+	$form_id = $set_linkage ? $form_id : null;
  1. If this is legacy API that must be maintained, at least document the parameter's purpose in the PHPDoc:
 /**
  * @param int        $id
- * @param mixed      $value
+ * @param mixed      $value If set, updates form_id to $form_id; if not set, clears the form linkage.
  * @param int|string $form_id
classes/models/FrmFormAction.php (2)

577-584: get_one() return type in PHPDoc is too narrow

get_one() delegates to get_all( $form_id, 1 ). When at least one action exists, get_all() collapses the result to a single prepared action object (WP_Post), and when there are none it returns an empty array. So @return array is misleading.

Consider widening the return type to reflect actual behavior, e.g.:

-	 * @param int|string $form_id
-	 *
-	 * @return array
+	 * @param int|string $form_id
+	 *
+	 * @return WP_Post|WP_Post[]

This matches prepare_action()’s WP_Post typing and still covers the empty-array case.


586-641: get_action_for_form() docblock should reflect union return type and $atts flexibility

get_action_for_form() can:

  • Return an empty array early in several branches.
  • For $type !== 'all', return the result of $action_controls->get_all( $form_id, $atts ), which may be an array of WP_Post objects or a single WP_Post when the limit is 1.
  • For $type === 'all', after building $settings, collapse to a single action when $limit === 1 ($settings = reset( $settings );).

Also, $atts can be either an array or an integer limit, since it is passed into prepare_get_action() (directly or via get_all()), which explicitly handles numeric arguments for backward compatibility.

To make the PHPDoc match behavior, I’d suggest:

-	 * @param int|string $form_id
-	 * @param string     $type
-	 * @param array      $atts
-	 *
-	 * @return array
+	 * @param int|string   $form_id
+	 * @param string       $type
+	 * @param array|int    $atts
+	 *
+	 * @return WP_Post|WP_Post[]

This should play nicer with static analysis and better document the API without changing runtime behavior.

classes/helpers/FrmAppHelper.php (1)

714-758: Docblock additions look consistent; consider tightening one return type annotation

The new @param/@return annotations across helpers like get_param, sanitize_request, recursive_function_map, is_assoc, prepare_field_arrays, fill_field_defaults, add_value_to_array, maybe_add_tooltip, prepare_action_slashes, and format_form_data align well with the implementations and should help static analysis. One small mismatch: in get_user_id_param (Line 2561), the function can return false if a falsy $user_id is passed in, while the docblock advertises int|string. If that false return is intentional, you may want to widen the @return type to include bool, or normalize falsy input to a consistent int/string value to keep the declared return type strict.

Also applies to: 892-905, 2373-2402, 2420-2427, 2556-2583, 2780-2798, 2801-2856, 3388-3401, 3404-3437, 3498-3521, 3629-3655

classes/models/FrmAddon.php (4)

72-81: insert_installed_addon PHPDoc matches implementation

The new docblock correctly documents array in and array out, matching the filter usage. If you want tighter static analysis, you could narrow this to something like array<string, FrmAddon> (or the appropriate addon interface), but it’s fine as-is.


292-301: set_active parameter type in PHPDoc vs actual usage

The new docblock declares @param bool $is_active, but maybe_set_active() passes the string 'valid' when activation succeeds. The parameter is currently unused in set_active(), so this mismatch is only visible to static analysis, but it’s still misleading.

Consider either:

  • Updating the docblock to @param bool|string $is_active to reflect current usage, or
  • Normalizing maybe_set_active() to pass a real boolean and, if needed, storing the 'valid' status separately.

530-546: is_current_version PHPDoc is accurate; possible clarity tweak

The @param object $transient and @return bool annotation lines up with usage: it expects an object with checked/response properties and returns a boolean flag. If you want to help tools like PHPStan further, you might tighten the param to stdClass or describe the expected shape in a more detailed PHPDoc, but that’s optional.


910-919: lock_key() docblock return type is incorrect

The docblock says @return bool, but lock_key() clearly returns a string identifier ($this->transient_lock_key . '_' . $this->license). This is an easy fix that will improve the accuracy of the new type annotations:

-	 * @return bool
+	 * @return string
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d98defa and 875542b.

⛔ Files ignored due to path filters (1)
  • psalm.xml is excluded by !**/*.xml
📒 Files selected for processing (26)
  • classes/controllers/FrmEntriesController.php (10 hunks)
  • classes/controllers/FrmFormActionsController.php (5 hunks)
  • classes/controllers/FrmFormsController.php (8 hunks)
  • classes/helpers/FrmAppHelper.php (9 hunks)
  • classes/helpers/FrmCSVExportHelper.php (13 hunks)
  • classes/helpers/FrmEntriesHelper.php (5 hunks)
  • classes/helpers/FrmFieldsHelper.php (15 hunks)
  • classes/helpers/FrmFormsHelper.php (7 hunks)
  • classes/helpers/FrmListHelper.php (6 hunks)
  • classes/helpers/FrmXMLHelper.php (9 hunks)
  • classes/models/FrmAddon.php (5 hunks)
  • classes/models/FrmEntry.php (6 hunks)
  • classes/models/FrmEntryMeta.php (6 hunks)
  • classes/models/FrmEntryShortcodeFormatter.php (1 hunks)
  • classes/models/FrmEntryValidate.php (9 hunks)
  • classes/models/FrmField.php (5 hunks)
  • classes/models/FrmForm.php (10 hunks)
  • classes/models/FrmFormAction.php (3 hunks)
  • classes/models/FrmFormMigrator.php (6 hunks)
  • classes/models/FrmMigrate.php (1 hunks)
  • classes/models/FrmSettings.php (3 hunks)
  • classes/models/fields/FrmFieldType.php (7 hunks)
  • phpstan.neon (2 hunks)
  • stripe/controllers/FrmStrpLiteEventsController.php (3 hunks)
  • stripe/helpers/FrmTransLiteAppHelper.php (6 hunks)
  • stripe/models/FrmTransLiteDb.php (4 hunks)
✅ Files skipped from review due to trivial changes (8)
  • classes/models/fields/FrmFieldType.php
  • classes/helpers/FrmEntriesHelper.php
  • classes/helpers/FrmFormsHelper.php
  • classes/models/FrmEntryMeta.php
  • classes/models/FrmForm.php
  • classes/helpers/FrmFieldsHelper.php
  • classes/models/FrmEntryValidate.php
  • classes/models/FrmMigrate.php
🚧 Files skipped from review as they are similar to previous changes (6)
  • classes/models/FrmEntryShortcodeFormatter.php
  • classes/controllers/FrmEntriesController.php
  • stripe/models/FrmTransLiteDb.php
  • classes/helpers/FrmCSVExportHelper.php
  • stripe/helpers/FrmTransLiteAppHelper.php
  • classes/models/FrmSettings.php
🧰 Additional context used
🧬 Code graph analysis (1)
stripe/controllers/FrmStrpLiteEventsController.php (1)
stripe/models/FrmTransLiteDb.php (1)
  • get_one_by (179-197)
⏰ 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: PHP 7.4 tests in WP trunk
  • GitHub Check: PHP 8 tests in WP trunk
  • GitHub Check: Cypress
🔇 Additional comments (40)
phpstan.neon (1)

137-162: Good approach: Transitioning from global to file-scoped ignores.

This change correctly narrows PHPStan's ignore rules from global patterns to explicit file paths. This prevents new files from silently inheriting these suppressions and clearly documents which files still need return type annotations.

classes/helpers/FrmXMLHelper.php (1)

13-18: LGTM! Excellent documentation improvements.

The PHPDoc annotations added throughout this file accurately document parameter types and return types for all modified methods. The type hints are correct and will improve IDE support, static analysis, and developer experience.

Also applies to: 289-293, 323-327, 349-355, 368-372, 572-577, 1214-1220, 1340-1345, 1462-1466

classes/controllers/FrmFormActionsController.php (6)

410-418: LGTM!

The PHPDoc accurately documents the method parameters and return type. The WP_Post type for $form_action aligns with its usage accessing post_excerpt property.


575-579: LGTM!

The PHPDoc correctly documents the array parameter and void return type.


723-729: LGTM!

The PHPDoc correctly documents all parameters including the union type for $form_id and the void return type.


747-751: LGTM!

The PHPDoc correctly documents the string parameter and return type, which is consistent with the SQL WHERE clause filtering logic.


788-792: LGTM!

The PHPDoc correctly documents the string parameter (class name) and void return type.


797-801: LGTM!

The PHPDoc correctly documents the string parameter (class name) and void return type.

classes/models/FrmFormMigrator.php (6)

201-216: LGTM!

The docblock accurately documents the method signature and return type. The int|string union type for $source_id correctly reflects that form IDs can be either type.


218-226: LGTM!

The docblock correctly documents this extensibility hook. The array|object type for $form appropriately handles both array and object representations from different source plugins, and the pass-by-reference parameter is properly indicated.


290-298: LGTM!

The docblock correctly documents this field-level extensibility hook with appropriate types and properly indicates the pass-by-reference parameter.


570-579: LGTM!

The docblock accurately documents this helper method with correct parameter and return types.


590-599: LGTM!

The docblock correctly documents this method with accurate types. The protected visibility allows child migrator classes to customize field-skipping behavior.


622-629: LGTM!

The docblock properly documents this method stub with the appropriate union type for $id. The implementation correctly provides an empty array as the default return value for child classes to override.

classes/helpers/FrmListHelper.php (3)

278-282: Docblock for hidden_search_inputs correctly reflects usage

$param_name is always passed as a string and the method only echoes HTML with no return value, so @param string and @return void are accurate. No further changes needed.


452-456: get_bulk_action return type matches implementation

The method guarantees either false or a non-empty, sanitized action string, so @return false|string is correct and helpful for static analysis.


750-754: add_disabled_link docblock is accurate

The method always returns an HTML string built from the $label, so @param string and @return string are appropriate.

classes/controllers/FrmFormsController.php (9)

1922-1928: replace_content_shortcodes PHPDoc is consistent with implementation

The parameter and return types (string, false|object, array, returning string) are consistent with how the method delegates to FrmFieldsHelper::replace_content_shortcodes.


2139-2143: json_error docblock correctly describes the filter signature

$errors as array in and out aligns with how this is used as a validation filter, and the description is clear.


2388-2392: is_viewable_draft_form docblock looks accurate

Documenting $form as object and return as bool matches the actual usage ($form->status check plus capability/preview checks).


2397-2403: get_form docblock matches current call patterns

The doc types (object $form, bool $title, bool $description, array $atts, returning string) line up with how show_form normalizes title/description before calling this method.


2421-2425: enqueue_scripts docblock is correct

The method only forwards $params to an action, so @param array $params / @return void is appropriate and helpful.


2430-2437: get_form_contents PHPDoc matches usage

The documented types for $form, $title, $description, and $atts, with @return void, are consistent with how the method is called and how it operates (side-effectful rendering only).


2558-2563: maybe_trigger_redirect docblock matches behavior

Param types (object $form, array $params, array $args) and void return are aligned with the implementation and how it passes those arrays into get_confirmation_method.


2606-2612: trigger_redirect docblock is accurate

The documented types and void return correctly reflect building $success_args and delegating to run_success_action.


3332-3338: maybe_load_css docblock correctly captures parameter shapes

$form as object, $this_load as int|string, and $global_load as bool match the way this method is called (e.g., from show_form_after_submit), and @return void is correct.

stripe/controllers/FrmStrpLiteEventsController.php (3)

206-208: LGTM!

The PHPDoc accurately documents the return type. The method correctly returns false when the invoice lacks a subscription or when no matching subscription is found, and returns an object representing the payment when successful.


327-331: LGTM!

The PHPDoc correctly documents the parameter and return type. The method returns object|null consistent with the underlying get_one_by() method's behavior, which wraps WordPress's $wpdb->get_row().

Also applies to: 335-335


350-354: LGTM!

The PHPDoc correctly documents the parameter and return type, accurately reflecting that get_one_by() returns either an object or null.

classes/models/FrmEntry.php (4)

460-465: LGTM!

The PHPDoc accurately reflects the method's signature and return type.


522-526: LGTM!

The PHPDoc correctly documents the parameter and return types for this method.


594-602: LGTM!

The PHPDoc accurately describes all parameters and the return type for this method.


858-864: LGTM!

The PHPDoc correctly documents this helper method's parameters and return type.

classes/models/FrmField.php (3)

487-494: LGTM!

The PHPDoc accurately documents the method parameters and return type.


891-898: LGTM!

The PHPDoc correctly documents the pass-by-reference parameter and void return type.


1413-1417: LGTM!

The PHPDoc accurately documents the parameter and return types.

classes/models/FrmFormAction.php (2)

113-121: Docblock for migrate_values() matches current usage

$action and $form are passed as objects from prepare_new()/migrate_to_2(), and the method always returns the $action object, so the new @param object / @return object annotations are accurate and helpful. No changes needed here.


410-443: duplicate_array_walk() PHPDoc is consistent with how it’s used

Within duplicate_one(), $action is treated as an array segment of post_content, $subkey can be either a string or an array of keys, and $val is mixed; the method always returns the modified $action array. The new docblock (@param array $action, @param array|string $subkey, @param mixed $val, @return array) correctly reflects this.

classes/models/FrmAddon.php (2)

233-240: set_license docblock aligns with behavior

@param string $license and @return void match how set_license() is used (storing the raw license string in the option). No functional issues here.


408-437: clear_expired_download docblock and logic look consistent

The @param mixed $transient / @return mixed annotation matches the behavior: the method accepts any value, short-circuits non-objects, and returns the original transient (possibly modified) without changing its type. The integration with is_current_version() and the update-reset path reads correctly.

Comment thread classes/models/FrmField.php
Comment thread classes/models/FrmField.php
Comment thread phpstan.neon Outdated
@Crabcyborg Crabcyborg changed the title Add return type comments Add return type comments and more missing param type comments Nov 27, 2025
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 (4)
classes/models/FrmEntryValidate.php (1)

87-91: Consider documenting by-reference parameters in PHPDoc.

Several newly added PHPDoc blocks don't indicate that parameters are passed by reference. While the code functions correctly, documenting reference parameters (&$param) improves documentation completeness and helps developers understand that these parameters will be modified.

Examples:

  • Line 88: set_item_key - $values is by reference
  • Line 132: validate_field - $errors is by reference
  • Line 691: add_site_info_to_akismet - $datas is by reference
  • Line 709: add_user_info_to_akismet - $datas is by reference
  • Line 895: add_server_values_to_akismet - $datas is by reference
  • Line 943: skip_adding_values_to_akismet - $values is by reference
  • Line 1042: prepare_values_for_spam_check - $values is by reference

You can add a note in the description indicating the parameter is modified, for example:

 /**
- * @param array $values
+ * @param array $values Entry values (passed by reference and modified).
  *
  * @return void
  */
 private static function set_item_key( &$values ) {

Also applies to: 130-137, 413-420, 432-439, 690-694, 708-713, 894-898, 942-944, 1041-1043

classes/models/FrmMigrate.php (2)

554-556: Optionally narrow get_fields_with_size return type

get_fields_with_size() is annotated as @return array but in practice returns the result of FrmDb::get_results, which appears to be an array of objects (likely stdClass). If you want stricter PHPStan help, consider something like @return array<stdClass> (or the concrete type used by FrmDb::get_results).


716-720: Consider broadening $size param type or clarifying pass‑by‑ref

convert_character_to_px( &$size ) may receive numeric or numeric‑string values before it normalizes to a 'NNNpx' string. The current @param string $size is functionally fine but slightly narrower than the apparent usage. You could optionally change this to @param int|string $size (or similar) and/or mention that it is passed by reference for clarity.

classes/models/FrmAddon.php (1)

171-173: Tighten a few docblocks to match actual return/param types

There are a handful of spots where the phpdoc doesn’t quite match what the code can do; adjusting these would avoid confusing PHPStan and future readers:

  • get_license() / activate_defined_license() (Lines 171–173, 216–222)
    Both can end up returning false (eg when no constant is defined and no option exists), not just a string. Either normalize the value to '' in code or broaden the docblocks to string|false.

  • set_active( $is_active ) (Lines 315–319)
    The param is annotated as bool, but maybe_set_active() passes the string 'valid'. Since the argument is unused and only its truthiness matters, you could either:

    • Change the phpdoc to @param bool|string $is_active, or
    • Cast to bool at the call site or in the method and keep the param as bool.
  • set_license_from_post() (Lines 883–884)
    self::get_addon( $plugin_slug ) can return false, so the effective return type is FrmAddon|false. Right now the docblock promises FrmAddon. Either:

    • Update the docblock to @return FrmAddon|false, and/or
    • Add a guard before calling methods on $this_plugin to fail gracefully if it’s false.
  • send_mothership_request() (Lines 893–896)
    The docblock says @return string, but $message can be an array when the decoded JSON response has no error key. The callers already handle array|string, so the docblock should ideally reflect that (array|string or a more specific array shape).

  • lock_key() (Lines 971–975)
    The docblock currently says @return bool, but the method returns a string key concatenated from $this->transient_lock_key and $this->license. This should be @return string.

A minimal phpdoc-only patch could look like:

-	 * @return string
+	 * @return string|false
@@
-	 * @return string
+	 * @return string|false
@@
-	 * @param bool $is_active
+	 * @param bool|string $is_active
@@
-	 * @return FrmAddon
+	 * @return FrmAddon|false
@@
-	 * @return string
+	 * @return array|string
@@
-	 * @return bool
+	 * @return string

Also applies to: 216-222, 315-319, 883-884, 893-896, 971-975

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 875542b and 85c83c6.

⛔ Files ignored due to path filters (1)
  • phpcs.xml is excluded by !**/*.xml
📒 Files selected for processing (20)
  • classes/helpers/FrmAppHelper.php (9 hunks)
  • classes/helpers/FrmEntriesHelper.php (9 hunks)
  • classes/helpers/FrmFieldsHelper.php (40 hunks)
  • classes/helpers/FrmFormsHelper.php (19 hunks)
  • classes/models/FrmAddon.php (21 hunks)
  • classes/models/FrmEntry.php (16 hunks)
  • classes/models/FrmEntryFormatter.php (30 hunks)
  • classes/models/FrmEntryMeta.php (8 hunks)
  • classes/models/FrmEntryValidate.php (17 hunks)
  • classes/models/FrmField.php (12 hunks)
  • classes/models/FrmFieldFormHtml.php (23 hunks)
  • classes/models/FrmForm.php (17 hunks)
  • classes/models/FrmFormAction.php (8 hunks)
  • classes/models/FrmFormMigrator.php (14 hunks)
  • classes/models/FrmMigrate.php (19 hunks)
  • classes/models/FrmOnSubmitAction.php (0 hunks)
  • classes/models/fields/FrmFieldType.php (33 hunks)
  • classes/views/frm-form-actions/email_action.php (0 hunks)
  • phpstan.neon (2 hunks)
  • stripe/helpers/FrmTransLiteListHelper.php (3 hunks)
💤 Files with no reviewable changes (2)
  • classes/models/FrmOnSubmitAction.php
  • classes/views/frm-form-actions/email_action.php
✅ Files skipped from review due to trivial changes (1)
  • classes/helpers/FrmFieldsHelper.php
🚧 Files skipped from review as they are similar to previous changes (10)
  • classes/models/FrmField.php
  • classes/models/FrmFormMigrator.php
  • classes/models/fields/FrmFieldType.php
  • classes/models/FrmEntry.php
  • classes/models/FrmForm.php
  • classes/helpers/FrmEntriesHelper.php
  • stripe/helpers/FrmTransLiteListHelper.php
  • classes/helpers/FrmAppHelper.php
  • classes/models/FrmFormAction.php
  • phpstan.neon
⏰ 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: PHP 7.4 tests in WP trunk
  • GitHub Check: PHP 8 tests in WP trunk
  • GitHub Check: Cypress
🔇 Additional comments (23)
classes/models/FrmEntryFormatter.php (2)

128-129: LGTM! Excellent type documentation improvements.

The added @return void and @return array annotations accurately reflect the methods' return behavior and align with the PR objectives to improve PHPStan compliance. All methods marked as returning void either modify properties, use pass-by-reference parameters, or have early returns without values.

Also applies to: 150-151, 186-187, 227-228, 242-243, 259-260, 274-275, 289-290, 302-303, 315-316, 328-329, 341-342, 354-355, 477-478, 528-529, 548-549, 573-574, 593-594, 612-613, 634-635, 657-658, 678-679, 698-699, 715-716, 729-730, 743-744, 757-758, 792-793, 815-816, 886-887


579-579: LGTM! Appropriate use of strict comparison.

The change from loose (==) to strict (===) comparison is correct since $this->direction is always a string value ('ltr' or 'rtl'), improving type safety without affecting behavior.

classes/models/FrmEntryMeta.php (8)

191-196: LGTM!

The PHPDoc accurately documents the parameter types and void return type for the duplicate_entry_metas method.


215-220: LGTM!

The PHPDoc correctly documents the return type as false|int, which matches the return value of $wpdb->query().


233-234: LGTM!

The void return type annotation is accurate for this cache-clearing utility method.


299-306: LGTM!

The PHPDoc correctly documents all parameter types and the array return type. The int|string type for $field_id appropriately reflects support for both field IDs and field keys.


342-343: LGTM!

The void return type is accurate for this query-building helper that modifies the $query array by reference.


371-375: LGTM!

The PHPDoc accurately reflects the parameter and return types for retrieving entry meta information.


410-418: LGTM!

The PHPDoc appropriately documents the flexible return type based on the $limit parameter—returning an array for multiple IDs or a single value (or null) when limited to one result.


584-590: LGTM!

The PHPDoc accurately documents the parameter types and array return type for this search method that supports both simple string searches and complex array-based date searches.

classes/helpers/FrmFormsHelper.php (1)

19-20: LGTM! Excellent PHPDoc additions.

The return type and parameter annotations are accurate and well-structured. These additions properly document method signatures for PHPStan analysis without altering any behavior. The types correctly reflect the actual runtime behavior:

  • void returns for methods that output HTML directly
  • Proper union types for parameters that accept multiple types (e.g., false|object, int|string)
  • Accurate array and string return types

Also applies to: 26-31, 39-45, 90-95, 105-106, 232-238, 411-417, 479-483, 495-496, 523-525, 543-551, 586-587, 747-750, 803-804, 867-868, 889-897, 952-956, 1127-1130, 1157-1160, 1187-1191, 1199-1203, 1428-1429

classes/models/FrmMigrate.php (1)

20-22: Docblocks for side‑effect‑only helpers look accurate

All the added @return void annotations on upgrade and the various migrate_to_*/helper methods correctly reflect their side‑effect‑only implementations and don’t affect runtime behaviour. This is a clean win for static analysis.

Also applies to: 81-82, 135-137, 292-294, 306-307, 327-328, 436-437, 458-459, 469-470, 483-484, 510-511, 524-525, 586-587, 635-636, 661-662, 674-675, 697-698

classes/models/FrmFieldFormHtml.php (10)

40-120: Setter helpers correctly annotated as void

_set, set_html, set_field_id, set_pass_args, and set_from_field only mutate object state and never return a value, so the added @return void annotations are accurate and help PHPStan without changing behavior.


122-131: get_html() @return string matches implementation

get_html() always returns $this->html, which is built and filtered as a string throughout the class, so the new @return string docblock correctly describes the method’s contract.


133-181: Pre-input shortcode helpers correctly marked as void

replace_shortcodes_before_input, replace_field_values, and replace_required_label_shortcode only modify $this->html and related state; they have no return statements, so documenting them as @return void is consistent with their behavior.


205-229: Description-related helpers accurately documented as void

Both replace_description_shortcode and maybe_add_description_id perform in-place updates (HTML and IDs) and do not return anything, so the added @return void tags are correct.


260-315: Error handling helpers correctly use @return void

replace_error_shortcode and maybe_add_error_id operate via side effects on $this->html and do not return values, making the new @return void annotations appropriate.


317-358: Required/form shortcode helpers properly annotated as void

replace_required_class, replace_form_shortcodes, and replace_shortcodes_after_input are all mutating helpers with no return value, so the @return void docblocks are accurate.


360-391: Post-processing helpers returning void as documented

filter_for_more_shortcodes and remove_collapse_shortcode only adjust HTML (including by-reference in the latter) and never return a value, so the @return void annotations correctly capture their behavior.


393-415: replace_shortcodes_with_atts() side-effect-only; void is correct

This method iterates over matches and rewrites $this->html without returning anything, so documenting it as @return void is consistent with its usage.


452-494: Label/entry/div helper methods correctly marked as void

add_class_to_label, replace_entry_key, and add_field_div_classes all modify $this->html based on state and do not return values, so the added @return void tags are appropriate.


539-550: process_wp_shortcodes() @return void is accurate

This method conditionally runs do_shortcode and assigns back to $this->html without returning a value; the new @return void annotation matches the actual control flow.

classes/models/FrmAddon.php (1)

67-69: Most new phpdoc annotations look consistent with runtime behavior

The majority of the added/updated @param/@return tags here (hooks registration, addon lookup, cache clearing, update transients, activation/deactivation handlers, etc.) match the actual values being passed around (arrays, FrmAddon|false, mixed, and void where appropriate). These should play nicely with PHPStan once the generic “no return type specified” ignore is removed.

Also applies to: 75-79, 86-90, 101-103, 171-173, 188-192, 216-222, 235-241, 248-252, 257-259, 269-270, 277-279, 315-319, 330-332, 361-365, 435-439, 471-474, 559-563, 585-587, 592-594, 673-677, 682-684, 775-777, 813-815, 831-832, 849-850, 883-884, 953-955

@Crabcyborg Crabcyborg merged commit 0f97777 into master Nov 27, 2025
15 of 16 checks passed
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