Skip to content

phpstan config updates and remove another private unused function#2658

Merged
Crabcyborg merged 3 commits into
masterfrom
phpstan_config_updates
Dec 13, 2025
Merged

phpstan config updates and remove another private unused function#2658
Crabcyborg merged 3 commits into
masterfrom
phpstan_config_updates

Conversation

@Crabcyborg
Copy link
Copy Markdown
Contributor

This update:

  • Removes another unused private function, get_default_settings_atts in the Square Settings controller.
  • Adjusts the phpstan baseline so exceptions are only for files throwing errors to help enforce rules in other files.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 13, 2025

Walkthrough

Replaced broad PHPStan global ignores with many file-scoped ignore rules in phpstan.neon, and removed a private helper get_default_settings_atts() from square/controllers/FrmSquareLiteSettingsController.php.

Changes

Cohort / File(s) Summary
PHPStan configuration
phpstan.neon
Removed some global ignores and shortened the "expects" type pattern (removed resource); added numerous granular, path-scoped ignore entries targeting specific files, controllers, helpers, models, and stubs with explicit message conditions.
Square controller
square/controllers/FrmSquareLiteSettingsController.php
Deleted private static method get_default_settings_atts() which returned a default array (errors and message keys). No replacement included.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Review each new path-scoped ignore in phpstan.neon for correctness and necessity (message patterns and file paths).
  • Search the codebase for any calls or references to get_default_settings_atts() and validate behavior where defaults were expected.
  • Spot-check a representative set of files listed in phpstan.neon to ensure ignores don't mask other real issues.

Possibly related PRs

Suggested reviewers

  • truongwp

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes both main changes: phpstan config updates and removal of a private unused function, matching the changeset content.
Description check ✅ Passed The description is directly related to the changeset, detailing the removal of an unused function and phpstan baseline adjustments as shown in the changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch phpstan_config_updates

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

🧹 Nitpick comments (4)
phpstan.neon (4)

31-31: Tightened “expects …” ignore is fine, but the regex is a bit sloppy.

(...|bool)+ allows repeated tokens and can overmatch; consider removing the trailing + (and using a non-capturing group) to keep this predictable.

-		- '#expects (array|string|int|callable|object|stdClass|float|bool)+#'
+		- '#expects (?:array|string|int|callable|object|stdClass|float|bool)#'

169-176: “is unused” ignore: make the regex more exact to avoid accidental matches.

#is unused.# treats . as “any char”. If the intent is the literal period, escape it and optionally anchor end-of-string.

-			message: '#is unused.#'
+			message: '#is unused\.\s*$#'

180-182: fwrite ignore looks appropriately scoped; consider switching to identifier-based ignores (if supported).

Message-based ignores tend to break on PHPStan wording changes. If phpstan/phpstan 1.4.0 in this repo supports identifier: for ignoreErrors, it’s typically more stable than matching message text.


183-280: The #should return# suppression is very broad; consider narrowing or using identifiers/baseline tooling.

Given reportUnmatchedIgnoredErrors: false (Line 3), any mistyped/stale ignores here will silently linger. Two options to reduce long-term drift:

  • Prefer identifier:-based ignores (if supported by your phpstan/phpstan version).
  • Or ensure CI runs with unmatched-ignored reporting enabled at least periodically (even if you keep it off locally).
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8a4703b and badf216.

📒 Files selected for processing (2)
  • phpstan.neon (2 hunks)
  • square/controllers/FrmSquareLiteSettingsController.php (0 hunks)
💤 Files with no reviewable changes (1)
  • square/controllers/FrmSquareLiteSettingsController.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). (6)
  • GitHub Check: Cypress
  • GitHub Check: PHP 7.4 tests in WP trunk
  • GitHub Check: PHP 8 tests in WP trunk
  • GitHub Check: Cypress
  • GitHub Check: PHP 8 tests in WP trunk
  • GitHub Check: PHP 7.4 tests in WP trunk

Comment thread phpstan.neon Outdated
@Crabcyborg Crabcyborg changed the title phpstan config updates phpstan config updates and remove another private unused function Dec 13, 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 (1)
phpstan.neon (1)

182-280: Large path list documents outstanding return type issues.

The extensive list of 99 files with #should return# ignores effectively documents which files have outstanding return type issues. While this is consistent with the PR's goal of narrowing exceptions to specific files, consider tracking these as technical debt to address incrementally. This makes the configuration more maintainable long-term.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between badf216 and 02904a8.

📒 Files selected for processing (1)
  • phpstan.neon (2 hunks)
⏰ 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). (1)
  • GitHub Check: Cypress
🔇 Additional comments (3)
phpstan.neon (3)

31-31: Stricter type checking for resource types.

Removing resource from the global expects ignore and handling it with a targeted path-specific ignore (line 179-180) improves type safety across the codebase.


176-177: Regex escaping is now correct.

The past review concern about escaping the ?? operator has been resolved. The pattern \?\? on line 176 correctly escapes both question marks to match the literal null coalescing operator.


168-180: Well-structured path-specific ignores.

Moving from global ignores to targeted, path-specific suppressions is a best practice. This allows PHPStan to enforce rules more strictly across the codebase while making necessary exceptions only for specific files.

@Crabcyborg Crabcyborg merged commit 7d73828 into master Dec 13, 2025
16 checks passed
@Crabcyborg Crabcyborg deleted the phpstan_config_updates branch December 13, 2025 01:54
@Crabcyborg Crabcyborg restored the phpstan_config_updates branch December 13, 2025 02:04
@Crabcyborg Crabcyborg modified the milestones: 6.27, 6.26.1 Dec 15, 2025
stephywells pushed a commit that referenced this pull request Apr 4, 2026
phpstan config updates and remove another private unused function
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