Skip to content

CRM: Fix code style formatting throughout codebase#46809

Merged
haqadn merged 23 commits intotrunkfrom
fix/crm-code-style-formatting
Feb 5, 2026
Merged

CRM: Fix code style formatting throughout codebase#46809
haqadn merged 23 commits intotrunkfrom
fix/crm-code-style-formatting

Conversation

@haqadn
Copy link
Copy Markdown
Contributor

@haqadn haqadn commented Jan 28, 2026

Proposed changes:

This PR fixes code style and formatting issues throughout the Jetpack CRM plugin codebase using automated tools and manual cleanup.

  • Ran phpcbf (PHP Code Beautifier and Fixer) across the entire CRM plugin with multiple passes
  • Updated .phpcs.dir.xml to exclude legacy naming convention errors (variables, properties, methods) and prevent auto-fixing of strict comparisons that could change behavior
  • Updated phan baseline to reflect formatting changes
  • All changes are purely cosmetic — no functional code modifications

Impact:

  • Reduced PHPCS errors from ~54,209 to 7,924 (85% reduction)
  • Reduced PHPCS warnings to 3,960
  • Zero remaining auto-fixable formatting violations (964 reported as "auto-fixable" are all intentionally excluded strict comparison changes)
  • 202 CRM files changed across includes, modules, admin pages, and API files

What was fixed:

  • Trailing whitespace and inconsistent indentation (tabs vs spaces)
  • Bracket positioning and brace alignment
  • Array alignment and spacing around operators
  • Comment formatting and doc block consistency
  • Empty parentheses spacing
  • Block comments moved out of function parameter lists

What remains (not in scope for this PR):

  • ~963 strict comparison issues (==/!= to ===/!==) excluded from auto-fix to prevent behavior changes
  • ~6,961 issues requiring manual review (unused variables, missing docs, security checks)

Safety measures taken:

  • Strict comparison auto-fixes disabled via phpcbf-only excludes to prevent behavior changes
  • in_array() strict parameter auto-addition disabled for the same reason
  • Verified no functional logic changes in the diff
  • Restored specific values that were incorrectly modified by automated tools (icon class names, strict in_array checks)
  • Added phpcs:disable/enable blocks for mixed PHP/JS contexts where formatting rules conflict
  • Refactored inline PHP in HTML attributes to avoid code style violations without changing output

Other information:

  • Have you written new tests for your changes, if applicable? — N/A (no functional changes)
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

None

Does this pull request change what data or activity we track or use?

No

Testing instructions:

This PR contains only code formatting changes with no functional modifications.

Manual verification:

  1. Review the diff to confirm changes are purely cosmetic (whitespace, indentation, bracket positioning)
  2. Run vendor/bin/phpcs -d memory_limit=1G --report=summary projects/plugins/crm/ to verify reduced error count
  3. Optionally run CRM PHP tests to confirm no breakage
  4. Smoke test CRM functionality (contacts, invoices, transactions) to verify no regressions

Copilot AI review requested due to automatic review settings January 28, 2026 20:31
@haqadn haqadn added [Status] Needs Review This PR is ready for review. [Plugin] CRM Issues about the Jetpack CRM plugin Code Quality labels Jan 28, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR applies automated code style fixes throughout the Jetpack CRM plugin codebase using phpcbf (PHP Code Beautifier and Fixer). The changes address formatting inconsistencies including whitespace, indentation, bracket positioning, and comment formatting. All modifications are cosmetic with no functional code changes.

Changes:

  • Fixed 80,992 style violations across 96 files
  • Updated .phpcs.dir.xml to exclude legacy naming convention errors
  • Reduced PHPCS errors from 54,209 to 31,990 (41% reduction)

Reviewed changes

Copilot reviewed 78 out of 188 changed files in this pull request and generated no comments.

Show a summary per file
File Description
projects/plugins/crm/includes/ZeroBSCRM.DAL3.ObjectLayer.php Reformatted control structures, fixed spacing and indentation
projects/plugins/crm/includes/ZeroBSCRM.DAL3.Obj.QuoteTemplates.php Fixed array formatting and indentation
projects/plugins/crm/includes/ZeroBSCRM.DAL3.Obj.Logs.php Standardized spacing and array formatting
projects/plugins/crm/includes/ZeroBSCRM.DAL3.Obj.EventReminders.php Fixed indentation and control structure formatting
projects/plugins/crm/includes/ZeroBSCRM.DAL3.Obj.Addresses.php Reformatted array definitions
projects/plugins/crm/includes/ZeroBSCRM.DAL3.Fields.php Changed == to === for strict comparisons
projects/plugins/crm/includes/ZeroBSCRM.DAL3.Export.php Changed == to === for strict comparisons
projects/plugins/crm/includes/ZeroBSCRM.DAL2.Mail.php Changed == to === for strict comparisons
projects/plugins/crm/includes/ZeroBSCRM.DAL.Fields.php Removed extra ! from comment block
Multiple admin/settings files Changed == to === for strict comparisons
Multiple admin files Changed == to === for strict comparisons, removed extra ! from comment blocks
Multiple API files Removed extra ! from comment blocks
projects/plugins/crm/.phpcs.dir.xml Added exclusions for legacy naming conventions
projects/plugins/crm/changelog/fix-code-style-formatting Added changelog entry

@github-actions
Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c6ecb26f85

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread projects/plugins/crm/admin/contact/add-file.page.php Outdated
$upload = jpcrm_save_admin_upload_to_folder( 'zbsc_file_attachment', $contact_dir_info['files'] );

if ( isset( $upload['error'] ) && $upload['error'] != 0 ) {
if ( isset( $upload['error'] ) && $upload['error'] !== 0 ) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Treat successful uploads as non-errors

In WordPress, wp_upload_bits() reports success with error set to false/empty string, not integer 0. The new strict check !== 0 therefore evaluates true on successful uploads, so the UI reports an error and aborts saving even when the upload succeeded. This needs a truthiness/empty check or explicit string comparison instead of strict int comparison.

Useful? React with 👍 / 👎.

Comment on lines 165 to 166
if ( ! empty( $slot ) && $originalSlot !== $slot && $slot !== -1 ) {
zeroBSCRM_fileslots_addToSlot( $slot, $ourFile['file'], $customer, ZBS_TYPE_CONTACT, true );
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep "None" slot from being stored

The slot dropdown uses value="-1" to represent “None”, which arrives as the string "-1". With the new strict comparison $slot !== -1, that sentinel no longer short‑circuits, so the code proceeds to zeroBSCRM_fileslots_addToSlot() and writes a meta slot for -1 instead of leaving the file unassigned. Cast $slot to int or compare to the string sentinel to preserve the intended behavior.

Useful? React with 👍 / 👎.

@jp-launch-control
Copy link
Copy Markdown

jp-launch-control Bot commented Jan 28, 2026

Code Coverage Summary

Coverage changed in 90 files. Only the first 5 are listed here.

File Coverage Δ% Δ Uncovered
projects/plugins/crm/includes/ZeroBSCRM.DAL3.php 0/3598 (0.00%) 0.00% 1038 💔
projects/plugins/crm/includes/ZeroBSCRM.DAL3.Obj.Contacts.php 0/2555 (0.00%) 0.00% 519 💔
projects/plugins/crm/includes/ZeroBSCRM.DAL3.Helpers.php 0/2835 (0.00%) 0.00% 424 💔
projects/plugins/crm/includes/ZeroBSCRM.DAL3.Obj.Companies.php 0/1528 (0.00%) 0.00% 355 💔
projects/plugins/crm/includes/ZeroBSCRM.DAL3.Obj.Quotes.php 0/1143 (0.00%) 0.00% 331 💔

Full summary · PHP report

If appropriate, add one of these labels to override the failing coverage check: Covered by non-unit tests Use to ignore the Code coverage requirement check when E2Es or other non-unit tests cover the code Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage.

haqadn and others added 2 commits January 28, 2026 15:44
Ran phpcbf on the entire CRM plugin to fix cosmetic style issues only:
- Fixed trailing whitespace
- Corrected inconsistent indentation (tabs vs spaces)
- Standardized bracket positioning
- Aligned array declarations
- Improved comment formatting
- Fixed spacing around operators

Fixed 126,032 style violations across 138 files using PHP Code Beautifier.
All changes are purely cosmetic with NO functional modifications.

Updated .phpcs.dir.xml to exclude rules that could change behavior:
- Excluded variable/property/method naming (legacy camelCase)
- Excluded strict comparison auto-fixes (== to ===)
- Excluded strict in_array parameter additions

Verified: NO == to === conversions were made (checked programmatically).
This reduces PHPCS errors from 54,209 to ~30,000 safely.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@haqadn haqadn force-pushed the fix/crm-code-style-formatting branch from c6ecb26 to d402d81 Compare January 28, 2026 20:50
haqadn and others added 2 commits January 28, 2026 15:56
The code formatting changes improved use statement organization,
which fixed some PhanUnreferencedUseNormal warnings in:
- ZeroBSCRM.Mail.php
- class-oauth-handler.php

Updated the phan baseline to reflect these improvements.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings January 28, 2026 21:44
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 79 out of 189 changed files in this pull request and generated no new comments.

haqadn and others added 2 commits January 29, 2026 17:44
Replace 3-space indentation with tabs in comment block section
dividers across helper and integration files. Fix excessive spacing
on format array keys in quotes object.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Apply phpcbf auto-fixes and manually correct indentation mismatches
where adjacent lines at the same scope level had different tab depths
across Quotes, Contacts, and Helpers DAL files.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@haqadn haqadn added [Status] In Progress and removed [Status] Needs Review This PR is ready for review. labels Jan 30, 2026
haqadn and others added 2 commits January 29, 2026 20:46
Normalize parentheses spacing and remove extra blank lines in DAL3 Helpers, Contacts, Quotes, and IntegrationFuncs files.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
haqadn and others added 2 commits February 4, 2026 17:52
Run phpcbf with full WordPress standard config on 9 CRM files, then
manually correct indentation issues the fixer introduced: expanded
arrays with wrong depth, global-scope code at inconsistent tab levels,
over-indented comments, and split /*! docblock headers.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 4, 2026 22:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 80 out of 195 changed files in this pull request and generated no new comments.

haqadn and others added 2 commits February 5, 2026 11:38
Regenerated baseline after code style fixes. Removes 3 dead use
imports (PhanUnreferencedUseNormal) and surfaces ~30 pre-existing
issues now detectable due to one-liner expansion.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…olations

Apply phpcbf fixes for array alignment and doc comment style in pure PHP
files. Add phpcs:disable/enable block around inline JS in List.php where
PHP indentation rules conflict with JS context. Refactor inline disabled
attribute in MetaBoxes3.Quotes.php to avoid brace-on-same-line violation.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 5, 2026 18:10
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 80 out of 195 changed files in this pull request and generated no new comments.

@haqadn haqadn requested a review from anomiex February 5, 2026 18:17
@haqadn haqadn added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Feb 5, 2026
@haqadn haqadn requested a review from a team February 5, 2026 18:17
anomiex
anomiex previously approved these changes Feb 5, 2026
Copy link
Copy Markdown
Contributor

@anomiex anomiex left a comment

Choose a reason for hiding this comment

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

Seems ok. Haven't tested at all though.

Comment thread projects/plugins/crm/includes/ZeroBSCRM.MetaBoxes3.Quotes.php Outdated
Co-authored-by: Brad Jorsch <anomiex@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 5, 2026 19:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 80 out of 195 changed files in this pull request and generated no new comments.

@haqadn haqadn merged commit 59d4722 into trunk Feb 5, 2026
64 of 66 checks passed
@haqadn haqadn deleted the fix/crm-code-style-formatting branch February 5, 2026 19:20
@github-actions github-actions Bot removed the [Status] Needs Review This PR is ready for review. label Feb 5, 2026
@haqadn
Copy link
Copy Markdown
Contributor Author

haqadn commented Feb 5, 2026

Merged this after temporarily disabling the "Linting / PHP Code Sniffer (changes to excluded files only)" rule.

If you find yourself in a situation where you want to revert this, please consider fixing the specific problem instead of reverting the whole PR.

@tbradsha
Copy link
Copy Markdown
Contributor

Linking some relevant cleanup PRs:

tbradsha added a commit that referenced this pull request Mar 20, 2026
tbradsha added a commit that referenced this pull request May 5, 2026
Newlines added in #46809 broke these. Let's one-line them by moving most logic to separate PHP.
@tbradsha
Copy link
Copy Markdown
Contributor

tbradsha commented May 5, 2026

Noting that #48496 fixed several more instances (see c3493ed).

tbradsha added a commit that referenced this pull request May 5, 2026
Newlines added in #46809 broke these. Let's one-line them by moving most logic to separate PHP.
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.

4 participants