Skip to content

Add var comments to object properties#2611

Merged
Crabcyborg merged 8 commits into
masterfrom
add_var_comments_to_object_properties
Nov 27, 2025
Merged

Add var comments to object properties#2611
Crabcyborg merged 8 commits into
masterfrom
add_var_comments_to_object_properties

Conversation

@Crabcyborg
Copy link
Copy Markdown
Contributor

No description provided.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Nov 27, 2025

Warning

Rate limit exceeded

@Crabcyborg has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 18 minutes and 9 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between bf3a5f4 and fe20abf.

📒 Files selected for processing (3)
  • classes/helpers/FrmTipsHelper.php (1 hunks)
  • classes/models/FrmAddon.php (1 hunks)
  • phpstan.neon (1 hunks)

Walkthrough

Added PHPDoc annotations and several new property declarations across multiple models and controllers; removed two unused properties; updated phpstan.neon rules; and added a new update_setting($key, $value, $sanitize) method to FrmSettings. No other behavioral changes detected.

Changes

Cohort / File(s) Summary
Docblocks & minor property annotations
classes/controllers/FrmFormActionsController.php, classes/helpers/FrmFieldGridHelper.php, classes/helpers/FrmFormsListHelper.php, classes/helpers/FrmListHelper.php, classes/models/FrmField.php, classes/models/FrmFieldFormHtml.php, classes/models/FrmFieldTypeOptionData.php, classes/models/FrmFormTemplateApi.php, classes/models/FrmInbox.php, classes/models/FrmOnSubmitAction.php, classes/models/FrmPersonalData.php, classes/models/FrmReviews.php, classes/models/FrmSolution.php, classes/models/FrmSpamCheckDenylist.php, stubs.php
Added PHPDoc @var annotations to existing properties (public/protected/private) without changing behavior.
Removed unused properties & small cleanup
classes/helpers/FrmEntriesListHelper.php
Removed two protected properties ($item, $field) and added/updated a docblock for $column_name.
New/expanded model properties
classes/models/FrmAddon.php, classes/models/FrmCreateFile.php, classes/models/FrmDb.php, classes/models/FrmMigrate.php, classes/models/FrmFormMigrator.php
Added numerous new public/protected/private properties with PHPDoc blocks to expand typed state (e.g., addon metadata, table name properties, migrator tracking fields, file creation metadata). No method logic changes shown.
FrmSettings expansion + new method
classes/models/FrmSettings.php
Added 30+ public configuration properties with docblocks (captcha keys, messages, email/settings, spam checks, etc.) and introduced public function update_setting($key, $value, $sanitize) to update a single setting with sanitization.
Event controllers — private properties
square/controllers/FrmSquareLiteEventsController.php, stripe/controllers/FrmStrpLiteEventsController.php
Added private properties with PHPDoc annotations ($event, and for Stripe: $invoice, $charge, $status) only.
phpstan configuration changes
phpstan.neon
Removed several broad ignore rules and added file-specific ignore patterns (and a duplicate entry) to narrow/adjust static analysis exceptions.
File header corruption fix
classes/helpers/FrmTipsHelper.php
Fixed corrupted PHP opening tag prefix that inserted the file path before <?php.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Areas needing extra attention:
    • classes/models/FrmSettings.php: confirm new properties align with persisted settings and verify correctness/safety of new update_setting() sanitization usage.
    • classes/models/FrmAddon.php: ensure new addon metadata properties match initialization/usage sites.
    • classes/models/FrmDb.php and classes/models/FrmMigrate.php: check table-name property uses in DB access code.
    • classes/helpers/FrmEntriesListHelper.php: verify removed $item/$field are not referenced elsewhere.
    • phpstan.neon: validate that removed global ignores do not surface many new issues and that added file-specific ignores are intentional.

Possibly related PRs

Suggested reviewers

  • lauramekaj1

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Description check ❓ Inconclusive No description was provided, making it impossible to assess relevance to the changeset. Add a description explaining the purpose and scope of adding var comments to properties, such as improving type hinting and IDE support.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding PHPDoc @var annotations to object properties across multiple files in the codebase.

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

Caution

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

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

167-198: Fix the pipeline failure: add null-check before foreach.

Psalm correctly identifies that $messages can be false (as documented in the PHPDoc on line 19), but the foreach on line 189 doesn't guard against this case.

Apply this diff to fix the issue:

 public function filter_messages( &$messages, $type = 'unread' ) {
+	if ( false === $messages || ! is_array( $messages ) ) {
+		return;
+	}
 	$user_id = get_current_user_id();
 	foreach ( $messages as $k => $message ) {

Alternatively, if $messages should never actually be false when this method is called, consider changing the type annotation and ensuring $messages is always initialized as an empty array instead of false.

🧹 Nitpick comments (1)
classes/models/FrmSettings.php (1)

629-640: Consider whether store() should be called or document the requirement.

The update_setting() method updates the property value but does not persist the change to the database by calling $this->store(). This means callers must explicitly call store() after using this method.

Verify this is intentional. If so, consider adding a @return PHPDoc note that callers must invoke store() separately to persist the changes.

Consider adding documentation:

 	/**
 	 * Updates a single setting with specified sanitization.
 	 *
 	 * @since 6.9
 	 *
 	 * @param string $key The setting key to update.
 	 * @param mixed  $value The new value for the setting.
 	 * @param string $sanitize The name of the sanitization function to apply to the new value.
-	 * @return bool True on success, false on failure.
+	 * @return bool True on success, false on failure. Note: Callers must invoke store() to persist changes.
 	 */
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0f97777 and 8f3e6a6.

📒 Files selected for processing (25)
  • classes/controllers/FrmFormActionsController.php (2 hunks)
  • classes/helpers/FrmEntriesListHelper.php (1 hunks)
  • classes/helpers/FrmFieldGridHelper.php (2 hunks)
  • classes/helpers/FrmFormsListHelper.php (1 hunks)
  • classes/helpers/FrmListHelper.php (1 hunks)
  • classes/models/FrmAddon.php (1 hunks)
  • classes/models/FrmCreateFile.php (1 hunks)
  • classes/models/FrmDb.php (1 hunks)
  • classes/models/FrmField.php (1 hunks)
  • classes/models/FrmFieldFormHtml.php (1 hunks)
  • classes/models/FrmFieldTypeOptionData.php (1 hunks)
  • classes/models/FrmFormMigrator.php (1 hunks)
  • classes/models/FrmFormTemplateApi.php (1 hunks)
  • classes/models/FrmInbox.php (1 hunks)
  • classes/models/FrmMigrate.php (1 hunks)
  • classes/models/FrmOnSubmitAction.php (1 hunks)
  • classes/models/FrmPersonalData.php (1 hunks)
  • classes/models/FrmReviews.php (1 hunks)
  • classes/models/FrmSettings.php (5 hunks)
  • classes/models/FrmSolution.php (2 hunks)
  • classes/models/FrmSpamCheckDenylist.php (1 hunks)
  • phpstan.neon (1 hunks)
  • square/controllers/FrmSquareLiteEventsController.php (1 hunks)
  • stripe/controllers/FrmStrpLiteEventsController.php (1 hunks)
  • stubs.php (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
classes/models/FrmAddon.php (3)
classes/models/FrmSolution.php (2)
  • download_id (765-767)
  • plugin_name (138-140)
classes/helpers/FrmAppHelper.php (1)
  • plugin_folder (51-53)
stripe/helpers/FrmTransLiteAppHelper.php (1)
  • plugin_folder (30-32)
🪛 GitHub Actions: Psalm Code Analysis
classes/models/FrmInbox.php

[error] 167-167: Psalm: PossiblyFalseIterator: Cannot iterate over falsable var array<array-key, mixed>|false (see https://psalm.dev/164)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Cypress
  • GitHub Check: Cypress
  • GitHub Check: PHP 7.4 tests in WP trunk
  • GitHub Check: PHP 8 tests in WP trunk
  • GitHub Check: PHP 7.4 tests in WP trunk
  • GitHub Check: PHP 8 tests in WP trunk
🔇 Additional comments (27)
classes/models/FrmFieldFormHtml.php (1)

11-39: LGTM! PHPDoc annotations are accurate.

The type annotations correctly document the property types:

  • int|string for $field_id appropriately handles both numeric IDs and string keys
  • Array types for $form and $pass_args match their initialization and usage patterns
classes/models/FrmPersonalData.php (1)

8-16: LGTM! Type annotations are correct.

Both $limit and $page are correctly typed as int - they're initialized with integer defaults and $page is explicitly cast via absint() when set.

classes/models/FrmCreateFile.php (1)

8-46: LGTM! Comprehensive type documentation.

All type annotations accurately reflect the property usage:

  • String types for path/name properties
  • array for $uploads (from wp_upload_dir())
  • int for chmod values (octal literals are integers in PHP)
  • bool for the permission flag
classes/models/FrmFieldTypeOptionData.php (1)

15-18: LGTM!

The @var array annotation correctly documents the static cache property used to store field type options.

classes/models/FrmSpamCheckDenylist.php (1)

19-27: LGTM!

Type annotations correctly document:

  • $posted_fields: Populated from FrmField::get_all_for_form() returning an array
  • $denylist: Populated from get_denylist_array() returning an array of denylist configurations
classes/models/FrmFormTemplateApi.php (1)

8-21: LGTM! Clear type documentation for static properties.

The PHPDoc annotations accurately document the types of these static properties, improving code clarity and static analysis capabilities.

classes/models/FrmField.php (1)

8-16: LGTM! Type annotations improve static analysis.

The PHPDoc blocks correctly document these public static properties, making their types explicit for developers and static analysis tools.

classes/helpers/FrmFormsListHelper.php (1)

8-11: LGTM! Type documentation aligns with usage.

The PHPDoc annotation correctly documents $status as a string, which is consistent with its initialization on line 16 using self::get_param().

classes/controllers/FrmFormActionsController.php (2)

8-11: LGTM! Type annotation for post type constant.

The PHPDoc correctly documents this static property as a string, matching its initialization value.


787-790: LGTM! Type documentation for action registry.

The PHPDoc correctly identifies $actions as an array, consistent with its initialization on line 790 and usage throughout the factory pattern implementation.

phpstan.neon (1)

161-163: LGTM! Improved static analysis strictness.

Removing the broad global ignore rule "#has no type specified.#" and replacing it with a targeted ignore for a specific file improves the effectiveness of static analysis. This change aligns well with the PR's goal of adding explicit type documentation throughout the codebase.

classes/helpers/FrmFieldGridHelper.php (2)

8-11: LGTM! Union type correctly documents dual usage.

The bool|string type annotation for $parent_li accurately reflects its dual usage: initialized as false (line 67) and later set to true (line 172).


58-61: LGTM! Property declaration with default value.

The PHPDoc and explicit initialization of $section_is_open to false improves code clarity. This property is used throughout the class (e.g., lines 89, 149, 217) and the default value is appropriate.

classes/models/FrmInbox.php (1)

13-21: LGTM! Type annotations are accurate.

The PHPDoc blocks correctly document the types of these private properties. The array|false type for $messages accurately reflects that it can be false before initialization (line 31).

classes/helpers/FrmListHelper.php (1)

82-90: LGTM! Array type annotations added.

The PHPDoc blocks correctly identify these protected properties as arrays, matching their initializations on lines 85 and 90-105.

classes/models/FrmReviews.php (1)

8-21: LGTM! Type annotations are accurate.

The PHPDoc annotations correctly document the property types and match their initialized values.

stripe/controllers/FrmStrpLiteEventsController.php (1)

13-31: LGTM! Property type annotations are accurate.

The PHPDoc blocks correctly document the nullable object and string types for these private properties based on their usage throughout the class.

square/controllers/FrmSquareLiteEventsController.php (1)

13-16: LGTM! Type annotation is correct.

The @var object|null annotation accurately reflects the property usage, as evidenced by the is_object() check at line 77.

classes/models/FrmOnSubmitAction.php (1)

15-18: LGTM! Type annotation is accurate.

The @var string annotation correctly documents the static property type.

classes/helpers/FrmEntriesListHelper.php (1)

8-11: LGTM! Type annotation is accurate.

The @var string|null annotation correctly reflects the property usage, as it's assigned from preg_replace() at line 364 which can return null.

classes/models/FrmSolution.php (1)

16-37: LGTM! Type annotations are accurate.

The PHPDoc blocks correctly document the string types for these protected properties, matching their initialized values.

stubs.php (2)

168-171: LGTM! Type annotation is appropriate.

The @var string annotation for the version property is reasonable.


335-338: LGTM! Type annotation is accurate.

The @var string annotation correctly matches the initialized value.

classes/models/FrmAddon.php (1)

9-77: LGTM! Property type annotations are accurate.

These PHPDoc blocks correctly document the property types based on their initialization values and usage throughout the class.

classes/models/FrmMigrate.php (1)

8-26: LGTM!

The PHPDoc type annotations are accurate and align with the property initialization in the constructor.

classes/models/FrmFormMigrator.php (1)

8-51: LGTM!

The PHPDoc type annotations accurately document the property types and align with their initialization and usage throughout the class.

classes/models/FrmSettings.php (1)

9-243: LGTM!

The PHPDoc type annotations accurately document the property types and support static analysis.

Comment thread classes/models/FrmAddon.php
Comment thread classes/models/FrmDb.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: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8f3e6a6 and bf3a5f4.

⛔ Files ignored due to path filters (1)
  • psalm.xml is excluded by !**/*.xml
📒 Files selected for processing (4)
  • classes/helpers/FrmTipsHelper.php (1 hunks)
  • classes/models/FrmAddon.php (1 hunks)
  • classes/models/FrmDb.php (1 hunks)
  • phpstan.neon (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • classes/models/FrmAddon.php
  • classes/models/FrmDb.php
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Cypress
  • GitHub Check: PHP 7.4 tests in WP trunk
  • GitHub Check: PHP 8 tests in WP trunk
🔇 Additional comments (1)
phpstan.neon (1)

158-176: Good approach: Moving to file-specific ignore rules.

The transition from broad ignore rules to file-specific suppressions is a positive change. This allows PHPStan to catch real issues in other parts of the codebase while acknowledging known edge cases in specific files.

Comment thread classes/helpers/FrmTipsHelper.php Outdated
Comment thread phpstan.neon Outdated
@Crabcyborg Crabcyborg merged commit 70a016e into master Nov 27, 2025
16 checks passed
@Crabcyborg Crabcyborg deleted the add_var_comments_to_object_properties branch November 27, 2025 19:52
stephywells pushed a commit that referenced this pull request Apr 4, 2026
…roperties

Add var comments to object properties
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