CRM: Fix code style formatting throughout codebase#46809
Conversation
There was a problem hiding this comment.
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.xmlto 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 |
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
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:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
There was a problem hiding this comment.
💡 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".
| $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 ) { |
There was a problem hiding this comment.
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 👍 / 👎.
| if ( ! empty( $slot ) && $originalSlot !== $slot && $slot !== -1 ) { | ||
| zeroBSCRM_fileslots_addToSlot( $slot, $ourFile['file'], $customer, ZBS_TYPE_CONTACT, true ); |
There was a problem hiding this comment.
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 👍 / 👎.
Code Coverage SummaryCoverage changed in 90 files. Only the first 5 are listed here.
If appropriate, add one of these labels to override the failing coverage check:
Covered by non-unit tests
|
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>
c6ecb26 to
d402d81
Compare
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>
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>
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>
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>
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>
anomiex
left a comment
There was a problem hiding this comment.
Seems ok. Haven't tested at all though.
Co-authored-by: Brad Jorsch <anomiex@users.noreply.github.com>
|
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. |
|
Linking some relevant cleanup PRs:
|
Newlines added in #46809 broke these. Let's one-line them by moving most logic to separate PHP.
Newlines added in #46809 broke these. Let's one-line them by moving most logic to separate PHP.
Proposed changes:
This PR fixes code style and formatting issues throughout the Jetpack CRM plugin codebase using automated tools and manual cleanup.
phpcbf(PHP Code Beautifier and Fixer) across the entire CRM plugin with multiple passes.phpcs.dir.xmlto exclude legacy naming convention errors (variables, properties, methods) and prevent auto-fixing of strict comparisons that could change behaviorImpact:
What was fixed:
What remains (not in scope for this PR):
==/!=to===/!==) excluded from auto-fix to prevent behavior changesSafety measures taken:
phpcbf-onlyexcludes to prevent behavior changesin_array()strict parameter auto-addition disabled for the same reasonin_arraychecks)phpcs:disable/enableblocks for mixed PHP/JS contexts where formatting rules conflictOther information:
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:
vendor/bin/phpcs -d memory_limit=1G --report=summary projects/plugins/crm/to verify reduced error count