Auto-fix via phpcbf for alignment/array-spacing/brace-placement errors,
plus minimal hand-edits for:
- 11 SQL errors in WorkspaceLockStore, CleanupRunRepository,
WorktreeInventoryRepository: added `phpcs:ignore` for
WordPress.DB.PreparedSQL warnings on internally-controlled table
names ($wpdb->prefix + schema constants, never user input).
- 1 `count()` in loop condition in DataMachineJobCleanupRunEvidenceStore:
extracted to $max_unit variable.
- 2 short ternary errors in WorkspacePreloadArtifact and GitHub.php:
expanded to full ternary (with `phpcs:ignore` on the GitHub one to
avoid double-encoding side effect of repeated wp_json_encode call).
- 2 Yoda condition errors in CleanupRunService and
WorkspaceWorktreeLifecycle: swapped operand order.
Reverted unsafe phpcbf changes that introduced behavior changes:
- WordPressRuntimeInspector / WorkspaceWorktreeLifecycle /
WorktreeContextInjector: phpcbf replaced @file_get_contents() with
$wp_filesystem->get_contents(), which fails when $wp_filesystem is
not initialized and ignores offset/length args. Reverted to native
calls with `phpcs:ignore` comments documenting the trust boundary.
Smoke test `smoke-github-fetch-by-number` was asserting on whitespace
in GitHub.php source via strpos — updated to match the new
phpcs-compliant alignment.
Closes #419
Errors: 33 -> 0. No behavior changes.
Summary
Cleans up the 34 pre-existing phpcs errors on
mainsohomeboy release data-machine-codestops requiring--skip-checks.Pure formatting/cleanup. No behavior changes.
Before / after
(Warnings dropped from 593 → 315 as a free side effect of the formatting pass on the same files. The remaining warnings are out of scope per the issue.)
How
homeboy lint --fix --errors-only(=phpcbfunder the hood) on the workspace.inc/change and reverted behavior-changing auto-fixes (see below).WordPress.DB.PreparedSQL.*errors inWorkspaceLockStore,CleanupRunRepository,WorktreeInventoryRepository— addedphpcs:ignorecomments scoped to the specific lines. All flagged queries use table names sourced from\$wpdb->prefix+ internal schema constants (CleanupSchema::runs_table(), etc.), never user input. The dynamic parameters are already passed through\$wpdb->prepare()with%splaceholders.count()in loop condition inDataMachineJobCleanupRunEvidenceStore::format_bytes()— extracted to\$max_unitlocal variable.WorkspacePreloadArtifact::clone_callback ?:— expanded to full ternary on the property read (no side effect, behavior-equivalent).GitHub.phphash('sha256', wp_json_encode(...) ?:— kept the short ternary withphpcs:ignoreto avoid double-encoding (a naive expansion would callwp_json_encode()twice per loop iteration).CleanupRunService::pending_rows_of_typeandWorkspaceWorktreeLifecycle::resolve_*— swapped operand order (symmetric comparisons, behavior-equivalent).Behavior-changing auto-fixes reverted
phpcbfapplied awp-filesystemruleset transform that replaced@file_get_contents()/@file()with\$wp_filesystem->get_contents()in three files. This was reverted because:\$wp_filesystemisnullunlessWP_Filesystem()has been initialized — caused fatal insmoke-worktree-context-injection.phpandsmoke-wordpress-runtime-inspection.php.\$wp_filesystem->get_contents()only accepts\$file— it silently ignores the offset/length args, so the 8 KiB read inWordPressRuntimeInspector::read()would have become a full-file read.Reverted to the original native calls with
phpcs:ignorecomments documenting the trust boundary (controlled worktree paths, validated upstream).Affected files (all reverts):
inc/Runtime/WordPressRuntimeInspector.php(2 reads)inc/Workspace/WorktreeContextInjector.php(3 reads)inc/Workspace/WorkspaceWorktreeLifecycle.php(2 reads)Files touched
The one test edit (
smoke-github-fetch-by-number.php) was forced by phpcs — the test was asserting viastrposon whitespace-sensitive substrings ofGitHub.phpsource (\$issue_number = (int) ...with two spaces). Once phpcs realigned those assignments to single space, the assertions had to be updated to match. No assertion logic changed, only the spacing in the matched string literals.Verification
homeboy lint data-machine-code --errors-only→ 0 errors (was 33).tests/smoke-*.php. 78 pass / 8 fail. Confirmed all 8 failures pre-exist onmain(verified by stashing my changes and re-running). No new regressions caused by this PR.preflight.lintshowsready(previously failed/required--skip-checks). The pre-existingWP_Agent_Token_Storecross-plugin compatibility break still affectspreflight.testat runtime — that's out of scope per the issue and tracked separately.docs/CHANGELOG.mdedits.Closes #419