Skip to content

dev!: Mark WP\MCP\Cli classes as final and cleanup internals - #306

Open
justlevine wants to merge 6 commits into
trunkfrom
dev/audit-cli-namespace
Open

dev!: Mark WP\MCP\Cli classes as final and cleanup internals#306
justlevine wants to merge 6 commits into
trunkfrom
dev/audit-cli-namespace

Conversation

@justlevine

@justlevine justlevine commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

What?

This PR audits and cleans up the PHP classes in the CLI namespace.

Note

While marking classes final is technically a breaking change, functionally the plugin doesn't support extending them anyway.

Why?

Reducing the footprint for potential breaking changes before the release to .org.

How?

  • Replaces use of blanket phpcs:ignore annotations with specific smells + reasons
  • Marks both Cli\McpCommand and Cli\StdioServerBridge as final
  • Reduces the cyclomatic complexity in StdioServerBridge and narrows the typehints to what those methods (and their callers expect).

Use of AI Tools

None

Testing Instructions

N/a

Screenshots or screencast

Before After

Changelog Entry

Developer - Mark WP\MCP\Cli classes as final and improve their internal type-safety.

Open WordPress Playground Preview

Copilot AI lite review requested due to automatic review settings August 27, 2026 05:48
@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: justlevine <justlevine@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@justlevine
justlevine requested a review from a team August 27, 2026 05:48
@justlevine justlevine changed the title Dev/audit cli namespace dev!: Mark WP\MCP\Cli classes as final and cleanup internals Aug 27, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 tightens the public surface area and improves internal type-safety for the MCP adapter’s CLI and transport layers, primarily by marking CLI classes as final and refining response/error typing/documentation.

Changes:

  • Mark WP\MCP\Cli\McpCommand and WP\MCP\Cli\StdioServerBridge as final.
  • Improve JSON-RPC response typing via array-shape PHPDoc updates and minor internal refactors.
  • Refine PHPCS configuration to better support non-VIP environments.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
includes/Transport/Infrastructure/JsonRpcResponseBuilder.php Refines PHPDoc for JSON-RPC success/error response shapes.
includes/Transport/Infrastructure/HttpRequestHandler.php Adds array-shape typing for protocol-version header validation errors.
includes/Cli/StdioServerBridge.php Marks class final, narrows/clarifies typing, and refactors JSON-RPC response formatting.
includes/Cli/McpCommand.php Marks WP-CLI command class final.
.phpcs.xml.dist Excludes a VIP-specific restriction to support non-VIP environments.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread includes/Cli/StdioServerBridge.php
Comment thread includes/Transport/Infrastructure/HttpRequestHandler.php Outdated
@codecov

codecov Bot commented Aug 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 76.92308% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.78%. Comparing base (7d8fbbf) to head (c314ef2).

Files with missing lines Patch % Lines
includes/Cli/StdioServerBridge.php 72.72% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##              trunk     #306   +/-   ##
=========================================
  Coverage     88.78%   88.78%           
  Complexity     1264     1264           
=========================================
  Files            54       54           
  Lines          4164     4164           
=========================================
  Hits           3697     3697           
  Misses          467      467           
Flag Coverage Δ
unit 88.78% <76.92%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

justlevine and others added 3 commits August 27, 2026 02:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants